mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 15:35:23 +00:00
Merge pull request #2404 from Capostrophic/framerate
Make framerate limit configurable in the launcher
This commit is contained in:
commit
576285573b
@ -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,13 @@ bool Launcher::GraphicsPage::loadSettings()
|
||||
customHeightSpinBox->setValue(height);
|
||||
}
|
||||
|
||||
float fpsLimit = mEngineSettings.getFloat("framerate limit", "Video");
|
||||
if (fpsLimit != 0)
|
||||
{
|
||||
framerateLimitCheckBox->setCheckState(Qt::Checked);
|
||||
framerateLimitSpinBox->setValue(fpsLimit);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -166,6 +174,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 +285,8 @@ void Launcher::GraphicsPage::slotStandardToggled(bool checked)
|
||||
customHeightSpinBox->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Launcher::GraphicsPage::slotFramerateLimitToggled(bool checked)
|
||||
{
|
||||
framerateLimitSpinBox->setEnabled(checked);
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ namespace Launcher
|
||||
private slots:
|
||||
void slotFullScreenChanged(int state);
|
||||
void slotStandardToggled(bool checked);
|
||||
void slotFramerateLimitToggled(bool checked);
|
||||
|
||||
private:
|
||||
Files::ConfigurationManager &mCfgMgr;
|
||||
|
@ -30,8 +30,8 @@ namespace Fallback
|
||||
{
|
||||
try
|
||||
{
|
||||
// We have to rely on Boost because std::stof from C++11
|
||||
// uses the current locale for separators which we don't want and often silently ignores parsing errors.
|
||||
// We have to rely on Boost because std::stof from C++11 uses the current locale
|
||||
// for separators (which is undesired) and it often silently ignores parsing errors.
|
||||
return boost::lexical_cast<float>(fallback);
|
||||
}
|
||||
catch (boost::bad_lexical_cast&)
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
namespace Settings
|
||||
{
|
||||
@ -354,12 +355,14 @@ float Manager::getFloat (const std::string& setting, const std::string& category
|
||||
const std::string value = getString(setting, category);
|
||||
try
|
||||
{
|
||||
return std::stof(value);
|
||||
// We have to rely on Boost because std::stof from C++11 uses the current locale
|
||||
// for separators (which is undesired) and it often silently ignores parsing errors.
|
||||
return boost::lexical_cast<float>(value);
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
catch (boost::bad_lexical_cast&)
|
||||
{
|
||||
Log(Debug::Warning) << "Cannot parse setting '" << setting << "' (invalid setting value: " << value << ").";
|
||||
return 0;
|
||||
return 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
@ -401,12 +404,16 @@ void Manager::setString(const std::string &setting, const std::string &category,
|
||||
|
||||
void Manager::setInt (const std::string& setting, const std::string& category, const int value)
|
||||
{
|
||||
setString(setting, category, std::to_string(value));
|
||||
std::ostringstream stream;
|
||||
stream << value;
|
||||
setString(setting, category, stream.str());
|
||||
}
|
||||
|
||||
void Manager::setFloat (const std::string &setting, const std::string &category, const float value)
|
||||
{
|
||||
setString(setting, category, std::to_string(value));
|
||||
std::ostringstream stream;
|
||||
stream << value;
|
||||
setString(setting, category, stream.str());
|
||||
}
|
||||
|
||||
void Manager::setBool(const std::string &setting, const std::string &category, const bool value)
|
||||
|
@ -34,7 +34,7 @@
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="windowBorderCheckBox">
|
||||
<property name="text">
|
||||
<string>Window border</string>
|
||||
<string>Window Border</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -62,6 +62,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="framerateLimitCheckBox">
|
||||
<property name="text">
|
||||
<string>Framerate Limit:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="antiAliasingComboBox">
|
||||
<item>
|
||||
@ -143,6 +150,31 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QDoubleSpinBox" name="framerateLimitSpinBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> FPS</string>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>1</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>15</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>300</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user