1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-23 21:07:45 +00:00
astra/launcher/main.cpp

98 lines
2.5 KiB
C++
Raw Normal View History

#include "launchercore.h"
2021-11-01 09:54:58 -04:00
#include <QApplication>
#include <QCommandLineParser>
#include <QDir>
#include "../launcher/tablet/include/tabletinterface.h"
#include "cmdinterface.h"
#include "config.h"
#include "desktopinterface.h"
#include "gameinstaller.h"
#include "sapphirelauncher.h"
#include "squareboot.h"
2021-11-01 09:54:58 -04:00
int main(int argc, char* argv[]) {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
2021-11-01 09:54:58 -04:00
QApplication app(argc, argv);
2022-02-23 19:00:17 -05:00
QCoreApplication::setApplicationName("astra");
QCoreApplication::setApplicationVersion(version);
// we want to decide which interface to use. this is decided by the
// -cli, -desktop, or -tablet
// the default is -desktop
// cli is a special case where it's always "enabled"
QCommandLineParser parser;
parser.setApplicationDescription("Cross-platform FFXIV Launcher");
auto helpOption = parser.addHelpOption();
auto versionOption = parser.addVersionOption();
2021-11-23 15:37:02 -05:00
QCommandLineOption desktopOption("desktop", "Open a desktop interface.");
#ifdef ENABLE_DESKTOP
parser.addOption(desktopOption);
#endif
QCommandLineOption tabletOption("tablet", "Open a tablet interface.");
#ifdef ENABLE_TABLET
parser.addOption(tabletOption);
#endif
QCommandLineOption cliOption("cli", "Don't open a main window, and use the cli interface.");
#ifdef ENABLE_CLI
parser.addOption(cliOption);
#endif
2021-11-23 15:37:02 -05:00
QCommandLineOption steamOption("steam", "Simulate booting the launcher via Steam.");
#ifdef ENABLE_STEAM
parser.addOption(steamOption);
#endif
auto cmd = std::make_unique<CMDInterface>(parser);
parser.process(app);
2022-08-15 11:14:37 -04:00
if (parser.isSet(versionOption)) {
parser.showVersion();
}
2022-08-15 11:14:37 -04:00
if (parser.isSet(helpOption)) {
parser.showHelp();
}
LauncherCore c;
std::unique_ptr<DesktopInterface> desktopInterface;
std::unique_ptr<TabletInterface> tabletInterface;
2022-09-05 17:30:15 -04:00
if(parser.isSet(steamOption)) {
c.isSteam = true;
2022-09-05 17:30:15 -04:00
for(auto& argument : QCoreApplication::arguments()) {
if(argument.contains("iscriptevaluator")) {
2022-09-06 10:18:12 -04:00
//return 0;
}
2022-09-05 17:30:15 -04:00
}
}
2022-08-15 11:14:37 -04:00
if (parser.isSet(tabletOption)) {
#ifdef ENABLE_TABLET
tabletInterface = std::make_unique<TabletInterface>(c);
#endif
2022-08-15 11:14:37 -04:00
} else if (parser.isSet(cliOption)) {
#ifdef ENABLE_CLI
2022-08-15 11:14:37 -04:00
if (!cmd->parse(parser, c))
return -1;
#endif
} else {
#ifdef ENABLE_DESKTOP
desktopInterface = std::make_unique<DesktopInterface>(c);
#endif
2021-11-23 15:37:02 -05:00
}
2021-11-01 09:54:58 -04:00
return app.exec();
}