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 75 by douglas, 2003-03-13T14:12:42-08:00 vs.
Revision 89 by douglas, 2003-03-15T22:00:25-08:00

# Line 8 | Line 8
8   #include "RenegadeConfig.h"
9  
10   #ifdef _WIN32
11 +
12   #include <io.h>
13   #include <fcntl.h>
14   #include "resource.h"
15 +
16   #else
17 < #include "gtk/gtk.h"
17 >
18 > #include "MapSelector.h"
19 >
20   #endif
21  
22   bool debug = false;
# Line 20 | Line 24 | string program;
24   RenegadeConfig* config;
25  
26   #ifndef _WIN32
27 +
28   inline string fix(const string& ansi) { return ansi; }
29   inline void munge(void) { debug = true; }
30 +
31   #else
32 +
33   inline string fix(const wstring& wide)
34   {
35          char* buffer = new char[wide.length() + 1];
# Line 65 | Line 72 | inline void munge(void)
72  
73          debug = true;
74   }
75 +
76   #endif
77  
78   #ifdef _WIN32
# Line 76 | Line 84 | int WINAPI WinMain(HINSTANCE hInstance,
84          int argc;
85          unsigned short** argv = CommandLineToArgvW(GetCommandLineW(), &argc);
86   #else
87 + void selector(void);
88 +
89   int main(int argc, char* argv[])
90   {
91 <        gtk_init(&argc, &argv);
91 >        if (!gtk_init_check(&argc, &argv))
92 >        {
93 >                cerr << argv[0] << ": Cannot open display, need a clue-by-four?\n";
94 >
95 >                return 1;
96 >        }
97   #endif
98  
99          string error;
# Line 106 | Line 121 | int main(int argc, char* argv[])
121  
122   #ifdef _WIN32
123                                  MessageBox(NULL, error.c_str(), "Bad Arguments", MB_ICONERROR);
124 + #else
125 +                                message(NULL, error, "Bad Arguments", GTK_MESSAGE_ERROR);
126   #endif
127                                  return 1;
128                          }
129                  }
130 +                else
131 +                {
132 +                        error = "The argument " + arg + " is not a valid argument.";
133 +
134 + #ifdef _WIN32
135 +                        MessageBox(NULL, error.c_str(), "Unknown Arguments", MB_ICONWARN);
136 + #else
137 +                        message(NULL, error, "Unknown Arguments", GTK_MESSAGE_WARNING);
138 + #endif
139 +                }
140          }
141  
142   #ifdef _WIN32
# Line 125 | Line 152 | int main(int argc, char* argv[])
152  
153   #ifdef _WIN32
154                  MessageBox(NULL, error.c_str(), "Bad File", MB_ICONERROR);
155 + #else
156 +                message(NULL, error, "Bad File", GTK_MESSAGE_ERROR);
157   #endif
158                  return 1;
159          }
# Line 132 | Line 161 | int main(int argc, char* argv[])
161   #ifdef _WIN32
162          DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAP_SELECTOR), NULL, selector);
163   #else
164 <        gtk_main();
164 >        MapSelector selector;
165   #endif
166  
167          delete config;
# Line 149 | Line 178 | int main(int argc, char* argv[])
178   }
179  
180   #ifdef _WIN32
181 +
182   int CALLBACK selector(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
183   {
184          switch (uMsg)
# Line 173 | Line 203 | int CALLBACK selector(HWND hwndDlg, UINT
203                          GetCurrentDirectory(MAX_PATH + 1, directory);
204                          if (debug) cerr << "directory = " << directory << "\n";
205  
206 <                        char* data = new char[MAX_PATH + 1];
206 >                        char* data = new char[strlen(directory) + 12];
207                          sprintf(data, "%s\\data\\*.mix", directory);
208                          delete [] directory;
209                          if (debug) cerr << "data = " << data << "\n";
# Line 453 | Line 483 | int CALLBACK selector(HWND hwndDlg, UINT
483  
484          return false;
485   }
486 +
487   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines