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 74 by douglas, 2003-03-13T13:05:06-08:00 vs.
Revision 94 by douglas, 2003-03-22T13:53:44-08:00

# Line 4 | Line 4
4   //
5   // RenegadeMapSelector.cpp
6  
7 + #include "RenegadeMapSelector.h"
8 + #include "RenegadeConfig.h"
9 +
10   #ifdef _WIN32
11 +
12   #include <io.h>
13   #include <fcntl.h>
14   #include "resource.h"
11 #endif
15  
16 < #include "RenegadeMapSelector.h"
17 < #include "RenegadeConfig.h"
16 > #else
17 >
18 > #include "MapSelector.h"
19 >
20 > #endif
21  
22   bool debug = false;
23   string program;
24   RenegadeConfig* config;
25  
26   #ifndef _WIN32
27 +
28   inline string fix(const string& ansi) { return ansi; }
29   inline void munge(void) { debug = true; }
30 +
31   #else
32 +
33   inline string fix(const wstring& wide)
34   {
35          char* buffer = new char[wide.length() + 1];
# Line 63 | Line 72 | inline void munge(void)
72  
73          debug = true;
74   }
75 +
76   #endif
77  
78   #ifdef _WIN32
# Line 74 | Line 84 | int WINAPI WinMain(HINSTANCE hInstance,
84          int argc;
85          unsigned short** argv = CommandLineToArgvW(GetCommandLineW(), &argc);
86   #else
87 + void selector(void);
88 +
89   int main(int argc, char* argv[])
90   {
91 +        if (!gtk_init_check(&argc, &argv))
92 +        {
93 +                cerr << argv[0] << ": Cannot open display, need a clue-by-four?\n";
94 +
95 +                return 1;
96 +        }
97   #endif
98  
99          string error;
# Line 101 | Line 119 | int main(int argc, char* argv[])
119                          {
120                                  error = "The argument -file must be followed by a filename.";
121  
122 +                                cerr << program << ": " << error << "\n";
123   #ifdef _WIN32
124                                  MessageBox(NULL, error.c_str(), "Bad Arguments", MB_ICONERROR);
125 + #else
126 +                                message(NULL, error, "Bad Arguments", GTK_MESSAGE_ERROR);
127   #endif
128                                  return 1;
129                          }
130                  }
131 +                else
132 +                {
133 +                        error = "The argument " + arg + " is not a valid argument.";
134 +
135 +                        cerr << program << ": " << error << "\n";
136 + #ifdef _WIN32
137 +                        MessageBox(NULL, error.c_str(), "Unknown Arguments", MB_ICONWARNING
138 +                                );
139 + #else
140 +                        message(NULL, error, "Unknown Arguments", GTK_MESSAGE_WARNING);
141 + #endif
142 +                }
143          }
144  
145   #ifdef _WIN32
# Line 120 | Line 153 | int main(int argc, char* argv[])
153          {
154                  error = "Could not open " + file + ".";
155  
156 +                cerr << program << ": " << error << "\n";
157   #ifdef _WIN32
158                  MessageBox(NULL, error.c_str(), "Bad File", MB_ICONERROR);
159 + #else
160 +                message(NULL, error, "Bad File", GTK_MESSAGE_ERROR);
161   #endif
162                  return 1;
163          }
164  
165   #ifdef _WIN32
166          DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAP_SELECTOR), NULL, selector);
167 + #else
168 +        MapSelector selector;
169   #endif
170  
171          delete config;
# Line 144 | Line 182 | int main(int argc, char* argv[])
182   }
183  
184   #ifdef _WIN32
185 +
186   int CALLBACK selector(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
187   {
188          switch (uMsg)
# Line 168 | Line 207 | int CALLBACK selector(HWND hwndDlg, UINT
207                          GetCurrentDirectory(MAX_PATH + 1, directory);
208                          if (debug) cerr << "directory = " << directory << "\n";
209  
210 <                        char* data = new char[MAX_PATH + 1];
210 >                        char* data = new char[strlen(directory) + 12];
211                          sprintf(data, "%s\\data\\*.mix", directory);
212                          delete [] directory;
213                          if (debug) cerr << "data = " << data << "\n";
# Line 195 | Line 234 | int CALLBACK selector(HWND hwndDlg, UINT
234                          if (GetListBoxInfo(GetDlgItem(hwndDlg, IDC_SELECTED)) == 0)
235                          {
236                                  MessageBox(hwndDlg, "You need at least one map.", "No Maps",
237 <                                        MB_ICONEXCLAMATION);
237 >                                        MB_ICONINFORMATION);
238  
239                                  return false;
240                          }
# Line 448 | Line 487 | int CALLBACK selector(HWND hwndDlg, UINT
487  
488          return false;
489   }
490 +
491   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines