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 256 by douglas, 2003-08-15T21:56:17-07:00 vs.
Revision 277 by douglas, 2003-08-24T00:31:45-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: VTBFileUtil2.cxx,v 1.2 2003/08/16 04:56:17 douglas Exp $
5 > // $Id: VTBFileUtil2.cxx,v 1.12 2003/08/24 07:31:45 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>
14  
12 #include "resource.h"
13
15   bool debug = false;
16   string program;
17   string programName = "Vance Thrift and Biller File Utility 2";
18   string programVersion = "2.0alpha";
19 <
19 < HICON icon;
20 <
21 < enum Mode { none, disc, scan };
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);
# Line 41 | Line 39 | inline void arguments(vector<string>& ar
39                          line.get();
40                  }
41  
42 <                args.push_back(arg);
42 >                if (arg != "")
43 >                {
44 >                        args.push_back(arg);
45 >                }
46          }
47          while (line.good());
48   }
# Line 49 | Line 50 | inline void arguments(vector<string>& ar
50   inline void munge(void)
51   {
52          AllocConsole();
53 <        SetConsoleTitle("Renegade Map Selector");
53 >        SetConsoleTitle(programName.c_str());
54  
55          int hin = _open_osfhandle(long(GetStdHandle(STD_INPUT_HANDLE)), _O_TEXT);
56          int hout = _open_osfhandle(long(GetStdHandle(STD_OUTPUT_HANDLE)), _O_TEXT);
# Line 72 | Line 73 | inline void munge(void)
73          cerr.sync_with_stdio();
74   }
75  
76 < inline void usage(HINSTANCE instance, HWND parent)
76 > inline void usage(HWND parent)
77   {
78 <        DialogBox(instance, MAKEINTRESOURCE(IDD_USAGE), parent, usage);
78 >        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_USAGE), parent, usage);
79   }
80  
81 < inline void version(HINSTANCE instance, HWND parent)
81 > inline void version(HWND parent)
82   {
83 <        DialogBox(instance, MAKEINTRESOURCE(IDD_VERSION), parent, version);
83 >        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_VERSION), parent, version);
84   }
85  
86   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
# Line 87 | Line 88 | int WINAPI WinMain(HINSTANCE hInstance,
88   {
89          vector<string> args;
90          
91 +        InitCommonControls();
92 +        CoInitialize(NULL);
93          arguments(args, GetCommandLine());
94  
95          program = args[0];
96  
97          Mode mode = none;
98  
99 <        icon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_VTB_ICON));
99 >        gui.instance = hInstance;
100 >        gui.icon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_VTB_ICON));
101 >        gui.show = nShowCmd;
102  
103          for (unsigned index = 1; index < args.size(); index++)
104          {
105                  if (args[index] == "-help")
106                  {
107 <                        usage(hInstance);
107 >                        usage();
108                          return 0;
109                  }
110                  else if (args[index] == "-version")
111                  {
112 <                        version(hInstance);
112 >                        version();
113                          return 0;
114                  }
115                  else if (args[index] == "-disc")
# Line 121 | Line 126 | int WINAPI WinMain(HINSTANCE hInstance,
126                          {
127                                  debug = true;
128  
129 <                                munge();
129 >                                cerr.setf(ios_base::boolalpha);
130                          }
131                  }
132 +                else
133 +                {
134 +                        string message = "Unknown argument: " + args[index];
135 +
136 +                        MessageBox(NULL, message.c_str(), programName.c_str(),
137 +                                MB_ICONWARNING);
138 +                }
139          }
140  
141          if (debug)
142          {
143 +                munge();
144                  cerr << "mode = ";
145  
146                  switch (mode)
# Line 151 | Line 164 | int WINAPI WinMain(HINSTANCE hInstance,
164  
165          if (mode == none)
166          {
167 <                //
167 >                Chooser chooser;
168 >
169 >                mode = chooser.choose();
170 >
171 >                if (debug)
172 >                {
173 >                        cerr << "mode = ";
174 >
175 >                        switch (mode)
176 >                        {
177 >                        case none:
178 >                                cerr << "none";
179 >                                break;
180 >                        case disc:
181 >                                cerr << "disc";
182 >                                break;
183 >                        case scan:
184 >                                cerr << "scan";
185 >                                break;
186 >                        default:
187 >                                cerr << mode;
188 >                                break;
189 >                        }
190 >
191 >                        cerr << "\n";
192 >                }
193          }
194  
195          if (mode == disc)
196          {
197 <                //
197 >                DiscBrowse browser;
198 >
199 >                browser.run();
200          }
201          else if (mode == scan)
202          {
203 <                //
203 >                ScanUtility utility;
204 >
205 >                utility.run();
206          }
207  
208 +        CoUninitialize();
209 +
210          if (debug)
211          {
212                  cout << "Press enter key to exit . . .";
# Line 178 | Line 222 | INT_PTR CALLBACK usage(HWND dialog, UINT
222          {
223          case WM_INITDIALOG:
224                  center(dialog);
225 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
225 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
226                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
227                  {
228                          ostringstream usage;
# Line 190 | Line 234 | INT_PTR CALLBACK usage(HWND dialog, UINT
234                                  << "  -disc\t\tStart in Disc Browse mode\n"
235                                  << "  -scan\t\tStart in Scan Utility mode\n";
236  
237 <                        SendMessage(GetDlgItem(dialog, IDC_USAGE_TEXT), WM_SETTEXT, 0,
194 <                                LPARAM(usage.str().c_str()));
237 >                        SetDlgItemText(dialog, IDC_USAGE_TEXT, usage.str().c_str());
238                  }
239                  break;
240          case WM_COMMAND:
# Line 216 | Line 259 | INT_PTR CALLBACK version(HWND dialog, UI
259          {
260          case WM_INITDIALOG:
261                  center(dialog);
262 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
262 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
263                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
264                  {
265                          ostringstream version;
266 <                        version << programName << " ( " << programVersion << " )\n\n"
266 >
267 >                        version << programName << " (" << programVersion << ")\n\n"
268                                  << "Copyright © 2003, Douglas Thrift.\n";
269  
270 <                        SendMessage(GetDlgItem(dialog, IDC_VERSION_TEXT), WM_SETTEXT, 0,
227 <                                LPARAM(version.str().c_str()));
270 >                        SetDlgItemText(dialog, IDC_VERSION_TEXT, version.str().c_str());
271                  }
272                  break;
273          case WM_COMMAND:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines