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; |
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]; |
72 |
|
|
73 |
|
debug = true; |
74 |
|
} |
75 |
+ |
|
76 |
|
#endif |
77 |
|
|
78 |
|
#ifdef _WIN32 |
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; |
119 |
|
{ |
120 |
|
error = "The argument -file must be followed by a filename."; |
121 |
|
|
122 |
+ |
cerr << program << ": " << error << "\n"; |
123 |
|
#ifdef _WIN32 |
124 |
|
MessageBox(NULL, error.c_str(), "Bad Arguments", MB_ICONERROR); |
125 |
+ |
#else |
126 |
+ |
message(NULL, error, "Bad Arguments", GTK_MESSAGE_ERROR); |
127 |
|
#endif |
128 |
|
return 1; |
129 |
|
} |
130 |
|
} |
131 |
+ |
else |
132 |
+ |
{ |
133 |
+ |
error = "The argument " + arg + " is not a valid argument."; |
134 |
+ |
|
135 |
+ |
cerr << program << ": " << error << "\n"; |
136 |
+ |
#ifdef _WIN32 |
137 |
+ |
MessageBox(NULL, error.c_str(), "Unknown Arguments", MB_ICONWARNING |
138 |
+ |
); |
139 |
+ |
#else |
140 |
+ |
message(NULL, error, "Unknown Arguments", GTK_MESSAGE_WARNING); |
141 |
+ |
#endif |
142 |
+ |
} |
143 |
|
} |
144 |
|
|
145 |
|
#ifdef _WIN32 |
153 |
|
{ |
154 |
|
error = "Could not open " + file + "."; |
155 |
|
|
156 |
+ |
cerr << program << ": " << error << "\n"; |
157 |
|
#ifdef _WIN32 |
158 |
|
MessageBox(NULL, error.c_str(), "Bad File", MB_ICONERROR); |
159 |
+ |
#else |
160 |
+ |
message(NULL, error, "Bad File", GTK_MESSAGE_ERROR); |
161 |
|
#endif |
162 |
|
return 1; |
163 |
|
} |
165 |
|
#ifdef _WIN32 |
166 |
|
DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAP_SELECTOR), NULL, selector); |
167 |
|
#else |
168 |
< |
gtk_main(); |
168 |
> |
MapSelector selector; |
169 |
|
#endif |
170 |
|
|
171 |
|
delete config; |
182 |
|
} |
183 |
|
|
184 |
|
#ifdef _WIN32 |
185 |
+ |
|
186 |
|
int CALLBACK selector(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
187 |
|
{ |
188 |
|
switch (uMsg) |
207 |
|
GetCurrentDirectory(MAX_PATH + 1, directory); |
208 |
|
if (debug) cerr << "directory = " << directory << "\n"; |
209 |
|
|
210 |
< |
char* data = new char[MAX_PATH + 1]; |
210 |
> |
char* data = new char[strlen(directory) + 12]; |
211 |
|
sprintf(data, "%s\\data\\*.mix", directory); |
212 |
|
delete [] directory; |
213 |
|
if (debug) cerr << "data = " << data << "\n"; |
234 |
|
if (GetListBoxInfo(GetDlgItem(hwndDlg, IDC_SELECTED)) == 0) |
235 |
|
{ |
236 |
|
MessageBox(hwndDlg, "You need at least one map.", "No Maps", |
237 |
< |
MB_ICONEXCLAMATION); |
237 |
> |
MB_ICONINFORMATION); |
238 |
|
|
239 |
|
return false; |
240 |
|
} |
487 |
|
|
488 |
|
return false; |
489 |
|
} |
490 |
+ |
|
491 |
|
#endif |