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

106 lines
2.6 KiB
C
Raw Normal View History

2021-11-01 09:54:58 -04:00
#pragma once
#include <QMainWindow>
#include <QNetworkAccessManager>
#include <QFuture>
#include <QSettings>
#include <QUuid>
#include <QProcess>
#include <QMessageBox>
2021-11-01 09:54:58 -04:00
class SapphireLauncher;
class SquareLauncher;
class SquareBoot;
class AssetUpdater;
2021-11-01 09:54:58 -04:00
struct ProfileSettings {
QUuid uuid;
QString name;
2021-11-09 21:13:21 -05:00
// game
int language = 1; // 1 is english, thats all i know
QString gamePath, winePath, winePrefixPath;
QString bootVersion, gameVersion;
int installedMaxExpansion = -1;
QList<QString> expansionVersions;
2021-11-09 21:13:21 -05:00
// wine
// 0 = system, 1 = custom, 2 = built-in (mac only)
// TODO: yes, i know this should be an enum
#if defined(Q_OS_MAC)
int wineVersion = 2;
#else
int wineVersion = 0;
#endif
2021-11-09 13:52:36 -05:00
bool useEsync = false, useGamescope = false, useGamemode = false;
bool useDX9 = false;
bool enableDXVKhud = false;
bool enableDalamud = false;
2021-11-09 21:13:21 -05:00
// login
bool encryptArguments = false;
bool isSapphire = false;
QString lobbyURL;
2021-11-09 13:52:36 -05:00
bool rememberUsername = false, rememberPassword = false;
};
2021-11-01 09:54:58 -04:00
struct LoginInformation {
const ProfileSettings* settings = nullptr;
2021-11-01 09:54:58 -04:00
QString username, password, oneTimePassword;
};
struct LoginAuth {
QString SID;
int region = 2; // america?
int maxExpansion = 1;
// if empty, dont set on the client
QString lobbyhost, frontierHost;
};
class LauncherCore : public QObject {
2021-11-01 09:54:58 -04:00
Q_OBJECT
public:
LauncherCore();
2021-11-01 09:54:58 -04:00
QNetworkAccessManager* mgr;
ProfileSettings getProfile(int index) const;
ProfileSettings& getProfile(int index);
int getProfileIndex(QString name);
QList<QString> profileList() const;
2021-11-09 11:44:27 -05:00
int addProfile();
2021-11-09 13:44:37 -05:00
int deleteProfile(QString name);
void launchGame(const ProfileSettings& settings, const LoginAuth auth);
void launchExecutable(const ProfileSettings& settings, QStringList args);
void launchExecutable(const ProfileSettings& settings, QProcess* process, QStringList args);
2021-11-01 09:54:58 -04:00
void buildRequest(QNetworkRequest& request);
void setSSL(QNetworkRequest& request);
QString readVersion(QString path);
void readInitialInformation();
void readGameVersion();
void readWineInfo(ProfileSettings& settings);
2021-11-09 12:16:14 -05:00
void saveSettings();
2021-11-01 09:54:58 -04:00
void addUpdateButtons(const ProfileSettings& settings, QMessageBox& messageBox);
QSettings settings;
2021-11-01 09:54:58 -04:00
SapphireLauncher* sapphireLauncher;
SquareBoot* squareBoot;
SquareLauncher* squareLauncher;
AssetUpdater* assetUpdater;
int defaultProfileIndex = 0;
signals:
void settingsChanged();
private:
void readExpansionVersions(ProfileSettings& info, int max);
QVector<ProfileSettings> profileSettings;
2021-11-01 09:54:58 -04:00
};