2021-11-01 09:54:58 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QFuture>
|
|
|
|
#include <QSettings>
|
2021-11-09 13:24:38 -05:00
|
|
|
#include <QUuid>
|
2021-11-23 14:37:37 -05:00
|
|
|
#include <QProcess>
|
2021-12-02 14:40:04 -05:00
|
|
|
#include <QMessageBox>
|
2021-11-01 09:54:58 -04:00
|
|
|
|
|
|
|
class SapphireLauncher;
|
|
|
|
class SquareLauncher;
|
|
|
|
class SquareBoot;
|
2021-11-23 14:37:37 -05:00
|
|
|
class AssetUpdater;
|
2021-11-01 09:54:58 -04:00
|
|
|
|
2021-11-09 11:03:44 -05:00
|
|
|
struct ProfileSettings {
|
2021-11-09 13:24:38 -05:00
|
|
|
QUuid uuid;
|
2021-11-09 11:25:15 -05:00
|
|
|
QString name;
|
|
|
|
|
2021-11-09 21:13:21 -05:00
|
|
|
// game
|
2021-11-09 11:03:44 -05:00
|
|
|
int language = 1; // 1 is english, thats all i know
|
|
|
|
QString gamePath, winePath, winePrefixPath;
|
|
|
|
QString bootVersion, gameVersion;
|
2021-12-02 15:02:59 -05:00
|
|
|
int installedMaxExpansion = -1;
|
|
|
|
QList<QString> expansionVersions;
|
2021-11-09 13:04:22 -05:00
|
|
|
|
2021-11-09 21:13:21 -05:00
|
|
|
// wine
|
2021-11-09 13:04:22 -05:00
|
|
|
// 0 = system, 1 = custom, 2 = built-in (mac only)
|
|
|
|
// TODO: yes, i know this should be an enum
|
2021-11-10 05:18:59 -05:00
|
|
|
#if defined(Q_OS_MAC)
|
|
|
|
int wineVersion = 2;
|
|
|
|
#else
|
2021-11-09 13:04:22 -05:00
|
|
|
int wineVersion = 0;
|
2021-11-10 05:18:59 -05:00
|
|
|
#endif
|
2021-11-09 13:52:36 -05:00
|
|
|
bool useEsync = false, useGamescope = false, useGamemode = false;
|
2021-11-09 11:03:44 -05:00
|
|
|
bool useDX9 = false;
|
|
|
|
bool enableDXVKhud = false;
|
2021-11-23 14:37:37 -05:00
|
|
|
bool enableDalamud = false;
|
2021-11-09 11:25:15 -05:00
|
|
|
|
2021-11-09 21:13:21 -05:00
|
|
|
// login
|
|
|
|
bool encryptArguments = false;
|
2021-11-09 11:25:15 -05:00
|
|
|
bool isSapphire = false;
|
|
|
|
QString lobbyURL;
|
2021-11-09 13:52:36 -05:00
|
|
|
bool rememberUsername = false, rememberPassword = false;
|
2021-11-09 11:03:44 -05:00
|
|
|
};
|
|
|
|
|
2021-11-01 09:54:58 -04:00
|
|
|
struct LoginInformation {
|
2021-11-23 16:02:02 -05:00
|
|
|
const ProfileSettings* settings = nullptr;
|
2021-11-23 15:34:23 -05:00
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2021-11-23 15:34:23 -05:00
|
|
|
class LauncherCore : public QObject {
|
2021-11-01 09:54:58 -04:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-11-23 15:34:23 -05:00
|
|
|
LauncherCore();
|
2021-11-01 09:54:58 -04:00
|
|
|
|
|
|
|
QNetworkAccessManager* mgr;
|
|
|
|
|
2021-11-09 12:06:30 -05:00
|
|
|
ProfileSettings getProfile(int index) const;
|
|
|
|
ProfileSettings& getProfile(int index);
|
|
|
|
|
2021-11-09 11:25:15 -05:00
|
|
|
int getProfileIndex(QString name);
|
2021-11-09 11:03:44 -05:00
|
|
|
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);
|
2021-11-01 14:35:32 -04:00
|
|
|
|
2021-11-23 15:34:23 -05:00
|
|
|
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);
|
2021-11-02 08:27:00 -04:00
|
|
|
void readInitialInformation();
|
2021-11-09 13:11:21 -05:00
|
|
|
void readGameVersion();
|
2021-11-10 04:30:01 -05:00
|
|
|
void readWineInfo(ProfileSettings& settings);
|
2021-11-09 12:16:14 -05:00
|
|
|
void saveSettings();
|
2021-11-01 09:54:58 -04:00
|
|
|
|
2021-12-02 14:40:04 -05:00
|
|
|
void addUpdateButtons(const ProfileSettings& settings, QMessageBox& messageBox);
|
|
|
|
|
2021-11-01 14:35:32 -04:00
|
|
|
QSettings settings;
|
|
|
|
|
2021-11-01 09:54:58 -04:00
|
|
|
SapphireLauncher* sapphireLauncher;
|
|
|
|
SquareBoot* squareBoot;
|
|
|
|
SquareLauncher* squareLauncher;
|
2021-11-23 14:37:37 -05:00
|
|
|
AssetUpdater* assetUpdater;
|
2021-11-09 11:03:44 -05:00
|
|
|
|
2021-11-23 15:34:23 -05:00
|
|
|
int defaultProfileIndex = 0;
|
|
|
|
signals:
|
|
|
|
void settingsChanged();
|
2021-11-09 12:25:54 -05:00
|
|
|
|
2021-11-23 15:34:23 -05:00
|
|
|
private:
|
2021-12-02 15:02:59 -05:00
|
|
|
void readExpansionVersions(ProfileSettings& info, int max);
|
|
|
|
|
2021-11-18 07:30:38 -05:00
|
|
|
QVector<ProfileSettings> profileSettings;
|
2021-11-01 09:54:58 -04:00
|
|
|
};
|