1 |
douglas |
63 |
// Renegade Map Selector |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// RenegadeMapSelector.cpp |
6 |
|
|
|
7 |
|
|
#include "RenegadeMapSelector.h" |
8 |
|
|
#include "resource.h" |
9 |
|
|
|
10 |
|
|
bool debug = false; |
11 |
|
|
string program; |
12 |
|
|
|
13 |
|
|
inline string widetoansi(const wstring& wide) |
14 |
|
|
{ |
15 |
|
|
char* buffer = new char[wide.length() + 1]; |
16 |
|
|
|
17 |
|
|
WideCharToMultiByte(CP_ACP, 0, wide.c_str(), -1, buffer, wide.length() + 1, |
18 |
|
|
NULL, NULL); |
19 |
|
|
|
20 |
|
|
string ansi = buffer; |
21 |
|
|
delete [] buffer; |
22 |
|
|
|
23 |
|
|
return ansi; |
24 |
|
|
} |
25 |
|
|
|
26 |
|
|
int CALLBACK selector(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); |
27 |
|
|
|
28 |
|
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR |
29 |
|
|
lpCmdLine, int nShowCmd) |
30 |
|
|
{ |
31 |
|
|
int argc; |
32 |
|
|
unsigned short** argv = CommandLineToArgvW(GetCommandLineW(), &argc); |
33 |
|
|
|
34 |
|
|
program = widetoansi(argv[0]); |
35 |
|
|
|
36 |
|
|
for (int index = 1; index < argc; index++) |
37 |
|
|
{ |
38 |
|
|
string arg = widetoansi(argv[index]); |
39 |
|
|
|
40 |
|
|
if (arg == "-D") |
41 |
|
|
{ |
42 |
|
|
debug = true; |
43 |
|
|
} |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
if (debug) MessageBox(NULL, program.c_str(), "Program", 0); |
47 |
|
|
|
48 |
|
|
DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAP_SELECTOR), NULL, selector); |
49 |
|
|
|
50 |
|
|
GlobalFree(argv); |
51 |
|
|
return 0; |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
int CALLBACK selector(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
55 |
|
|
{ |
56 |
|
|
switch (uMsg) |
57 |
|
|
{ |
58 |
|
|
case WM_INITDIALOG: |
59 |
|
|
{ |
60 |
|
|
RECT rc, rcDlg, rcDesktop; |
61 |
|
|
|
62 |
|
|
GetWindowRect(GetDesktopWindow(), &rcDesktop); |
63 |
|
|
GetWindowRect(hwndDlg, &rcDlg); |
64 |
|
|
CopyRect(&rc, &rcDesktop); |
65 |
|
|
|
66 |
|
|
OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top); |
67 |
|
|
OffsetRect(&rc, -rc.left, -rc.top); |
68 |
|
|
OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom); |
69 |
|
|
|
70 |
|
|
SetWindowPos(hwndDlg, HWND_TOP, rcDesktop.left + (rc.right / 2), |
71 |
|
|
rcDesktop.top + (rc.bottom / 2), 0, 0, SWP_NOSIZE); |
72 |
|
|
} |
73 |
|
|
{ |
74 |
|
|
char* directory = new char[MAX_PATH + 1]; |
75 |
|
|
GetCurrentDirectory(MAX_PATH + 1, directory); |
76 |
|
|
if (debug) MessageBox(hwndDlg, directory, "Directory", 0); |
77 |
|
|
|
78 |
|
|
char* data = new char[MAX_PATH + 1]; |
79 |
|
|
sprintf(data, "%s\\data\\*.mix", directory); |
80 |
|
|
delete [] directory; |
81 |
|
|
if (debug) MessageBox(hwndDlg, data, "Data", 0); |
82 |
|
|
|
83 |
|
|
DlgDirList(hwndDlg, data, IDC_AVAILABLE, 0, DDL_ARCHIVE); |
84 |
|
|
|
85 |
|
|
delete [] data; |
86 |
|
|
} |
87 |
|
|
break; |
88 |
|
|
case WM_COMMAND: |
89 |
|
|
switch (LOWORD(wParam)) |
90 |
|
|
{ |
91 |
|
|
case IDOK: |
92 |
|
|
// |
93 |
|
|
case IDCANCEL: |
94 |
|
|
EndDialog(hwndDlg, wParam); |
95 |
|
|
return true; |
96 |
|
|
} |
97 |
|
|
break; |
98 |
|
|
} |
99 |
|
|
|
100 |
|
|
return false; |
101 |
|
|
} |