diff --git a/CMakeLists.txt b/CMakeLists.txt index d6e5aac..8e8ba9b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,9 @@ set(SRC src/assetupdater.cpp src/assetupdater.h src/launcherwindow.cpp - src/launcherwindow.h) + src/launcherwindow.h + src/gamescopesettingswindow.cpp + src/gamescopesettingswindow.h) set(LIBRARIES Qt5::Core Qt5::Widgets Qt5::Network qt5keychain QuaZip) diff --git a/src/gamescopesettingswindow.cpp b/src/gamescopesettingswindow.cpp new file mode 100644 index 0000000..9da1175 --- /dev/null +++ b/src/gamescopesettingswindow.cpp @@ -0,0 +1,63 @@ +#include "gamescopesettingswindow.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "launchercore.h" +#include "launcherwindow.h" + +GamescopeSettingsWindow::GamescopeSettingsWindow(ProfileSettings& settings, QWidget* parent) : QDialog(parent) { + setWindowTitle("Gamescope Settings"); + setWindowModality(Qt::WindowModality::ApplicationModal); + + auto mainLayout = new QFormLayout(this); + setLayout(mainLayout); + + auto fullscreenBox = new QCheckBox("Fullscreen"); + fullscreenBox->setChecked(settings.gamescope.fullscreen); + connect(fullscreenBox, &QCheckBox::clicked, [&](bool checked) { + settings.gamescope.fullscreen = checked; + }); + mainLayout->addWidget(fullscreenBox); + + auto borderlessBox = new QCheckBox("Borderless"); + borderlessBox->setChecked(settings.gamescope.fullscreen); + connect(borderlessBox, &QCheckBox::clicked, [&](bool checked) { + settings.gamescope.borderless = checked; + }); + mainLayout->addWidget(borderlessBox); + + auto widthBox = new QSpinBox(); + widthBox->setValue(settings.gamescope.width); + widthBox->setSpecialValueText("Default"); + connect(widthBox, QOverload::of(&QSpinBox::valueChanged), [&](int value) { + settings.gamescope.width = value; + }); + mainLayout->addRow("Width", widthBox); + + auto heightBox = new QSpinBox(); + heightBox->setValue(settings.gamescope.height); + heightBox->setSpecialValueText("Default"); + connect(heightBox, QOverload::of(&QSpinBox::valueChanged), [&](int value) { + settings.gamescope.height = value; + }); + mainLayout->addRow("Height", heightBox); + + auto refreshRateBox = new QSpinBox(); + refreshRateBox->setValue(settings.gamescope.refreshRate); + refreshRateBox->setSpecialValueText("Default"); + connect(refreshRateBox, QOverload::of(&QSpinBox::valueChanged), [&](int value) { + settings.gamescope.refreshRate = value; + }); + mainLayout->addRow("Refresh Rate", refreshRateBox); +} \ No newline at end of file diff --git a/src/gamescopesettingswindow.h b/src/gamescopesettingswindow.h new file mode 100644 index 0000000..4dd822b --- /dev/null +++ b/src/gamescopesettingswindow.h @@ -0,0 +1,18 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +class LauncherCore; +class LauncherWindow; +struct ProfileSettings; + +class GamescopeSettingsWindow : public QDialog { +public: + GamescopeSettingsWindow(ProfileSettings& settings, QWidget* parent = nullptr); +}; diff --git a/src/launchercore.cpp b/src/launchercore.cpp index 35dfe12..f08c181 100755 --- a/src/launchercore.cpp +++ b/src/launchercore.cpp @@ -212,8 +212,21 @@ void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* pr #if defined(Q_OS_LINUX) if(profile.useGamescope) { arguments.push_back("gamescope"); - arguments.push_back("-f"); - arguments.push_back("-b"); + + if(profile.gamescope.fullscreen) + arguments.push_back("-f"); + + if(profile.gamescope.borderless) + arguments.push_back("-b"); + + if(profile.gamescope.width >= 0) + arguments.push_back("-w " + QString::number(profile.gamescope.width)); + + if(profile.gamescope.height >= 0) + arguments.push_back("-h " + QString::number(profile.gamescope.height)); + + if(profile.gamescope.refreshRate >= 0) + arguments.push_back("-r " + QString::number(profile.gamescope.refreshRate)); } if(profile.useGamemode) @@ -319,6 +332,13 @@ void LauncherCore::readInitialInformation() { profile.enableDXVKhud = settings.value("enableDXVKhud", false).toBool(); profile.enableWatchdog = settings.value("enableWatchdog", false).toBool(); + // gamescope + profile.gamescope.fullscreen = settings.value("gamescopeFullscreen", true).toBool(); + profile.gamescope.borderless = settings.value("gamescopeBorderless", true).toBool(); + profile.gamescope.width = settings.value("gamescopeWidth", 0).toInt(); + profile.gamescope.height = settings.value("gamescopeHeight", 0).toInt(); + profile.gamescope.refreshRate = settings.value("gamescopeRefreshRate", 0).toInt(); + profile.enableDalamud = settings.value("enableDalamud", false).toBool(); profileSettings[settings.value("index").toInt()] = profile; @@ -482,6 +502,13 @@ void LauncherCore::saveSettings() { settings.setValue("useGamescope", profile.useGamescope); settings.setValue("useGamemode", profile.useGamemode); + // gamescope + settings.setValue("gamescopeFullscreen", profile.gamescope.fullscreen); + settings.setValue("gamescopeBorderless", profile.gamescope.borderless); + settings.setValue("gamescopeWidth", profile.gamescope.width); + settings.setValue("gamescopeHeight", profile.gamescope.height); + settings.setValue("gamescopeRefreshRate", profile.gamescope.refreshRate); + // login settings.setValue("encryptArguments", profile.encryptArguments); settings.setValue("isSapphire", profile.isSapphire); diff --git a/src/launchercore.h b/src/launchercore.h index 098e63a..ce78ebb 100755 --- a/src/launchercore.h +++ b/src/launchercore.h @@ -39,6 +39,14 @@ struct ProfileSettings { bool enableDXVKhud = false; bool enableDalamud = false; + struct GamescopeOptions { + bool fullscreen = true; + bool borderless = true; + int width = 0; + int height = 0; + int refreshRate = 0; + } gamescope; + // login bool encryptArguments = true; bool isSapphire = false; diff --git a/src/launcherwindow.cpp b/src/launcherwindow.cpp index 4ac8fcd..0b59586 100644 --- a/src/launcherwindow.cpp +++ b/src/launcherwindow.cpp @@ -20,7 +20,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo QAction* settingsAction = fileMenu->addAction("Settings..."); connect(settingsAction, &QAction::triggered, [=] { - auto window = new SettingsWindow(*this, this->core); + auto window = new SettingsWindow(*this, this->core, this); connect(&this->core, &LauncherCore::settingsChanged, window, &SettingsWindow::reloadControls); window->show(); }); diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index 37974ae..e6c4bdf 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -14,8 +14,9 @@ #include "launchercore.h" #include "launcherwindow.h" +#include "gamescopesettingswindow.h" -SettingsWindow::SettingsWindow(LauncherWindow& window, LauncherCore& core, QWidget* parent) : core(core), window(window), QWidget(parent) { +SettingsWindow::SettingsWindow(LauncherWindow& window, LauncherCore& core, QWidget* parent) : core(core), window(window), QDialog(parent) { setWindowTitle("Settings"); setWindowModality(Qt::WindowModality::ApplicationModal); @@ -270,6 +271,13 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, LauncherCore& core, QWidg }); wineBoxLayout->addWidget(gamescopeLabel); + auto gamescopeCfg = new QPushButton("Configure..."); + connect(gamescopeCfg, &QPushButton::pressed, [&] { + auto gamescopeSettingsWindow = new GamescopeSettingsWindow(getCurrentProfile(), this); + gamescopeSettingsWindow->show(); + }); + wineBoxLayout->addWidget(gamescopeCfg); + connect(useGamescope, &QCheckBox::stateChanged, [this](int state) { getCurrentProfile().useGamescope = state; diff --git a/src/settingswindow.h b/src/settingswindow.h index 27f2087..03a443f 100644 --- a/src/settingswindow.h +++ b/src/settingswindow.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include @@ -12,7 +12,7 @@ class LauncherCore; class LauncherWindow; struct ProfileSettings; -class SettingsWindow : public QWidget { +class SettingsWindow : public QDialog { public: SettingsWindow(LauncherWindow& window, LauncherCore& core, QWidget* parent = nullptr);