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 265 by douglas, 2003-08-16T20:55:39-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.8 2003/08/17 03:55:39 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 49 | 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 72 | Line 70 | inline void munge(void)
70          cerr.sync_with_stdio();
71   }
72  
73 < inline void usage(HINSTANCE instance, HWND parent)
73 > inline void usage(HWND parent)
74   {
75 <        DialogBox(instance, MAKEINTRESOURCE(IDD_USAGE), parent, usage);
75 >        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_USAGE), parent, usage);
76   }
77  
78 < inline void version(HINSTANCE instance, HWND parent)
78 > inline void version(HWND parent)
79   {
80 <        DialogBox(instance, MAKEINTRESOURCE(IDD_VERSION), parent, version);
80 >        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_VERSION), parent, version);
81   }
82  
83   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
# Line 87 | Line 85 | int WINAPI WinMain(HINSTANCE hInstance,
85   {
86          vector<string> args;
87          
88 +        InitCommonControls();
89          arguments(args, GetCommandLine());
90  
91          program = args[0];
92  
93          Mode mode = none;
94  
95 <        icon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_VTB_ICON));
95 >        gui.instance = hInstance;
96 >        gui.icon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_VTB_ICON));
97 >        gui.tips = 0;
98  
99          for (unsigned index = 1; index < args.size(); index++)
100          {
101                  if (args[index] == "-help")
102                  {
103 <                        usage(hInstance);
103 >                        usage();
104                          return 0;
105                  }
106                  else if (args[index] == "-version")
107                  {
108 <                        version(hInstance);
108 >                        version();
109                          return 0;
110                  }
111                  else if (args[index] == "-disc")
# Line 121 | 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)
# Line 151 | Line 160 | int WINAPI WinMain(HINSTANCE hInstance,
160  
161          if (mode == none)
162          {
163 <                //
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 <                //
193 >                DiscBrowse browser;
194 >
195 >                browser.run();
196          }
197          else if (mode == scan)
198          {
199 <                //
199 >                ScanUtility utility;
200 >
201 >                utility.run();
202          }
203  
204          if (debug)
# Line 172 | Line 210 | int WINAPI WinMain(HINSTANCE hInstance,
210          return 0;
211   }
212  
213 + void tooltip(HWND tool, const string& tip)
214 + {
215 +        HWND tooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP
216 +                | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT,
217 +                CW_USEDEFAULT, CW_USEDEFAULT, tool, NULL, gui.instance, NULL);
218 +        RECT rect;
219 +
220 +        SetWindowPos(tooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE |
221 +                SWP_NOACTIVATE);
222 +
223 +        GetClientRect(tool, &rect);
224 +
225 +        TOOLINFO toolinfo;
226 +        LPTSTR ctip = new CHAR[tip.length()];
227 +
228 +        sprintf(ctip, "%s", tip.c_str());
229 +
230 +        if (debug) cerr << "ctip = " << ctip << "\n";
231 +
232 +        toolinfo.cbSize = sizeof(TOOLINFO);
233 +        toolinfo.uFlags = TTF_SUBCLASS;
234 +        toolinfo.hwnd = tool;
235 +        toolinfo.hinst = gui.instance;
236 +        toolinfo.uId = gui.tips++;
237 +        toolinfo.lpszText = ctip;
238 +        toolinfo.rect.left = rect.left;
239 +        toolinfo.rect.top = rect.top;
240 +        toolinfo.rect.right = rect.right;
241 +        toolinfo.rect.bottom = rect.bottom;
242 +
243 +        SendMessage(tooltip, TTM_ADDTOOL, 0, LPARAM(LPTOOLINFO(&toolinfo)));
244 + }
245 +
246   INT_PTR CALLBACK usage(HWND dialog, UINT msg, WPARAM w, LPARAM l)
247   {
248          switch (msg)
249          {
250          case WM_INITDIALOG:
251                  center(dialog);
252 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
252 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
253                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
254                  {
255                          ostringstream usage;
# Line 216 | Line 287 | INT_PTR CALLBACK version(HWND dialog, UI
287          {
288          case WM_INITDIALOG:
289                  center(dialog);
290 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
290 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
291                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
292                  {
293                          ostringstream version;
294 <                        version << programName << " ( " << programVersion << " )\n\n"
294 >
295 >                        version << programName << " (" << programVersion << ")\n\n"
296                                  << "Copyright © 2003, Douglas Thrift.\n";
297  
298                          SendMessage(GetDlgItem(dialog, IDC_VERSION_TEXT), WM_SETTEXT, 0,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines