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 63 by douglas, 2003-03-10T23:38:36-08:00 vs.
Revision 66 by douglas, 2003-03-11T14:43:01-08:00

# Line 4 | Line 4
4   //
5   // RenegadeMapSelector.cpp
6  
7 + #ifdef _WIN32
8 + #include <io.h>
9 + #include <fcntl.h>
10 + #endif
11 +
12   #include "RenegadeMapSelector.h"
13   #include "resource.h"
14  
15   bool debug = false;
16   string program;
17  
18 < inline string widetoansi(const wstring& wide)
18 > #ifndef _WIN32
19 > inline string fix(const string& ansi) { return ansi; }
20 > #else
21 > inline string fix(const wstring& wide)
22   {
23          char* buffer = new char[wide.length() + 1];
24  
# Line 23 | Line 31 | inline string widetoansi(const wstring&
31          return ansi;
32   }
33  
34 + inline munge(void)
35 + {
36 +        AllocConsole();
37 +        SetConsoleTitle("Renegade Map Selector");
38 +
39 +        int hin = _open_osfhandle(long(GetStdHandle(STD_INPUT_HANDLE)), _O_TEXT);
40 +        int hout = _open_osfhandle(long(GetStdHandle(STD_OUTPUT_HANDLE)), _O_TEXT);
41 +        int herr = _open_osfhandle(long(GetStdHandle(STD_ERROR_HANDLE)), _O_TEXT);
42 +
43 +        FILE* fin = _fdopen(hin, "r");
44 +        FILE* fout = _fdopen(hout, "w");
45 +        FILE* ferr = _fdopen(herr, "w");
46 +
47 +        *stdin = *fin;
48 +        *stdout = *fout;
49 +        *stderr = *ferr;
50 +
51 +        setvbuf(stdin, NULL, _IONBF, 0);
52 +        setvbuf(stdout, NULL, _IONBF, 0);
53 +        setvbuf(stderr, NULL, _IONBF, 0);
54 +
55 +        cin.sync_with_stdio();
56 +        cout.sync_with_stdio();
57 +        cerr.sync_with_stdio();
58 + }
59 + #endif
60 +
61   int CALLBACK selector(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
62  
63   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
# Line 31 | Line 66 | int WINAPI WinMain(HINSTANCE hInstance,
66          int argc;
67          unsigned short** argv = CommandLineToArgvW(GetCommandLineW(), &argc);
68  
69 <        program = widetoansi(argv[0]);
69 >        program = fix(argv[0]);
70  
71          for (int index = 1; index < argc; index++)
72          {
73 <                string arg = widetoansi(argv[index]);
73 >                string arg = fix(argv[index]);
74  
75                  if (arg == "-D")
76                  {
# Line 43 | Line 78 | int WINAPI WinMain(HINSTANCE hInstance,
78                  }
79          }
80  
81 <        if (debug) MessageBox(NULL, program.c_str(), "Program", 0);
81 >        if (debug) munge();
82  
83          DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAP_SELECTOR), NULL, selector);
84  
85 +        if (debug) FreeConsole();
86          GlobalFree(argv);
87          return 0;
88   }
# Line 73 | Line 109 | int CALLBACK selector(HWND hwndDlg, UINT
109                  {
110                          char* directory = new char[MAX_PATH + 1];
111                          GetCurrentDirectory(MAX_PATH + 1, directory);
112 <                        if (debug) MessageBox(hwndDlg, directory, "Directory", 0);
112 >                        if (debug) cerr << "directory = " << directory << "\n";
113  
114                          char* data = new char[MAX_PATH + 1];
115                          sprintf(data, "%s\\data\\*.mix", directory);
116                          delete [] directory;
117 <                        if (debug) MessageBox(hwndDlg, data, "Data", 0);
117 >                        if (debug) cerr << "data = " << data << "\n";
118  
119                          DlgDirList(hwndDlg, data, IDC_AVAILABLE, 0, DDL_ARCHIVE);
120  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines