2015-01-01 17:15:05 +00:00
|
|
|
#include <iostream>
|
2015-02-01 15:19:05 +00:00
|
|
|
#include <csignal>
|
2015-01-01 17:15:05 +00:00
|
|
|
|
2011-03-28 23:36:26 +00:00
|
|
|
#include <QApplication>
|
2013-02-24 02:14:19 +00:00
|
|
|
#include <QTextCodec>
|
2013-02-20 18:29:12 +00:00
|
|
|
#include <QDir>
|
2013-06-26 08:09:26 +00:00
|
|
|
#include <QDebug>
|
|
|
|
|
2013-11-10 16:58:57 +00:00
|
|
|
#ifdef MAC_OS_X_VERSION_MIN_REQUIRED
|
|
|
|
#undef MAC_OS_X_VERSION_MIN_REQUIRED
|
2013-09-01 19:17:41 +00:00
|
|
|
// We need to do this because of Qt: https://bugreports.qt-project.org/browse/QTBUG-22154
|
|
|
|
#define MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
|
2013-11-10 16:58:57 +00:00
|
|
|
#endif // MAC_OS_X_VERSION_MIN_REQUIRED
|
|
|
|
|
2013-06-23 18:45:24 +00:00
|
|
|
#include <SDL.h>
|
2013-01-26 17:19:04 +00:00
|
|
|
|
2011-04-07 21:57:03 +00:00
|
|
|
#include "maindialog.hpp"
|
2011-03-28 23:36:26 +00:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2014-12-18 02:24:10 +00:00
|
|
|
try
|
2013-06-23 18:45:24 +00:00
|
|
|
{
|
2014-12-18 02:24:10 +00:00
|
|
|
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software");
|
|
|
|
SDL_SetMainReady();
|
|
|
|
if (SDL_Init(SDL_INIT_VIDEO) != 0)
|
|
|
|
{
|
2015-02-06 17:05:02 +00:00
|
|
|
qDebug() << "SDL_Init failed: " << QString::fromUtf8(SDL_GetError());
|
2014-12-18 02:24:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2015-02-01 15:19:05 +00:00
|
|
|
signal(SIGINT, SIG_DFL); // We don't want to use the SDL event loop in the launcher,
|
|
|
|
// so reset SIGINT which SDL wants to redirect to an SDL_Quit event.
|
2013-06-23 01:49:30 +00:00
|
|
|
|
2014-12-18 02:24:10 +00:00
|
|
|
QApplication app(argc, argv);
|
2011-03-28 23:36:26 +00:00
|
|
|
|
2014-12-18 02:24:10 +00:00
|
|
|
// Now we make sure the current dir is set to application path
|
|
|
|
QDir dir(QCoreApplication::applicationDirPath());
|
2011-05-10 20:47:08 +00:00
|
|
|
|
2014-12-18 02:24:10 +00:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
if (dir.dirName() == "MacOS") {
|
|
|
|
dir.cdUp();
|
|
|
|
dir.cdUp();
|
|
|
|
dir.cdUp();
|
|
|
|
}
|
2012-02-15 07:27:51 +00:00
|
|
|
|
2014-12-18 02:24:10 +00:00
|
|
|
// force Qt to load only LOCAL plugins, don't touch system Qt installation
|
|
|
|
QDir pluginsPath(QCoreApplication::applicationDirPath());
|
|
|
|
pluginsPath.cdUp();
|
|
|
|
pluginsPath.cd("Plugins");
|
2012-02-15 07:27:51 +00:00
|
|
|
|
2014-12-18 02:24:10 +00:00
|
|
|
QStringList libraryPaths;
|
|
|
|
libraryPaths << pluginsPath.path() << QCoreApplication::applicationDirPath();
|
|
|
|
app.setLibraryPaths(libraryPaths);
|
|
|
|
#endif
|
2011-05-03 13:09:21 +00:00
|
|
|
|
2014-12-18 02:24:10 +00:00
|
|
|
QDir::setCurrent(dir.absolutePath());
|
2011-05-10 20:47:08 +00:00
|
|
|
|
2014-12-18 02:24:10 +00:00
|
|
|
// Support non-latin characters
|
|
|
|
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
2013-02-24 02:14:19 +00:00
|
|
|
|
2014-12-18 02:24:10 +00:00
|
|
|
Launcher::MainDialog mainWin;
|
2013-01-26 17:19:04 +00:00
|
|
|
|
2014-12-18 02:24:10 +00:00
|
|
|
if (!mainWin.showFirstRunDialog())
|
|
|
|
return 0;
|
2014-05-30 00:12:48 +00:00
|
|
|
|
2014-12-18 02:24:10 +00:00
|
|
|
// if (!mainWin.setup()) {
|
|
|
|
// return 0;
|
|
|
|
// }
|
2014-05-30 00:12:48 +00:00
|
|
|
|
2014-12-18 02:24:10 +00:00
|
|
|
mainWin.show();
|
2013-01-26 17:19:04 +00:00
|
|
|
|
2014-12-18 02:24:10 +00:00
|
|
|
int returnValue = app.exec();
|
|
|
|
SDL_Quit();
|
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
|
|
|
std::cerr << "ERROR: " << e.what() << std::endl;
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-28 23:36:26 +00:00
|
|
|
}
|