1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00

Make tablet interface functional

Right now OTP and other stuff is missing for an actual login, but it
calls!
This commit is contained in:
Joshua Goins 2022-06-08 13:55:15 -04:00
parent a007f8567e
commit 55aaf7c1f6
14 changed files with 170 additions and 123 deletions

View file

@ -19,7 +19,7 @@ bool CMDInterface::parse(QCommandLineParser &parser, LauncherCore &core) {
}
if(parser.isSet(autologinOption)) {
auto profile = core.getProfile(core.defaultProfileIndex);
auto& profile = core.getProfile(core.defaultProfileIndex);
if(!profile.rememberUsername || !profile.rememberPassword) {
qInfo() << "Profile does not have a username and/or password saved, autologin disabled.";
@ -52,12 +52,15 @@ bool CMDInterface::parse(QCommandLineParser &parser, LauncherCore &core) {
loop->exec();
auto info = LoginInformation{&profile, username, password, ""};
auto info = new LoginInformation();
info->settings = &profile;
info->username = username;
info->password = password;
if(profile.isSapphire) {
core.sapphireLauncher->login(profile.lobbyURL, info);
core.sapphireLauncher->login(profile.lobbyURL, *info);
} else {
core.squareBoot->bootCheck(info);
core.squareBoot->bootCheck(*info);
}
}

View file

@ -43,6 +43,7 @@ target_link_libraries(astra_core PUBLIC
Qt5::Core
Qt5::Network
Qt5::Widgets # widgets is required by watchdog, to be fixed/removed later
Qt5::Quick # required for some type registrations
PRIVATE
astra_desktop) # desktop is currently required by the core, to be fixed/removed later

View file

@ -7,10 +7,12 @@
#include <QUuid>
#include <QProcess>
#include <QMessageBox>
#include <QtQml>
#include "squareboot.h"
class SapphireLauncher;
class SquareLauncher;
class SquareBoot;
class AssetUpdater;
class Watchdog;
@ -33,7 +35,10 @@ enum class DalamudChannel {
Net5
};
struct ProfileSettings {
class ProfileSettings : public QObject {
Q_OBJECT
QML_ELEMENT
public:
QUuid uuid;
QString name;
@ -94,7 +99,14 @@ struct AppSettings {
bool showNewsList = true;
};
struct LoginInformation {
class LoginInformation : public QObject {
Q_OBJECT
Q_PROPERTY(QString username MEMBER username)
Q_PROPERTY(QString password MEMBER password)
Q_PROPERTY(QString oneTimePassword MEMBER oneTimePassword)
Q_PROPERTY(ProfileSettings* settings MEMBER settings)
QML_ELEMENT
public:
ProfileSettings* settings = nullptr;
QString username, password, oneTimePassword;
@ -110,18 +122,28 @@ struct LoginAuth {
};
class LauncherCore : public QObject {
Q_OBJECT
Q_OBJECT
Q_PROPERTY(SquareBoot* squareBoot MEMBER squareBoot)
public:
LauncherCore();
~LauncherCore();
// used for qml only, TODO: move this to a dedicated factory
Q_INVOKABLE LoginInformation* createNewLoginInfo() {
return new LoginInformation();
}
QNetworkAccessManager* mgr;
ProfileSettings getProfile(int index) const;
ProfileSettings& getProfile(int index);
// used for qml only
Q_INVOKABLE ProfileSettings* getProfileQML(int index) {
return profileSettings[index];
}
int getProfileIndex(QString name);
QList<QString> profileList() const;
Q_INVOKABLE QList<QString> profileList() const;
int addProfile();
int deleteProfile(QString name);
@ -190,5 +212,5 @@ private:
QString getDefaultGamePath();
QString getDefaultWinePrefixPath();
QVector<ProfileSettings> profileSettings;
QVector<ProfileSettings*> profileSettings;
};

View file

@ -1,15 +1,17 @@
#pragma once
#include <QProgressDialog>
#include "launchercore.h"
class SquareLauncher;
class LauncherCore;
struct LoginInformation;
class SquareBoot : public QObject {
Q_OBJECT
public:
SquareBoot(LauncherCore& window, SquareLauncher& launcher);
void checkGateStatus(const LoginInformation& info);
Q_INVOKABLE void checkGateStatus(LoginInformation* info);
void bootCheck(const LoginInformation& info);

View file

@ -134,10 +134,10 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
if(profile.dalamud.enabled) {
auto socket = new QTcpServer();
connect(socket, &QTcpServer::newConnection, [this, profile, socket] {
connect(socket, &QTcpServer::newConnection, [this, &profile, socket] {
auto connection = socket->nextPendingConnection();
connect(connection, &QTcpSocket::readyRead, [this, connection, profile, socket] {
connect(connection, &QTcpSocket::readyRead, [this, connection, &profile, socket] {
QString output = connection->readAll();
bool success;
int exitCode = output.toInt(&success, 10);
@ -381,69 +381,68 @@ void LauncherCore::readInitialInformation() {
profileSettings.resize(profiles.size());
for(const auto& uuid : profiles) {
ProfileSettings profile;
profile.uuid = QUuid(uuid);
ProfileSettings* profile = new ProfileSettings();
profile->uuid = QUuid(uuid);
settings.beginGroup(uuid);
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()) {
profile.gamePath = settings.value("gamePath").toString();
profile->gamePath = settings.value("gamePath").toString();
} else {
profile.gamePath = getDefaultGamePath();
profile->gamePath = getDefaultGamePath();
}
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 {
profile.winePrefixPath = getDefaultWinePrefixPath();
profile->winePrefixPath = getDefaultWinePrefixPath();
}
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();
}
ProfileSettings defaultSettings;
// login
profile.encryptArguments = settings.value("encryptArguments", defaultSettings.encryptArguments).toBool();
profile.isSapphire = settings.value("isSapphire", defaultSettings.isSapphire).toBool();
profile.lobbyURL = settings.value("lobbyURL", defaultSettings.lobbyURL).toString();
profile.rememberUsername = settings.value("rememberUsername", defaultSettings.rememberUsername).toBool();
profile.rememberPassword = settings.value("rememberPassword", defaultSettings.rememberPassword).toBool();
profile.useOneTimePassword = settings.value("useOneTimePassword", defaultSettings.useOneTimePassword).toBool();
profile.license = (GameLicense)settings.value("license", (int)defaultSettings.license).toInt();
profile.isFreeTrial = settings.value("isFreeTrial", defaultSettings.isFreeTrial).toBool();
profile->encryptArguments = settings.value("encryptArguments", defaultSettings.encryptArguments).toBool();
profile->isSapphire = settings.value("isSapphire", defaultSettings.isSapphire).toBool();
profile->lobbyURL = settings.value("lobbyURL", defaultSettings.lobbyURL).toString();
profile->rememberUsername = settings.value("rememberUsername", defaultSettings.rememberUsername).toBool();
profile->rememberPassword = settings.value("rememberPassword", defaultSettings.rememberPassword).toBool();
profile->useOneTimePassword = settings.value("useOneTimePassword", defaultSettings.useOneTimePassword).toBool();
profile->license = (GameLicense)settings.value("license", (int)defaultSettings.license).toInt();
profile->isFreeTrial = settings.value("isFreeTrial", defaultSettings.isFreeTrial).toBool();
profile.useDX9 = settings.value("useDX9", defaultSettings.useDX9).toBool();
profile->useDX9 = settings.value("useDX9", defaultSettings.useDX9).toBool();
// wine
profile.wineType = (WineType)settings.value("wineType", (int)defaultSettings.wineType).toInt();
profile.useEsync = settings.value("useEsync", defaultSettings.useEsync).toBool();
profile->wineType = (WineType)settings.value("wineType", (int)defaultSettings.wineType).toInt();
profile->useEsync = settings.value("useEsync", defaultSettings.useEsync).toBool();
readWineInfo(profile);
readWineInfo(*profile);
if(gamescopeAvailable)
profile.useGamescope = settings.value("useGamescope", defaultSettings.useGamescope).toBool();
profile->useGamescope = settings.value("useGamescope", defaultSettings.useGamescope).toBool();
if(gamemodeAvailable)
profile.useGamemode = settings.value("useGamemode", defaultSettings.useGamemode).toBool();
profile->useGamemode = settings.value("useGamemode", defaultSettings.useGamemode).toBool();
profile.enableDXVKhud = settings.value("enableDXVKhud", defaultSettings.enableDXVKhud).toBool();
profile->enableDXVKhud = settings.value("enableDXVKhud", defaultSettings.enableDXVKhud).toBool();
profile.enableWatchdog = settings.value("enableWatchdog", defaultSettings.enableWatchdog).toBool();
profile->enableWatchdog = settings.value("enableWatchdog", defaultSettings.enableWatchdog).toBool();
// gamescope
profile.gamescope.fullscreen = settings.value("gamescopeFullscreen", defaultSettings.gamescope.fullscreen).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.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.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.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();
profileSettings[settings.value("index").toInt()] = profile;
@ -498,11 +497,11 @@ void LauncherCore::readWineInfo(ProfileSettings& profile) {
void LauncherCore::readGameVersion() {
for(auto& profile : profileSettings) {
profile.bootVersion = readVersion(profile.gamePath + "/boot/ffxivboot.ver");
profile.installedMaxExpansion = 0;
profile->bootVersion = readVersion(profile->gamePath + "/boot/ffxivboot.ver");
profile->installedMaxExpansion = 0;
auto sqpackDirectories = QDir(profile.gamePath + "/game/sqpack/").entryList(QDir::Filter::Dirs | QDir::Filter::NoDotAndDotDot);
profile.gameVersions.resize(sqpackDirectories.size());
auto sqpackDirectories = QDir(profile->gamePath + "/game/sqpack/").entryList(QDir::Filter::Dirs | QDir::Filter::NoDotAndDotDot);
profile->gameVersions.resize(sqpackDirectories.size());
for(auto dir : sqpackDirectories) {
if(dir.contains("ex") || dir == "ffxiv") {
@ -512,7 +511,7 @@ void LauncherCore::readGameVersion() {
if(dir == "ffxiv") {
expansion = 0;
profile.gameVersions[0] = readVersion(profile.gamePath + QString("/game/ffxivgame.ver"));
profile->gameVersions[0] = readVersion(profile->gamePath + QString("/game/ffxivgame.ver"));
} else {
QString originalName = dir.remove("ex");
bool ok = false;
@ -520,17 +519,17 @@ void LauncherCore::readGameVersion() {
if(ok)
expansion = convertedInt;
profile.gameVersions[convertedInt] = readVersion(QString("%1/game/sqpack/ex%2/ex%2.ver").arg(profile.gamePath, QString::number(expansion)));
profile->gameVersions[convertedInt] = readVersion(QString("%1/game/sqpack/ex%2/ex%2.ver").arg(profile->gamePath, QString::number(expansion)));
}
if(expansion != -1) {
profile.installedMaxExpansion = std::max(profile.installedMaxExpansion, expansion);
profile->installedMaxExpansion = std::max(profile->installedMaxExpansion, expansion);
}
}
}
if(profile.installedMaxExpansion >= 0)
readGameData(profile);
if(profile->installedMaxExpansion >= 0)
readGameData(*profile);
}
}
@ -554,17 +553,13 @@ LauncherCore::~LauncherCore() noexcept {
#endif
}
ProfileSettings LauncherCore::getProfile(int index) const {
return profileSettings[index];
}
ProfileSettings& LauncherCore::getProfile(int index) {
return profileSettings[index];
return *profileSettings[index];
}
int LauncherCore::getProfileIndex(QString name) {
for(int i = 0; i < profileSettings.size(); i++) {
if(profileSettings[i].name == name)
if(profileSettings[i]->name == name)
return i;
}
@ -574,21 +569,21 @@ int LauncherCore::getProfileIndex(QString name) {
QList<QString> LauncherCore::profileList() const {
QList<QString> list;
for(auto profile : profileSettings) {
list.append(profile.name);
list.append(profile->name);
}
return list;
}
int LauncherCore::addProfile() {
ProfileSettings newProfile;
newProfile.uuid = QUuid::createUuid();
newProfile.name = "New Profile";
ProfileSettings* newProfile = new ProfileSettings();
newProfile->uuid = QUuid::createUuid();
newProfile->name = "New Profile";
readWineInfo(newProfile);
readWineInfo(*newProfile);
newProfile.gamePath = getDefaultGamePath();
newProfile.winePrefixPath = getDefaultWinePrefixPath();
newProfile->gamePath = getDefaultGamePath();
newProfile->winePrefixPath = getDefaultWinePrefixPath();
profileSettings.append(newProfile);
@ -600,12 +595,12 @@ int LauncherCore::addProfile() {
int LauncherCore::deleteProfile(QString name) {
int index = 0;
for(int i = 0; i < profileSettings.size(); i++) {
if(profileSettings[i].name == name)
if(profileSettings[i]->name == name)
index = i;
}
// remove group so it doesnt stay
settings.beginGroup(profileSettings[index].uuid.toString(QUuid::StringFormat::WithoutBraces));
settings.beginGroup(profileSettings[index]->uuid.toString(QUuid::StringFormat::WithoutBraces));
settings.remove("");
settings.endGroup();
@ -623,45 +618,45 @@ void LauncherCore::saveSettings() {
for(int i = 0; i < profileSettings.size(); i++) {
const auto& profile = profileSettings[i];
settings.beginGroup(profile.uuid.toString(QUuid::StringFormat::WithoutBraces));
settings.beginGroup(profile->uuid.toString(QUuid::StringFormat::WithoutBraces));
settings.setValue("name", profile.name);
settings.setValue("name", profile->name);
settings.setValue("index", i);
// game
settings.setValue("useDX9", profile.useDX9);
settings.setValue("gamePath", profile.gamePath);
settings.setValue("useDX9", profile->useDX9);
settings.setValue("gamePath", profile->gamePath);
// wine
settings.setValue("wineType", (int)profile.wineType);
settings.setValue("winePath", profile.winePath);
settings.setValue("winePrefixPath", profile.winePrefixPath);
settings.setValue("wineType", (int)profile->wineType);
settings.setValue("winePath", profile->winePath);
settings.setValue("winePrefixPath", profile->winePrefixPath);
settings.setValue("useEsync", profile.useEsync);
settings.setValue("useGamescope", profile.useGamescope);
settings.setValue("useGamemode", profile.useGamemode);
settings.setValue("useEsync", profile->useEsync);
settings.setValue("useGamescope", profile->useGamescope);
settings.setValue("useGamemode", profile->useGamemode);
// gamescope
settings.setValue("gamescopeFullscreen", profile.gamescope.fullscreen);
settings.setValue("gamescopeBorderless", profile.gamescope.borderless);
settings.setValue("gamescopeWidth", profile.gamescope.width);
settings.setValue("gamescopeHeight", profile.gamescope.height);
settings.setValue("gamescopeRefreshRate", profile.gamescope.refreshRate);
settings.setValue("gamescopeFullscreen", profile->gamescope.fullscreen);
settings.setValue("gamescopeBorderless", profile->gamescope.borderless);
settings.setValue("gamescopeWidth", profile->gamescope.width);
settings.setValue("gamescopeHeight", profile->gamescope.height);
settings.setValue("gamescopeRefreshRate", profile->gamescope.refreshRate);
// login
settings.setValue("encryptArguments", profile.encryptArguments);
settings.setValue("isSapphire", profile.isSapphire);
settings.setValue("lobbyURL", profile.lobbyURL);
settings.setValue("rememberUsername", profile.rememberUsername);
settings.setValue("rememberPassword", profile.rememberPassword);
settings.setValue("useOneTimePassword", profile.useOneTimePassword);
settings.setValue("license", (int)profile.license);
settings.setValue("isFreeTrial", profile.isFreeTrial);
settings.setValue("encryptArguments", profile->encryptArguments);
settings.setValue("isSapphire", profile->isSapphire);
settings.setValue("lobbyURL", profile->lobbyURL);
settings.setValue("rememberUsername", profile->rememberUsername);
settings.setValue("rememberPassword", profile->rememberPassword);
settings.setValue("useOneTimePassword", profile->useOneTimePassword);
settings.setValue("license", (int)profile->license);
settings.setValue("isFreeTrial", profile->isFreeTrial);
settings.setValue("enableDalamud", profile.dalamud.enabled);
settings.setValue("dalamudOptOut", profile.dalamud.optOutOfMbCollection);
settings.setValue("dalamudChannel", (int)profile.dalamud.channel);
settings.setValue("enableWatchdog", profile.enableWatchdog);
settings.setValue("enableDalamud", profile->dalamud.enabled);
settings.setValue("dalamudOptOut", profile->dalamud.optOutOfMbCollection);
settings.setValue("dalamudChannel", (int)profile->dalamud.channel);
settings.setValue("enableWatchdog", profile->enableWatchdog);
settings.endGroup();
}
@ -669,7 +664,7 @@ void LauncherCore::saveSettings() {
void LauncherCore::addUpdateButtons(const ProfileSettings& settings, QMessageBox& messageBox) {
auto launcherButton = messageBox.addButton("Launch Official Launcher", QMessageBox::NoRole);
connect(launcherButton, &QPushButton::clicked, [=] {
connect(launcherButton, &QPushButton::clicked, [&] {
launchExecutable(settings, {settings.gamePath + "/boot/ffxivboot.exe"});
});

View file

@ -24,7 +24,7 @@ void SapphireLauncher::login(QString lobbyUrl, const LoginInformation& info) {
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
auto reply = window.mgr->post(request, QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Compact));
connect(reply, &QNetworkReply::finished, [=] {
connect(reply, &QNetworkReply::finished, [&] {
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
if(!document.isEmpty()) {
LoginAuth auth;
@ -55,7 +55,7 @@ void SapphireLauncher::registerAccount(QString lobbyUrl, const LoginInformation&
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
auto reply = window.mgr->post(request, QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Compact));
connect(reply, &QNetworkReply::finished, [=] {
connect(reply, &QNetworkReply::finished, [&] {
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
LoginAuth auth;

View file

@ -40,7 +40,7 @@ void SquareBoot::bootCheck(const LoginInformation& info) {
request.setRawHeader("Host", "patch-bootver.ffxiv.com");
auto reply = window.mgr->get(request);
connect(reply, &QNetworkReply::finished, [=] {
connect(reply, &QNetworkReply::finished, [=, &info] {
const QString response = reply->readAll();
if(response.isEmpty()) {
@ -77,7 +77,7 @@ void SquareBoot::bootCheck(const LoginInformation& info) {
dialog->setValue(recieved);
});
connect(patchReply, &QNetworkReply::finished, [=] {
connect(patchReply, &QNetworkReply::finished, [&] {
const QString dataDir =
QStandardPaths::writableLocation(QStandardPaths::TempLocation);
@ -103,7 +103,7 @@ void SquareBoot::bootCheck(const LoginInformation& info) {
});
}
void SquareBoot::checkGateStatus(const LoginInformation& info) {
void SquareBoot::checkGateStatus(LoginInformation* info) {
QUrlQuery query;
query.addQueryItem("", QString::number(QDateTime::currentMSecsSinceEpoch()));
@ -115,7 +115,7 @@ void SquareBoot::checkGateStatus(const LoginInformation& info) {
request.setUrl(url);
// TODO: really?
window.buildRequest(*info.settings, request);
window.buildRequest(*info->settings, request);
auto reply = window.mgr->get(request);
connect(reply, &QNetworkReply::finished, [=] {
@ -132,7 +132,7 @@ void SquareBoot::checkGateStatus(const LoginInformation& info) {
const bool isGateOpen = !document.isEmpty() && document.object()["status"].toInt() != 0;
if(isGateOpen) {
bootCheck(info);
bootCheck(*info);
} else {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical,
"Failed to Login",

View file

@ -58,7 +58,7 @@ void SquareLauncher::getStored(const LoginInformation& info) {
QNetworkReply* reply = window.mgr->get(request);
connect(reply, &QNetworkReply::finished, [=] {
connect(reply, &QNetworkReply::finished, [=, &info] {
auto str = QString(reply->readAll());
// fetches Steam username
@ -102,7 +102,7 @@ void SquareLauncher::login(const LoginInformation& info, const QUrl referer) {
request.setRawHeader("Cache-Control", "no-cache");
auto reply = window.mgr->post(request, postData.toString(QUrl::FullyEncoded).toUtf8());
connect(reply, &QNetworkReply::finished, [=] {
connect(reply, &QNetworkReply::finished, [=, &info] {
auto str = QString(reply->readAll());
QRegularExpression re(R"lit(window.external.user\("login=auth,ok,(?<launchParams>.*)\);)lit");
@ -175,7 +175,7 @@ void SquareLauncher::registerSession(const LoginInformation& info) {
report += QString("\nex%1\t%2").arg(QString::number(i), info.settings->gameVersions[i]);
auto reply = window.mgr->post(request, report.toUtf8());
connect(reply, &QNetworkReply::finished, [=] {
connect(reply, &QNetworkReply::finished, [&] {
if(reply->rawHeaderList().contains("X-Patch-Unique-Id")) {
auth.SID = reply->rawHeader("X-Patch-Unique-Id");

View file

@ -17,7 +17,6 @@ class LauncherWindow : public QMainWindow {
public:
explicit LauncherWindow(LauncherCore& core, QWidget* parent = nullptr);
ProfileSettings currentProfile() const;
ProfileSettings& currentProfile();
void openPath(const QString path);

View file

@ -73,7 +73,7 @@ void AssetUpdater::update(const ProfileSettings& profile) {
QNetworkRequest request(dalamudAssetManifestURL);
auto reply = launcher.mgr->get(request);
connect(reply, &QNetworkReply::finished, [reply, this, profile] {
connect(reply, &QNetworkReply::finished, [reply, this, &profile] {
dialog->setLabelText("Checking for Dalamud asset updates...");
// TODO: handle asset failure
@ -97,7 +97,7 @@ void AssetUpdater::update(const ProfileSettings& profile) {
remoteNativeLauncherVersion.clear();
auto reply = launcher.mgr->get(request);
connect(reply, &QNetworkReply::finished, [this, profile, reply] {
connect(reply, &QNetworkReply::finished, [this, &profile, reply] {
dialog->setLabelText("Checking for native launcher updates...");
remoteNativeLauncherVersion = reply->readAll().trimmed();
@ -119,7 +119,7 @@ void AssetUpdater::update(const ProfileSettings& profile) {
remoteRuntimeVersion.clear();
auto reply = launcher.mgr->get(request);
connect(reply, &QNetworkReply::finished, [this, profile, reply] {
connect(reply, &QNetworkReply::finished, [this, &profile, reply] {
dialog->setLabelText("Checking for Dalamud updates...");
QByteArray str = reply->readAll();

View file

@ -5,7 +5,7 @@ DesktopInterface::DesktopInterface(LauncherCore& core) {
window = new LauncherWindow(core);
window->show();
auto defaultProfile = core.getProfile(core.defaultProfileIndex);
auto& defaultProfile = core.getProfile(core.defaultProfileIndex);
if(!defaultProfile.isGameInstalled()) {
auto messageBox = new QMessageBox(window);

View file

@ -258,7 +258,13 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
setCentralWidget(emptyWidget);
connect(core.assetUpdater, &AssetUpdater::finishedUpdating, [=] {
auto info = LoginInformation{&currentProfile(), usernameEdit->text(), passwordEdit->text(), otpEdit->text()};
auto& profile = currentProfile();
LoginInformation info;
info.settings = &profile;
info.username = usernameEdit->text();
info.password = passwordEdit->text();
info.oneTimePassword = otpEdit->text();
#ifndef QT_DEBUG
if(currentProfile().rememberUsername) {
@ -281,7 +287,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
if(currentProfile().isSapphire) {
this->core.sapphireLauncher->login(currentProfile().lobbyURL, info);
} else {
this->core.squareBoot->checkGateStatus(info);
this->core.squareBoot->checkGateStatus(&info);
}
});
@ -292,7 +298,14 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
connect(registerButton, &QPushButton::released, [=] {
if(currentProfile().isSapphire) {
auto info = LoginInformation{&currentProfile(), usernameEdit->text(), passwordEdit->text(), otpEdit->text()};
auto& profile = currentProfile();
LoginInformation info;
info.settings = &profile;
info.username = usernameEdit->text();
info.password = passwordEdit->text();
info.oneTimePassword = otpEdit->text();
this->core.sapphireLauncher->registerAccount(currentProfile().lobbyURL, info);
}
});
@ -315,10 +328,6 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
reloadControls();
}
ProfileSettings LauncherWindow::currentProfile() const {
return core.getProfile(profileSelect->currentIndex());
}
ProfileSettings& LauncherWindow::currentProfile() {
return core.getProfile(profileSelect->currentIndex());
}

View file

@ -1,6 +1,7 @@
import QtQuick 2.7
import QtQuick.Controls 2.15
import QtQuick.Window 2.0
import Astra 1.0
ApplicationWindow {
id: window
@ -45,6 +46,14 @@ ApplicationWindow {
anchors.top: passwordField.bottom
onClicked: print("Hooray!");
onClicked: {
var info = core.createNewLoginInfo();
info.settings = core.getProfileQML(0);
info.username = usernameField.text
info.password = passwordField.text
print(info);
core.squareBoot.checkGateStatus(info);
}
}
}

View file

@ -1,7 +1,14 @@
#include "../launcher/tablet/include/tabletinterface.h"
#include "tabletinterface.h"
#include <QQuickView>
#include <QQmlContext>
TabletInterface::TabletInterface(LauncherCore &core) {
qmlRegisterType<ProfileSettings>("Astra", 1, 0, "ProfileSettings");
qmlRegisterType<LoginInformation>("Astra", 1, 0, "LoginInformation");
applicationEngine = new QQmlApplicationEngine();
applicationEngine->rootContext()->setContextProperty("core", &core);
applicationEngine->load("qrc:/main.qml");
}