1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-24 05:17:46 +00:00

Add a configuration menu for gamescope

This commit is contained in:
Joshua Goins 2022-02-23 21:18:53 -05:00
parent 7435bba6e8
commit f270cfe1ec
8 changed files with 133 additions and 7 deletions

View file

@ -29,7 +29,9 @@ set(SRC
src/assetupdater.cpp src/assetupdater.cpp
src/assetupdater.h src/assetupdater.h
src/launcherwindow.cpp src/launcherwindow.cpp
src/launcherwindow.h) src/launcherwindow.h
src/gamescopesettingswindow.cpp
src/gamescopesettingswindow.h)
set(LIBRARIES set(LIBRARIES
Qt5::Core Qt5::Widgets Qt5::Network qt5keychain QuaZip) Qt5::Core Qt5::Widgets Qt5::Network qt5keychain QuaZip)

View file

@ -0,0 +1,63 @@
#include "gamescopesettingswindow.h"
#include <QFormLayout>
#include <QPushButton>
#include <QDesktopServices>
#include <QLabel>
#include <QFileDialog>
#include <QCheckBox>
#include <QGroupBox>
#include <QMessageBox>
#include <QProcess>
#include <QGridLayout>
#include <QToolTip>
#include <QSpinBox>
#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<int>::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<int>::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<int>::of(&QSpinBox::valueChanged), [&](int value) {
settings.gamescope.refreshRate = value;
});
mainLayout->addRow("Refresh Rate", refreshRateBox);
}

View file

@ -0,0 +1,18 @@
#pragma once
#include <QDialog>
#include <QListWidget>
#include <QComboBox>
#include <QLineEdit>
#include <QCheckBox>
#include <QLabel>
#include <QPushButton>
class LauncherCore;
class LauncherWindow;
struct ProfileSettings;
class GamescopeSettingsWindow : public QDialog {
public:
GamescopeSettingsWindow(ProfileSettings& settings, QWidget* parent = nullptr);
};

View file

@ -212,8 +212,21 @@ void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* pr
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
if(profile.useGamescope) { if(profile.useGamescope) {
arguments.push_back("gamescope"); arguments.push_back("gamescope");
if(profile.gamescope.fullscreen)
arguments.push_back("-f"); arguments.push_back("-f");
if(profile.gamescope.borderless)
arguments.push_back("-b"); 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) if(profile.useGamemode)
@ -319,6 +332,13 @@ void LauncherCore::readInitialInformation() {
profile.enableDXVKhud = settings.value("enableDXVKhud", false).toBool(); profile.enableDXVKhud = settings.value("enableDXVKhud", false).toBool();
profile.enableWatchdog = settings.value("enableWatchdog", 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(); profile.enableDalamud = settings.value("enableDalamud", false).toBool();
profileSettings[settings.value("index").toInt()] = profile; profileSettings[settings.value("index").toInt()] = profile;
@ -482,6 +502,13 @@ void LauncherCore::saveSettings() {
settings.setValue("useGamescope", profile.useGamescope); settings.setValue("useGamescope", profile.useGamescope);
settings.setValue("useGamemode", profile.useGamemode); 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 // login
settings.setValue("encryptArguments", profile.encryptArguments); settings.setValue("encryptArguments", profile.encryptArguments);
settings.setValue("isSapphire", profile.isSapphire); settings.setValue("isSapphire", profile.isSapphire);

View file

@ -39,6 +39,14 @@ struct ProfileSettings {
bool enableDXVKhud = false; bool enableDXVKhud = false;
bool enableDalamud = false; bool enableDalamud = false;
struct GamescopeOptions {
bool fullscreen = true;
bool borderless = true;
int width = 0;
int height = 0;
int refreshRate = 0;
} gamescope;
// login // login
bool encryptArguments = true; bool encryptArguments = true;
bool isSapphire = false; bool isSapphire = false;

View file

@ -20,7 +20,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
QAction* settingsAction = fileMenu->addAction("Settings..."); QAction* settingsAction = fileMenu->addAction("Settings...");
connect(settingsAction, &QAction::triggered, [=] { 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); connect(&this->core, &LauncherCore::settingsChanged, window, &SettingsWindow::reloadControls);
window->show(); window->show();
}); });

View file

@ -14,8 +14,9 @@
#include "launchercore.h" #include "launchercore.h"
#include "launcherwindow.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"); setWindowTitle("Settings");
setWindowModality(Qt::WindowModality::ApplicationModal); setWindowModality(Qt::WindowModality::ApplicationModal);
@ -270,6 +271,13 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, LauncherCore& core, QWidg
}); });
wineBoxLayout->addWidget(gamescopeLabel); 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) { connect(useGamescope, &QCheckBox::stateChanged, [this](int state) {
getCurrentProfile().useGamescope = state; getCurrentProfile().useGamescope = state;

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <QWidget> #include <QDialog>
#include <QListWidget> #include <QListWidget>
#include <QComboBox> #include <QComboBox>
#include <QLineEdit> #include <QLineEdit>
@ -12,7 +12,7 @@ class LauncherCore;
class LauncherWindow; class LauncherWindow;
struct ProfileSettings; struct ProfileSettings;
class SettingsWindow : public QWidget { class SettingsWindow : public QDialog {
public: public:
SettingsWindow(LauncherWindow& window, LauncherCore& core, QWidget* parent = nullptr); SettingsWindow(LauncherWindow& window, LauncherCore& core, QWidget* parent = nullptr);