1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-21 20:27:45 +00:00

Reformat code

This commit is contained in:
Joshua Goins 2022-08-15 11:14:37 -04:00
parent bbdb78f2a8
commit 5a96467f14
36 changed files with 598 additions and 606 deletions

View file

@ -31,4 +31,3 @@ AllowShortFunctionsOnASingleLine: 'Empty'
AllowShortLambdasOnASingleLine: 'Empty' AllowShortLambdasOnASingleLine: 'Empty'
AllowShortLoopsOnASingleLine: 'false' AllowShortLoopsOnASingleLine: 'false'
SeparateDefinitionBlocks : 'Always' SeparateDefinitionBlocks : 'Always'
...

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <QCommandLineParser>
#include "launchercore.h" #include "launchercore.h"
#include <QCommandLineParser>
/* /*
* The CLI interface for Astra, driven primarily by the command-line. * The CLI interface for Astra, driven primarily by the command-line.
@ -13,6 +13,11 @@ public:
bool parse(QCommandLineParser& parser, LauncherCore& core); bool parse(QCommandLineParser& parser, LauncherCore& core);
private: private:
QCommandLineOption profileOption = {"default-profile", "Profile to use for default profile and autologin.", "profile"}; QCommandLineOption profileOption = {
QCommandLineOption autologinOption = {"autologin", "Auto-login with the default profile. This requires the profile to have remember username/password enabled!"}; "default-profile",
"Profile to use for default profile and autologin.",
"profile"};
QCommandLineOption autologinOption = {
"autologin",
"Auto-login with the default profile. This requires the profile to have remember username/password enabled!"};
}; };

View file

@ -1,7 +1,7 @@
#include <keychain.h>
#include "cmdinterface.h" #include "cmdinterface.h"
#include "squareboot.h"
#include "sapphirelauncher.h" #include "sapphirelauncher.h"
#include "squareboot.h"
#include <keychain.h>
CMDInterface::CMDInterface(QCommandLineParser& parser) { CMDInterface::CMDInterface(QCommandLineParser& parser) {
parser.addOption(autologinOption); parser.addOption(autologinOption);
@ -34,7 +34,8 @@ bool CMDInterface::parse(QCommandLineParser &parser, LauncherCore &core) {
usernameJob->setKey(profile.name + "-username"); usernameJob->setKey(profile.name + "-username");
usernameJob->start(); usernameJob->start();
core.connect(usernameJob, &QKeychain::ReadPasswordJob::finished, [loop, usernameJob, &username](QKeychain::Job* j) { core.connect(
usernameJob, &QKeychain::ReadPasswordJob::finished, [loop, usernameJob, &username](QKeychain::Job* j) {
username = usernameJob->textData(); username = usernameJob->textData();
loop->quit(); loop->quit();
}); });
@ -45,7 +46,8 @@ bool CMDInterface::parse(QCommandLineParser &parser, LauncherCore &core) {
passwordJob->setKey(profile.name + "-password"); passwordJob->setKey(profile.name + "-password");
passwordJob->start(); passwordJob->start();
core.connect(passwordJob, &QKeychain::ReadPasswordJob::finished, [loop, passwordJob, &password](QKeychain::Job* j) { core.connect(
passwordJob, &QKeychain::ReadPasswordJob::finished, [loop, passwordJob, &password](QKeychain::Job* j) {
password = passwordJob->textData(); password = passwordJob->textData();
loop->quit(); loop->quit();
}); });

View file

@ -4,10 +4,7 @@
#include <physis.hpp> #include <physis.hpp>
// from xivdev // from xivdev
static char ChecksumTable[] = { static char ChecksumTable[] = {'f', 'X', '1', 'p', 'G', 't', 'd', 'S', '5', 'C', 'A', 'P', '4', '_', 'V', 'L'};
'f', 'X', '1', 'p', 'G', 't', 'd', 'S',
'5', 'C', 'A', 'P', '4', '_', 'V', 'L'
};
inline char GetChecksum(unsigned int key) { inline char GetChecksum(unsigned int key) {
auto value = key & 0x000F0000; auto value = key & 0x000F0000;
@ -31,13 +28,13 @@ inline QString encryptGameArg(QString arg) {
QByteArray toEncrypt = (QString(" /T =%1").arg(ticks) + arg).toUtf8(); QByteArray toEncrypt = (QString(" /T =%1").arg(ticks) + arg).toUtf8();
physis_blowfish_encrypt(blowfish, physis_blowfish_encrypt(
reinterpret_cast<uint8_t*>(toEncrypt.data()), toEncrypt.size(), &out_data, &out_size); blowfish, reinterpret_cast<uint8_t*>(toEncrypt.data()), toEncrypt.size(), &out_data, &out_size);
QByteArray encryptedArg = QByteArray::fromRawData( QByteArray encryptedArg = QByteArray::fromRawData(reinterpret_cast<const char*>(out_data), out_size);
reinterpret_cast<const char*>(out_data), out_size);
QString base64 = encryptedArg.toBase64(QByteArray::Base64Option::Base64UrlEncoding | QByteArray::Base64Option::OmitTrailingEquals); QString base64 = encryptedArg.toBase64(
QByteArray::Base64Option::Base64UrlEncoding | QByteArray::Base64Option::OmitTrailingEquals);
char checksum = GetChecksum(key); char checksum = GetChecksum(key);
return QString("//**sqex0003%1%2**//").arg(base64, QString(checksum)); return QString("//**sqex0003%1%2**//").arg(base64, QString(checksum));

View file

@ -1,8 +1,8 @@
#pragma once #pragma once
#include <QImage> #include <QImage>
#include <tesseract/baseapi.h>
#include <leptonica/allheaders.h> #include <leptonica/allheaders.h>
#include <tesseract/baseapi.h>
enum class ScreenState { enum class ScreenState {
Splash, Splash,

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <QUrl>
#include <QDateTime> #include <QDateTime>
#include <QUrl>
struct News { struct News {
QDateTime date; QDateTime date;

View file

@ -1,12 +1,12 @@
#pragma once #pragma once
#include <QMainWindow>
#include <QNetworkAccessManager>
#include <QFuture> #include <QFuture>
#include <QMainWindow>
#include <QMessageBox>
#include <QNetworkAccessManager>
#include <QProcess>
#include <QSettings> #include <QSettings>
#include <QUuid> #include <QUuid>
#include <QProcess>
#include <QMessageBox>
#include <QtQml> #include <QtQml>
#include "squareboot.h" #include "squareboot.h"
@ -162,7 +162,12 @@ public:
/* /*
* This just wraps it in wine if needed. * This just wraps it in wine if needed.
*/ */
void launchExecutable(const ProfileSettings& settings, QProcess* process, QStringList args, bool isGame, bool needsRegistrySetup); void launchExecutable(
const ProfileSettings& settings,
QProcess* process,
QStringList args,
bool isGame,
bool needsRegistrySetup);
/* /*
* Launches an external tool. Gamescope for example is intentionally excluded. * Launches an external tool. Gamescope for example is intentionally excluded.

View file

@ -1,8 +1,8 @@
#pragma once #pragma once
#include <QString>
#include <QProgressDialog>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QProgressDialog>
#include <QString>
#include <physis.hpp> #include <physis.hpp>
// General-purpose patcher routine. It opens a nice dialog box, handles downloading // General-purpose patcher routine. It opens a nice dialog box, handles downloading

View file

@ -2,6 +2,4 @@
#include "launchercore.h" #include "launchercore.h"
void installDXVK(LauncherCore& launcher, ProfileSettings& profile, std::function<void()> returnFunc) { void installDXVK(LauncherCore& launcher, ProfileSettings& profile, std::function<void()> returnFunc) {}
}

View file

@ -1,8 +1,8 @@
#include "encryptedarg.h" #include "encryptedarg.h"
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
#include <sys/sysctl.h>
#include <mach/mach_time.h> #include <mach/mach_time.h>
#include <sys/sysctl.h>
#endif #endif
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)

View file

@ -1,8 +1,8 @@
#include "gameinstaller.h" #include "gameinstaller.h"
#include <QFile>
#include <QNetworkReply> #include <QNetworkReply>
#include <QStandardPaths> #include <QStandardPaths>
#include <QFile>
#include <physis.hpp> #include <physis.hpp>
#include "launchercore.h" #include "launchercore.h"
@ -17,15 +17,15 @@ void installGame(LauncherCore& launcher, ProfileSettings& profile, std::function
auto reply = launcher.mgr->get(request); auto reply = launcher.mgr->get(request);
launcher.connect(reply, &QNetworkReply::finished, [reply, installDirectory, returnFunc] { launcher.connect(reply, &QNetworkReply::finished, [reply, installDirectory, returnFunc] {
QString dataDir = QString dataDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
QStandardPaths::writableLocation(QStandardPaths::TempLocation);
QFile file(dataDir + "/ffxivsetup.exe"); QFile file(dataDir + "/ffxivsetup.exe");
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
file.write(reply->readAll()); file.write(reply->readAll());
file.close(); file.close();
physis_install_game(installDirectory.toStdString().c_str(), (dataDir + "/ffxivsetup.exe").toStdString().c_str()); physis_install_game(
installDirectory.toStdString().c_str(), (dataDir + "/ffxivsetup.exe").toStdString().c_str());
qDebug() << "Done installing to " << installDirectory << "!"; qDebug() << "Done installing to " << installDirectory << "!";

View file

@ -1,8 +1,8 @@
#include "gameparser.h" #include "gameparser.h"
#include <QBuffer>
#include <QDebug> #include <QDebug>
#include <QRegularExpression> #include <QRegularExpression>
#include <QBuffer>
GameParser::GameParser() { GameParser::GameParser() {
api = new tesseract::TessBaseAPI(); api = new tesseract::TessBaseAPI();

View file

@ -1,12 +1,12 @@
#include "headline.h" #include "headline.h"
#include <QUrlQuery>
#include <QNetworkRequest>
#include <QDateTime> #include <QDateTime>
#include <QNetworkReply> #include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QJsonArray> #include <QNetworkReply>
#include <QNetworkRequest>
#include <QUrlQuery>
#include "launchercore.h" #include "launchercore.h"
@ -21,7 +21,8 @@ void getHeadline(LauncherCore& core, std::function<void(Headline)> return_func)
url.setPath("/news/headline.json"); url.setPath("/news/headline.json");
url.setQuery(query); url.setQuery(query);
auto request = QNetworkRequest(QString("%1&%2").arg(url.toString(), QString::number(QDateTime::currentMSecsSinceEpoch()))); auto request =
QNetworkRequest(QString("%1&%2").arg(url.toString(), QString::number(QDateTime::currentMSecsSinceEpoch())));
// TODO: really? // TODO: really?
core.buildRequest(core.getProfile(core.defaultProfileIndex), request); core.buildRequest(core.getProfile(core.defaultProfileIndex), request);
@ -29,7 +30,11 @@ void getHeadline(LauncherCore& core, std::function<void(Headline)> return_func)
qInfo() << request.url(); qInfo() << request.url();
request.setRawHeader("Accept", "application/json, text/plain, */*"); request.setRawHeader("Accept", "application/json, text/plain, */*");
request.setRawHeader("Origin", "https://launcher.finalfantasyxiv.com"); request.setRawHeader("Origin", "https://launcher.finalfantasyxiv.com");
request.setRawHeader("Referer", QString("https://launcher.finalfantasyxiv.com/v600/index.html?rc_lang=%1&time=%2").arg("en-us", QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd-HH")).toUtf8()); request.setRawHeader(
"Referer",
QString("https://launcher.finalfantasyxiv.com/v600/index.html?rc_lang=%1&time=%2")
.arg("en-us", QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd-HH"))
.toUtf8());
auto reply = core.mgr->get(request); auto reply = core.mgr->get(request);
core.connect(reply, &QNetworkReply::finished, [=] { core.connect(reply, &QNetworkReply::finished, [=] {

View file

@ -1,32 +1,32 @@
#include <QPushButton> #include <QCheckBox>
#include <QProcess> #include <QComboBox>
#include <QNetworkAccessManager> #include <QCoreApplication>
#include <QNetworkReply>
#include <QUrlQuery>
#include <QDir> #include <QDir>
#include <QFormLayout> #include <QFormLayout>
#include <QLineEdit>
#include <QRegularExpression>
#include <QComboBox>
#include <QJsonObject>
#include <QJsonDocument> #include <QJsonDocument>
#include <QCheckBox> #include <QJsonObject>
#include <keychain.h> #include <QLineEdit>
#include <QMessageBox>
#include <QMenuBar> #include <QMenuBar>
#include <QCoreApplication> #include <QMessageBox>
#include <QStandardPaths> #include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QProcess>
#include <QPushButton>
#include <QRegularExpression>
#include <QRegularExpressionMatch> #include <QRegularExpressionMatch>
#include <algorithm> #include <QStandardPaths>
#include <QTcpServer> #include <QTcpServer>
#include <QUrlQuery>
#include <algorithm>
#include <keychain.h>
#include "launchercore.h"
#include "sapphirelauncher.h"
#include "squarelauncher.h"
#include "squareboot.h"
#include "settingswindow.h"
#include "assetupdater.h" #include "assetupdater.h"
#include "encryptedarg.h" #include "encryptedarg.h"
#include "launchercore.h"
#include "sapphirelauncher.h"
#include "settingswindow.h"
#include "squareboot.h"
#include "squarelauncher.h"
#ifdef ENABLE_WATCHDOG #ifdef ENABLE_WATCHDOG
#include "watchdog.h" #include "watchdog.h"
@ -46,12 +46,15 @@ void LauncherCore::buildRequest(const ProfileSettings& settings, QNetworkRequest
if (settings.license == GameLicense::macOS) { if (settings.license == GameLicense::macOS) {
request.setHeader(QNetworkRequest::UserAgentHeader, "macSQEXAuthor/2.0.0(MacOSX; ja-jp)"); request.setHeader(QNetworkRequest::UserAgentHeader, "macSQEXAuthor/2.0.0(MacOSX; ja-jp)");
} else { } else {
request.setHeader(QNetworkRequest::UserAgentHeader, request.setHeader(
QNetworkRequest::UserAgentHeader,
QString("SQEXAuthor/2.0.0(Windows 6.2; ja-jp; %1)").arg(QString(QSysInfo::bootUniqueId()))); QString("SQEXAuthor/2.0.0(Windows 6.2; ja-jp; %1)").arg(QString(QSysInfo::bootUniqueId())));
} }
request.setRawHeader("Accept", request.setRawHeader(
"image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/xaml+xml, application/x-ms-xbap, */*"); "Accept",
"image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/xaml+xml, "
"application/x-ms-xbap, */*");
request.setRawHeader("Accept-Encoding", "gzip, deflate"); request.setRawHeader("Accept-Encoding", "gzip, deflate");
request.setRawHeader("Accept-Language", "en-us"); request.setRawHeader("Accept-Language", "en-us");
} }
@ -107,8 +110,7 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
if (profile.dalamud.enabled) { if (profile.dalamud.enabled) {
// TODO: this depends on the default wine Z: path existing, which may not // TODO: this depends on the default wine Z: path existing, which may not
// always the case. // always the case.
env.insert("DALAMUD_RUNTIME", env.insert("DALAMUD_RUNTIME", "Z:" + dataDir.replace('/', '\\') + "\\DalamudRuntime");
"Z:" + dataDir.replace('/', '\\') + "\\DalamudRuntime");
} }
gameProcess->setProcessEnvironment(env); gameProcess->setProcessEnvironment(env);
@ -169,7 +171,12 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
auto list = dalamudProcess->processEnvironment().toStringList(); auto list = dalamudProcess->processEnvironment().toStringList();
launchExecutable(profile, dalamudProcess, {dataDir + "/Dalamud/" + "Dalamud.Injector.exe", QString::number(exitCode), argsEncoded}, false, true); launchExecutable(
profile,
dalamudProcess,
{dataDir + "/Dalamud/" + "Dalamud.Injector.exe", QString::number(exitCode), argsEncoded},
false,
true);
connection->close(); connection->close();
socket->close(); socket->close();
@ -180,7 +187,11 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
socket->listen(QHostAddress::Any, 5248); socket->listen(QHostAddress::Any, 5248);
} }
connect(gameProcess, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), this, [this](int code, QProcess::ExitStatus status) { connect(
gameProcess,
qOverload<int, QProcess::ExitStatus>(&QProcess::finished),
this,
[this](int code, QProcess::ExitStatus status) {
gameClosed(); gameClosed();
}); });
@ -209,7 +220,12 @@ void LauncherCore::launchGameExecutable(const ProfileSettings& profile, QProcess
launchExecutable(profile, process, arguments, true, true); launchExecutable(profile, process, arguments, true, true);
} }
void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* process, const QStringList args, bool isGame, bool needsRegistrySetup) { void LauncherCore::launchExecutable(
const ProfileSettings& profile,
QProcess* process,
const QStringList args,
bool isGame,
bool needsRegistrySetup) {
QList<QString> arguments; QList<QString> arguments;
auto env = process->processEnvironment(); auto env = process->processEnvironment();
@ -235,16 +251,13 @@ void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* pr
arguments.push_back("-b"); arguments.push_back("-b");
if (profile.gamescope.width > 0) if (profile.gamescope.width > 0)
arguments.push_back("-w " + arguments.push_back("-w " + QString::number(profile.gamescope.width));
QString::number(profile.gamescope.width));
if (profile.gamescope.height > 0) if (profile.gamescope.height > 0)
arguments.push_back("-h " + arguments.push_back("-h " + QString::number(profile.gamescope.height));
QString::number(profile.gamescope.height));
if (profile.gamescope.refreshRate > 0) if (profile.gamescope.refreshRate > 0)
arguments.push_back( arguments.push_back("-r " + QString::number(profile.gamescope.refreshRate));
"-r " + QString::number(profile.gamescope.refreshRate));
} }
if (profile.useGamemode) if (profile.useGamemode)
@ -266,7 +279,8 @@ void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* pr
// XIV on Mac bundle their own Wine install directory, complete with libs etc // XIV on Mac bundle their own Wine install directory, complete with libs etc
if (profile.wineType == WineType::XIVOnMac) { if (profile.wineType == WineType::XIVOnMac) {
// TODO: don't hardcode this // TODO: don't hardcode this
QString xivLibPath = "/Applications/XIV on Mac.app/Contents/Resources/wine/lib:/Applications/XIV on Mac.app/Contents/Resources/MoltenVK/modern"; QString xivLibPath = "/Applications/XIV on Mac.app/Contents/Resources/wine/lib:/Applications/XIV on "
"Mac.app/Contents/Resources/MoltenVK/modern";
env.insert("DYLD_FALLBACK_LIBRARY_PATH", xivLibPath); env.insert("DYLD_FALLBACK_LIBRARY_PATH", xivLibPath);
env.insert("DYLD_VERSIONED_LIBRARY_PATH", xivLibPath); env.insert("DYLD_VERSIONED_LIBRARY_PATH", xivLibPath);
@ -317,8 +331,7 @@ void LauncherCore::readInitialInformation() {
gamescopeAvailable = checkIfInPath("gamescope"); gamescopeAvailable = checkIfInPath("gamescope");
gamemodeAvailable = checkIfInPath("gamemoderun"); gamemodeAvailable = checkIfInPath("gamemoderun");
const QString dataDir = const QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
const bool hasDalamud = QFile::exists(dataDir + "/Dalamud"); const bool hasDalamud = QFile::exists(dataDir + "/Dalamud");
if (hasDalamud) { if (hasDalamud) {
@ -330,18 +343,10 @@ void LauncherCore::readInitialInformation() {
QString versionString; QString versionString;
if (doc["targets"].toObject().contains(".NETCoreApp,Version=v5.0")) { if (doc["targets"].toObject().contains(".NETCoreApp,Version=v5.0")) {
versionString = versionString =
doc["targets"] doc["targets"].toObject()[".NETCoreApp,Version=v5.0"].toObject().keys().filter("Dalamud")[0];
.toObject()[".NETCoreApp,Version=v5.0"]
.toObject()
.keys()
.filter("Dalamud")[0];
} else { } else {
versionString = versionString =
doc["targets"] doc["targets"].toObject()[".NETCoreApp,Version=v6.0"].toObject().keys().filter("Dalamud")[0];
.toObject()[".NETCoreApp,Version=v6.0"]
.toObject()
.keys()
.filter("Dalamud")[0];
} }
dalamudVersion = versionString.remove("Dalamud/"); dalamudVersion = versionString.remove("Dalamud/");
@ -385,19 +390,22 @@ void LauncherCore::readInitialInformation() {
profile->name = settings.value("name", "Default").toString(); profile->name = settings.value("name", "Default").toString();
if(settings.contains("gamePath") && settings.value("gamePath").canConvert<QString>() && !settings.value("gamePath").toString().isEmpty()) { if (settings.contains("gamePath") && settings.value("gamePath").canConvert<QString>() &&
!settings.value("gamePath").toString().isEmpty()) {
profile->gamePath = settings.value("gamePath").toString(); profile->gamePath = settings.value("gamePath").toString();
} else { } else {
profile->gamePath = getDefaultGamePath(); profile->gamePath = getDefaultGamePath();
} }
if(settings.contains("winePrefixPath") && settings.value("winePrefixPath").canConvert<QString>() && !settings.value("winePrefixPath").toString().isEmpty()) { if (settings.contains("winePrefixPath") && settings.value("winePrefixPath").canConvert<QString>() &&
!settings.value("winePrefixPath").toString().isEmpty()) {
profile->winePrefixPath = settings.value("winePrefixPath").toString(); profile->winePrefixPath = settings.value("winePrefixPath").toString();
} else { } else {
profile->winePrefixPath = getDefaultWinePrefixPath(); profile->winePrefixPath = getDefaultWinePrefixPath();
} }
if(settings.contains("winePath") && settings.value("winePath").canConvert<QString>() && !settings.value("winePath").toString().isEmpty()) { if (settings.contains("winePath") && settings.value("winePath").canConvert<QString>() &&
!settings.value("winePath").toString().isEmpty()) {
profile->winePath = settings.value("winePath").toString(); profile->winePath = settings.value("winePath").toString();
} }
@ -432,14 +440,18 @@ void LauncherCore::readInitialInformation() {
profile->enableWatchdog = settings.value("enableWatchdog", defaultSettings.enableWatchdog).toBool(); profile->enableWatchdog = settings.value("enableWatchdog", defaultSettings.enableWatchdog).toBool();
// gamescope // gamescope
profile->gamescope.borderless = settings.value("gamescopeBorderless", defaultSettings.gamescope.borderless).toBool(); profile->gamescope.borderless =
settings.value("gamescopeBorderless", defaultSettings.gamescope.borderless).toBool();
profile->gamescope.width = settings.value("gamescopeWidth", defaultSettings.gamescope.width).toInt(); profile->gamescope.width = settings.value("gamescopeWidth", defaultSettings.gamescope.width).toInt();
profile->gamescope.height = settings.value("gamescopeHeight", defaultSettings.gamescope.height).toInt(); profile->gamescope.height = settings.value("gamescopeHeight", defaultSettings.gamescope.height).toInt();
profile->gamescope.refreshRate = settings.value("gamescopeRefreshRate", defaultSettings.gamescope.refreshRate).toInt(); profile->gamescope.refreshRate =
settings.value("gamescopeRefreshRate", defaultSettings.gamescope.refreshRate).toInt();
profile->dalamud.enabled = settings.value("enableDalamud", defaultSettings.dalamud.enabled).toBool(); profile->dalamud.enabled = settings.value("enableDalamud", defaultSettings.dalamud.enabled).toBool();
profile->dalamud.optOutOfMbCollection = settings.value("dalamudOptOut", defaultSettings.dalamud.optOutOfMbCollection).toBool(); profile->dalamud.optOutOfMbCollection =
profile->dalamud.channel = (DalamudChannel)settings.value("dalamudChannel", (int)defaultSettings.dalamud.channel).toInt(); settings.value("dalamudOptOut", defaultSettings.dalamud.optOutOfMbCollection).toBool();
profile->dalamud.channel =
(DalamudChannel)settings.value("dalamudChannel", (int)defaultSettings.dalamud.channel).toInt();
profileSettings[settings.value("index").toInt()] = profile; profileSettings[settings.value("index").toInt()] = profile;
@ -459,7 +471,8 @@ void LauncherCore::readWineInfo(ProfileSettings& profile) {
profile.winePath = profile.winePath; profile.winePath = profile.winePath;
break; break;
case WineType::Builtin: // ffxiv built-in (for mac users) case WineType::Builtin: // ffxiv built-in (for mac users)
profile.winePath = "/Applications/FINAL FANTASY XIV ONLINE.app/Contents/SharedSupport/finalfantasyxiv/FINAL FANTASY XIV ONLINE/wine"; profile.winePath = "/Applications/FINAL FANTASY XIV "
"ONLINE.app/Contents/SharedSupport/finalfantasyxiv/FINAL FANTASY XIV ONLINE/wine";
break; break;
case WineType::XIVOnMac: case WineType::XIVOnMac:
profile.winePath = "/Applications/XIV on Mac.app/Contents/Resources/wine/bin/wine64"; profile.winePath = "/Applications/XIV on Mac.app/Contents/Resources/wine/bin/wine64";
@ -504,7 +517,8 @@ void LauncherCore::readGameVersion() {
} }
} }
LauncherCore::LauncherCore() : settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::applicationName()) { LauncherCore::LauncherCore()
: settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::applicationName()) {
mgr = new QNetworkAccessManager(); mgr = new QNetworkAccessManager();
sapphireLauncher = new SapphireLauncher(*this); sapphireLauncher = new SapphireLauncher(*this);
squareLauncher = new SquareLauncher(*this); squareLauncher = new SquareLauncher(*this);
@ -663,7 +677,9 @@ QString LauncherCore::getDefaultGamePath() {
#endif #endif
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
return QDir::homePath() + "/Library/Application Support/FINAL FANTASY XIV ONLINE/Bottles/published_Final_Fantasy/drive_c/Program Files (x86)/SquareEnix/FINAL FANTASY XIV - A Realm Reborn"; return QDir::homePath() +
"/Library/Application Support/FINAL FANTASY XIV ONLINE/Bottles/published_Final_Fantasy/drive_c/Program "
"Files (x86)/SquareEnix/FINAL FANTASY XIV - A Realm Reborn";
#endif #endif
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
@ -671,8 +687,7 @@ QString LauncherCore::getDefaultGamePath() {
#endif #endif
} }
void LauncherCore::addRegistryKey(const ProfileSettings& settings, void LauncherCore::addRegistryKey(const ProfileSettings& settings, QString key, QString value, QString data) {
QString key, QString value, QString data) {
auto process = new QProcess(this); auto process = new QProcess(this);
process->setProcessEnvironment(QProcessEnvironment::systemEnvironment()); process->setProcessEnvironment(QProcessEnvironment::systemEnvironment());
launchExecutable(settings, process, {"reg", "add", key, "/v", value, "/d", data, "/f"}, false, false); launchExecutable(settings, process, {"reg", "add", key, "/v", value, "/d", data, "/f"}, false, false);

View file

@ -1,10 +1,10 @@
#include "patcher.h" #include "patcher.h"
#include <QDir>
#include <QFile> #include <QFile>
#include <QNetworkReply> #include <QNetworkReply>
#include <QNetworkRequest> #include <QNetworkRequest>
#include <QStandardPaths> #include <QStandardPaths>
#include <physis.hpp> #include <physis.hpp>
#include <QDir>
Patcher::Patcher(QString baseDirectory, BootData* boot_data) : boot_data(boot_data), baseDirectory(baseDirectory) { Patcher::Patcher(QString baseDirectory, BootData* boot_data) : boot_data(boot_data), baseDirectory(baseDirectory) {
dialog = new QProgressDialog(); dialog = new QProgressDialog();
@ -57,9 +57,11 @@ void Patcher::processPatchList(QNetworkAccessManager& mgr, QString patchList) {
repository = url_parts[url_parts.size() - 3]; repository = url_parts[url_parts.size() - 3];
if (isBoot()) { if (isBoot()) {
dialog->setLabelText("Updating the FINAL FANTASY XIV Updater/Launcher version.\nDownloading ffxivboot - " + version); dialog->setLabelText(
"Updating the FINAL FANTASY XIV Updater/Launcher version.\nDownloading ffxivboot - " + version);
} else { } else {
dialog->setLabelText("Updating the FINAL FANTASY XIV Game version.\nDownloading " + repository + " - " + version); dialog->setLabelText(
"Updating the FINAL FANTASY XIV Game version.\nDownloading " + repository + " - " + version);
} }
dialog->setMinimum(0); dialog->setMinimum(0);

View file

@ -1,19 +1,14 @@
#include "sapphirelauncher.h" #include "sapphirelauncher.h"
#include <QJsonObject>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject>
#include <QMessageBox> #include <QMessageBox>
#include <QNetworkReply> #include <QNetworkReply>
SapphireLauncher::SapphireLauncher(LauncherCore& window) : window(window), QObject(&window) { SapphireLauncher::SapphireLauncher(LauncherCore& window) : window(window), QObject(&window) {}
}
void SapphireLauncher::login(QString lobbyUrl, const LoginInformation& info) { void SapphireLauncher::login(QString lobbyUrl, const LoginInformation& info) {
QJsonObject data { QJsonObject data{{"username", info.username}, {"pass", info.password}};
{"username", info.username},
{"pass", info.password}
};
QUrl url; QUrl url;
url.setScheme("http"); url.setScheme("http");
@ -35,17 +30,15 @@ void SapphireLauncher::login(QString lobbyUrl, const LoginInformation& info) {
window.launchGame(*info.settings, auth); window.launchGame(*info.settings, auth);
} else { } else {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Invalid username/password."); auto messageBox =
new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Invalid username/password.");
messageBox->show(); messageBox->show();
} }
}); });
} }
void SapphireLauncher::registerAccount(QString lobbyUrl, const LoginInformation& info) { void SapphireLauncher::registerAccount(QString lobbyUrl, const LoginInformation& info) {
QJsonObject data { QJsonObject data{{"username", info.username}, {"pass", info.password}};
{"username", info.username},
{"pass", info.password}
};
QUrl url; QUrl url;
url.setScheme("http"); url.setScheme("http");
url.setHost(lobbyUrl); url.setHost(lobbyUrl);

View file

@ -1,20 +1,19 @@
#include "squareboot.h" #include "squareboot.h"
#include <QUrlQuery>
#include <QNetworkReply>
#include <QMessageBox>
#include <QPushButton>
#include <QStandardPaths>
#include <QFile> #include <QFile>
#include <physis.hpp>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QMessageBox>
#include <QNetworkReply>
#include <QPushButton>
#include <QStandardPaths>
#include <QUrlQuery>
#include <physis.hpp>
#include "squarelauncher.h" #include "squarelauncher.h"
SquareBoot::SquareBoot(LauncherCore& window, SquareLauncher& launcher) : window(window), launcher(launcher), QObject(&window) { SquareBoot::SquareBoot(LauncherCore& window, SquareLauncher& launcher)
: window(window), launcher(launcher), QObject(&window) {}
}
void SquareBoot::bootCheck(const LoginInformation& info) { void SquareBoot::bootCheck(const LoginInformation& info) {
patcher = new Patcher(info.settings->gamePath + "/boot", info.settings->bootData); patcher = new Patcher(info.settings->gamePath + "/boot", info.settings->bootData);
@ -69,9 +68,10 @@ void SquareBoot::checkGateStatus(LoginInformation* info) {
// I happen to run into this issue often, if I start the launcher really quickly after bootup // I happen to run into this issue often, if I start the launcher really quickly after bootup
// it's possible to actually check this quicker than the network is actually available, // it's possible to actually check this quicker than the network is actually available,
// causing the launcher to be stuck in "maintenace mode". so if that happens, we try to rerun this logic. // causing the launcher to be stuck in "maintenace mode". so if that happens, we try to rerun this logic.
// TODO: this selection of errors is currently guesswork, i'm assuming one of these will fit the bill of "internet is unavailable" in // TODO: this selection of errors is currently guesswork, i'm assuming one of these will fit the bill of
// some way. // "internet is unavailable" in some way.
if(reply->error() == QNetworkReply::HostNotFoundError || reply->error() == QNetworkReply::TimeoutError || reply->error() == QNetworkReply::UnknownServerError) if (reply->error() == QNetworkReply::HostNotFoundError || reply->error() == QNetworkReply::TimeoutError ||
reply->error() == QNetworkReply::UnknownServerError)
checkGateStatus(info); checkGateStatus(info);
QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
@ -81,7 +81,8 @@ void SquareBoot::checkGateStatus(LoginInformation* info) {
if (isGateOpen) { if (isGateOpen) {
bootCheck(*info); bootCheck(*info);
} else { } else {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, auto messageBox = new QMessageBox(
QMessageBox::Icon::Critical,
"Failed to Login", "Failed to Login",
"The login gate is closed, the game may be under maintenance."); "The login gate is closed, the game may be under maintenance.");

View file

@ -1,14 +1,14 @@
#include "squarelauncher.h" #include "squarelauncher.h"
#include <QDesktopServices>
#include <QFile> #include <QFile>
#include <QUrlQuery>
#include <QNetworkReply>
#include <QRegularExpressionMatch>
#include <QMessageBox>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QMessageBox>
#include <QNetworkReply>
#include <QPushButton> #include <QPushButton>
#include <QDesktopServices> #include <QRegularExpressionMatch>
#include <QUrlQuery>
#include "launchercore.h" #include "launchercore.h"
@ -16,9 +16,7 @@
#include "watchdog.h" #include "watchdog.h"
#endif #endif
SquareLauncher::SquareLauncher(LauncherCore& window) : window(window), QObject(&window) { SquareLauncher::SquareLauncher(LauncherCore& window) : window(window), QObject(&window) {}
}
QString getFileHash(QString file) { QString getFileHash(QString file) {
auto f = QFile(file); auto f = QFile(file);
@ -69,7 +67,10 @@ void SquareLauncher::getStored(const LoginInformation& info) {
if (match.hasMatch()) { if (match.hasMatch()) {
username = match.captured(1); username = match.captured(1);
} else { } else {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Could not get Steam username, have you attached your account?"); auto messageBox = new QMessageBox(
QMessageBox::Icon::Critical,
"Failed to Login",
"Could not get Steam username, have you attached your account?");
messageBox->show(); messageBox->show();
} }
} else { } else {
@ -82,7 +83,10 @@ void SquareLauncher::getStored(const LoginInformation& info) {
stored = match.captured(1); stored = match.captured(1);
login(info, url); login(info, url);
} else { } else {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Failed to contact SE servers. They may be in maintenance."); auto messageBox = new QMessageBox(
QMessageBox::Icon::Critical,
"Failed to Login",
"Failed to contact SE servers. They may be in maintenance.");
messageBox->show(); messageBox->show();
} }
}); });
@ -114,7 +118,11 @@ void SquareLauncher::login(const LoginInformation& info, const QUrl referer) {
const bool playable = parts[9] == "1"; const bool playable = parts[9] == "1";
if (!playable) { if (!playable) {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Your game is unplayable. Please check that you have the right license selected, and a subscription to play."); auto messageBox = new QMessageBox(
QMessageBox::Icon::Critical,
"Failed to Login",
"Your game is unplayable. Please check that you have the right license selected, and a "
"subscription to play.");
auto launcherButton = messageBox->addButton("Open Mog Station", QMessageBox::HelpRole); auto launcherButton = messageBox->addButton("Open Mog Station", QMessageBox::HelpRole);
connect(launcherButton, &QPushButton::clicked, [=] { connect(launcherButton, &QPushButton::clicked, [=] {
@ -129,7 +137,10 @@ void SquareLauncher::login(const LoginInformation& info, const QUrl referer) {
} }
if (!terms) { if (!terms) {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Your game is unplayable. You need to accept the terms of service from the official launcher."); auto messageBox = new QMessageBox(
QMessageBox::Icon::Critical,
"Failed to Login",
"Your game is unplayable. You need to accept the terms of service from the official launcher.");
window.addUpdateButtons(*info.settings, *messageBox); window.addUpdateButtons(*info.settings, *messageBox);
messageBox->show(); messageBox->show();
@ -161,7 +172,8 @@ void SquareLauncher::registerSession(const LoginInformation& info) {
QUrl url; QUrl url;
url.setScheme("https"); url.setScheme("https");
url.setHost("patch-gamever.ffxiv.com"); url.setHost("patch-gamever.ffxiv.com");
url.setPath(QString("/http/win32/ffxivneo_release_game/%1/%2").arg(info.settings->repositories.repositories[0].version, SID)); url.setPath(QString("/http/win32/ffxivneo_release_game/%1/%2")
.arg(info.settings->repositories.repositories[0].version, SID));
auto request = QNetworkRequest(url); auto request = QNetworkRequest(url);
window.setSSL(request); window.setSSL(request);
@ -173,8 +185,8 @@ void SquareLauncher::registerSession(const LoginInformation& info) {
for (int i = 1; i < auth.maxExpansion + 1; i++) { for (int i = 1; i < auth.maxExpansion + 1; i++) {
if (i <= info.settings->repositories.repositories_count) { if (i <= info.settings->repositories.repositories_count) {
report += QString("\nex%1\t%2") report +=
.arg(QString::number(i), info.settings->repositories.repositories[i].version); QString("\nex%1\t%2").arg(QString::number(i), info.settings->repositories.repositories[i].version);
} else { } else {
report += QString("\nex%1\t2012.01.01.0000.0000").arg(QString::number(i)); report += QString("\nex%1\t2012.01.01.0000.0000").arg(QString::number(i));
} }
@ -204,7 +216,10 @@ void SquareLauncher::registerSession(const LoginInformation& info) {
patcher->processPatchList(*window.mgr, body); patcher->processPatchList(*window.mgr, body);
} else { } else {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Failed the anti-tamper check. Please restore your game to the original state or update the game."); auto messageBox = new QMessageBox(
QMessageBox::Icon::Critical,
"Failed to Login",
"Failed the anti-tamper check. Please restore your game to the original state or update the game.");
window.addUpdateButtons(*info.settings, *messageBox); window.addUpdateButtons(*info.settings, *messageBox);
messageBox->show(); messageBox->show();
@ -213,15 +228,13 @@ void SquareLauncher::registerSession(const LoginInformation& info) {
} }
QString SquareLauncher::getBootHash(const LoginInformation& info) { QString SquareLauncher::getBootHash(const LoginInformation& info) {
const QList<QString> fileList = const QList<QString> fileList = {
{
"ffxivboot.exe", "ffxivboot.exe",
"ffxivboot64.exe", "ffxivboot64.exe",
"ffxivlauncher.exe", "ffxivlauncher.exe",
"ffxivlauncher64.exe", "ffxivlauncher64.exe",
"ffxivupdater.exe", "ffxivupdater.exe",
"ffxivupdater64.exe" "ffxivupdater64.exe"};
};
QString result; QString result;
for (int i = 0; i < fileList.count(); i++) { for (int i = 0; i < fileList.count(); i++) {

View file

@ -1,9 +1,9 @@
#include "watchdog.h" #include "watchdog.h"
#include <QTimer>
#include <QScreen>
#include <QGuiApplication> #include <QGuiApplication>
#include <QMenu> #include <QMenu>
#include <QScreen>
#include <QTimer>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -20,12 +20,11 @@ QImage qimageFromXImage(XImage *xi) {
else if (xi->depth == 16) else if (xi->depth == 16)
format = QImage::Format_RGB16; format = QImage::Format_RGB16;
QImage image = QImage(reinterpret_cast<uchar *>(xi->data), xi->width, xi->height, xi->bytes_per_line, QImage image = QImage(reinterpret_cast<uchar*>(xi->data), xi->width, xi->height, xi->bytes_per_line, format).copy();
format).copy();
// we may have to swap the byte order // we may have to swap the byte order
if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && xi->byte_order == MSBFirst) if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && xi->byte_order == MSBFirst) ||
|| (QSysInfo::ByteOrder == QSysInfo::BigEndian && xi->byte_order == LSBFirst)) { (QSysInfo::ByteOrder == QSysInfo::BigEndian && xi->byte_order == LSBFirst)) {
for (int i = 0; i < image.height(); i++) { for (int i = 0; i < image.height(); i++) {
if (xi->depth == 16) { if (xi->depth == 16) {
@ -39,8 +38,8 @@ QImage qimageFromXImage(XImage *xi) {
uint* p = reinterpret_cast<uint*>(image.scanLine(i)); uint* p = reinterpret_cast<uint*>(image.scanLine(i));
uint* end = p + image.width(); uint* end = p + image.width();
while (p < end) { while (p < end) {
*p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000) *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000) | ((*p >> 8) & 0x0000ff00) |
| ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff); ((*p >> 24) & 0x000000ff);
p++; p++;
} }
} }
@ -92,7 +91,9 @@ void Watchdog::launchGame(const ProfileSettings &settings, LoginAuth auth) {
if (processWindowId == -1) { if (processWindowId == -1) {
auto xdoProcess = new QProcess(); auto xdoProcess = new QProcess();
connect(xdoProcess, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), connect(
xdoProcess,
static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
[=](int, QProcess::ExitStatus) { [=](int, QProcess::ExitStatus) {
QString output = xdoProcess->readAllStandardOutput(); QString output = xdoProcess->readAllStandardOutput();
qDebug() << "Found XIV Window: " << output.toInt(); qDebug() << "Found XIV Window: " << output.toInt();
@ -123,8 +124,7 @@ void Watchdog::launchGame(const ProfileSettings &settings, LoginAuth auth) {
XRenderPictureAttributes pa; XRenderPictureAttributes pa;
pa.subwindow_mode = IncludeInferiors; pa.subwindow_mode = IncludeInferiors;
Picture picture = XRenderCreatePicture(display, processWindowId, format, Picture picture = XRenderCreatePicture(display, processWindowId, format, CPSubwindowMode, &pa);
CPSubwindowMode, &pa);
XFlush(display); // TODO: does this actually make a difference? XFlush(display); // TODO: does this actually make a difference?
XImage* image = XGetImage(display, processWindowId, 0, 0, attr.width, attr.height, AllPlanes, ZPixmap); XImage* image = XGetImage(display, processWindowId, 0, 0, attr.width, attr.height, AllPlanes, ZPixmap);
@ -139,28 +139,25 @@ void Watchdog::launchGame(const ProfileSettings &settings, LoginAuth auth) {
switch (result.state) { switch (result.state) {
case ScreenState::InLoginQueue: { case ScreenState::InLoginQueue: {
icon->showMessage("Watchdog", icon->showMessage(
QString("You are now at position %1 (moved %2 spots)").arg( "Watchdog",
result.playersInQueue).arg( QString("You are now at position %1 (moved %2 spots)")
lastResult.playersInQueue - result.playersInQueue)); .arg(result.playersInQueue)
.arg(lastResult.playersInQueue - result.playersInQueue));
icon->setToolTip(QString("Queue Status (%1)").arg(result.playersInQueue)); icon->setToolTip(QString("Queue Status (%1)").arg(result.playersInQueue));
} } break;
break;
case ScreenState::LobbyError: { case ScreenState::LobbyError: {
// TODO: kill game? // TODO: kill game?
icon->showMessage("Watchdog", "You have been disconnected due to a lobby error."); icon->showMessage("Watchdog", "You have been disconnected due to a lobby error.");
} } break;
break;
case ScreenState::ConnectingToDataCenter: { case ScreenState::ConnectingToDataCenter: {
icon->showMessage("Watchdog", icon->showMessage(
"You are in the process of being connected to the data center."); "Watchdog", "You are in the process of being connected to the data center.");
} } break;
break;
case ScreenState::WorldFull: { case ScreenState::WorldFull: {
icon->showMessage("Watchdog", "You have been disconnected due to a lobby error."); icon->showMessage("Watchdog", "You have been disconnected due to a lobby error.");
} } break;
break;
} }
lastResult = result; lastResult = result;

View file

@ -1,9 +1,9 @@
#pragma once #pragma once
#include <QObject>
#include <QTemporaryDir>
#include <QProgressDialog>
#include <QJsonArray> #include <QJsonArray>
#include <QObject>
#include <QProgressDialog>
#include <QTemporaryDir>
#include "launchercore.h" #include "launchercore.h"

View file

@ -1,11 +1,11 @@
#pragma once #pragma once
#include <QDialog>
#include <QListWidget>
#include <QComboBox>
#include <QLineEdit>
#include <QCheckBox> #include <QCheckBox>
#include <QComboBox>
#include <QDialog>
#include <QLabel> #include <QLabel>
#include <QLineEdit>
#include <QListWidget>
#include <QPushButton> #include <QPushButton>
class LauncherCore; class LauncherCore;

View file

@ -1,16 +1,16 @@
#pragma once #pragma once
#include <QMainWindow>
#include <QComboBox>
#include <QCheckBox> #include <QCheckBox>
#include <QPushButton> #include <QComboBox>
#include <QTreeWidget>
#include <QGridLayout>
#include <QFormLayout> #include <QFormLayout>
#include <QGridLayout>
#include <QMainWindow>
#include <QPushButton>
#include <QScrollArea> #include <QScrollArea>
#include <QTreeWidget>
#include "launchercore.h"
#include "headline.h" #include "headline.h"
#include "launchercore.h"
class LauncherWindow : public QMainWindow { class LauncherWindow : public QMainWindow {
Q_OBJECT Q_OBJECT

View file

@ -1,13 +1,13 @@
#pragma once #pragma once
#include <QDialog>
#include <QListWidget>
#include <QComboBox>
#include <QLineEdit>
#include <QCheckBox> #include <QCheckBox>
#include <QLabel> #include <QComboBox>
#include <QPushButton> #include <QDialog>
#include <QFormLayout> #include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
#include <QPushButton>
class LauncherCore; class LauncherCore;
class LauncherWindow; class LauncherWindow;

View file

@ -1,12 +1,12 @@
#include "aboutwindow.h" #include "aboutwindow.h"
#include <QVBoxLayout>
#include <QTabWidget>
#include <QLabel> #include <QLabel>
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QTabWidget>
#include <QVBoxLayout>
#include "license.h"
#include "config.h" #include "config.h"
#include "license.h"
AboutWindow::AboutWindow(QWidget* widget) : QDialog(widget) { AboutWindow::AboutWindow(QWidget* widget) : QDialog(widget) {
setWindowTitle("About"); setWindowTitle("About");

View file

@ -1,11 +1,11 @@
#include "assetupdater.h" #include "assetupdater.h"
#include <QFile> #include <QFile>
#include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QNetworkReply> #include <QNetworkReply>
#include <QStandardPaths> #include <QStandardPaths>
#include <QJsonArray>
#include <JlCompress.h> #include <JlCompress.h>
@ -20,10 +20,8 @@ const QString dalamudVersionManifestURL = baseDalamudDistribution + "%1version";
const QString baseDalamudAssetDistribution = baseGoatDomain + "/DalamudAssets"; const QString baseDalamudAssetDistribution = baseGoatDomain + "/DalamudAssets";
const QString dalamudAssetManifestURL = baseDalamudAssetDistribution + "/asset.json"; const QString dalamudAssetManifestURL = baseDalamudAssetDistribution + "/asset.json";
const QString baseNativeLauncherDistribution = const QString baseNativeLauncherDistribution = "https://xiv.zone/astra-distrib/nativelauncher";
"https://xiv.zone/astra-distrib/nativelauncher"; const QString nativeLauncherLatestPackageURL = baseNativeLauncherDistribution + "/NativeLauncher.exe";
const QString nativeLauncherLatestPackageURL =
baseNativeLauncherDistribution + "/NativeLauncher.exe";
const QString nativeLauncherVersionManifestURL = baseNativeLauncherDistribution + "/version"; const QString nativeLauncherVersionManifestURL = baseNativeLauncherDistribution + "/version";
const QString dotnetRuntimePackageURL = const QString dotnetRuntimePackageURL =
@ -34,14 +32,12 @@ const QString dotnetDesktopPackageURL =
QMap<DalamudChannel, QString> channelToDistribPrefix = { QMap<DalamudChannel, QString> channelToDistribPrefix = {
{DalamudChannel::Stable, "/"}, {DalamudChannel::Stable, "/"},
{DalamudChannel::Staging, "stg/"}, {DalamudChannel::Staging, "stg/"},
{DalamudChannel::Net5, "net5/"} {DalamudChannel::Net5, "net5/"}};
};
AssetUpdater::AssetUpdater(LauncherCore& launcher) : launcher(launcher), QObject(&launcher) { AssetUpdater::AssetUpdater(LauncherCore& launcher) : launcher(launcher), QObject(&launcher) {
launcher.mgr->setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy); launcher.mgr->setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy);
dataDir = dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
if (!QDir().exists(dataDir)) if (!QDir().exists(dataDir))
QDir().mkdir(dataDir); QDir().mkdir(dataDir);
@ -147,9 +143,7 @@ void AssetUpdater::update(const ProfileSettings& profile) {
void AssetUpdater::beginInstall() { void AssetUpdater::beginInstall() {
if (needsDalamudInstall) { if (needsDalamudInstall) {
bool success = !JlCompress::extractDir(tempDir.path() + "/latest.zip", bool success = !JlCompress::extractDir(tempDir.path() + "/latest.zip", dataDir + "/Dalamud").empty();
dataDir + "/Dalamud")
.empty();
if (!success) { if (!success) {
// TODO: handle failure here // TODO: handle failure here
@ -165,8 +159,7 @@ void AssetUpdater::beginInstall() {
if (QFile::exists(dataDir + "/NativeLauncher.exe")) if (QFile::exists(dataDir + "/NativeLauncher.exe"))
QFile::remove(dataDir + "/NativeLauncher.exe"); QFile::remove(dataDir + "/NativeLauncher.exe");
bool success = QFile::copy(tempDir.path() + "/NativeLauncher.exe", bool success = QFile::copy(tempDir.path() + "/NativeLauncher.exe", dataDir + "/NativeLauncher.exe");
dataDir + "/NativeLauncher.exe");
if (!success) { if (!success) {
qInfo() << "Failed to install native launcher!"; qInfo() << "Failed to install native launcher!";
@ -181,13 +174,10 @@ void AssetUpdater::beginInstall() {
} }
if (needsRuntimeInstall) { if (needsRuntimeInstall) {
bool success = !JlCompress::extractDir(tempDir.path() + "/dotnet-core.zip", bool success =
dataDir + "/DalamudRuntime") !JlCompress::extractDir(tempDir.path() + "/dotnet-core.zip", dataDir + "/DalamudRuntime").empty();
.empty();
success |= !JlCompress::extractDir(tempDir.path() + "/dotnet-desktop.zip", success |= !JlCompress::extractDir(tempDir.path() + "/dotnet-desktop.zip", dataDir + "/DalamudRuntime").empty();
dataDir + "/DalamudRuntime")
.empty();
if (!success) { if (!success) {
qInfo() << "Failed to install dotnet!"; qInfo() << "Failed to install dotnet!";
@ -226,11 +216,8 @@ void AssetUpdater::checkIfFinished() {
if (dialog->wasCanceled()) if (dialog->wasCanceled())
return; return;
if (doneDownloadingDalamud && if (doneDownloadingDalamud && doneDownloadingNativelauncher && doneDownloadingRuntimeCore &&
doneDownloadingNativelauncher && doneDownloadingRuntimeDesktop && dalamudAssetNeededFilenames.empty()) {
doneDownloadingRuntimeCore &&
doneDownloadingRuntimeDesktop &&
dalamudAssetNeededFilenames.empty()) {
if (needsRuntimeInstall || needsNativeInstall || needsDalamudInstall) { if (needsRuntimeInstall || needsNativeInstall || needsDalamudInstall) {
beginInstall(); beginInstall();
} else { } else {
@ -246,7 +233,8 @@ void AssetUpdater::checkIfCheckingIsDone() {
if (dialog->wasCanceled()) if (dialog->wasCanceled())
return; return;
if(remoteDalamudVersion.isEmpty() || remoteRuntimeVersion.isEmpty() || remoteDalamudAssetVersion == -1 || remoteNativeLauncherVersion.isEmpty()) { if (remoteDalamudVersion.isEmpty() || remoteRuntimeVersion.isEmpty() || remoteDalamudAssetVersion == -1 ||
remoteNativeLauncherVersion.isEmpty()) {
return; return;
} }

View file

@ -13,8 +13,10 @@ DesktopInterface::DesktopInterface(LauncherCore& core) {
messageBox->setText("No Game Found"); messageBox->setText("No Game Found");
messageBox->setInformativeText("FFXIV is not installed. Would you like to install it now?"); messageBox->setInformativeText("FFXIV is not installed. Would you like to install it now?");
QString detailedText = QString("Astra will install FFXIV for you at '%1'").arg(core.getProfile(core.defaultProfileIndex).gamePath); QString detailedText =
detailedText.append("\n\nIf you do not wish to install it to this location, please set it in your default profile first."); QString("Astra will install FFXIV for you at '%1'").arg(core.getProfile(core.defaultProfileIndex).gamePath);
detailedText.append(
"\n\nIf you do not wish to install it to this location, please set it in your default profile first.");
messageBox->setDetailedText(detailedText); messageBox->setDetailedText(detailedText);
messageBox->setWindowModality(Qt::WindowModal); messageBox->setWindowModality(Qt::WindowModal);

View file

@ -1,22 +1,23 @@
#include "gamescopesettingswindow.h" #include "gamescopesettingswindow.h"
#include <QFormLayout>
#include <QPushButton>
#include <QDesktopServices>
#include <QLabel>
#include <QFileDialog>
#include <QCheckBox> #include <QCheckBox>
#include <QDesktopServices>
#include <QFileDialog>
#include <QFormLayout>
#include <QGridLayout>
#include <QGroupBox> #include <QGroupBox>
#include <QLabel>
#include <QMessageBox> #include <QMessageBox>
#include <QProcess> #include <QProcess>
#include <QGridLayout> #include <QPushButton>
#include <QToolTip>
#include <QSpinBox> #include <QSpinBox>
#include <QToolTip>
#include "launchercore.h" #include "launchercore.h"
#include "launcherwindow.h" #include "launcherwindow.h"
GamescopeSettingsWindow::GamescopeSettingsWindow(ProfileSettings& settings, LauncherCore& core, QWidget* parent) : QDialog(parent) { GamescopeSettingsWindow::GamescopeSettingsWindow(ProfileSettings& settings, LauncherCore& core, QWidget* parent)
: QDialog(parent) {
setWindowTitle("Gamescope Settings"); setWindowTitle("Gamescope Settings");
setWindowModality(Qt::WindowModality::ApplicationModal); setWindowModality(Qt::WindowModality::ApplicationModal);

View file

@ -1,28 +1,28 @@
#include "launcherwindow.h" #include "launcherwindow.h"
#include <QMenuBar>
#include <keychain.h>
#include <QFormLayout>
#include <QApplication> #include <QApplication>
#include <QDesktopServices> #include <QDesktopServices>
#include <QNetworkReply>
#include <QTreeWidgetItem>
#include <QHeaderView>
#include <QDirIterator> #include <QDirIterator>
#include <QTimer> #include <QFormLayout>
#include <QHeaderView>
#include <QMenuBar>
#include <QNetworkReply>
#include <QScrollBar> #include <QScrollBar>
#include <QTimer>
#include <QTreeWidgetItem>
#include <keychain.h>
#include "aboutwindow.h"
#include "assetupdater.h"
#include "bannerwidget.h"
#include "config.h"
#include "encryptedarg.h"
#include "gameinstaller.h"
#include "headline.h"
#include "sapphirelauncher.h"
#include "settingswindow.h" #include "settingswindow.h"
#include "squareboot.h" #include "squareboot.h"
#include "squarelauncher.h" #include "squarelauncher.h"
#include "sapphirelauncher.h"
#include "assetupdater.h"
#include "headline.h"
#include "config.h"
#include "aboutwindow.h"
#include "gameinstaller.h"
#include "bannerwidget.h"
#include "encryptedarg.h"
LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindow(parent), core(core) { LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindow(parent), core(core) {
setWindowTitle("Astra"); setWindowTitle("Astra");
@ -71,7 +71,9 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
} }
} }
arguments.push_back({"UserPath", QString(R"(C:\Users\%1\Documents\My Games\FINAL FANTASY XIV - A Realm Reborn)").arg(userPath)}); arguments.push_back(
{"UserPath",
QString(R"(C:\Users\%1\Documents\My Games\FINAL FANTASY XIV - A Realm Reborn)").arg(userPath)});
const QString argFormat = " /%1 =%2"; const QString argFormat = " /%1 =%2";
@ -82,7 +84,8 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
QString finalArg = encryptGameArg(argJoined); QString finalArg = encryptGameArg(argJoined);
this->core.launchExecutable(currentProfile(), {currentProfile().gamePath + "/boot/ffxivlauncher64.exe", finalArg}); this->core.launchExecutable(
currentProfile(), {currentProfile().gamePath + "/boot/ffxivlauncher64.exe", finalArg});
}); });
launchSysInfo = toolsMenu->addAction("Open System Info..."); launchSysInfo = toolsMenu->addAction("Open System Info...");
@ -116,7 +119,8 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
messageBox->setInformativeText("FFXIV will be installed to your selected game directory."); messageBox->setInformativeText("FFXIV will be installed to your selected game directory.");
QString detailedText = QString("Astra will install FFXIV for you at '%1'").arg(this->currentProfile().gamePath); QString detailedText = QString("Astra will install FFXIV for you at '%1'").arg(this->currentProfile().gamePath);
detailedText.append("\n\nIf you do not wish to install it to this location, please change your profile settings."); detailedText.append(
"\n\nIf you do not wish to install it to this location, please change your profile settings.");
messageBox->setDetailedText(detailedText); messageBox->setDetailedText(detailedText);
messageBox->setWindowModality(Qt::WindowModal); messageBox->setWindowModality(Qt::WindowModal);
@ -127,7 +131,6 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
this->core.readGameVersion(); this->core.readGameVersion();
messageBox->close(); messageBox->close();
}); });
}); });
@ -491,8 +494,7 @@ void LauncherWindow::reloadNews() {
if (currentBanner >= headline.banner.size()) if (currentBanner >= headline.banner.size())
currentBanner = 0; currentBanner = 0;
bannerScrollArea->ensureVisible( bannerScrollArea->ensureVisible(640 * (currentBanner + 1), 0, 0, 0);
640 * (currentBanner + 1), 0, 0, 0);
currentBanner++; currentBanner++;
}); });
@ -507,46 +509,37 @@ void LauncherWindow::reloadNews() {
} }
if (core.appSettings.showNewsList) { if (core.appSettings.showNewsList) {
QTreeWidgetItem* newsItem = new QTreeWidgetItem( QTreeWidgetItem* newsItem = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList("News"));
(QTreeWidgetItem*)nullptr, QStringList("News"));
for (auto news : headline.news) { for (auto news : headline.news) {
QTreeWidgetItem* item = new QTreeWidgetItem(); QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0, news.title); item->setText(0, news.title);
item->setText(1, QLocale().toString( item->setText(1, QLocale().toString(news.date, QLocale::ShortFormat));
news.date, QLocale::ShortFormat));
item->setData(0, Qt::UserRole, news.url); item->setData(0, Qt::UserRole, news.url);
newsItem->addChild(item); newsItem->addChild(item);
} }
QTreeWidgetItem* pinnedItem = new QTreeWidgetItem( QTreeWidgetItem* pinnedItem = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList("Pinned"));
(QTreeWidgetItem*)nullptr, QStringList("Pinned"));
for (auto pinned : headline.pinned) { for (auto pinned : headline.pinned) {
QTreeWidgetItem* item = new QTreeWidgetItem(); QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0, pinned.title); item->setText(0, pinned.title);
item->setText(1, item->setText(1, QLocale().toString(pinned.date, QLocale::ShortFormat));
QLocale().toString(pinned.date,
QLocale::ShortFormat));
item->setData(0, Qt::UserRole, pinned.url); item->setData(0, Qt::UserRole, pinned.url);
pinnedItem->addChild(item); pinnedItem->addChild(item);
} }
QTreeWidgetItem* topicsItem = new QTreeWidgetItem( QTreeWidgetItem* topicsItem = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList("Topics"));
(QTreeWidgetItem*)nullptr, QStringList("Topics"));
for (auto news : headline.topics) { for (auto news : headline.topics) {
QTreeWidgetItem* item = new QTreeWidgetItem(); QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0, news.title); item->setText(0, news.title);
item->setText(1, QLocale().toString( item->setText(1, QLocale().toString(news.date, QLocale::ShortFormat));
news.date, QLocale::ShortFormat));
item->setData(0, Qt::UserRole, news.url); item->setData(0, Qt::UserRole, news.url);
topicsItem->addChild(item); topicsItem->addChild(item);
} }
newsListView->insertTopLevelItems( newsListView->insertTopLevelItems(0, QList<QTreeWidgetItem*>({newsItem, pinnedItem, topicsItem}));
0, QList<QTreeWidgetItem*>(
{newsItem, pinnedItem, topicsItem}));
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
newsListView->expandItem(newsListView->topLevelItem(i)); newsListView->expandItem(newsListView->topLevelItem(i));

View file

@ -1,22 +1,23 @@
#include "settingswindow.h" #include "settingswindow.h"
#include <QFormLayout>
#include <QPushButton>
#include <QDesktopServices>
#include <QLabel>
#include <QFileDialog>
#include <QCheckBox> #include <QCheckBox>
#include <QDesktopServices>
#include <QFileDialog>
#include <QFormLayout>
#include <QGridLayout>
#include <QGroupBox> #include <QGroupBox>
#include <QLabel>
#include <QMessageBox> #include <QMessageBox>
#include <QProcess> #include <QProcess>
#include <QGridLayout> #include <QPushButton>
#include <QToolTip> #include <QToolTip>
#include "gamescopesettingswindow.h"
#include "launchercore.h" #include "launchercore.h"
#include "launcherwindow.h" #include "launcherwindow.h"
#include "gamescopesettingswindow.h"
SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherCore& core, QWidget* parent) : core(core), window(window), QDialog(parent) { SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherCore& core, QWidget* parent)
: core(core), window(window), QDialog(parent) {
setWindowTitle("Settings"); setWindowTitle("Settings");
setWindowModality(Qt::WindowModality::ApplicationModal); setWindowModality(Qt::WindowModality::ApplicationModal);
@ -76,8 +77,7 @@ SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherC
profileWidget->addItem("INVALID *DEBUG*"); profileWidget->addItem("INVALID *DEBUG*");
profileWidget->setCurrentRow(0); profileWidget->setCurrentRow(0);
connect(profileWidget, &QListWidget::currentRowChanged, this, connect(profileWidget, &QListWidget::currentRowChanged, this, &SettingsWindow::reloadControls);
&SettingsWindow::reloadControls);
profileLayout->addWidget(profileWidget, 0, 0, 3, 1); profileLayout->addWidget(profileWidget, 0, 0, 3, 1);
@ -91,8 +91,7 @@ SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherC
deleteProfileButton = new QPushButton("Delete Profile"); deleteProfileButton = new QPushButton("Delete Profile");
connect(deleteProfileButton, &QPushButton::pressed, [=] { connect(deleteProfileButton, &QPushButton::pressed, [=] {
profileWidget->setCurrentRow( profileWidget->setCurrentRow(this->core.deleteProfile(getCurrentProfile().name));
this->core.deleteProfile(getCurrentProfile().name));
this->core.saveSettings(); this->core.saveSettings();
}); });
@ -314,12 +313,8 @@ void SettingsWindow::setupGameTab(QFormLayout& layout) {
directXCombo->addItem("DirectX 9"); directXCombo->addItem("DirectX 9");
layout.addRow("DirectX Version", directXCombo); layout.addRow("DirectX Version", directXCombo);
connect(directXCombo, connect(directXCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=](int index) {
static_cast<void (QComboBox::*)(int)>( getCurrentProfile().useDX9 = directXCombo->currentIndex() == 1;
&QComboBox::currentIndexChanged),
[=](int index) {
getCurrentProfile().useDX9 =
directXCombo->currentIndex() == 1;
this->core.saveSettings(); this->core.saveSettings();
}); });
@ -334,8 +329,7 @@ void SettingsWindow::setupGameTab(QFormLayout& layout) {
auto selectDirectoryButton = new QPushButton("Select Game Directory"); auto selectDirectoryButton = new QPushButton("Select Game Directory");
connect(selectDirectoryButton, &QPushButton::pressed, [this] { connect(selectDirectoryButton, &QPushButton::pressed, [this] {
getCurrentProfile().gamePath = getCurrentProfile().gamePath = QFileDialog::getExistingDirectory(this, "Open Game Directory");
QFileDialog::getExistingDirectory(this, "Open Game Directory");
this->reloadControls(); this->reloadControls();
this->core.saveSettings(); this->core.saveSettings();
@ -345,8 +339,9 @@ void SettingsWindow::setupGameTab(QFormLayout& layout) {
gameDirButtonLayout->addWidget(selectDirectoryButton); gameDirButtonLayout->addWidget(selectDirectoryButton);
gameDirectoryButton = new QPushButton("Open Game Directory"); gameDirectoryButton = new QPushButton("Open Game Directory");
connect(gameDirectoryButton, &QPushButton::pressed, connect(gameDirectoryButton, &QPushButton::pressed, [this] {
[this] { window.openPath(getCurrentProfile().gamePath); }); window.openPath(getCurrentProfile().gamePath);
});
gameDirButtonLayout->addWidget(gameDirectoryButton); gameDirButtonLayout->addWidget(gameDirectoryButton);
#ifdef ENABLE_WATCHDOG #ifdef ENABLE_WATCHDOG
@ -370,8 +365,7 @@ void SettingsWindow::setupGameTab(QFormLayout& layout) {
void SettingsWindow::setupLoginTab(QFormLayout& layout) { void SettingsWindow::setupLoginTab(QFormLayout& layout) {
encryptArgumentsBox = new QCheckBox(); encryptArgumentsBox = new QCheckBox();
connect(encryptArgumentsBox, &QCheckBox::stateChanged, [=](int) { connect(encryptArgumentsBox, &QCheckBox::stateChanged, [=](int) {
getCurrentProfile().encryptArguments = getCurrentProfile().encryptArguments = encryptArgumentsBox->isChecked();
encryptArgumentsBox->isChecked();
this->core.saveSettings(); this->core.saveSettings();
}); });
@ -381,10 +375,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) {
serverType->insertItem(0, "Square Enix"); serverType->insertItem(0, "Square Enix");
serverType->insertItem(1, "Sapphire"); serverType->insertItem(1, "Sapphire");
connect(serverType, connect(serverType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=](int index) {
static_cast<void (QComboBox::*)(int)>(
&QComboBox::currentIndexChanged),
[=](int index) {
getCurrentProfile().isSapphire = index == 1; getCurrentProfile().isSapphire = index == 1;
reloadControls(); reloadControls();
@ -405,10 +396,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) {
gameLicenseBox->insertItem(1, "Windows (Steam)"); gameLicenseBox->insertItem(1, "Windows (Steam)");
gameLicenseBox->insertItem(2, "macOS"); gameLicenseBox->insertItem(2, "macOS");
connect(gameLicenseBox, connect(gameLicenseBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=](int index) {
static_cast<void (QComboBox::*)(int)>(
&QComboBox::currentIndexChanged),
[=](int index) {
getCurrentProfile().license = (GameLicense)index; getCurrentProfile().license = (GameLicense)index;
this->core.saveSettings(); this->core.saveSettings();
@ -418,8 +406,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) {
freeTrialBox = new QCheckBox(); freeTrialBox = new QCheckBox();
connect(freeTrialBox, &QCheckBox::stateChanged, [=](int) { connect(freeTrialBox, &QCheckBox::stateChanged, [=](int) {
getCurrentProfile().isFreeTrial = getCurrentProfile().isFreeTrial = freeTrialBox->isChecked();
freeTrialBox->isChecked();
this->core.saveSettings(); this->core.saveSettings();
}); });
@ -427,8 +414,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) {
rememberUsernameBox = new QCheckBox(); rememberUsernameBox = new QCheckBox();
connect(rememberUsernameBox, &QCheckBox::stateChanged, [=](int) { connect(rememberUsernameBox, &QCheckBox::stateChanged, [=](int) {
getCurrentProfile().rememberUsername = getCurrentProfile().rememberUsername = rememberUsernameBox->isChecked();
rememberUsernameBox->isChecked();
this->core.saveSettings(); this->core.saveSettings();
}); });
@ -436,8 +422,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) {
rememberPasswordBox = new QCheckBox(); rememberPasswordBox = new QCheckBox();
connect(rememberPasswordBox, &QCheckBox::stateChanged, [=](int) { connect(rememberPasswordBox, &QCheckBox::stateChanged, [=](int) {
getCurrentProfile().rememberPassword = getCurrentProfile().rememberPassword = rememberPasswordBox->isChecked();
rememberPasswordBox->isChecked();
this->core.saveSettings(); this->core.saveSettings();
}); });
@ -445,8 +430,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) {
useOneTimePassword = new QCheckBox(); useOneTimePassword = new QCheckBox();
connect(useOneTimePassword, &QCheckBox::stateChanged, [=](int) { connect(useOneTimePassword, &QCheckBox::stateChanged, [=](int) {
getCurrentProfile().useOneTimePassword = getCurrentProfile().useOneTimePassword = useOneTimePassword->isChecked();
useOneTimePassword->isChecked();
this->core.saveSettings(); this->core.saveSettings();
this->window.reloadControls(); this->window.reloadControls();
@ -482,10 +466,7 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
layout.addWidget(selectWineButton); layout.addWidget(selectWineButton);
#endif #endif
connect(wineTypeCombo, connect(wineTypeCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this](int index) {
static_cast<void (QComboBox::*)(int)>(
&QComboBox::currentIndexChanged),
[this](int index) {
getCurrentProfile().wineType = (WineType)index; getCurrentProfile().wineType = (WineType)index;
this->core.readWineInfo(getCurrentProfile()); this->core.readWineInfo(getCurrentProfile());
@ -494,8 +475,7 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
}); });
connect(selectWineButton, &QPushButton::pressed, [this] { connect(selectWineButton, &QPushButton::pressed, [this] {
getCurrentProfile().winePath = getCurrentProfile().winePath = QFileDialog::getOpenFileName(this, "Open Wine Executable");
QFileDialog::getOpenFileName(this, "Open Wine Executable");
this->core.saveSettings(); this->core.saveSettings();
this->reloadControls(); this->reloadControls();
@ -519,8 +499,7 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
auto selectPrefixButton = new QPushButton("Select Wine Prefix"); auto selectPrefixButton = new QPushButton("Select Wine Prefix");
connect(selectPrefixButton, &QPushButton::pressed, [this] { connect(selectPrefixButton, &QPushButton::pressed, [this] {
getCurrentProfile().winePrefixPath = getCurrentProfile().winePrefixPath = QFileDialog::getExistingDirectory(this, "Open Wine Prefix");
QFileDialog::getExistingDirectory(this, "Open Wine Prefix");
this->core.saveSettings(); this->core.saveSettings();
this->reloadControls(); this->reloadControls();
@ -528,8 +507,9 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
winePrefixButtonLayout->addWidget(selectPrefixButton); winePrefixButtonLayout->addWidget(selectPrefixButton);
auto openPrefixButton = new QPushButton("Open Wine Prefix"); auto openPrefixButton = new QPushButton("Open Wine Prefix");
connect(openPrefixButton, &QPushButton::pressed, connect(openPrefixButton, &QPushButton::pressed, [this] {
[this] { window.openPath(getCurrentProfile().winePrefixPath); }); window.openPath(getCurrentProfile().winePrefixPath);
});
winePrefixButtonLayout->addWidget(openPrefixButton); winePrefixButtonLayout->addWidget(openPrefixButton);
auto enableDXVKhud = new QCheckBox("Enable DXVK HUD"); auto enableDXVKhud = new QCheckBox("Enable DXVK HUD");
@ -537,17 +517,16 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
connect(enableDXVKhud, &QCheckBox::stateChanged, [this](int state) { connect(enableDXVKhud, &QCheckBox::stateChanged, [this](int state) {
getCurrentProfile().enableDXVKhud = state; getCurrentProfile().enableDXVKhud = state;
this->core.settings.setValue("enableDXVKhud", this->core.settings.setValue("enableDXVKhud", static_cast<bool>(state));
static_cast<bool>(state));
}); });
#endif #endif
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
useEsync = new QCheckBox( useEsync = new QCheckBox("Use Better Sync Primitives (Esync, Fsync, and Futex2)");
"Use Better Sync Primitives (Esync, Fsync, and Futex2)");
layout.addWidget(useEsync); layout.addWidget(useEsync);
useEsync->setToolTip("This may improve game performance, but requires a Wine and kernel with the patches included."); useEsync->setToolTip(
"This may improve game performance, but requires a Wine and kernel with the patches included.");
connect(useEsync, &QCheckBox::stateChanged, [this](int state) { connect(useEsync, &QCheckBox::stateChanged, [this](int state) {
getCurrentProfile().useEsync = state; getCurrentProfile().useEsync = state;
@ -558,7 +537,9 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
useGamescope = new QCheckBox("Use Gamescope"); useGamescope = new QCheckBox("Use Gamescope");
layout.addWidget(useGamescope); layout.addWidget(useGamescope);
useGamescope->setToolTip("Use the micro-compositor compositor that uses Wayland and XWayland to create a nested session.\nIf you primarily use fullscreen mode, this may improve input handling especially on Wayland."); useGamescope->setToolTip(
"Use the micro-compositor compositor that uses Wayland and XWayland to create a nested session.\nIf you "
"primarily use fullscreen mode, this may improve input handling especially on Wayland.");
auto gamescopeButtonLayout = new QHBoxLayout(); auto gamescopeButtonLayout = new QHBoxLayout();
auto gamescopeButtonContainer = new QWidget(); auto gamescopeButtonContainer = new QWidget();
@ -567,8 +548,7 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
configureGamescopeButton = new QPushButton("Configure..."); configureGamescopeButton = new QPushButton("Configure...");
connect(configureGamescopeButton, &QPushButton::pressed, [&] { connect(configureGamescopeButton, &QPushButton::pressed, [&] {
auto gamescopeSettingsWindow = new GamescopeSettingsWindow( auto gamescopeSettingsWindow = new GamescopeSettingsWindow(getCurrentProfile(), this->core, this);
getCurrentProfile(), this->core, this);
gamescopeSettingsWindow->show(); gamescopeSettingsWindow->show();
}); });
gamescopeButtonLayout->addWidget(configureGamescopeButton); gamescopeButtonLayout->addWidget(configureGamescopeButton);
@ -583,7 +563,8 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
useGamemode = new QCheckBox("Use GameMode"); useGamemode = new QCheckBox("Use GameMode");
layout.addWidget(useGamemode); layout.addWidget(useGamemode);
useGamemode->setToolTip("A special game performance enhancer, which automatically tunes your CPU scheduler among other things. This may improve game performance."); useGamemode->setToolTip("A special game performance enhancer, which automatically tunes your CPU scheduler among "
"other things. This may improve game performance.");
connect(useGamemode, &QCheckBox::stateChanged, [this](int state) { connect(useGamemode, &QCheckBox::stateChanged, [this](int state) {
getCurrentProfile().useGamemode = state; getCurrentProfile().useGamemode = state;
@ -615,10 +596,7 @@ void SettingsWindow::setupDalamudTab(QFormLayout& layout) {
dalamudChannel->insertItem(1, "Staging"); dalamudChannel->insertItem(1, "Staging");
dalamudChannel->insertItem(2, ".NET 5"); dalamudChannel->insertItem(2, ".NET 5");
connect(dalamudChannel, connect(dalamudChannel, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=](int index) {
static_cast<void (QComboBox::*)(int)>(
&QComboBox::currentIndexChanged),
[=](int index) {
getCurrentProfile().dalamud.channel = (DalamudChannel)index; getCurrentProfile().dalamud.channel = (DalamudChannel)index;
this->core.saveSettings(); this->core.saveSettings();
@ -639,6 +617,4 @@ void SettingsWindow::setupDalamudTab(QFormLayout& layout) {
layout.addRow("Native Launcher Version", nativeLauncherVersionLabel); layout.addRow("Native Launcher Version", nativeLauncherVersionLabel);
} }
void SettingsWindow::setupAccountsTab(QFormLayout& layout) { void SettingsWindow::setupAccountsTab(QFormLayout& layout) {}
}

View file

@ -3,8 +3,8 @@
#include <QApplication> #include <QApplication>
#include <QCommandLineParser> #include <QCommandLineParser>
#include <keychain.h>
#include <QDir> #include <QDir>
#include <keychain.h>
#include <physis.hpp> #include <physis.hpp>
#include "../launcher/tablet/include/tabletinterface.h" #include "../launcher/tablet/include/tabletinterface.h"

View file

@ -1,7 +1,7 @@
#include "tabletinterface.h" #include "tabletinterface.h"
#include <QQuickView>
#include <QQmlContext> #include <QQmlContext>
#include <QQuickView>
TabletInterface::TabletInterface(LauncherCore& core) { TabletInterface::TabletInterface(LauncherCore& core) {
qmlRegisterType<ProfileSettings>("Astra", 1, 0, "ProfileSettings"); qmlRegisterType<ProfileSettings>("Astra", 1, 0, "ProfileSettings");