ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/VTBFileUtil2/VTBFileUtil2.cxx
(Generate patch)

Comparing trunk/VTBFileUtil2/VTBFileUtil2.cxx (file contents):
Revision 255 by douglas, 2003-08-15T17:12:57-07:00 vs.
Revision 273 by douglas, 2003-08-20T23:29:24-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: VTBFileUtil2.cxx,v 1.1 2003/08/16 00:12:57 douglas Exp $
5 > // $Id: VTBFileUtil2.cxx,v 1.11 2003/08/21 06:29:24 douglas Exp $
6  
7   #include "VTBFileUtil2.h"
8 + #include "Chooser.h"
9 + #include "DiscBrowse.h"
10 + #include "ScanUtility.h"
11  
12   #include <io.h>
13   #include <fcntl.h>
# Line 12 | Line 15
15   bool debug = false;
16   string program;
17   string programName = "Vance Thrift and Biller File Utility 2";
18 < unsigned programVersion = 0x00101000;
18 > string programVersion = "2.0alpha";
19 > Gui gui;
20 >
21 > INT_PTR CALLBACK usage(HWND dialog, UINT msg, WPARAM w, LPARAM l);
22 > INT_PTR CALLBACK version(HWND dialog, UINT msg, WPARAM w, LPARAM l);
23  
24   inline void arguments(vector<string>& args, const string& command)
25   {
# Line 40 | Line 47 | inline void arguments(vector<string>& ar
47   inline void munge(void)
48   {
49          AllocConsole();
50 <        SetConsoleTitle("Renegade Map Selector");
50 >        SetConsoleTitle(programName.c_str());
51  
52          int hin = _open_osfhandle(long(GetStdHandle(STD_INPUT_HANDLE)), _O_TEXT);
53          int hout = _open_osfhandle(long(GetStdHandle(STD_OUTPUT_HANDLE)), _O_TEXT);
# Line 63 | Line 70 | inline void munge(void)
70          cerr.sync_with_stdio();
71   }
72  
73 + inline void usage(HWND parent)
74 + {
75 +        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_USAGE), parent, usage);
76 + }
77 +
78 + inline void version(HWND parent)
79 + {
80 +        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_VERSION), parent, version);
81 + }
82 +
83   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
84          lpCmdLine, int nShowCmd)
85   {
86          vector<string> args;
87          
88 +        InitCommonControls();
89 +        CoInitialize(NULL);
90          arguments(args, GetCommandLine());
91  
92          program = args[0];
93  
94 +        Mode mode = none;
95 +
96 +        gui.instance = hInstance;
97 +        gui.icon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_VTB_ICON));
98 +
99          for (unsigned index = 1; index < args.size(); index++)
100          {
101                  if (args[index] == "-help")
# Line 86 | Line 110 | int WINAPI WinMain(HINSTANCE hInstance,
110                  }
111                  else if (args[index] == "-disc")
112                  {
113 <                        //
113 >                        mode = disc;
114                  }
115                  else if (args[index] == "-scan")
116                  {
117 <                        //
117 >                        mode = scan;
118                  }
119                  else if (args[index] == "-D")
120                  {
# Line 98 | Line 122 | int WINAPI WinMain(HINSTANCE hInstance,
122                          {
123                                  debug = true;
124  
125 <                                munge();
125 >                                cerr.setf(ios_base::boolalpha);
126 >                        }
127 >                }
128 >                else
129 >                {
130 >                        string message = "Unknown argument: " + args[index];
131 >
132 >                        MessageBox(NULL, message.c_str(), programName.c_str(),
133 >                                MB_ICONWARNING);
134 >                }
135 >        }
136 >
137 >        if (debug)
138 >        {
139 >                munge();
140 >                cerr << "mode = ";
141 >
142 >                switch (mode)
143 >                {
144 >                case none:
145 >                        cerr << "none";
146 >                        break;
147 >                case disc:
148 >                        cerr << "disc";
149 >                        break;
150 >                case scan:
151 >                        cerr << "scan";
152 >                        break;
153 >                default:
154 >                        cerr << mode;
155 >                        break;
156 >                }
157 >
158 >                cerr << "\n";
159 >        }
160 >
161 >        if (mode == none)
162 >        {
163 >                Chooser chooser;
164 >
165 >                mode = chooser.choose();
166 >
167 >                if (debug)
168 >                {
169 >                        cerr << "mode = ";
170 >
171 >                        switch (mode)
172 >                        {
173 >                        case none:
174 >                                cerr << "none";
175 >                                break;
176 >                        case disc:
177 >                                cerr << "disc";
178 >                                break;
179 >                        case scan:
180 >                                cerr << "scan";
181 >                                break;
182 >                        default:
183 >                                cerr << mode;
184 >                                break;
185                          }
186 +
187 +                        cerr << "\n";
188                  }
189          }
190  
191 +        if (mode == disc)
192 +        {
193 +                DiscBrowse browser;
194 +
195 +                browser.run();
196 +        }
197 +        else if (mode == scan)
198 +        {
199 +                ScanUtility utility;
200 +
201 +                utility.run();
202 +        }
203 +
204 +        CoUninitialize();
205 +
206 +        if (debug)
207 +        {
208 +                cout << "Press enter key to exit . . .";
209 +                cin.get();
210 +        }
211 +
212          return 0;
213   }
214  
215 < void usage(void)
215 > INT_PTR CALLBACK usage(HWND dialog, UINT msg, WPARAM w, LPARAM l)
216   {
217 <        //
217 >        switch (msg)
218 >        {
219 >        case WM_INITDIALOG:
220 >                center(dialog);
221 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
222 >                SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
223 >                {
224 >                        ostringstream usage;
225 >
226 >                        usage << "Usage: VTBFileUtil [-help | -version | -disc | -scan]\n"
227 >                                << "\nOptions:\n"
228 >                                << "  -help\t\tDisplay this information\n"
229 >                                << "  -version\tDisplay version information\n"
230 >                                << "  -disc\t\tStart in Disc Browse mode\n"
231 >                                << "  -scan\t\tStart in Scan Utility mode\n";
232 >
233 >                        SetDlgItemText(dialog, IDC_USAGE_TEXT, usage.str().c_str());
234 >                }
235 >                break;
236 >        case WM_COMMAND:
237 >                switch (LOWORD(w))
238 >                {
239 >                case IDOK:
240 >                case IDCANCEL:
241 >                        EndDialog(dialog, w);
242 >                        return TRUE;
243 >                default:
244 >                        break;
245 >                }
246 >                break;
247 >        }
248 >
249 >        return FALSE;
250   }
251  
252 < void version(void)
252 > INT_PTR CALLBACK version(HWND dialog, UINT msg, WPARAM w, LPARAM l)
253   {
254 <        //
254 >        switch (msg)
255 >        {
256 >        case WM_INITDIALOG:
257 >                center(dialog);
258 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
259 >                SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
260 >                {
261 >                        ostringstream version;
262 >
263 >                        version << programName << " (" << programVersion << ")\n\n"
264 >                                << "Copyright © 2003, Douglas Thrift.\n";
265 >
266 >                        SetDlgItemText(dialog, IDC_VERSION_TEXT, version.str().c_str());
267 >                }
268 >                break;
269 >        case WM_COMMAND:
270 >                switch (LOWORD(w))
271 >                {
272 >                case IDOK:
273 >                case IDCANCEL:
274 >                        EndDialog(dialog, w);
275 >                        return TRUE;
276 >                default:
277 >                        break;
278 >                }
279 >                break;
280 >        }
281 >
282 >        return FALSE;
283   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines