ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/RenegadeMapSelector/RenegadeMapSelector.cpp
(Generate patch)

Comparing trunk/RenegadeMapSelector/RenegadeMapSelector.cpp (file contents):
Revision 70 by douglas, 2003-03-11T19:48:27-08:00 vs.
Revision 75 by douglas, 2003-03-13T14:12:42-08:00

# Line 4 | Line 4
4   //
5   // RenegadeMapSelector.cpp
6  
7 + #include "RenegadeMapSelector.h"
8 + #include "RenegadeConfig.h"
9 +
10   #ifdef _WIN32
11   #include <io.h>
12   #include <fcntl.h>
13   #include "resource.h"
14 + #else
15 + #include "gtk/gtk.h"
16   #endif
17  
13 #include "RenegadeMapSelector.h"
14 #include "RenegadeConfig.h"
15
18   bool debug = false;
19   string program;
20   RenegadeConfig* config;
21  
22   #ifndef _WIN32
23   inline string fix(const string& ansi) { return ansi; }
24 < inline void munge(void) { return; }
24 > inline void munge(void) { debug = true; }
25   #else
26   inline string fix(const wstring& wide)
27   {
# Line 65 | Line 67 | inline void munge(void)
67   }
68   #endif
69  
70 + #ifdef _WIN32
71   int CALLBACK selector(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
72  
73   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
# Line 72 | Line 75 | int WINAPI WinMain(HINSTANCE hInstance,
75   {
76          int argc;
77          unsigned short** argv = CommandLineToArgvW(GetCommandLineW(), &argc);
78 + #else
79 + int main(int argc, char* argv[])
80 + {
81 +        gtk_init(&argc, &argv);
82 + #endif
83  
84          string error;
85          string file = "svrcfg_cnc.ini";
# Line 96 | Line 104 | int WINAPI WinMain(HINSTANCE hInstance,
104                          {
105                                  error = "The argument -file must be followed by a filename.";
106  
107 + #ifdef _WIN32
108                                  MessageBox(NULL, error.c_str(), "Bad Arguments", MB_ICONERROR);
109 + #endif
110                                  return 1;
111                          }
112                  }
113          }
114  
115 + #ifdef _WIN32
116          GlobalFree(argv);
117 + #endif
118  
119          if (debug) cerr << "file = " << file << "\n";
120  
# Line 111 | Line 123 | int WINAPI WinMain(HINSTANCE hInstance,
123          {
124                  error = "Could not open " + file + ".";
125  
126 + #ifdef _WIN32
127                  MessageBox(NULL, error.c_str(), "Bad File", MB_ICONERROR);
128 + #endif
129                  return 1;
130          }
131  
132 + #ifdef _WIN32
133          DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAP_SELECTOR), NULL, selector);
134 + #else
135 +        gtk_main();
136 + #endif
137  
138          delete config;
139  
140 + #ifdef _WIN32
141          if (debug)
142          {
143                  cout << "Press enter key to exit . . .";
144                  cin.get();
145          }
146 + #endif
147  
148          return 0;
149   }
150  
151 + #ifdef _WIN32
152   int CALLBACK selector(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
153   {
154          switch (uMsg)
# Line 269 | Line 290 | int CALLBACK selector(HWND hwndDlg, UINT
290                          }
291                          break;
292                  case IDC_UP_MAP:
293 <                        cout << "STUB: up\a\n";
293 >                        {
294 >                                unsigned count = SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
295 >                                        LB_GETSELCOUNT, 0, 0);
296 >                                unsigned* ups = new unsigned[count];
297 >
298 >                                SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_GETSELITEMS,
299 >                                        count, long(ups));
300 >
301 >                                unsigned insert = ups[0] - 1;
302 >
303 >                                if (debug) cerr << "ups = {\n";
304 >                                for (unsigned index = 0; index < count; index++)
305 >                                {
306 >                                        if (debug) cerr << "   [" << index << "] = " << ups[index]
307 >                                                << "\n";
308 >
309 >                                        char* up = new char[SendMessage(GetDlgItem(hwndDlg,
310 >                                                IDC_SELECTED), LB_GETTEXTLEN, ups[index], 0) + 1];
311 >
312 >                                        SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_GETTEXT,
313 >                                                ups[index], long(up));
314 >                                        SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
315 >                                                LB_DELETESTRING, ups[index], 0);
316 >                                        SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
317 >                                                LB_INSERTSTRING, insert, long(up));
318 >                                        SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_SETSEL,
319 >                                                true, insert++);
320 >                                }
321 >                                if (debug) cerr << "}\n";
322 >
323 >                                delete [] ups;
324 >
325 >                                if (SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
326 >                                        LB_GETSEL, 0, 0) == 0)
327 >                                {
328 >                                        EnableWindow(GetDlgItem(hwndDlg, IDC_UP_MAP), true);
329 >                                }
330 >                                else
331 >                                {
332 >                                        EnableWindow(GetDlgItem(hwndDlg, IDC_UP_MAP), false);
333 >                                }
334 >
335 >                                if (SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
336 >                                        LB_GETSEL, SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED
337 >                                        ), LB_GETCOUNT, 0, 0) - 1, 0) == 0)
338 >                                {
339 >                                        EnableWindow(GetDlgItem(hwndDlg, IDC_DOWN_MAP), true);
340 >                                }
341 >                        }
342                          break;
343                  case IDC_DOWN_MAP:
344 <                        cout << "STUB: down\a\n";
344 >                        {
345 >                                unsigned count = SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
346 >                                        LB_GETSELCOUNT, 0, 0);
347 >                                unsigned* downs = new unsigned[count];
348 >
349 >                                SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_GETSELITEMS,
350 >                                        count, long(downs));
351 >
352 >                                unsigned insert = downs[count - 1] + 1;
353 >
354 >                                if (debug) cerr << "downs = {\n";
355 >                                for (unsigned index = count; index > 0; index--)
356 >                                {
357 >                                        if (debug) cerr << "   [" << index << "] = " << downs[index
358 >                                                - 1] << "\n";
359 >
360 >                                        char* down = new char[SendMessage(GetDlgItem(hwndDlg,
361 >                                                IDC_SELECTED), LB_GETTEXTLEN, downs[index - 1], 0) +
362 >                                                1];
363 >
364 >                                        SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_GETTEXT,
365 >                                                downs[index - 1], long(down));
366 >                                        SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
367 >                                                LB_DELETESTRING, downs[index - 1], 0);
368 >                                        SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
369 >                                                LB_INSERTSTRING, insert, long(down));
370 >                                        SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_SETSEL,
371 >                                                true, insert--);
372 >                                }
373 >                                if (debug) cerr << "}\n";
374 >
375 >                                delete [] downs;
376 >
377 >                                if (SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
378 >                                        LB_GETSEL, 0, 0) == 0)
379 >                                {
380 >                                        EnableWindow(GetDlgItem(hwndDlg, IDC_UP_MAP), true);
381 >                                }
382 >
383 >                                if (SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED),
384 >                                        LB_GETSEL, SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED
385 >                                        ), LB_GETCOUNT, 0, 0) - 1, 0) == 0)
386 >                                {
387 >                                        EnableWindow(GetDlgItem(hwndDlg, IDC_DOWN_MAP), true);
388 >                                }
389 >                                else
390 >                                {
391 >                                        EnableWindow(GetDlgItem(hwndDlg, IDC_DOWN_MAP), false);
392 >                                }
393 >                        }
394                          break;
395                  case IDC_AVAILABLE:
396                          switch (HIWORD(wParam))
# Line 335 | Line 453 | int CALLBACK selector(HWND hwndDlg, UINT
453  
454          return false;
455   }
456 + #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines