diff --git a/include/launchercore.h b/include/launchercore.h index 5d609c4..4ff5db0 100755 --- a/include/launchercore.h +++ b/include/launchercore.h @@ -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 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; }; diff --git a/include/launcherwindow.h b/include/launcherwindow.h index e1fa7de..68a6a68 100644 --- a/include/launcherwindow.h +++ b/include/launcherwindow.h @@ -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 }; \ No newline at end of file diff --git a/include/settingswindow.h b/include/settingswindow.h index 65d74ba..dbf60f2 100644 --- a/include/settingswindow.h +++ b/include/settingswindow.h @@ -36,7 +36,7 @@ private: QPushButton* gameDirectoryButton = nullptr; // wine - QComboBox* wineVersionCombo; + QComboBox* wineTypeCombo; QPushButton* selectWineButton; QLineEdit* winePathLabel; QLineEdit* winePrefixDirectory; diff --git a/src/launchercore.cpp b/src/launchercore.cpp index 3e55358..6930f96 100755 --- a/src/launchercore.cpp +++ b/src/launchercore.cpp @@ -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 -} diff --git a/src/launcherwindow.cpp b/src/launcherwindow.cpp index 5afe0ed..10e9f2a 100644 --- a/src/launcherwindow.cpp +++ b/src/launcherwindow.cpp @@ -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; } diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index 3de873c..b9a78c1 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -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( &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