7 |
|
#ifdef _WIN32 |
8 |
|
#include <io.h> |
9 |
|
#include <fcntl.h> |
10 |
+ |
#include "resource.h" |
11 |
|
#endif |
12 |
|
|
13 |
|
#include "RenegadeMapSelector.h" |
14 |
< |
#include "resource.h" |
14 |
> |
#include "RenegadeConfig.h" |
15 |
|
|
16 |
|
bool debug = false; |
17 |
|
string program; |
18 |
+ |
RenegadeConfig* config; |
19 |
|
|
20 |
|
#ifndef _WIN32 |
21 |
|
inline string fix(const string& ansi) { return ansi; } |
22 |
+ |
inline void munge(void) { return; } |
23 |
|
#else |
24 |
|
inline string fix(const wstring& wide) |
25 |
|
{ |
34 |
|
return ansi; |
35 |
|
} |
36 |
|
|
37 |
< |
inline munge(void) |
37 |
> |
inline void munge(void) |
38 |
|
{ |
39 |
+ |
if (debug) return; |
40 |
+ |
|
41 |
|
AllocConsole(); |
42 |
|
SetConsoleTitle("Renegade Map Selector"); |
43 |
|
|
60 |
|
cin.sync_with_stdio(); |
61 |
|
cout.sync_with_stdio(); |
62 |
|
cerr.sync_with_stdio(); |
63 |
+ |
|
64 |
+ |
debug = true; |
65 |
|
} |
66 |
|
#endif |
67 |
|
|
73 |
|
int argc; |
74 |
|
unsigned short** argv = CommandLineToArgvW(GetCommandLineW(), &argc); |
75 |
|
|
76 |
+ |
string file = "svrcfg_cnc.ini"; |
77 |
+ |
|
78 |
|
program = fix(argv[0]); |
79 |
|
|
80 |
|
for (int index = 1; index < argc; index++) |
81 |
|
{ |
82 |
|
string arg = fix(argv[index]); |
83 |
+ |
string error; |
84 |
|
|
85 |
|
if (arg == "-D") |
86 |
|
{ |
87 |
< |
debug = true; |
87 |
> |
munge(); |
88 |
> |
} |
89 |
> |
else if (arg == "-file") |
90 |
> |
{ |
91 |
> |
if (++index < argc) |
92 |
> |
{ |
93 |
> |
file = fix(argv[index]); |
94 |
> |
} |
95 |
> |
else |
96 |
> |
{ |
97 |
> |
error = "The argument -file must be followed by a filename."; |
98 |
> |
|
99 |
> |
MessageBox(NULL, error.c_str(), "Bad Arguments", MB_ICONERROR); |
100 |
> |
return 1; |
101 |
> |
} |
102 |
|
} |
103 |
|
} |
104 |
|
|
105 |
< |
if (debug) munge(); |
105 |
> |
GlobalFree(argv); |
106 |
> |
|
107 |
> |
if (debug) cerr << "file = " << file << "\n"; |
108 |
> |
|
109 |
> |
config = new RenegadeConfig(file); |
110 |
> |
config->load(); |
111 |
|
|
112 |
|
DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAP_SELECTOR), NULL, selector); |
113 |
|
|
114 |
< |
if (debug) FreeConsole(); |
115 |
< |
GlobalFree(argv); |
114 |
> |
delete config; |
115 |
> |
|
116 |
|
return 0; |
117 |
|
} |
118 |
|
|
154 |
|
switch (LOWORD(wParam)) |
155 |
|
{ |
156 |
|
case IDOK: |
157 |
< |
// |
157 |
> |
config->save(); |
158 |
|
case IDCANCEL: |
159 |
|
EndDialog(hwndDlg, wParam); |
160 |
|
return true; |