/[enigma]/enigma/src/main.cc
ViewVC logotype

Diff of /enigma/src/main.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by mhawlisch, Tue Apr 1 09:58:28 2003 UTC revision 1.10 by reallysoft, Tue Apr 8 08:02:18 2003 UTC
# Line 5  Line 5 
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
# Line 50  namespace Line 50  namespace
50  //======================================================================  //======================================================================
51  // APPLICATION DATA  // APPLICATION DATA
52  //======================================================================  //======================================================================
53  namespace enigma  namespace enigma
54  {  {
55      Application app;      Application app;
56  }  }
# Line 72  static std::fstream logfile; Line 72  static std::fstream logfile;
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"
# Line 82  static void usage() Line 82  static void usage()
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");
# Line 92  namespace Line 93  namespace
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
# Line 101  namespace Line 102  namespace
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    
# Line 112  namespace Line 113  namespace
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);
# Line 121  namespace Line 123  namespace
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;
# Line 137  namespace Line 139  namespace
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;
# Line 160  namespace Line 163  namespace
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;
# Line 200  load_oxyd_datfiles (const string &sounds Line 203  load_oxyd_datfiles (const string &sounds
203      }      }
204  }  }
205    
206  static void  static void
207  init()  init()
208  {  {
209      enigma::Log.rdbuf(new Nulbuf);      enigma::Log.rdbuf(new Nulbuf);
# Line 213  init() Line 216  init()
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      {      {
# Line 245  init() Line 248  init()
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());
# Line 271  init() Line 274  init()
274      video::ShowMouse();      video::ShowMouse();
275  }  }
276    
277  static void  static void
278  shutdown()  shutdown()
279  {  {
280      world::Shutdown();      world::Shutdown();
# Line 301  main(int argc, char** argv) Line 304  main(int argc, char** argv)
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    
# Line 315  main(int argc, char** argv) Line 318  main(int argc, char** argv)
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;

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26