Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/Main.cc @ 2273

Last change on this file since 2273 was 2103, checked in by rgrieder, 16 years ago

Merged r2101 (objecthierarchy) to trunk.

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
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
24 *      Reto Grieder
25 *   Co-authors:
26 *      ...
27 *
28 */
29
30 /**
31 @file
32 @brief Entry point of the program. Platform specific code.
33  */
34
35#include "OrxonoxStableHeaders.h"
36
37#include <exception>
38#include <cassert>
39
40#include "util/OrxonoxPlatform.h"
41#include "util/Debug.h"
42#include "util/SignalHandler.h"
43#include "core/ConfigFileManager.h"
44#include "core/CommandLine.h"
45
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
55#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
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{
63    char path[1024];
64    CFBundleRef mainBundle = CFBundleGetMainBundle();
65    assert(mainBundle);
66
67    CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
68    assert(mainBundleURL);
69
70    CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
71    assert(cfStringRef);
72
73    CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
74
75    CFRelease(mainBundleURL);
76    CFRelease(cfStringRef);
77
78    return std::string(path);
79}
80#endif
81
82
83//#ifdef __cplusplus
84//extern "C" {
85//#endif
86
87SetCommandLineArgument(settingsFile, "orxonox.ini");
88
89int main(int argc, char** argv)
90{
91    using namespace orxonox;
92
93    // create a signal handler (only works for linux)
94    SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
95
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
108    // setConfigValues() in the constructor (required).
109    ConfigFileManager* configFileManager = new ConfigFileManager();
110    configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString());
111
112    // create the gamestates
113    GSRoot root;
114    GSGraphics graphics;
115    GSStandalone standalone;
116    GSServer server;
117    GSClient client;
118    GSDedicated dedicated;
119    GSGUI gui;
120    GSIOConsole ioConsole;
121
122    // make the hierarchy
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
131    // Here happens the game
132    root.start();
133
134    // Destroy ConfigFileManager again.
135    delete configFileManager;
136
137    return 0;
138}
139
140//#ifdef __cplusplus
141//}
142//#endif
Note: See TracBrowser for help on using the repository browser.