Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy/src/orxonox/Main.cc @ 2110

Last change on this file since 2110 was 2101, checked in by rgrieder, 16 years ago

Finally managed to have a master InputState which enables:

  • Console always opens
  • Debug overlay toggles visibility in gui mode too

Had to change several other code:

  • ConfigFileManager uses special class instead of enum for ConfigFileType
  • You can add an arbitrary config file and get the ConfigFileType
  • ConfigFileManager is an Ogre singleton too. Created in Main.cc
  • CommandLineArgument "optionsFile" specifies another file for command line arguments
  • CommandLineArgument "settingsFile" declares the file used for settings (orxonox.ini)
  • changed all fileNames to filenames
  • "Loaded config file blah" now uses COUT(3) instead of COUT(0)
  • fixed a bug in ConfigFileManager::load() that cause orxonox.ini to double its size after every call
  • Property svn:eol-style set to native
File size: 3.8 KB
RevLine 
[612]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
[1293]3 *                    > www.orxonox.net <
[612]4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
[1755]24 *      Reto Grieder
[612]25 *   Co-authors:
26 *      ...
27 *
28 */
29
30 /**
[1021]31 @file
32 @brief Entry point of the program. Platform specific code.
[612]33  */
34
[1293]35#include "OrxonoxStableHeaders.h"
[612]36
[1293]37#include <exception>
[1755]38#include <cassert>
[1293]39
[1502]40#include "util/OrxonoxPlatform.h"
[1891]41#include "util/Debug.h"
[2030]42#include "util/SignalHandler.h"
[1891]43#include "core/ConfigFileManager.h"
[2101]44#include "core/CommandLine.h"
[612]45
[1755]46#include "gamestates/GSRoot.h"
47#include "gamestates/GSGraphics.h"
48#include "gamestates/GSStandalone.h"
49#include "gamestates/GSServer.h"
50#include "gamestates/GSClient.h"
51#include "gamestates/GSDedicated.h"
52#include "gamestates/GSGUI.h"
53#include "gamestates/GSIOConsole.h"
54
[1021]55#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
[612]56#include <CoreFoundation/CoreFoundation.h>
57
58// This function will locate the path to our application on OS X,
59// unlike windows you can not rely on the curent working directory
60// for locating your configuration files and resources.
61             std::string macBundlePath()
62{
[1755]63    char path[1024];
64    CFBundleRef mainBundle = CFBundleGetMainBundle();
65    assert(mainBundle);
[612]66
[1755]67    CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
68    assert(mainBundleURL);
[612]69
[1755]70    CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
71    assert(cfStringRef);
[612]72
[1755]73    CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
[612]74
[1755]75    CFRelease(mainBundleURL);
76    CFRelease(cfStringRef);
[612]77
[1755]78    return std::string(path);
[612]79}
80#endif
81
82
[1755]83//#ifdef __cplusplus
84//extern "C" {
85//#endif
86
[2101]87SetCommandLineArgument(settingsFile, "orxonox.ini");
88
[1755]89int main(int argc, char** argv)
[622]90{
[2101]91    using namespace orxonox;
92
[1755]93    // create a signal handler (only works for linux)
[612]94    SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
[1021]95
[2101]96    // Parse command line arguments
97    try
98    {
99        CommandLine::parseAll(argc, argv);
100    }
101    catch (ArgumentException& ex)
102    {
103        COUT(1) << ex.what() << std::endl;
104        COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
105    }
106
107    // Create the ConfigFileManager before creating the GameStates in order to have
[1891]108    // setConfigValues() in the constructor (required).
[2101]109    ConfigFileManager* configFileManager = new ConfigFileManager();
110    configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString());
[1891]111
112    // create the gamestates
[1755]113    GSRoot root;
114    GSGraphics graphics;
115    GSStandalone standalone;
116    GSServer server;
117    GSClient client;
118    GSDedicated dedicated;
119    GSGUI gui;
120    GSIOConsole ioConsole;
[612]121
[1891]122    // make the hierarchy
[1755]123    root.addChild(&graphics);
124    graphics.addChild(&standalone);
125    graphics.addChild(&server);
126    graphics.addChild(&client);
127    graphics.addChild(&gui);
128    root.addChild(&ioConsole);
129    root.addChild(&dedicated);
130
[1891]131    // Here happens the game
[2101]132    root.start();
[1755]133
[2101]134    // Destroy ConfigFileManager again.
135    delete configFileManager;
136
[1755]137    return 0;
[612]138}
139
[1755]140//#ifdef __cplusplus
141//}
142//#endif
Note: See TracBrowser for help on using the repository browser.