Debian Codegraph @

src/game/main.cpp

raw symbols SCIP
1 // This file is part of Dust Racing 2D.
2 // Copyright (C) 2015 Jussi Lind <[email protected]>
3 //
4 // Dust Racing 2D is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 // Dust Racing 2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>.
15
16 #include <QDebug>
17 #include <QDir>
18 #include <QLocale>
19 #include <QSettings>
20
21 #include "../common/config.hpp"
22 #include "../common/userexception.hpp"
23
24 #include "application.hpp"
25 #include "game.hpp"
26
27 #include "simple_logger.hpp"
28
29 #include <iostream>
30 #include <string>
31 #include <vector>
32
33 using juzzlin::L;
34
35 static void initLogger()
36 {
37 QString logPath = QDir::tempPath() + QDir::separator() + "dr2d.log";
38 L::initialize(logPath.toStdString().c_str());
39 L::setTimestampMode(L::TimestampMode::DateTime);
40 L::setLevelSymbol(L::Level::Trace, "<T>");
41 L::setLevelSymbol(L::Level::Debug, "<D>");
42 L::setLevelSymbol(L::Level::Info, "<I>");
43 L::setLevelSymbol(L::Level::Warning, "<W>");
44 L::setLevelSymbol(L::Level::Fatal, "<F>");
45 L::enableEchoMode(true);
46 L().info() << "Dust Racing 2D version " << VERSION;
47 L().info() << "Compiled against Qt version " << QT_VERSION_STR;
48 }
49
50 int main(int argc, char ** argv)
51 {
52 QGuiApplication::setOrganizationName(Config::General::QT_ORGANIZATION_NAME);
53 QGuiApplication::setApplicationName(Config::Game::QT_APPLICATION_NAME);
54 #ifdef Q_OS_WIN32
55 QSettings::setDefaultFormat(QSettings::IniFormat);
56 #endif
57
58 try
59 {
60 initLogger();
61 return Game(argc, argv).run();
62 } //
63 catch (std::exception & e)
64 {
65 if (!dynamic_cast<UserException *>(&e))
66 {
67 L().fatal() << e.what();
68 L().fatal() << "Initializing the game failed!";
69 }
70 return EXIT_FAILURE;
71 }
72 }