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'
AllowShortLoopsOnASingleLine: 'false'
SeparateDefinitionBlocks : 'Always'
...

View file

@ -1,7 +1,7 @@
#pragma once
#include <QCommandLineParser>
#include "launchercore.h"
#include <QCommandLineParser>
/*
* The CLI interface for Astra, driven primarily by the command-line.
@ -13,6 +13,11 @@ public:
bool parse(QCommandLineParser& parser, LauncherCore& core);
private:
QCommandLineOption profileOption = {"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!"};
QCommandLineOption profileOption = {
"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 "squareboot.h"
#include "sapphirelauncher.h"
#include "squareboot.h"
#include <keychain.h>
CMDInterface::CMDInterface(QCommandLineParser& parser) {
parser.addOption(autologinOption);
@ -34,7 +34,8 @@ bool CMDInterface::parse(QCommandLineParser &parser, LauncherCore &core) {
usernameJob->setKey(profile.name + "-username");
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();
loop->quit();
});
@ -45,7 +46,8 @@ bool CMDInterface::parse(QCommandLineParser &parser, LauncherCore &core) {
passwordJob->setKey(profile.name + "-password");
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();
loop->quit();
});

View file

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

View file

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

View file

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

View file

@ -1,12 +1,12 @@
#pragma once
#include <QMainWindow>
#include <QNetworkAccessManager>
#include <QFuture>
#include <QMainWindow>
#include <QMessageBox>
#include <QNetworkAccessManager>
#include <QProcess>
#include <QSettings>
#include <QUuid>
#include <QProcess>
#include <QMessageBox>
#include <QtQml>
#include "squareboot.h"
@ -162,7 +162,12 @@ public:
/*
* 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.

View file

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

View file

@ -2,6 +2,4 @@
#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"
#if defined(Q_OS_MAC)
#include <sys/sysctl.h>
#include <mach/mach_time.h>
#include <sys/sysctl.h>
#endif
#if defined(Q_OS_WIN)

View file

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

View file

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

View file

@ -1,12 +1,12 @@
#include "headline.h"
#include <QUrlQuery>
#include <QNetworkRequest>
#include <QDateTime>
#include <QNetworkReply>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QUrlQuery>
#include "launchercore.h"
@ -21,7 +21,8 @@ void getHeadline(LauncherCore& core, std::function<void(Headline)> return_func)
url.setPath("/news/headline.json");
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?
core.buildRequest(core.getProfile(core.defaultProfileIndex), request);
@ -29,7 +30,11 @@ void getHeadline(LauncherCore& core, std::function<void(Headline)> return_func)
qInfo() << request.url();
request.setRawHeader("Accept", "application/json, text/plain, */*");
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);
core.connect(reply, &QNetworkReply::finished, [=] {

View file

@ -1,32 +1,32 @@
#include <QPushButton>
#include <QProcess>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QUrlQuery>
#include <QCheckBox>
#include <QComboBox>
#include <QCoreApplication>
#include <QDir>
#include <QFormLayout>
#include <QLineEdit>
#include <QRegularExpression>
#include <QComboBox>
#include <QJsonObject>
#include <QJsonDocument>
#include <QCheckBox>
#include <keychain.h>
#include <QMessageBox>
#include <QJsonObject>
#include <QLineEdit>
#include <QMenuBar>
#include <QCoreApplication>
#include <QStandardPaths>
#include <QMessageBox>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QProcess>
#include <QPushButton>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <algorithm>
#include <QStandardPaths>
#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 "encryptedarg.h"
#include "launchercore.h"
#include "sapphirelauncher.h"
#include "settingswindow.h"
#include "squareboot.h"
#include "squarelauncher.h"
#ifdef ENABLE_WATCHDOG
#include "watchdog.h"
@ -46,12 +46,15 @@ void LauncherCore::buildRequest(const ProfileSettings& settings, QNetworkRequest
if (settings.license == GameLicense::macOS) {
request.setHeader(QNetworkRequest::UserAgentHeader, "macSQEXAuthor/2.0.0(MacOSX; ja-jp)");
} else {
request.setHeader(QNetworkRequest::UserAgentHeader,
request.setHeader(
QNetworkRequest::UserAgentHeader,
QString("SQEXAuthor/2.0.0(Windows 6.2; ja-jp; %1)").arg(QString(QSysInfo::bootUniqueId())));
}
request.setRawHeader("Accept",
"image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/xaml+xml, application/x-ms-xbap, */*");
request.setRawHeader(
"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-Language", "en-us");
}
@ -107,8 +110,7 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
if (profile.dalamud.enabled) {
// TODO: this depends on the default wine Z: path existing, which may not
// always the case.
env.insert("DALAMUD_RUNTIME",
"Z:" + dataDir.replace('/', '\\') + "\\DalamudRuntime");
env.insert("DALAMUD_RUNTIME", "Z:" + dataDir.replace('/', '\\') + "\\DalamudRuntime");
}
gameProcess->setProcessEnvironment(env);
@ -169,7 +171,12 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
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();
socket->close();
@ -180,7 +187,11 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
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();
});
@ -209,7 +220,12 @@ void LauncherCore::launchGameExecutable(const ProfileSettings& profile, QProcess
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;
auto env = process->processEnvironment();
@ -235,16 +251,13 @@ void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* pr
arguments.push_back("-b");
if (profile.gamescope.width > 0)
arguments.push_back("-w " +
QString::number(profile.gamescope.width));
arguments.push_back("-w " + QString::number(profile.gamescope.width));
if (profile.gamescope.height > 0)
arguments.push_back("-h " +
QString::number(profile.gamescope.height));
arguments.push_back("-h " + QString::number(profile.gamescope.height));
if (profile.gamescope.refreshRate > 0)
arguments.push_back(
"-r " + QString::number(profile.gamescope.refreshRate));
arguments.push_back("-r " + QString::number(profile.gamescope.refreshRate));
}
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
if (profile.wineType == WineType::XIVOnMac) {
// 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_VERSIONED_LIBRARY_PATH", xivLibPath);
@ -317,8 +331,7 @@ void LauncherCore::readInitialInformation() {
gamescopeAvailable = checkIfInPath("gamescope");
gamemodeAvailable = checkIfInPath("gamemoderun");
const QString dataDir =
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
const QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
const bool hasDalamud = QFile::exists(dataDir + "/Dalamud");
if (hasDalamud) {
@ -330,18 +343,10 @@ void LauncherCore::readInitialInformation() {
QString versionString;
if (doc["targets"].toObject().contains(".NETCoreApp,Version=v5.0")) {
versionString =
doc["targets"]
.toObject()[".NETCoreApp,Version=v5.0"]
.toObject()
.keys()
.filter("Dalamud")[0];
doc["targets"].toObject()[".NETCoreApp,Version=v5.0"].toObject().keys().filter("Dalamud")[0];
} else {
versionString =
doc["targets"]
.toObject()[".NETCoreApp,Version=v6.0"]
.toObject()
.keys()
.filter("Dalamud")[0];
doc["targets"].toObject()[".NETCoreApp,Version=v6.0"].toObject().keys().filter("Dalamud")[0];
}
dalamudVersion = versionString.remove("Dalamud/");
@ -385,19 +390,22 @@ void LauncherCore::readInitialInformation() {
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();
} else {
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();
} else {
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();
}
@ -432,14 +440,18 @@ void LauncherCore::readInitialInformation() {
profile->enableWatchdog = settings.value("enableWatchdog", defaultSettings.enableWatchdog).toBool();
// 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.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.optOutOfMbCollection = settings.value("dalamudOptOut", defaultSettings.dalamud.optOutOfMbCollection).toBool();
profile->dalamud.channel = (DalamudChannel)settings.value("dalamudChannel", (int)defaultSettings.dalamud.channel).toInt();
profile->dalamud.optOutOfMbCollection =
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;
@ -459,7 +471,8 @@ void LauncherCore::readWineInfo(ProfileSettings& profile) {
profile.winePath = profile.winePath;
break;
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;
case WineType::XIVOnMac:
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();
sapphireLauncher = new SapphireLauncher(*this);
squareLauncher = new SquareLauncher(*this);
@ -663,7 +677,9 @@ QString LauncherCore::getDefaultGamePath() {
#endif
#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
#if defined(Q_OS_LINUX)
@ -671,8 +687,7 @@ QString LauncherCore::getDefaultGamePath() {
#endif
}
void LauncherCore::addRegistryKey(const ProfileSettings& settings,
QString key, QString value, QString data) {
void LauncherCore::addRegistryKey(const ProfileSettings& settings, QString key, QString value, QString data) {
auto process = new QProcess(this);
process->setProcessEnvironment(QProcessEnvironment::systemEnvironment());
launchExecutable(settings, process, {"reg", "add", key, "/v", value, "/d", data, "/f"}, false, false);

View file

@ -1,10 +1,10 @@
#include "patcher.h"
#include <QDir>
#include <QFile>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QStandardPaths>
#include <physis.hpp>
#include <QDir>
Patcher::Patcher(QString baseDirectory, BootData* boot_data) : boot_data(boot_data), baseDirectory(baseDirectory) {
dialog = new QProgressDialog();
@ -57,9 +57,11 @@ void Patcher::processPatchList(QNetworkAccessManager& mgr, QString patchList) {
repository = url_parts[url_parts.size() - 3];
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 {
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);

View file

@ -1,19 +1,14 @@
#include "sapphirelauncher.h"
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonObject>
#include <QMessageBox>
#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) {
QJsonObject data {
{"username", info.username},
{"pass", info.password}
};
QJsonObject data{{"username", info.username}, {"pass", info.password}};
QUrl url;
url.setScheme("http");
@ -35,17 +30,15 @@ void SapphireLauncher::login(QString lobbyUrl, const LoginInformation& info) {
window.launchGame(*info.settings, auth);
} 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();
}
});
}
void SapphireLauncher::registerAccount(QString lobbyUrl, const LoginInformation& info) {
QJsonObject data {
{"username", info.username},
{"pass", info.password}
};
QJsonObject data{{"username", info.username}, {"pass", info.password}};
QUrl url;
url.setScheme("http");
url.setHost(lobbyUrl);

View file

@ -1,20 +1,19 @@
#include "squareboot.h"
#include <QUrlQuery>
#include <QNetworkReply>
#include <QMessageBox>
#include <QPushButton>
#include <QStandardPaths>
#include <QFile>
#include <physis.hpp>
#include <QJsonDocument>
#include <QJsonObject>
#include <QMessageBox>
#include <QNetworkReply>
#include <QPushButton>
#include <QStandardPaths>
#include <QUrlQuery>
#include <physis.hpp>
#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) {
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
// 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.
// TODO: this selection of errors is currently guesswork, i'm assuming one of these will fit the bill of "internet is unavailable" in
// some way.
if(reply->error() == QNetworkReply::HostNotFoundError || reply->error() == QNetworkReply::TimeoutError || reply->error() == QNetworkReply::UnknownServerError)
// TODO: this selection of errors is currently guesswork, i'm assuming one of these will fit the bill of
// "internet is unavailable" in some way.
if (reply->error() == QNetworkReply::HostNotFoundError || reply->error() == QNetworkReply::TimeoutError ||
reply->error() == QNetworkReply::UnknownServerError)
checkGateStatus(info);
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
@ -81,7 +81,8 @@ void SquareBoot::checkGateStatus(LoginInformation* info) {
if (isGateOpen) {
bootCheck(*info);
} else {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical,
auto messageBox = new QMessageBox(
QMessageBox::Icon::Critical,
"Failed to Login",
"The login gate is closed, the game may be under maintenance.");

View file

@ -1,14 +1,14 @@
#include "squarelauncher.h"
#include <QDesktopServices>
#include <QFile>
#include <QUrlQuery>
#include <QNetworkReply>
#include <QRegularExpressionMatch>
#include <QMessageBox>
#include <QJsonDocument>
#include <QJsonObject>
#include <QMessageBox>
#include <QNetworkReply>
#include <QPushButton>
#include <QDesktopServices>
#include <QRegularExpressionMatch>
#include <QUrlQuery>
#include "launchercore.h"
@ -16,9 +16,7 @@
#include "watchdog.h"
#endif
SquareLauncher::SquareLauncher(LauncherCore& window) : window(window), QObject(&window) {
}
SquareLauncher::SquareLauncher(LauncherCore& window) : window(window), QObject(&window) {}
QString getFileHash(QString file) {
auto f = QFile(file);
@ -69,7 +67,10 @@ void SquareLauncher::getStored(const LoginInformation& info) {
if (match.hasMatch()) {
username = match.captured(1);
} 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();
}
} else {
@ -82,7 +83,10 @@ void SquareLauncher::getStored(const LoginInformation& info) {
stored = match.captured(1);
login(info, url);
} 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();
}
});
@ -114,7 +118,11 @@ void SquareLauncher::login(const LoginInformation& info, const QUrl referer) {
const bool playable = parts[9] == "1";
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);
connect(launcherButton, &QPushButton::clicked, [=] {
@ -129,7 +137,10 @@ void SquareLauncher::login(const LoginInformation& info, const QUrl referer) {
}
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);
messageBox->show();
@ -161,7 +172,8 @@ void SquareLauncher::registerSession(const LoginInformation& info) {
QUrl url;
url.setScheme("https");
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);
window.setSSL(request);
@ -173,8 +185,8 @@ void SquareLauncher::registerSession(const LoginInformation& info) {
for (int i = 1; i < auth.maxExpansion + 1; i++) {
if (i <= info.settings->repositories.repositories_count) {
report += QString("\nex%1\t%2")
.arg(QString::number(i), info.settings->repositories.repositories[i].version);
report +=
QString("\nex%1\t%2").arg(QString::number(i), info.settings->repositories.repositories[i].version);
} else {
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);
} 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);
messageBox->show();
@ -213,15 +228,13 @@ void SquareLauncher::registerSession(const LoginInformation& info) {
}
QString SquareLauncher::getBootHash(const LoginInformation& info) {
const QList<QString> fileList =
{
const QList<QString> fileList = {
"ffxivboot.exe",
"ffxivboot64.exe",
"ffxivlauncher.exe",
"ffxivlauncher64.exe",
"ffxivupdater.exe",
"ffxivupdater64.exe"
};
"ffxivupdater64.exe"};
QString result;
for (int i = 0; i < fileList.count(); i++) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -13,8 +13,10 @@ DesktopInterface::DesktopInterface(LauncherCore& core) {
messageBox->setText("No Game Found");
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);
detailedText.append("\n\nIf you do not wish to install it to this location, please set it in your default profile first.");
QString detailedText =
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->setWindowModality(Qt::WindowModal);

View file

@ -1,22 +1,23 @@
#include "gamescopesettingswindow.h"
#include <QFormLayout>
#include <QPushButton>
#include <QDesktopServices>
#include <QLabel>
#include <QFileDialog>
#include <QCheckBox>
#include <QDesktopServices>
#include <QFileDialog>
#include <QFormLayout>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QMessageBox>
#include <QProcess>
#include <QGridLayout>
#include <QToolTip>
#include <QPushButton>
#include <QSpinBox>
#include <QToolTip>
#include "launchercore.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");
setWindowModality(Qt::WindowModality::ApplicationModal);

View file

@ -1,28 +1,28 @@
#include "launcherwindow.h"
#include <QMenuBar>
#include <keychain.h>
#include <QFormLayout>
#include <QApplication>
#include <QDesktopServices>
#include <QNetworkReply>
#include <QTreeWidgetItem>
#include <QHeaderView>
#include <QDirIterator>
#include <QTimer>
#include <QFormLayout>
#include <QHeaderView>
#include <QMenuBar>
#include <QNetworkReply>
#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 "squareboot.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) {
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";
@ -82,7 +84,8 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
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...");
@ -116,7 +119,8 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
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);
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->setWindowModality(Qt::WindowModal);
@ -127,7 +131,6 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
this->core.readGameVersion();
messageBox->close();
});
});
@ -491,8 +494,7 @@ void LauncherWindow::reloadNews() {
if (currentBanner >= headline.banner.size())
currentBanner = 0;
bannerScrollArea->ensureVisible(
640 * (currentBanner + 1), 0, 0, 0);
bannerScrollArea->ensureVisible(640 * (currentBanner + 1), 0, 0, 0);
currentBanner++;
});
@ -507,46 +509,37 @@ void LauncherWindow::reloadNews() {
}
if (core.appSettings.showNewsList) {
QTreeWidgetItem* newsItem = new QTreeWidgetItem(
(QTreeWidgetItem*)nullptr, QStringList("News"));
QTreeWidgetItem* newsItem = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList("News"));
for (auto news : headline.news) {
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0, news.title);
item->setText(1, QLocale().toString(
news.date, QLocale::ShortFormat));
item->setText(1, QLocale().toString(news.date, QLocale::ShortFormat));
item->setData(0, Qt::UserRole, news.url);
newsItem->addChild(item);
}
QTreeWidgetItem* pinnedItem = new QTreeWidgetItem(
(QTreeWidgetItem*)nullptr, QStringList("Pinned"));
QTreeWidgetItem* pinnedItem = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList("Pinned"));
for (auto pinned : headline.pinned) {
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0, pinned.title);
item->setText(1,
QLocale().toString(pinned.date,
QLocale::ShortFormat));
item->setText(1, QLocale().toString(pinned.date, QLocale::ShortFormat));
item->setData(0, Qt::UserRole, pinned.url);
pinnedItem->addChild(item);
}
QTreeWidgetItem* topicsItem = new QTreeWidgetItem(
(QTreeWidgetItem*)nullptr, QStringList("Topics"));
QTreeWidgetItem* topicsItem = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList("Topics"));
for (auto news : headline.topics) {
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0, news.title);
item->setText(1, QLocale().toString(
news.date, QLocale::ShortFormat));
item->setText(1, QLocale().toString(news.date, QLocale::ShortFormat));
item->setData(0, Qt::UserRole, news.url);
topicsItem->addChild(item);
}
newsListView->insertTopLevelItems(
0, QList<QTreeWidgetItem*>(
{newsItem, pinnedItem, topicsItem}));
newsListView->insertTopLevelItems(0, QList<QTreeWidgetItem*>({newsItem, pinnedItem, topicsItem}));
for (int i = 0; i < 3; i++) {
newsListView->expandItem(newsListView->topLevelItem(i));

View file

@ -1,22 +1,23 @@
#include "settingswindow.h"
#include <QFormLayout>
#include <QPushButton>
#include <QDesktopServices>
#include <QLabel>
#include <QFileDialog>
#include <QCheckBox>
#include <QDesktopServices>
#include <QFileDialog>
#include <QFormLayout>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QMessageBox>
#include <QProcess>
#include <QGridLayout>
#include <QPushButton>
#include <QToolTip>
#include "gamescopesettingswindow.h"
#include "launchercore.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");
setWindowModality(Qt::WindowModality::ApplicationModal);
@ -76,8 +77,7 @@ SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherC
profileWidget->addItem("INVALID *DEBUG*");
profileWidget->setCurrentRow(0);
connect(profileWidget, &QListWidget::currentRowChanged, this,
&SettingsWindow::reloadControls);
connect(profileWidget, &QListWidget::currentRowChanged, this, &SettingsWindow::reloadControls);
profileLayout->addWidget(profileWidget, 0, 0, 3, 1);
@ -91,8 +91,7 @@ SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherC
deleteProfileButton = new QPushButton("Delete Profile");
connect(deleteProfileButton, &QPushButton::pressed, [=] {
profileWidget->setCurrentRow(
this->core.deleteProfile(getCurrentProfile().name));
profileWidget->setCurrentRow(this->core.deleteProfile(getCurrentProfile().name));
this->core.saveSettings();
});
@ -314,12 +313,8 @@ void SettingsWindow::setupGameTab(QFormLayout& layout) {
directXCombo->addItem("DirectX 9");
layout.addRow("DirectX Version", directXCombo);
connect(directXCombo,
static_cast<void (QComboBox::*)(int)>(
&QComboBox::currentIndexChanged),
[=](int index) {
getCurrentProfile().useDX9 =
directXCombo->currentIndex() == 1;
connect(directXCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=](int index) {
getCurrentProfile().useDX9 = directXCombo->currentIndex() == 1;
this->core.saveSettings();
});
@ -334,8 +329,7 @@ void SettingsWindow::setupGameTab(QFormLayout& layout) {
auto selectDirectoryButton = new QPushButton("Select Game Directory");
connect(selectDirectoryButton, &QPushButton::pressed, [this] {
getCurrentProfile().gamePath =
QFileDialog::getExistingDirectory(this, "Open Game Directory");
getCurrentProfile().gamePath = QFileDialog::getExistingDirectory(this, "Open Game Directory");
this->reloadControls();
this->core.saveSettings();
@ -345,8 +339,9 @@ void SettingsWindow::setupGameTab(QFormLayout& layout) {
gameDirButtonLayout->addWidget(selectDirectoryButton);
gameDirectoryButton = new QPushButton("Open Game Directory");
connect(gameDirectoryButton, &QPushButton::pressed,
[this] { window.openPath(getCurrentProfile().gamePath); });
connect(gameDirectoryButton, &QPushButton::pressed, [this] {
window.openPath(getCurrentProfile().gamePath);
});
gameDirButtonLayout->addWidget(gameDirectoryButton);
#ifdef ENABLE_WATCHDOG
@ -370,8 +365,7 @@ void SettingsWindow::setupGameTab(QFormLayout& layout) {
void SettingsWindow::setupLoginTab(QFormLayout& layout) {
encryptArgumentsBox = new QCheckBox();
connect(encryptArgumentsBox, &QCheckBox::stateChanged, [=](int) {
getCurrentProfile().encryptArguments =
encryptArgumentsBox->isChecked();
getCurrentProfile().encryptArguments = encryptArgumentsBox->isChecked();
this->core.saveSettings();
});
@ -381,10 +375,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) {
serverType->insertItem(0, "Square Enix");
serverType->insertItem(1, "Sapphire");
connect(serverType,
static_cast<void (QComboBox::*)(int)>(
&QComboBox::currentIndexChanged),
[=](int index) {
connect(serverType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=](int index) {
getCurrentProfile().isSapphire = index == 1;
reloadControls();
@ -405,10 +396,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) {
gameLicenseBox->insertItem(1, "Windows (Steam)");
gameLicenseBox->insertItem(2, "macOS");
connect(gameLicenseBox,
static_cast<void (QComboBox::*)(int)>(
&QComboBox::currentIndexChanged),
[=](int index) {
connect(gameLicenseBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=](int index) {
getCurrentProfile().license = (GameLicense)index;
this->core.saveSettings();
@ -418,8 +406,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) {
freeTrialBox = new QCheckBox();
connect(freeTrialBox, &QCheckBox::stateChanged, [=](int) {
getCurrentProfile().isFreeTrial =
freeTrialBox->isChecked();
getCurrentProfile().isFreeTrial = freeTrialBox->isChecked();
this->core.saveSettings();
});
@ -427,8 +414,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) {
rememberUsernameBox = new QCheckBox();
connect(rememberUsernameBox, &QCheckBox::stateChanged, [=](int) {
getCurrentProfile().rememberUsername =
rememberUsernameBox->isChecked();
getCurrentProfile().rememberUsername = rememberUsernameBox->isChecked();
this->core.saveSettings();
});
@ -436,8 +422,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) {
rememberPasswordBox = new QCheckBox();
connect(rememberPasswordBox, &QCheckBox::stateChanged, [=](int) {
getCurrentProfile().rememberPassword =
rememberPasswordBox->isChecked();
getCurrentProfile().rememberPassword = rememberPasswordBox->isChecked();
this->core.saveSettings();
});
@ -445,8 +430,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) {
useOneTimePassword = new QCheckBox();
connect(useOneTimePassword, &QCheckBox::stateChanged, [=](int) {
getCurrentProfile().useOneTimePassword =
useOneTimePassword->isChecked();
getCurrentProfile().useOneTimePassword = useOneTimePassword->isChecked();
this->core.saveSettings();
this->window.reloadControls();
@ -482,10 +466,7 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
layout.addWidget(selectWineButton);
#endif
connect(wineTypeCombo,
static_cast<void (QComboBox::*)(int)>(
&QComboBox::currentIndexChanged),
[this](int index) {
connect(wineTypeCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this](int index) {
getCurrentProfile().wineType = (WineType)index;
this->core.readWineInfo(getCurrentProfile());
@ -494,8 +475,7 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
});
connect(selectWineButton, &QPushButton::pressed, [this] {
getCurrentProfile().winePath =
QFileDialog::getOpenFileName(this, "Open Wine Executable");
getCurrentProfile().winePath = QFileDialog::getOpenFileName(this, "Open Wine Executable");
this->core.saveSettings();
this->reloadControls();
@ -519,8 +499,7 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
auto selectPrefixButton = new QPushButton("Select Wine Prefix");
connect(selectPrefixButton, &QPushButton::pressed, [this] {
getCurrentProfile().winePrefixPath =
QFileDialog::getExistingDirectory(this, "Open Wine Prefix");
getCurrentProfile().winePrefixPath = QFileDialog::getExistingDirectory(this, "Open Wine Prefix");
this->core.saveSettings();
this->reloadControls();
@ -528,8 +507,9 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
winePrefixButtonLayout->addWidget(selectPrefixButton);
auto openPrefixButton = new QPushButton("Open Wine Prefix");
connect(openPrefixButton, &QPushButton::pressed,
[this] { window.openPath(getCurrentProfile().winePrefixPath); });
connect(openPrefixButton, &QPushButton::pressed, [this] {
window.openPath(getCurrentProfile().winePrefixPath);
});
winePrefixButtonLayout->addWidget(openPrefixButton);
auto enableDXVKhud = new QCheckBox("Enable DXVK HUD");
@ -537,17 +517,16 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
connect(enableDXVKhud, &QCheckBox::stateChanged, [this](int state) {
getCurrentProfile().enableDXVKhud = state;
this->core.settings.setValue("enableDXVKhud",
static_cast<bool>(state));
this->core.settings.setValue("enableDXVKhud", static_cast<bool>(state));
});
#endif
#if defined(Q_OS_LINUX)
useEsync = new QCheckBox(
"Use Better Sync Primitives (Esync, Fsync, and Futex2)");
useEsync = new QCheckBox("Use Better Sync Primitives (Esync, Fsync, and Futex2)");
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) {
getCurrentProfile().useEsync = state;
@ -558,7 +537,9 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
useGamescope = new QCheckBox("Use Gamescope");
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 gamescopeButtonContainer = new QWidget();
@ -567,8 +548,7 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
configureGamescopeButton = new QPushButton("Configure...");
connect(configureGamescopeButton, &QPushButton::pressed, [&] {
auto gamescopeSettingsWindow = new GamescopeSettingsWindow(
getCurrentProfile(), this->core, this);
auto gamescopeSettingsWindow = new GamescopeSettingsWindow(getCurrentProfile(), this->core, this);
gamescopeSettingsWindow->show();
});
gamescopeButtonLayout->addWidget(configureGamescopeButton);
@ -583,7 +563,8 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) {
useGamemode = new QCheckBox("Use GameMode");
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) {
getCurrentProfile().useGamemode = state;
@ -615,10 +596,7 @@ void SettingsWindow::setupDalamudTab(QFormLayout& layout) {
dalamudChannel->insertItem(1, "Staging");
dalamudChannel->insertItem(2, ".NET 5");
connect(dalamudChannel,
static_cast<void (QComboBox::*)(int)>(
&QComboBox::currentIndexChanged),
[=](int index) {
connect(dalamudChannel, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=](int index) {
getCurrentProfile().dalamud.channel = (DalamudChannel)index;
this->core.saveSettings();
@ -639,6 +617,4 @@ void SettingsWindow::setupDalamudTab(QFormLayout& layout) {
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 <QCommandLineParser>
#include <keychain.h>
#include <QDir>
#include <keychain.h>
#include <physis.hpp>
#include "../launcher/tablet/include/tabletinterface.h"

View file

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