[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 | */ |
---|
[5693] | 29 | |
---|
[3196] | 30 | /** |
---|
| 31 | @file |
---|
| 32 | @brief |
---|
[5929] | 33 | The main function of Orxonox (but not the entry point of the program!) |
---|
[3196] | 34 | */ |
---|
[612] | 35 | |
---|
[7430] | 36 | #include "Main.h" |
---|
[612] | 37 | |
---|
[7816] | 38 | #include <memory> |
---|
[7423] | 39 | #include <QApplication> |
---|
| 40 | #include <QCoreApplication> |
---|
| 41 | |
---|
[7816] | 42 | #ifdef ORXONOX_PLATFORM_WINDOWS |
---|
| 43 | # include <windows.h> |
---|
| 44 | #endif |
---|
| 45 | |
---|
[7424] | 46 | #include "util/Debug.h" |
---|
[7816] | 47 | #include "util/Exception.h" |
---|
[7425] | 48 | #include "core/CommandLineParser.h" |
---|
[7424] | 49 | #include "core/Core.h" |
---|
[7430] | 50 | #include "MainWindow.h" |
---|
[612] | 51 | |
---|
[5693] | 52 | namespace orxonox |
---|
[622] | 53 | { |
---|
[7424] | 54 | SetCommandLineArgument(generateDoc, "") |
---|
| 55 | .information("Generates a Doxygen file from things like SetConsoleCommand"); |
---|
| 56 | |
---|
[5693] | 57 | /** |
---|
| 58 | @brief |
---|
[5929] | 59 | Starting point of orxonox (however not the entry point of the program!) |
---|
[5693] | 60 | */ |
---|
[7423] | 61 | int main(int argc, char** argv) |
---|
[2103] | 62 | { |
---|
[7423] | 63 | QApplication app(argc, argv); |
---|
[2103] | 64 | |
---|
[7816] | 65 | std::auto_ptr<Core> core; |
---|
| 66 | try |
---|
| 67 | { |
---|
| 68 | QStringList arguments = QCoreApplication::arguments(); |
---|
| 69 | if (!arguments.value(0).isEmpty() && arguments.value(0)[0] != '-') |
---|
| 70 | arguments.pop_front(); // Remove application path |
---|
| 71 | core.reset(new Core(arguments.join(" ").toStdString())); |
---|
| 72 | } |
---|
| 73 | catch (const Exception& ex) |
---|
| 74 | { |
---|
| 75 | COUT(0) << "Exception: " << ex.getDescription() << endl; |
---|
| 76 | #ifdef ORXONOX_PLATFORM_WINDOWS |
---|
| 77 | MessageBox(NULL, ex.getDescription().c_str(), "Exception", MB_ICONERROR); |
---|
| 78 | #endif |
---|
| 79 | return 1; |
---|
| 80 | } |
---|
[7424] | 81 | |
---|
[7430] | 82 | QCoreApplication::setOrganizationName("Orxonox"); |
---|
| 83 | QCoreApplication::setOrganizationDomain("www.orxonox.net"); |
---|
| 84 | QCoreApplication::setApplicationName("Orxonox Sandbox"); |
---|
| 85 | QString versionString; |
---|
| 86 | versionString += QString::number(ORXONOX_VERSION_MAJOR); |
---|
| 87 | versionString += QString::number(ORXONOX_VERSION_MINOR); |
---|
| 88 | versionString += QString::number(ORXONOX_VERSION_PATCH); |
---|
| 89 | QCoreApplication::setApplicationVersion(versionString); |
---|
[7423] | 90 | |
---|
[7816] | 91 | // Define library path |
---|
| 92 | // Note: May not work (untested) because QApplication was already created. |
---|
| 93 | // However doing the beforehand is difficult because the Core is required. |
---|
| 94 | QStringList libraryPaths = QCoreApplication::libraryPaths(); |
---|
| 95 | libraryPaths.prepend(PathConfig::getExecutablePath().path() + "/plugins"); |
---|
| 96 | QCoreApplication::setLibraryPaths(libraryPaths); |
---|
| 97 | |
---|
| 98 | try |
---|
[7430] | 99 | { |
---|
[7816] | 100 | if (CommandLineParser::getValue("generateDoc").toString().isEmpty()) |
---|
| 101 | { |
---|
| 102 | MainWindow window; |
---|
| 103 | window.show(); |
---|
| 104 | return app.exec(); |
---|
| 105 | } |
---|
| 106 | else |
---|
| 107 | return 0; |
---|
[7430] | 108 | } |
---|
[7816] | 109 | catch (const Exception& ex) |
---|
| 110 | { |
---|
| 111 | COUT(0) << "Exception: " << ex.getDescription() << endl; |
---|
| 112 | #ifdef ORXONOX_PLATFORM_WINDOWS |
---|
| 113 | MessageBox(NULL, ex.getDescription().c_str(), "Exception", MB_ICONERROR); |
---|
| 114 | #endif |
---|
| 115 | return 1; |
---|
| 116 | } |
---|
[5693] | 117 | } |
---|
[612] | 118 | } |
---|