From b87b29eeb00ec5e4a6fdbae67a51e65f3256d855 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Thu, 30 May 2019 07:11:13 +0300 Subject: [PATCH] Make framerate limit configurable in the launcher --- apps/launcher/graphicspage.cpp | 28 ++++++++++++++++++++++++++++ apps/launcher/graphicspage.hpp | 1 + files/ui/graphicspage.ui | 29 +++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index 56cd08680..f9d8e1e1d 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -44,6 +44,7 @@ Launcher::GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, Settings: connect(fullScreenCheckBox, SIGNAL(stateChanged(int)), this, SLOT(slotFullScreenChanged(int))); connect(standardRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); connect(screenComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(screenChanged(int))); + connect(framerateLimitCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotFramerateLimitToggled(bool))); } @@ -121,6 +122,17 @@ bool Launcher::GraphicsPage::loadSettings() customHeightSpinBox->setValue(height); } + float fpsLimit = mEngineSettings.getFloat("framerate limit", "Video"); + if (fpsLimit != 0) + { + framerateLimitCheckBox->setCheckState(Qt::Checked); + framerateLimitSpinBox->setValue(fpsLimit); + } + else + { + framerateLimitSpinBox->setEnabled(false); + } + return true; } @@ -166,6 +178,17 @@ void Launcher::GraphicsPage::saveSettings() int cScreen = screenComboBox->currentIndex(); if (cScreen != mEngineSettings.getInt("screen", "Video")) mEngineSettings.setInt("screen", "Video", cScreen); + + if (framerateLimitCheckBox->checkState()) + { + float cFpsLimit = framerateLimitSpinBox->value(); + if (cFpsLimit != mEngineSettings.getFloat("framerate limit", "Video")) + mEngineSettings.setFloat("framerate limit", "Video", cFpsLimit); + } + else if (mEngineSettings.getFloat("framerate limit", "Video") != 0) + { + mEngineSettings.setFloat("framerate limit", "Video", 0); + } } QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen) @@ -266,3 +289,8 @@ void Launcher::GraphicsPage::slotStandardToggled(bool checked) customHeightSpinBox->setEnabled(true); } } + +void Launcher::GraphicsPage::slotFramerateLimitToggled(bool checked) +{ + framerateLimitSpinBox->setEnabled(checked); +} diff --git a/apps/launcher/graphicspage.hpp b/apps/launcher/graphicspage.hpp index 9d943d5e2..05915e680 100644 --- a/apps/launcher/graphicspage.hpp +++ b/apps/launcher/graphicspage.hpp @@ -31,6 +31,7 @@ namespace Launcher private slots: void slotFullScreenChanged(int state); void slotStandardToggled(bool checked); + void slotFramerateLimitToggled(bool checked); private: Files::ConfigurationManager &mCfgMgr; diff --git a/files/ui/graphicspage.ui b/files/ui/graphicspage.ui index 0afda6ac7..1f91fb19d 100644 --- a/files/ui/graphicspage.ui +++ b/files/ui/graphicspage.ui @@ -62,6 +62,13 @@ + + + + Framerate limit + + + @@ -143,6 +150,28 @@ + + + + FPS + + + 1 + + + 1 + + + 999 + + + 15 + + + 300 + + +