5 |
* modify it under the terms of the GNU General Public License |
* modify it under the terms of the GNU General Public License |
6 |
* as published by the Free Software Foundation; either version 2 |
* as published by the Free Software Foundation; either version 2 |
7 |
* of the License, or (at your option) any later version. |
* of the License, or (at your option) any later version. |
8 |
* |
* |
9 |
* This program is distributed in the hope that it will be useful, |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
50 |
//====================================================================== |
//====================================================================== |
51 |
// APPLICATION DATA |
// APPLICATION DATA |
52 |
//====================================================================== |
//====================================================================== |
53 |
namespace enigma |
namespace enigma |
54 |
{ |
{ |
55 |
Application app; |
Application app; |
56 |
} |
} |
72 |
// Startup |
// Startup |
73 |
//---------------------------------------------------------------------- |
//---------------------------------------------------------------------- |
74 |
|
|
75 |
static void usage() |
static void usage() |
76 |
{ |
{ |
77 |
printf("Available command line options for Enigma:\n\n" |
printf("Available command line options for Enigma:\n\n" |
78 |
" --nosound Disable music and sound\n" |
" --nosound Disable music and sound\n" |
82 |
" --version Print the executable's version number\n" |
" --version Print the executable's version number\n" |
83 |
// " --8bpp Use 256 color mode\n" |
// " --8bpp Use 256 color mode\n" |
84 |
" --nograb Do not use exclusive mouse/keyboard access\n" |
" --nograb Do not use exclusive mouse/keyboard access\n" |
85 |
|
" --nozoom Do not create previews\n" |
86 |
" --soundset -s [enigma|oxyd|oxyd1|peroxyd|oxydmagnum|magnumgold|oxydextra]\n" |
" --soundset -s [enigma|oxyd|oxyd1|peroxyd|oxydmagnum|magnumgold|oxydextra]\n" |
87 |
" Choose your preferred soundset; default is 'oxyd'\n" |
" Choose your preferred soundset; default is 'oxyd'\n" |
88 |
"\n"); |
"\n"); |
93 |
struct AP : public argp::ArgParser { |
struct AP : public argp::ArgParser { |
94 |
public: |
public: |
95 |
enum { |
enum { |
96 |
OPT_NOSOUND, OPT_NOMUSIC, OPT_VERSION, OPT_HELP, |
OPT_NOSOUND, OPT_NOMUSIC, OPT_VERSION, OPT_HELP, |
97 |
OPT_WINDOW, OPT_WIZARD, OPT_NOGRAB, OPT_LOG, |
OPT_WINDOW, OPT_WIZARD, OPT_NOGRAB, OPT_NOZOOM, OPT_LOG, |
98 |
OPT_8BPP, OPT_GAME, |
OPT_8BPP, OPT_GAME, |
99 |
OPT_SOUNDSET, |
OPT_SOUNDSET, |
100 |
// OPT_PEROXYD, OPT_OXYD1, OPT_EXTRA, OPT_MAGNUM |
// OPT_PEROXYD, OPT_OXYD1, OPT_EXTRA, OPT_MAGNUM |
102 |
|
|
103 |
AP() : ArgParser (app.args.begin(), app.args.end()) |
AP() : ArgParser (app.args.begin(), app.args.end()) |
104 |
{ |
{ |
105 |
nosound = nomusic = show_help = show_version = do_log = false; |
nosound = nomusic = show_help = show_version = do_log = false; |
106 |
gamename = ""; |
gamename = ""; |
107 |
gametype = GAMET_ENIGMA; |
gametype = GAMET_ENIGMA; |
108 |
|
|
113 |
def (OPT_WINDOW, 'w', "window"); |
def (OPT_WINDOW, 'w', "window"); |
114 |
def (OPT_WIZARD, 0, "wizard"); |
def (OPT_WIZARD, 0, "wizard"); |
115 |
def (OPT_NOGRAB, 0, "nograb"); |
def (OPT_NOGRAB, 0, "nograb"); |
116 |
|
def (OPT_NOZOOM, 0, "nozoom"); |
117 |
def (OPT_LOG, 'l', "log"); |
def (OPT_LOG, 'l', "log"); |
118 |
def (OPT_8BPP, '8', "8bpp"); |
def (OPT_8BPP, '8', "8bpp"); |
119 |
def (OPT_GAME, 'g', "game", true); |
def (OPT_GAME, 'g', "game", true); |
123 |
// def (OPT_MAGNUM,0, "oxydmagnum"); |
// def (OPT_MAGNUM,0, "oxydmagnum"); |
124 |
def (OPT_SOUNDSET, 's', "soundset", true); |
def (OPT_SOUNDSET, 's', "soundset", true); |
125 |
} |
} |
126 |
|
|
127 |
// ArgParser interface. |
// ArgParser interface. |
128 |
void on_error (ErrorType t, const string &option) { |
void on_error (ErrorType t, const string &option) { |
129 |
cout << errormsg(t, option) << endl; |
cout << errormsg(t, option) << endl; |
139 |
case OPT_WINDOW: options::FullScreen=false; break; |
case OPT_WINDOW: options::FullScreen=false; break; |
140 |
case OPT_WIZARD: options::WizardMode=true; break; |
case OPT_WIZARD: options::WizardMode=true; break; |
141 |
case OPT_NOGRAB: options::Nograb=true; break; |
case OPT_NOGRAB: options::Nograb=true; break; |
142 |
|
case OPT_NOZOOM: options::Nozoom=true; break; |
143 |
case OPT_8BPP: options::BitsPerPixel = 8; break; |
case OPT_8BPP: options::BitsPerPixel = 8; break; |
144 |
case OPT_GAME: gamename = param; break; |
case OPT_GAME: gamename = param; break; |
145 |
case OPT_LOG: do_log = true; break; |
case OPT_LOG: do_log = true; break; |
163 |
} |
} |
164 |
|
|
165 |
static void |
static void |
166 |
load_oxyd_datfiles (const string &soundset) |
load_oxyd_datfiles (const string &soundset) |
167 |
{ |
{ |
168 |
OxydVersion oxyd_version = OxydVersion_Invalid; |
OxydVersion oxyd_version = OxydVersion_Invalid; |
169 |
DatFile *datfile = 0; |
DatFile *datfile = 0; |
203 |
} |
} |
204 |
} |
} |
205 |
|
|
206 |
static void |
static void |
207 |
init() |
init() |
208 |
{ |
{ |
209 |
enigma::Log.rdbuf(new Nulbuf); |
enigma::Log.rdbuf(new Nulbuf); |
216 |
fprintf(stderr, "Your installation may be incomplete or invalid.\n"); |
fprintf(stderr, "Your installation may be incomplete or invalid.\n"); |
217 |
exit (1); |
exit (1); |
218 |
} |
} |
219 |
|
|
220 |
lua::Dofile("levels/index.lua"); |
lua::Dofile("levels/index.lua"); |
221 |
lua::DoSubfolderfile("levels", "index.lua"); |
lua::DoSubfolderfile("levels", "index.lua"); |
222 |
|
|
223 |
// Load preferences |
// Load preferences |
224 |
if (!options::Load()) |
if (!options::Load()) |
225 |
{ |
{ |
248 |
|
|
249 |
int sdl_flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE; |
int sdl_flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE; |
250 |
if (!ap.nosound) |
if (!ap.nosound) |
251 |
sdl_flags |= SDL_INIT_AUDIO; |
sdl_flags |= SDL_INIT_AUDIO; |
252 |
|
|
253 |
if (SDL_Init(sdl_flags) < 0) { |
if (SDL_Init(sdl_flags) < 0) { |
254 |
fprintf(stderr, "Couldn't init SDL: %s\n", SDL_GetError()); |
fprintf(stderr, "Couldn't init SDL: %s\n", SDL_GetError()); |
274 |
video::ShowMouse(); |
video::ShowMouse(); |
275 |
} |
} |
276 |
|
|
277 |
static void |
static void |
278 |
shutdown() |
shutdown() |
279 |
{ |
{ |
280 |
world::Shutdown(); |
world::Shutdown(); |
304 |
c = (char*) parentdir; |
c = (char*) parentdir; |
305 |
|
|
306 |
while (*c != '\0') /* go to end */ |
while (*c != '\0') /* go to end */ |
307 |
c++; |
c++; |
308 |
|
|
309 |
while (*c != '/') /* back up to parent */ |
while (*c != '/') /* back up to parent */ |
310 |
c--; |
c--; |
311 |
|
|
312 |
*c++ = '\0'; /* cut off last part (binary name) */ |
*c++ = '\0'; /* cut off last part (binary name) */ |
313 |
|
|
318 |
app.init(argc,argv); |
app.init(argc,argv); |
319 |
|
|
320 |
init(); |
init(); |
321 |
|
|
322 |
GUI_MainMenu(LevelPacks[0], 0); |
GUI_MainMenu(LevelPacks[0], 0); |
323 |
shutdown(); |
shutdown(); |
324 |
return 0; |
return 0; |