Welcome to the NetCologne GmbH open source mirroring service!

This machine mirrors various open-source projects. 20 Gbit/s uplink.

If there are any issues or you want another project mirrored, please contact mirror-service -=AT=- netcologne DOT de !

construo_main.cxx Source File
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

construo_main.cxx

Go to the documentation of this file.
00001 //  $Id: construo_main.cxx,v 1.22 2003/01/11 19:07:48 grumbel Exp $
00002 //
00003 //  Construo - A wire-frame construction game
00004 //  Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #include <fstream>
00021 #include "construo.hxx"
00022 #include "particle.hxx"
00023 #include "config.h"
00024 #include "world.hxx"
00025 #include "construo_error.hxx"
00026 
00027 #ifdef USE_X11_DISPLAY
00028 #  include "x11_display.hxx"
00029 #  include "unix_system.hxx"
00030 #else 
00031 #  ifdef USE_GLUT_DISPLAY
00032 #    include "glut_display.hxx"
00033 #    include "unix_system.hxx"
00034 #  endif
00035 #endif
00036 
00037 #include "controller.hxx"
00038 #include "command_line.hxx"
00039 #include "settings.hxx"
00040 #include "gui_manager.hxx"
00041 
00042 #include "construo_main.hxx"
00043 
00044 ConstruoMain* construo_main;
00045 Controller*   controller;
00046 
00047 ConstruoMain::ConstruoMain ()
00048 {
00049   do_quit = false;
00050 }
00051 
00052 ConstruoMain::~ConstruoMain ()
00053 {
00054 }
00055 
00056 char* 
00057 ConstruoMain::get_title ()
00058 {
00059   return "Construo";
00060 }
00061 
00062 void
00063 ConstruoMain::on_exit()
00064 {
00065   std::cout << "Calling on_exit()" << std::endl;
00066 
00067   //if (!controller->has_been_run())
00068     {
00069       controller->save_world("/user/laststate.construo");
00070     }
00071 
00072   std::cout << "\n\n            Thank you for playing Construo!\n\n\n"
00073             << "  New versions and more information can be found at:\n\n"
00074             << "    * http://fs.fsf.org/construo/\n\n"
00075             << "  Comments, critique, suggestions self build\n  construction and patches can be send to:\n\n"
00076             << "    * Ingo Ruhnke <grumbel@gmx.de>\n\n" << std::endl;
00077 }
00078 
00079 int 
00080 ConstruoMain::main (int argc, char* argv[]) // FIXME: pass an option class, instead command line arguments
00081 {
00082   CommandLine::parse(argc, argv);
00083 
00084   try {
00085 #ifdef USE_X11_DISPLAY
00086     X11Display display (settings.screen_width, settings.screen_height, 
00087                         settings.fullscreen);
00088 #elif USE_GLUT_DISPLAY
00089     GlutDisplay display (settings.screen_width, settings.screen_height);
00090 #else
00091 #  error "No display type defined"
00092 #endif
00093     UnixSystem system;
00094 
00095     // Init the display, input systems
00096     graphic_context = &display;
00097     input_context   = &display;
00098     system_context  = &system;
00099   
00100     std::cout << PACKAGE_STRING"\n" << std::endl;
00101     std::cout << "If you have throuble with programm startup, delete the file:\n\n" 
00102               << "    " << system_context->get_construo_rc_path() << "laststate.construo\n" << std::endl;
00103 
00104     GUIManager* gui_manager = new GUIManager ();
00105 
00106     if (!settings.startup_file.empty())
00107       {
00108         controller  = new Controller (settings.startup_file);
00109       }
00110     else
00111       {
00112         try 
00113           {
00114             controller = new Controller ("/user/laststate.construo");
00115           } 
00116         catch (ConstruoError& err) 
00117           {
00118             std::cout << "ConstruoMain: " << err.msg << std::endl;
00119             controller = new Controller ();
00120           }
00121       }
00122   
00123     display.run();
00124 
00125     on_exit();
00126     
00127     delete gui_manager;
00128 
00129   } catch (ConstruoError& err) {
00130     std::cout << "Error ocurred: " << err.msg << std::endl;
00131     return EXIT_FAILURE;
00132   }
00133 
00134   return 0;
00135 }
00136 
00138 // Real Main Function //
00140 int main (int argc, char** argv)
00141 {
00142   ConstruoMain app;
00143   construo_main = &app;
00144   return app.main (argc, argv);
00145 }
00146 
00147 /* EOF */

Generated on Thu Jul 24 10:24:29 2003 for Construo by doxygen1.3-rc3