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 257 by douglas, 2003-08-15T23:44:42-07:00 vs.
Revision 264 by douglas, 2003-08-16T17:43:49-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: VTBFileUtil2.cxx,v 1.3 2003/08/16 06:44:42 douglas Exp $
5 > // $Id: VTBFileUtil2.cxx,v 1.7 2003/08/17 00:43:49 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 < Mode choiceMode = none;
21 < bool choiceAlways = false;
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);
25 INT_PTR CALLBACK choice(HWND dialog, UINT msg, WPARAM w, LPARAM l);
23  
24   inline void arguments(vector<string>& args, const string& command)
25   {
# Line 50 | 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 73 | 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);
79 < }
80 <
81 < inline void version(HINSTANCE instance, HWND parent)
82 < {
83 <        DialogBox(instance, MAKEINTRESOURCE(IDD_VERSION), parent, version);
75 >        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_USAGE), parent, usage);
76   }
77  
78 < inline void choice(Mode& mode, HINSTANCE instance, HWND parent)
78 > inline void version(HWND parent)
79   {
80 <        DialogBox(instance, MAKEINTRESOURCE(IDD_CHOICE), parent, choice);
89 <
90 <        mode = choiceMode;
80 >        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_VERSION), parent, version);
81   }
82  
83   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
# Line 102 | Line 92 | int WINAPI WinMain(HINSTANCE hInstance,
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 130 | Line 122 | int WINAPI WinMain(HINSTANCE hInstance,
122                          {
123                                  debug = true;
124  
133                                munge();
125                                  cerr.setf(ios_base::boolalpha);
126                          }
127                  }
# Line 145 | Line 136 | int WINAPI WinMain(HINSTANCE hInstance,
136  
137          if (debug)
138          {
139 +                munge();
140                  cerr << "mode = ";
141  
142                  switch (mode)
# Line 168 | Line 160 | int WINAPI WinMain(HINSTANCE hInstance,
160  
161          if (mode == none)
162          {
163 <                choice(mode, hInstance);
163 >                Chooser chooser;
164 >
165 >                mode = chooser.choose();
166  
167                  if (debug)
168                  {
# Line 214 | Line 208 | int WINAPI WinMain(HINSTANCE hInstance,
208          return 0;
209   }
210  
211 + void tooltip(HWND tool, const string& tip)
212 + {
213 +        HWND tooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP
214 +                | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT,
215 +                CW_USEDEFAULT, CW_USEDEFAULT, tool, NULL, gui.instance, NULL);
216 +        RECT rect;
217 +
218 +        SetWindowPos(tooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE |
219 +                SWP_NOACTIVATE);
220 +
221 +        GetClientRect(tool, &rect);
222 +
223 +        TOOLINFO toolinfo;
224 +        LPTSTR ctip = new CHAR[tip.length()];
225 +
226 +        sprintf(ctip, "%s", tip.c_str());
227 +
228 +        if (debug) cerr << "ctip = " << ctip << "\n";
229 +
230 +        toolinfo.cbSize = sizeof(TOOLINFO);
231 +        toolinfo.uFlags = TTF_SUBCLASS;
232 +        toolinfo.hwnd = tool;
233 +        toolinfo.hinst = gui.instance;
234 +        toolinfo.uId = gui.tips++;
235 +        toolinfo.lpszText = ctip;
236 +        toolinfo.rect.left = rect.left;
237 +        toolinfo.rect.top = rect.top;
238 +        toolinfo.rect.right = rect.right;
239 +        toolinfo.rect.bottom = rect.bottom;
240 +
241 +        SendMessage(tooltip, TTM_ADDTOOL, 0, LPARAM(LPTOOLINFO(&toolinfo)));
242 + }
243 +
244   INT_PTR CALLBACK usage(HWND dialog, UINT msg, WPARAM w, LPARAM l)
245   {
246          switch (msg)
247          {
248          case WM_INITDIALOG:
249                  center(dialog);
250 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
250 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
251                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
252                  {
253                          ostringstream usage;
# Line 258 | Line 285 | INT_PTR CALLBACK version(HWND dialog, UI
285          {
286          case WM_INITDIALOG:
287                  center(dialog);
288 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
288 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
289                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
290                  {
291                          ostringstream version;
292  
293 <                        version << programName << " ( " << programVersion << " )\n\n"
293 >                        version << programName << " (" << programVersion << ")\n\n"
294                                  << "Copyright © 2003, Douglas Thrift.\n";
295  
296                          SendMessage(GetDlgItem(dialog, IDC_VERSION_TEXT), WM_SETTEXT, 0,
# Line 278 | Line 305 | INT_PTR CALLBACK version(HWND dialog, UI
305                          EndDialog(dialog, w);
306                          return TRUE;
307                  default:
281                        break;
282                }
283                break;
284        }
285
286        return FALSE;
287 }
288
289 INT_PTR CALLBACK choice(HWND dialog, UINT msg, WPARAM w, LPARAM l)
290 {
291        switch (msg)
292        {
293        case WM_INITDIALOG:
294                center(dialog);
295                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
296                SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
297                break;
298        case WM_COMMAND:
299                switch (LOWORD(w))
300                {
301                case IDC_CHOICE_DISC:
302                        choiceMode = disc;
303                        if (debug) cerr << "choiceMode = disc\n";
304                        EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE);
305                        EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
306                        break;
307                case IDC_CHOICE_SCAN:
308                        choiceMode = scan;
309                        if (debug) cerr << "choiceMode = scan\n";
310                        EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE);
311                        EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
312                        break;
313                case IDC_CHOICE_ALWAYS:
314                        choiceAlways = !choiceAlways;
315                        if (debug) cerr << "choiceAlways = " << choiceAlways << "\n";
316                        break;
317                case IDCANCEL:
318                        choiceMode = none;
319                case IDOK:
320                        EndDialog(dialog, w);
321                        return TRUE;
322                default:
308                          break;
309                  }
310                  break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines