Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10241 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
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
33    The main function of Orxonox (but not the entry point of the program!)
34*/
35
36#include "Main.h"
37
38#include <memory>
39#include <QApplication>
40#include <QCoreApplication>
41
42#ifdef ORXONOX_PLATFORM_WINDOWS
43#  include <windows.h>
44#endif
45
46#include "util/Debug.h"
47#include "util/Exception.h"
48#include "core/CommandLineParser.h"
49#include "core/Core.h"
50#include "Analyser.h"
51
52namespace orxonox
53{
54    SetCommandLineArgument(generateDoc, "")
55        .information("Generates a Doxygen file from things like SetConsoleCommand");
56
57    /**
58    @brief
59        Starting point of orxonox (however not the entry point of the program!)
60    */
61    int main(int argc, char** argv)
62    {
63        QApplication app(argc, argv);
64
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        }
81
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);
90
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
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        }
111    }
112}
Note: See TracBrowser for help on using the repository browser.