Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/forks/pch_analyser/src/orxonox/Main.cc @ 11293

Last change on this file since 11293 was 7817, checked in by rgrieder, 14 years ago

Merged r7816 from sandbox_qt.

  • Property svn:eol-style set to native
File size: 3.5 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 */
[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
[7817]38#include <memory>
[7423]39#include <QApplication>
40#include <QCoreApplication>
41
[7817]42#ifdef ORXONOX_PLATFORM_WINDOWS
43#  include <windows.h>
44#endif
45
[7424]46#include "util/Debug.h"
[7817]47#include "util/Exception.h"
[7425]48#include "core/CommandLineParser.h"
[7424]49#include "core/Core.h"
[7815]50#include "Analyser.h"
[612]51
[5693]52namespace 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
[7817]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
[7817]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);
[7815]97
[7817]98        try
99        {
100            parse();
101            return 0;
102        }
103        catch (const Exception& ex)
104        {
105            COUT(0) << "Exception: " << ex.getDescription() << endl;
106#ifdef ORXONOX_PLATFORM_WINDOWS
107            MessageBox(NULL, ex.getDescription().c_str(), "Exception", MB_ICONERROR);
108#endif
109            return 1;
110        }
[5693]111    }
[612]112}
Note: See TracBrowser for help on using the repository browser.