1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-21 20:27:45 +00:00

Check for wine version

This isn't displayed in the settings UI yet.
This commit is contained in:
Joshua Goins 2022-04-09 17:28:24 -04:00
parent b095b343fe
commit 7b2a0ca1c2
6 changed files with 58 additions and 38 deletions

View file

@ -21,6 +21,12 @@ enum class GameLicense {
FreeTrial
};
enum class WineType {
System,
Custom,
Builtin // macos only
};
struct ProfileSettings {
QUuid uuid;
QString name;
@ -28,7 +34,7 @@ struct ProfileSettings {
// game
int language = 1; // 1 is english, thats all i know
QString gamePath, winePath, winePrefixPath;
QString bootVersion, gameVersion;
QString bootVersion, gameVersion, wineVersion;
int installedMaxExpansion = -1;
QList<QString> expansionVersions;
bool enableWatchdog = false;
@ -37,14 +43,16 @@ struct ProfileSettings {
return !gameVersion.isEmpty();
}
// wine
// 0 = system, 1 = custom, 2 = built-in (mac only)
// TODO: yes, i know this should be an enum
bool isWineInstalled() const {
return !wineVersion.isEmpty();
}
#if defined(Q_OS_MAC)
int wineVersion = 2;
WineType wineType = WineType::Builtin;
#else
int wineVersion = 0;
WineType wineType = WineType::System;
#endif
bool useEsync = false, useGamescope = false, useGamemode = false;
bool useDX9 = false;
bool enableDXVKhud = false;
@ -160,7 +168,6 @@ private:
QString getDefaultGamePath();
QString getDefaultWinePrefixPath();
int getDefaultWineVersion();
QVector<ProfileSettings> profileSettings;
};

View file

@ -42,4 +42,8 @@ private:
QLineEdit* otpEdit;
QCheckBox* rememberUsernameBox, *rememberPasswordBox;
QPushButton* loginButton, *registerButton;
#if defined(Q_OS_MAC) || defined(Q_OS_LINUX)
QAction* wineCfg;
#endif
};

View file

@ -36,7 +36,7 @@ private:
QPushButton* gameDirectoryButton = nullptr;
// wine
QComboBox* wineVersionCombo;
QComboBox* wineTypeCombo;
QPushButton* selectWineButton;
QLineEdit* winePathLabel;
QLineEdit* winePrefixDirectory;

View file

@ -327,7 +327,6 @@ void LauncherCore::readInitialInformation() {
settings.beginGroup(uuid);
profile.name = settings.value("name", "Default").toString();
profile.wineVersion = settings.value("wineVersion", getDefaultWineVersion()).toInt();
readWineInfo(profile);
@ -358,6 +357,9 @@ void LauncherCore::readInitialInformation() {
profile.license = (GameLicense)settings.value("license", (int)defaultSettings.license).toInt();
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();
if(gamescopeAvailable)
@ -367,6 +369,7 @@ void LauncherCore::readInitialInformation() {
profile.useGamemode = settings.value("useGamemode", defaultSettings.useGamemode).toBool();
profile.enableDXVKhud = settings.value("enableDXVKhud", defaultSettings.enableDXVKhud).toBool();
profile.enableWatchdog = settings.value("enableWatchdog", defaultSettings.enableWatchdog).toBool();
// gamescope
@ -389,29 +392,41 @@ void LauncherCore::readInitialInformation() {
void LauncherCore::readWineInfo(ProfileSettings& profile) {
#if defined(Q_OS_MAC)
switch(profile.wineVersion) {
case 0: // system wine
switch(profile.wineType) {
case WineType::System: // system wine
profile.winePath = "/usr/local/bin/wine64";
break;
case 1: // custom path
case WineType::Custom: // custom path
profile.winePath = profile.winePath;
break;
case 2: // ffxiv built-in (for mac users)
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";
break;
}
#endif
#if defined(Q_OS_LINUX)
switch(profile.wineVersion) {
case 0: // system wine (should be in $PATH)
profile.winePath = "wine";
switch(profile.wineType) {
case WineType::System: // system wine (should be in $PATH)
profile.winePath = "/usr/bin/wine";
break;
case 1: // custom pth
case WineType::Custom: // custom pth
profile.winePath = profile.winePath;
break;
}
#endif
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
auto wineProcess = new QProcess();
wineProcess->setProcessChannelMode(QProcess::MergedChannels);
connect(wineProcess, &QProcess::readyRead, this, [wineProcess, &profile] {
profile.wineVersion = wineProcess->readAllStandardOutput().trimmed();
});
wineProcess->start(profile.winePath, {"--version"});
wineProcess->waitForFinished();
#endif
}
void LauncherCore::readGameVersion() {
@ -489,8 +504,6 @@ int LauncherCore::addProfile() {
newProfile.uuid = QUuid::createUuid();
newProfile.name = "New Profile";
newProfile.wineVersion = getDefaultWineVersion();
readWineInfo(newProfile);
newProfile.gamePath = getDefaultGamePath();
@ -537,7 +550,7 @@ void LauncherCore::saveSettings() {
settings.setValue("gamePath", profile.gamePath);
// wine
settings.setValue("wineVersion", profile.wineVersion);
settings.setValue("wineType", (int)profile.wineType);
settings.setValue("winePath", profile.winePath);
settings.setValue("winePrefixPath", profile.winePrefixPath);
@ -618,11 +631,3 @@ QString LauncherCore::getDefaultGamePath() {
return QDir::homePath() + "/.wine/drive_c/Program Files (x86)/SquareEnix/FINAL FANTASY XIV - A Realm Reborn";
#endif
}
int LauncherCore::getDefaultWineVersion() {
#if defined(Q_OS_MAC)
return 2;
#else
return 0;
#endif
}

View file

@ -71,7 +71,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
#if defined(Q_OS_MAC) || defined(Q_OS_LINUX)
fileMenu->addSeparator();
QAction* wineCfg = fileMenu->addAction("Configure Wine...");
wineCfg = fileMenu->addAction("Configure Wine...");
wineCfg->setIcon(QIcon::fromTheme("settings"));
connect(wineCfg, &QAction::triggered, [=] {
this->core.launchExecutable(currentProfile(), {"winecfg.exe"});
@ -331,6 +331,10 @@ void LauncherWindow::reloadControls() {
launchCfgBackup->setEnabled(currentProfile().isGameInstalled());
openGameDir->setEnabled(currentProfile().isGameInstalled());
#if defined(Q_OS_MAC) || defined(Q_OS_LINUX)
wineCfg->setEnabled(currentProfile().isWineInstalled());
#endif
currentlyReloadingControls = false;
}

View file

@ -231,25 +231,25 @@ SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherC
winePathLabel->setReadOnly(true);
wineBoxLayout->addRow("Wine Executable", winePathLabel);
wineVersionCombo = new QComboBox();
wineTypeCombo = new QComboBox();
#if defined(Q_OS_MAC)
wineVersionCombo->insertItem(2, "FFXIV Built-In");
wineTypeCombo->insertItem(2, "FFXIV Built-In");
#endif
wineVersionCombo->insertItem(0, "System Wine");
wineVersionCombo->insertItem(1, "Custom Path...");
wineTypeCombo->insertItem(0, "System Wine");
wineTypeCombo->insertItem(1, "Custom Wine");
wineBoxLayout->addWidget(wineVersionCombo);
wineBoxLayout->addWidget(wineTypeCombo);
selectWineButton = new QPushButton("Select Wine Executable");
wineBoxLayout->addWidget(selectWineButton);
connect(wineVersionCombo,
connect(wineTypeCombo,
static_cast<void (QComboBox::*)(int)>(
&QComboBox::currentIndexChanged),
[this](int index) {
getCurrentProfile().wineVersion = index;
getCurrentProfile().wineType = (WineType)index;
this->core.readWineInfo(getCurrentProfile());
this->core.saveSettings();
@ -450,8 +450,8 @@ void SettingsWindow::reloadControls() {
// wine
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
wineVersionCombo->setCurrentIndex(profile.wineVersion);
selectWineButton->setEnabled(profile.wineVersion == 1);
wineTypeCombo->setCurrentIndex((int)profile.wineType);
selectWineButton->setEnabled(profile.wineType == WineType::Custom);
winePathLabel->setText(profile.winePath);
winePrefixDirectory->setText(profile.winePrefixPath);
#endif