[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 |
---|
[1638] | 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> |
---|
[1638] | 38 | #include <cassert> |
---|
[1293] | 39 | |
---|
[1502] | 40 | #include "util/OrxonoxPlatform.h" |
---|
[612] | 41 | #include "core/SignalHandler.h" |
---|
[1638] | 42 | #include "core/Debug.h" |
---|
[1663] | 43 | #include "core/CommandLine.h" |
---|
| 44 | //#include "Orxonox.h" |
---|
[612] | 45 | |
---|
[1661] | 46 | #include "gamestates/GSRoot.h" |
---|
| 47 | #include "gamestates/GSGraphics.h" |
---|
| 48 | #include "gamestates/GSLevel.h" |
---|
| 49 | #include "gamestates/GSGUI.h" |
---|
| 50 | |
---|
[612] | 51 | using namespace orxonox; |
---|
[1638] | 52 | |
---|
[1021] | 53 | #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE |
---|
[612] | 54 | #include <CoreFoundation/CoreFoundation.h> |
---|
| 55 | |
---|
| 56 | // This function will locate the path to our application on OS X, |
---|
| 57 | // unlike windows you can not rely on the curent working directory |
---|
| 58 | // for locating your configuration files and resources. |
---|
| 59 | std::string macBundlePath() |
---|
| 60 | { |
---|
[1638] | 61 | char path[1024]; |
---|
| 62 | CFBundleRef mainBundle = CFBundleGetMainBundle(); |
---|
| 63 | assert(mainBundle); |
---|
[612] | 64 | |
---|
[1638] | 65 | CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle); |
---|
| 66 | assert(mainBundleURL); |
---|
[612] | 67 | |
---|
[1638] | 68 | CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle); |
---|
| 69 | assert(cfStringRef); |
---|
[612] | 70 | |
---|
[1638] | 71 | CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII); |
---|
[612] | 72 | |
---|
[1638] | 73 | CFRelease(mainBundleURL); |
---|
| 74 | CFRelease(cfStringRef); |
---|
[612] | 75 | |
---|
[1638] | 76 | return std::string(path); |
---|
[612] | 77 | } |
---|
| 78 | #endif |
---|
| 79 | |
---|
[1638] | 80 | |
---|
[612] | 81 | #ifdef __cplusplus |
---|
| 82 | extern "C" { |
---|
| 83 | #endif |
---|
| 84 | |
---|
[1638] | 85 | int main(int argc, char** argv) |
---|
[622] | 86 | { |
---|
[1663] | 87 | try |
---|
[1638] | 88 | { |
---|
[1663] | 89 | orxonox::CommandLine::parse(argc, argv); |
---|
| 90 | } |
---|
| 91 | catch (orxonox::ArgumentException& ex) |
---|
| 92 | { |
---|
| 93 | COUT(1) << ex.what() << std::endl; |
---|
[1638] | 94 | COUT(0) << "Usage:" << std::endl << "orxonox [--mode client|server|dedicated|standalone] " |
---|
| 95 | << "[--data PATH] [--ip IP] [--port PORT]" << std::endl; |
---|
| 96 | } |
---|
| 97 | |
---|
[1660] | 98 | |
---|
[1663] | 99 | // create a signal handler (only works for linux) |
---|
| 100 | SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log"); |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | |
---|
[1660] | 104 | /*GameState* state1 = new GameState("state1"); |
---|
| 105 | GameState* state2 = new GameState("state2"); |
---|
| 106 | GameState* state3 = new GameState("state3"); |
---|
| 107 | GameState* state4 = new GameState("state4"); |
---|
| 108 | GameState* state5 = new GameState("state5"); |
---|
| 109 | GameState* state6 = new GameState("state6"); |
---|
| 110 | |
---|
| 111 | state1->addChild(state4); |
---|
| 112 | state1->addChild(state6); |
---|
| 113 | state2->addChild(state3); |
---|
| 114 | state2->addChild(state5); |
---|
| 115 | state6->addChild(state2); |
---|
| 116 | |
---|
[1661] | 117 | state6->removeChild("state2"); |
---|
| 118 | |
---|
[1660] | 119 | state5->requestState("state3"); |
---|
| 120 | COUT(2) << std::endl; |
---|
| 121 | state2->requestState("state2"); |
---|
| 122 | COUT(2) << std::endl; |
---|
| 123 | state2->requestState("state1"); |
---|
| 124 | COUT(2) << std::endl; |
---|
| 125 | state4->requestState("state3"); |
---|
| 126 | COUT(2) << std::endl; |
---|
| 127 | state1->requestState("state4"); |
---|
| 128 | COUT(2) << std::endl; |
---|
| 129 | state1->requestState("state2"); |
---|
| 130 | COUT(2) << std::endl; |
---|
| 131 | state1->requestState("stat"); |
---|
| 132 | COUT(2) << std::endl; |
---|
| 133 | state1->requestState("state5"); |
---|
| 134 | COUT(2) << std::endl;*/ |
---|
| 135 | |
---|
| 136 | |
---|
[1661] | 137 | GSRoot root; |
---|
| 138 | GSGraphics graphics; |
---|
| 139 | GSLevel level; |
---|
| 140 | GSGUI gui; |
---|
[1660] | 141 | |
---|
[1661] | 142 | root.addChild(&graphics); |
---|
| 143 | graphics.addChild(&level); |
---|
| 144 | graphics.addChild(&gui); |
---|
| 145 | |
---|
| 146 | root.requestState("gui"); |
---|
| 147 | root.tick(0.0f); |
---|
| 148 | root.requestState(""); |
---|
| 149 | |
---|
| 150 | |
---|
[1663] | 151 | //Orxonox orxonoxInstance; |
---|
[1638] | 152 | |
---|
| 153 | try |
---|
| 154 | { |
---|
[1021] | 155 | #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE |
---|
[1638] | 156 | orxonoxInstance.start(macBundlePath()); |
---|
[612] | 157 | #else |
---|
[1661] | 158 | //orxonoxInstance.start(); |
---|
[612] | 159 | #endif |
---|
[1638] | 160 | } |
---|
| 161 | catch (std::exception& ex) |
---|
| 162 | { |
---|
| 163 | COUT(1) << ex.what() << std::endl; |
---|
| 164 | COUT(1) << "Abort." << std::endl; |
---|
| 165 | } |
---|
[612] | 166 | |
---|
[1638] | 167 | return 0; |
---|
[612] | 168 | } |
---|
| 169 | |
---|
[1021] | 170 | #ifdef __cplusplus |
---|
| 171 | } |
---|
| 172 | #endif |
---|