mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-24 21:37:46 +00:00
Modify readInitialInformation() to load multiple profiles
This commit is contained in:
parent
53d0587559
commit
6737a363fe
2 changed files with 84 additions and 84 deletions
|
@ -116,67 +116,84 @@ QString LauncherWindow::readVersion(QString path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::readInitialInformation() {
|
void LauncherWindow::readInitialInformation() {
|
||||||
const int wineVersion = settings.value("wineVersion", 0).toInt();
|
auto profiles = settings.childGroups();
|
||||||
|
|
||||||
|
// create the Default profile if it doesnt exist
|
||||||
|
if(profiles.empty())
|
||||||
|
profiles.append("Default");
|
||||||
|
|
||||||
|
for(const auto& profile_name : profiles) {
|
||||||
|
ProfileSettings profile;
|
||||||
|
profile.name = profile_name;
|
||||||
|
|
||||||
|
settings.beginGroup(profile_name);
|
||||||
|
|
||||||
|
const int wineVersion = settings.value("wineVersion", 0).toInt();
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
switch(wineVersion) {
|
switch(wineVersion) {
|
||||||
case 0: // system wine
|
case 0: // system wine
|
||||||
winePath = "/usr/local/bin/wine64";
|
profile.winePath = "/usr/local/bin/wine64";
|
||||||
break;
|
break;
|
||||||
case 1: // custom path
|
case 1: // custom path
|
||||||
winePath = settings.value("winePath").toString();
|
profile.winePath = settings.value("winePath").toString();
|
||||||
break;
|
break;
|
||||||
case 2: // ffxiv built-in (for mac users)
|
case 2: // ffxiv built-in (for mac users)
|
||||||
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;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
switch(wineVersion) {
|
switch(wineVersion) {
|
||||||
case 0: // system wine (should be in $PATH)
|
case 0: // system wine (should be in $PATH)
|
||||||
currentProfile().winePath = "wine";
|
profile.winePath = "wine";
|
||||||
break;
|
break;
|
||||||
case 1: // custom pth
|
case 1: // custom pth
|
||||||
currentProfile().winePath = settings.value("winePath").toString();
|
profile.winePath = settings.value("winePath").toString();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
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()) {
|
||||||
currentProfile().gamePath = settings.value("gamePath").toString();
|
profile.gamePath = settings.value("gamePath").toString();
|
||||||
} else {
|
} else {
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
gamePath = "C:\\Program Files (x86)\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn";
|
profile.gamePath = "C:\\Program Files (x86)\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_MACOS)
|
#if defined(Q_OS_MACOS)
|
||||||
gamePath = 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";
|
profile.gamePath = 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)
|
||||||
currentProfile().gamePath = QDir::homePath() + "/.wine/drive_c/Program Files (x86)/SquareEnix/FINAL FANTASY XIV - A Realm Reborn";
|
profile.gamePath = QDir::homePath() + "/.wine/drive_c/Program Files (x86)/SquareEnix/FINAL FANTASY XIV - A Realm Reborn";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if(settings.contains("winePrefix") && settings.value("winePrefix").canConvert<QString>() && !settings.value("winePrefix").toString().isEmpty()) {
|
if(settings.contains("winePrefix") && settings.value("winePrefix").canConvert<QString>() && !settings.value("winePrefix").toString().isEmpty()) {
|
||||||
currentProfile().winePrefixPath = settings.value("winePrefix").toString();
|
profile.winePrefixPath = settings.value("winePrefix").toString();
|
||||||
} else {
|
} else {
|
||||||
#if defined(Q_OS_MACOS)
|
#if defined(Q_OS_MACOS)
|
||||||
winePrefixPath = QDir::homePath() + "/Library/Application Support/FINAL FANTASY XIV ONLINE/Bottles/published_Final_Fantasy";
|
profile.winePrefixPath = QDir::homePath() + "/Library/Application Support/FINAL FANTASY XIV ONLINE/Bottles/published_Final_Fantasy";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
currentProfile().winePrefixPath = QDir::homePath() + "/.wine";
|
profile.winePrefixPath = QDir::homePath() + "/.wine";
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.bootVersion = readVersion(profile.gamePath + "/boot/ffxivboot.ver");
|
||||||
|
profile.gameVersion = readVersion(profile.gamePath + "/game/ffxivgame.ver");
|
||||||
|
|
||||||
|
profile.useEsync = settings.value("useEsync", false).toBool();
|
||||||
|
profile.useGamemode = settings.value("useGamemode", false).toBool();
|
||||||
|
profile.useGamescope = settings.value("useGamescope", false).toBool();
|
||||||
|
profile.enableDXVKhud = settings.value("enableDXVKhud", false).toBool();
|
||||||
|
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
profileSettings.append(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentProfile().bootVersion = readVersion(currentProfile().gamePath + "/boot/ffxivboot.ver");
|
|
||||||
currentProfile().gameVersion = readVersion(currentProfile().gamePath + "/game/ffxivgame.ver");
|
|
||||||
|
|
||||||
currentProfile().useEsync = settings.value("useEsync", false).toBool();
|
|
||||||
currentProfile().useGamemode = settings.value("useGamemode", false).toBool();
|
|
||||||
currentProfile().useGamescope = settings.value("useGamescope", false).toBool();
|
|
||||||
currentProfile().enableDXVKhud = settings.value("enableDXVKhud", false).toBool();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LauncherWindow::LauncherWindow(QWidget* parent) :
|
LauncherWindow::LauncherWindow(QWidget* parent) :
|
||||||
|
@ -186,7 +203,7 @@ LauncherWindow::LauncherWindow(QWidget* parent) :
|
||||||
squareLauncher = new SquareLauncher(*this);
|
squareLauncher = new SquareLauncher(*this);
|
||||||
squareBoot = new SquareBoot(*this, *squareLauncher);
|
squareBoot = new SquareBoot(*this, *squareLauncher);
|
||||||
|
|
||||||
profileSettings.append(ProfileSettings());
|
readInitialInformation();
|
||||||
|
|
||||||
QMenu* fileMenu = menuBar()->addMenu("File");
|
QMenu* fileMenu = menuBar()->addMenu("File");
|
||||||
// sorry linux users, for some reason my global menu does not like qt6 apps right now
|
// sorry linux users, for some reason my global menu does not like qt6 apps right now
|
||||||
|
@ -231,11 +248,6 @@ LauncherWindow::LauncherWindow(QWidget* parent) :
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const auto savedServerType = settings.value("serverType", 0).toInt();
|
|
||||||
const auto savedLobbyURL = settings.value("lobbyURL", "127.0.0.1").toString();
|
|
||||||
const auto shouldRememberUsername = settings.value("rememberUsername", false).toBool();
|
|
||||||
const auto shouldRememberPassword = settings.value("rememberPassword", false).toBool();
|
|
||||||
|
|
||||||
auto layout = new QFormLayout();
|
auto layout = new QFormLayout();
|
||||||
|
|
||||||
auto profileSelect = new QComboBox();
|
auto profileSelect = new QComboBox();
|
||||||
|
@ -245,7 +257,7 @@ LauncherWindow::LauncherWindow(QWidget* parent) :
|
||||||
auto usernameEdit = new QLineEdit();
|
auto usernameEdit = new QLineEdit();
|
||||||
layout->addRow("Username", usernameEdit);
|
layout->addRow("Username", usernameEdit);
|
||||||
|
|
||||||
if(shouldRememberUsername) {
|
if(currentProfile().rememberUsername) {
|
||||||
auto job = new QKeychain::ReadPasswordJob("LauncherWindow");
|
auto job = new QKeychain::ReadPasswordJob("LauncherWindow");
|
||||||
job->setKey("username");
|
job->setKey("username");
|
||||||
job->start();
|
job->start();
|
||||||
|
@ -256,14 +268,14 @@ LauncherWindow::LauncherWindow(QWidget* parent) :
|
||||||
}
|
}
|
||||||
|
|
||||||
auto rememberUsernameBox = new QCheckBox();
|
auto rememberUsernameBox = new QCheckBox();
|
||||||
rememberUsernameBox->setChecked(shouldRememberUsername);
|
rememberUsernameBox->setChecked(currentProfile().rememberUsername);
|
||||||
layout->addRow("Remember Username?", rememberUsernameBox);
|
layout->addRow("Remember Username?", rememberUsernameBox);
|
||||||
|
|
||||||
auto passwordEdit = new QLineEdit();
|
auto passwordEdit = new QLineEdit();
|
||||||
passwordEdit->setEchoMode(QLineEdit::EchoMode::Password);
|
passwordEdit->setEchoMode(QLineEdit::EchoMode::Password);
|
||||||
layout->addRow("Password", passwordEdit);
|
layout->addRow("Password", passwordEdit);
|
||||||
|
|
||||||
if(shouldRememberPassword) {
|
if(currentProfile().rememberPassword) {
|
||||||
auto job = new QKeychain::ReadPasswordJob("LauncherWindow");
|
auto job = new QKeychain::ReadPasswordJob("LauncherWindow");
|
||||||
job->setKey("password");
|
job->setKey("password");
|
||||||
job->start();
|
job->start();
|
||||||
|
@ -274,7 +286,7 @@ LauncherWindow::LauncherWindow(QWidget* parent) :
|
||||||
}
|
}
|
||||||
|
|
||||||
auto rememberPasswordBox = new QCheckBox();
|
auto rememberPasswordBox = new QCheckBox();
|
||||||
rememberPasswordBox->setChecked(shouldRememberPassword);
|
rememberPasswordBox->setChecked(currentProfile().rememberPassword);
|
||||||
layout->addRow("Remember Password?", rememberPasswordBox);
|
layout->addRow("Remember Password?", rememberPasswordBox);
|
||||||
|
|
||||||
auto otpEdit = new QLineEdit();
|
auto otpEdit = new QLineEdit();
|
||||||
|
@ -286,62 +298,46 @@ LauncherWindow::LauncherWindow(QWidget* parent) :
|
||||||
auto registerButton = new QPushButton("Register");
|
auto registerButton = new QPushButton("Register");
|
||||||
layout->addRow(registerButton);
|
layout->addRow(registerButton);
|
||||||
|
|
||||||
/*const auto refreshControls = [=](int index) {
|
const auto refreshControls = [=]() {
|
||||||
lobbyServerURL->setEnabled(index == 1);
|
registerButton->setEnabled(currentProfile().isSapphire);
|
||||||
registerButton->setEnabled(index == 1);
|
otpEdit->setEnabled(!currentProfile().isSapphire);
|
||||||
otpEdit->setEnabled(index == 0);
|
|
||||||
};
|
};
|
||||||
refreshControls(serverType->currentIndex());
|
refreshControls();
|
||||||
|
|
||||||
connect(serverType, &QComboBox::currentIndexChanged, [=](int index) {
|
|
||||||
refreshControls(index);
|
|
||||||
});*/
|
|
||||||
|
|
||||||
auto emptyWidget = new QWidget();
|
auto emptyWidget = new QWidget();
|
||||||
emptyWidget->setLayout(layout);
|
emptyWidget->setLayout(layout);
|
||||||
setCentralWidget(emptyWidget);
|
setCentralWidget(emptyWidget);
|
||||||
|
|
||||||
readInitialInformation();
|
|
||||||
|
|
||||||
connect(loginButton, &QPushButton::released, [=] {
|
connect(loginButton, &QPushButton::released, [=] {
|
||||||
auto info = LoginInformation{usernameEdit->text(), passwordEdit->text(), otpEdit->text()};
|
auto info = LoginInformation{usernameEdit->text(), passwordEdit->text(), otpEdit->text()};
|
||||||
|
|
||||||
settings.setValue("gamePath", currentProfile().gamePath);
|
if(currentProfile().rememberUsername) {
|
||||||
settings.setValue("winePrefix", currentProfile().winePrefixPath);
|
|
||||||
|
|
||||||
settings.setValue("rememberUsername", rememberUsernameBox->checkState() == Qt::CheckState::Checked);
|
|
||||||
if(rememberUsernameBox->checkState() == Qt::CheckState::Checked) {
|
|
||||||
auto job = new QKeychain::WritePasswordJob("LauncherWindow");
|
auto job = new QKeychain::WritePasswordJob("LauncherWindow");
|
||||||
job->setTextData(usernameEdit->text());
|
job->setTextData(usernameEdit->text());
|
||||||
job->setKey("username");
|
job->setKey("username");
|
||||||
job->start();
|
job->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.setValue("rememberPassword", rememberPasswordBox->checkState() == Qt::CheckState::Checked);
|
if(currentProfile().rememberPassword) {
|
||||||
if(rememberPasswordBox->checkState() == Qt::CheckState::Checked) {
|
|
||||||
auto job = new QKeychain::WritePasswordJob("LauncherWindow");
|
auto job = new QKeychain::WritePasswordJob("LauncherWindow");
|
||||||
job->setTextData(passwordEdit->text());
|
job->setTextData(passwordEdit->text());
|
||||||
job->setKey("password");
|
job->setKey("password");
|
||||||
job->start();
|
job->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
//settings.setValue("serverType", serverType->currentIndex());
|
if(currentProfile().isSapphire) {
|
||||||
//settings.setValue("lobbyURL", lobbyServerURL->text());
|
sapphireLauncher->login(currentProfile().lobbyURL, info);
|
||||||
|
} else {
|
||||||
//if(serverType->currentIndex() == 0) {
|
|
||||||
// begin se's booting process
|
|
||||||
squareBoot->bootCheck(info);
|
squareBoot->bootCheck(info);
|
||||||
//} else {
|
}
|
||||||
// sapphireLauncher->login(lobbyServerURL->text(), info);
|
|
||||||
//}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/*connect(registerButton, &QPushButton::released, [=] {
|
connect(registerButton, &QPushButton::released, [=] {
|
||||||
if(serverType->currentIndex() == 1) {
|
if(currentProfile().isSapphire) {
|
||||||
auto info = LoginInformation{usernameEdit->text(), passwordEdit->text(), otpEdit->text()};
|
auto info = LoginInformation{usernameEdit->text(), passwordEdit->text(), otpEdit->text()};
|
||||||
sapphireLauncher->registerAccount(lobbyServerURL->text(), info);
|
sapphireLauncher->registerAccount(currentProfile().lobbyURL, info);
|
||||||
}
|
}
|
||||||
});*/
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
LauncherWindow::~LauncherWindow() = default;
|
LauncherWindow::~LauncherWindow() = default;
|
||||||
|
@ -355,23 +351,22 @@ ProfileSettings& LauncherWindow::currentProfile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::setProfile(QString name) {
|
void LauncherWindow::setProfile(QString name) {
|
||||||
for(int i = 0; i < profileSettings.size(); i++) {
|
currentProfileIndex = getProfileIndex(name);
|
||||||
currentProfileIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
currentProfileIndex = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileSettings LauncherWindow::getProfile(QString name) {
|
int LauncherWindow::getProfileIndex(QString name) {
|
||||||
for(auto profile : profileSettings) {
|
for(int i = 0; i < profileSettings.size(); i++) {
|
||||||
return profile;
|
if(profileSettings[i].name == name)
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString> LauncherWindow::profileList() const {
|
QList<QString> LauncherWindow::profileList() const {
|
||||||
QList<QString> list;
|
QList<QString> list;
|
||||||
for(auto profile : profileSettings) {
|
for(auto profile : profileSettings) {
|
||||||
list.append("Default");
|
list.append(profile.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
|
|
@ -10,13 +10,18 @@ class SquareLauncher;
|
||||||
class SquareBoot;
|
class SquareBoot;
|
||||||
|
|
||||||
struct ProfileSettings {
|
struct ProfileSettings {
|
||||||
|
QString name;
|
||||||
|
|
||||||
int language = 1; // 1 is english, thats all i know
|
int language = 1; // 1 is english, thats all i know
|
||||||
QString gamePath, winePath, winePrefixPath;
|
QString gamePath, winePath, winePrefixPath;
|
||||||
QString bootVersion, gameVersion;
|
QString bootVersion, gameVersion;
|
||||||
|
|
||||||
bool useEsync, useGamescope, useGamemode;
|
bool useEsync, useGamescope, useGamemode;
|
||||||
bool useDX9 = false;
|
bool useDX9 = false;
|
||||||
bool enableDXVKhud = false;
|
bool enableDXVKhud = false;
|
||||||
|
|
||||||
|
bool isSapphire = false;
|
||||||
|
QString lobbyURL;
|
||||||
|
bool rememberUsername, rememberPassword;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LoginInformation {
|
struct LoginInformation {
|
||||||
|
@ -44,7 +49,7 @@ public:
|
||||||
ProfileSettings currentProfile() const;
|
ProfileSettings currentProfile() const;
|
||||||
ProfileSettings& currentProfile();
|
ProfileSettings& currentProfile();
|
||||||
void setProfile(QString name);
|
void setProfile(QString name);
|
||||||
ProfileSettings getProfile(QString name);
|
int getProfileIndex(QString name);
|
||||||
QList<QString> profileList() const;
|
QList<QString> profileList() const;
|
||||||
|
|
||||||
void launchGame(const LoginAuth auth);
|
void launchGame(const LoginAuth auth);
|
||||||
|
|
Loading…
Add table
Reference in a new issue