--- trunk/RenegadeMapSelector/RenegadeMapSelector.cpp 2003/03/12 02:39:01 69 +++ trunk/RenegadeMapSelector/RenegadeMapSelector.cpp 2003/03/12 04:33:33 73 @@ -19,7 +19,7 @@ RenegadeConfig* config; #ifndef _WIN32 inline string fix(const string& ansi) { return ansi; } -inline void munge(void) { return; } +inline void munge(void) { debug = true; } #else inline string fix(const wstring& wide) { @@ -65,6 +65,7 @@ inline void munge(void) } #endif +#ifdef _WIN32 int CALLBACK selector(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR @@ -72,6 +73,10 @@ int WINAPI WinMain(HINSTANCE hInstance, { int argc; unsigned short** argv = CommandLineToArgvW(GetCommandLineW(), &argc); +#else +int main(int argc, char* argv[]) +{ +#endif string error; string file = "svrcfg_cnc.ini"; @@ -96,13 +101,17 @@ int WINAPI WinMain(HINSTANCE hInstance, { error = "The argument -file must be followed by a filename."; +#ifdef _WIN32 MessageBox(NULL, error.c_str(), "Bad Arguments", MB_ICONERROR); +#endif return 1; } } } +#ifdef _WIN32 GlobalFree(argv); +#endif if (debug) cerr << "file = " << file << "\n"; @@ -111,19 +120,30 @@ int WINAPI WinMain(HINSTANCE hInstance, { error = "Could not open " + file + "."; +#ifdef _WIN32 MessageBox(NULL, error.c_str(), "Bad File", MB_ICONERROR); +#endif return 1; } +#ifdef _WIN32 DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAP_SELECTOR), NULL, selector); +#endif delete config; - if (debug) cin.get(); +#ifdef _WIN32 + if (debug) + { + cout << "Press enter key to exit . . ."; + cin.get(); + } +#endif return 0; } +#ifdef _WIN32 int CALLBACK selector(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) @@ -203,12 +223,72 @@ int CALLBACK selector(HWND hwndDlg, UINT EndDialog(hwndDlg, wParam); return true; case IDC_ADD_MAP: + { + unsigned count = SendMessage(GetDlgItem(hwndDlg, + IDC_AVAILABLE), LB_GETSELCOUNT, 0, 0); + unsigned* additions = new unsigned[count]; + + SendMessage(GetDlgItem(hwndDlg, IDC_AVAILABLE), LB_GETSELITEMS, + count, long(additions)); + + if (debug) cerr << "additions = {\n"; + for (unsigned index = 0; index < count; index++) + { + if (debug) cerr << " [" << index << "] = " << + additions[index] << "\n"; + + char* name = new char[SendMessage(GetDlgItem(hwndDlg, + IDC_AVAILABLE), LB_GETTEXTLEN, additions[index], 0) + 1 + ]; + + SendMessage(GetDlgItem(hwndDlg, IDC_AVAILABLE), LB_GETTEXT, + additions[index], long(name)); + SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), + LB_ADDSTRING, 0, long(name)); + + delete [] name; + } + if (debug) cerr << "}\n"; + + delete [] additions; + + SendMessage(GetDlgItem(hwndDlg, IDC_AVAILABLE), LB_SETSEL, + false, -1); + EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_MAP), false); + } break; case IDC_REMOVE_MAP: + { + unsigned count = SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), + LB_GETSELCOUNT, 0, 0); + unsigned* removals = new unsigned[count]; + + SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), LB_GETSELITEMS, + count, long(removals)); + + if (debug) cerr << "removals = {\n"; + for (unsigned index = count; index > 0; index--) + { + if (debug) cerr << " [" << index - 1 << "] = " << + removals[index - 1] << "\n"; + + SendMessage(GetDlgItem(hwndDlg, IDC_SELECTED), + LB_DELETESTRING, removals[index - 1], 0); + } + if (debug) cerr << "}\n"; + + delete [] removals; + + EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVE_MAP), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_UP_MAP), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_DOWN_MAP), false); + } break; case IDC_UP_MAP: + cout << "STUB: up\a\n"; break; case IDC_DOWN_MAP: + cout << "STUB: down\a\n"; break; case IDC_AVAILABLE: switch (HIWORD(wParam)) @@ -271,3 +351,4 @@ int CALLBACK selector(HWND hwndDlg, UINT return false; } +#endif