1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 18:19:55 +00:00

[Launcher] Replacing static method access through instances

This addresses the Clang Tidy check [readability-static-accessed-through-instance](https://clang.llvm.org/extra/clang-tidy/checks/readability-static-accessed-through-instance.html). It also simplifies the code by reducing the number of parameters we're passing around.
This commit is contained in:
Thunderforge 2021-05-08 23:28:29 -05:00
parent caf382c19f
commit ead51784dc
5 changed files with 116 additions and 123 deletions

View file

@ -13,11 +13,9 @@
#include "utils/openalutil.hpp" #include "utils/openalutil.hpp"
Launcher::AdvancedPage::AdvancedPage(Config::GameSettings &gameSettings, Launcher::AdvancedPage::AdvancedPage(Config::GameSettings &gameSettings, QWidget *parent)
Settings::Manager &engineSettings, QWidget *parent)
: QWidget(parent) : QWidget(parent)
, mGameSettings(gameSettings) , mGameSettings(gameSettings)
, mEngineSettings(engineSettings)
{ {
setObjectName ("AdvancedPage"); setObjectName ("AdvancedPage");
setupUi(this); setupUi(this);
@ -100,12 +98,12 @@ bool Launcher::AdvancedPage::loadSettings()
loadSettingBool(normaliseRaceSpeedCheckBox, "normalise race speed", "Game"); loadSettingBool(normaliseRaceSpeedCheckBox, "normalise race speed", "Game");
loadSettingBool(swimUpwardCorrectionCheckBox, "swim upward correction", "Game"); loadSettingBool(swimUpwardCorrectionCheckBox, "swim upward correction", "Game");
loadSettingBool(avoidCollisionsCheckBox, "NPCs avoid collisions", "Game"); loadSettingBool(avoidCollisionsCheckBox, "NPCs avoid collisions", "Game");
int unarmedFactorsStrengthIndex = mEngineSettings.getInt("strength influences hand to hand", "Game"); int unarmedFactorsStrengthIndex = Settings::Manager::getInt("strength influences hand to hand", "Game");
if (unarmedFactorsStrengthIndex >= 0 && unarmedFactorsStrengthIndex <= 2) if (unarmedFactorsStrengthIndex >= 0 && unarmedFactorsStrengthIndex <= 2)
unarmedFactorsStrengthComboBox->setCurrentIndex(unarmedFactorsStrengthIndex); unarmedFactorsStrengthComboBox->setCurrentIndex(unarmedFactorsStrengthIndex);
loadSettingBool(stealingFromKnockedOutCheckBox, "always allow stealing from knocked out actors", "Game"); loadSettingBool(stealingFromKnockedOutCheckBox, "always allow stealing from knocked out actors", "Game");
loadSettingBool(enableNavigatorCheckBox, "enable", "Navigator"); loadSettingBool(enableNavigatorCheckBox, "enable", "Navigator");
int numPhysicsThreads = mEngineSettings.getInt("async num threads", "Physics"); int numPhysicsThreads = Settings::Manager::getInt("async num threads", "Physics");
if (numPhysicsThreads >= 0) if (numPhysicsThreads >= 0)
physicsThreadsSpinBox->setValue(numPhysicsThreads); physicsThreadsSpinBox->setValue(numPhysicsThreads);
loadSettingBool(allowNPCToFollowOverWaterSurfaceCheckBox, "allow actors to follow over water surface", "Game"); loadSettingBool(allowNPCToFollowOverWaterSurfaceCheckBox, "allow actors to follow over water surface", "Game");
@ -130,26 +128,26 @@ bool Launcher::AdvancedPage::loadSettings()
loadSettingBool(turnToMovementDirectionCheckBox, "turn to movement direction", "Game"); loadSettingBool(turnToMovementDirectionCheckBox, "turn to movement direction", "Game");
loadSettingBool(smoothMovementCheckBox, "smooth movement", "Game"); loadSettingBool(smoothMovementCheckBox, "smooth movement", "Game");
const bool distantTerrain = mEngineSettings.getBool("distant terrain", "Terrain"); const bool distantTerrain = Settings::Manager::getBool("distant terrain", "Terrain");
const bool objectPaging = mEngineSettings.getBool("object paging", "Terrain"); const bool objectPaging = Settings::Manager::getBool("object paging", "Terrain");
if (distantTerrain && objectPaging) { if (distantTerrain && objectPaging) {
distantLandCheckBox->setCheckState(Qt::Checked); distantLandCheckBox->setCheckState(Qt::Checked);
} }
loadSettingBool(activeGridObjectPagingCheckBox, "object paging active grid", "Terrain"); loadSettingBool(activeGridObjectPagingCheckBox, "object paging active grid", "Terrain");
viewingDistanceComboBox->setValue(convertToCells(mEngineSettings.getInt("viewing distance", "Camera"))); viewingDistanceComboBox->setValue(convertToCells(Settings::Manager::getInt("viewing distance", "Camera")));
int lightingMethod = 1; int lightingMethod = 1;
if (mEngineSettings.getString("lighting method", "Shaders") == "legacy") if (Settings::Manager::getString("lighting method", "Shaders") == "legacy")
lightingMethod = 0; lightingMethod = 0;
else if (mEngineSettings.getString("lighting method", "Shaders") == "shaders") else if (Settings::Manager::getString("lighting method", "Shaders") == "shaders")
lightingMethod = 2; lightingMethod = 2;
lightingMethodComboBox->setCurrentIndex(lightingMethod); lightingMethodComboBox->setCurrentIndex(lightingMethod);
} }
// Audio // Audio
{ {
std::string selectedAudioDevice = mEngineSettings.getString("device", "Sound"); std::string selectedAudioDevice = Settings::Manager::getString("device", "Sound");
if (selectedAudioDevice.empty() == false) if (selectedAudioDevice.empty() == false)
{ {
int audioDeviceIndex = audioDeviceSelectorComboBox->findData(QString::fromStdString(selectedAudioDevice)); int audioDeviceIndex = audioDeviceSelectorComboBox->findData(QString::fromStdString(selectedAudioDevice));
@ -158,12 +156,12 @@ bool Launcher::AdvancedPage::loadSettings()
audioDeviceSelectorComboBox->setCurrentIndex(audioDeviceIndex); audioDeviceSelectorComboBox->setCurrentIndex(audioDeviceIndex);
} }
} }
int hrtfEnabledIndex = mEngineSettings.getInt("hrtf enable", "Sound"); int hrtfEnabledIndex = Settings::Manager::getInt("hrtf enable", "Sound");
if (hrtfEnabledIndex >= -1 && hrtfEnabledIndex <= 1) if (hrtfEnabledIndex >= -1 && hrtfEnabledIndex <= 1)
{ {
enableHRTFComboBox->setCurrentIndex(hrtfEnabledIndex + 1); enableHRTFComboBox->setCurrentIndex(hrtfEnabledIndex + 1);
} }
std::string selectedHRTFProfile = mEngineSettings.getString("hrtf", "Sound"); std::string selectedHRTFProfile = Settings::Manager::getString("hrtf", "Sound");
if (selectedHRTFProfile.empty() == false) if (selectedHRTFProfile.empty() == false)
{ {
int hrtfProfileIndex = hrtfProfileSelectorComboBox->findData(QString::fromStdString(selectedHRTFProfile)); int hrtfProfileIndex = hrtfProfileSelectorComboBox->findData(QString::fromStdString(selectedHRTFProfile));
@ -185,7 +183,7 @@ bool Launcher::AdvancedPage::loadSettings()
loadSettingBool(deferredPreviewRotationCheckBox, "deferred preview rotation", "Camera"); loadSettingBool(deferredPreviewRotationCheckBox, "deferred preview rotation", "Camera");
loadSettingBool(headBobbingCheckBox, "head bobbing", "Camera"); loadSettingBool(headBobbingCheckBox, "head bobbing", "Camera");
defaultShoulderComboBox->setCurrentIndex( defaultShoulderComboBox->setCurrentIndex(
mEngineSettings.getVector2("view over shoulder offset", "Camera").x() >= 0 ? 0 : 1); Settings::Manager::getVector2("view over shoulder offset", "Camera").x() >= 0 ? 0 : 1);
} }
// Interface Changes // Interface Changes
@ -195,13 +193,13 @@ bool Launcher::AdvancedPage::loadSettings()
loadSettingBool(showMeleeInfoCheckBox, "show melee info", "Game"); loadSettingBool(showMeleeInfoCheckBox, "show melee info", "Game");
loadSettingBool(showProjectileDamageCheckBox, "show projectile damage", "Game"); loadSettingBool(showProjectileDamageCheckBox, "show projectile damage", "Game");
loadSettingBool(changeDialogTopicsCheckBox, "color topic enable", "GUI"); loadSettingBool(changeDialogTopicsCheckBox, "color topic enable", "GUI");
int showOwnedIndex = mEngineSettings.getInt("show owned", "Game"); int showOwnedIndex = Settings::Manager::getInt("show owned", "Game");
// Match the index with the option (only 0, 1, 2, or 3 are valid). Will default to 0 if invalid. // Match the index with the option (only 0, 1, 2, or 3 are valid). Will default to 0 if invalid.
if (showOwnedIndex >= 0 && showOwnedIndex <= 3) if (showOwnedIndex >= 0 && showOwnedIndex <= 3)
showOwnedComboBox->setCurrentIndex(showOwnedIndex); showOwnedComboBox->setCurrentIndex(showOwnedIndex);
loadSettingBool(stretchBackgroundCheckBox, "stretch menu background", "GUI"); loadSettingBool(stretchBackgroundCheckBox, "stretch menu background", "GUI");
loadSettingBool(graphicHerbalismCheckBox, "graphic herbalism", "Game"); loadSettingBool(graphicHerbalismCheckBox, "graphic herbalism", "Game");
scalingSpinBox->setValue(mEngineSettings.getFloat("scaling factor", "GUI")); scalingSpinBox->setValue(Settings::Manager::getFloat("scaling factor", "GUI"));
} }
// Bug fixes // Bug fixes
@ -214,10 +212,10 @@ bool Launcher::AdvancedPage::loadSettings()
{ {
// Saves // Saves
loadSettingBool(timePlayedCheckbox, "timeplayed", "Saves"); loadSettingBool(timePlayedCheckbox, "timeplayed", "Saves");
maximumQuicksavesComboBox->setValue(mEngineSettings.getInt("max quicksaves", "Saves")); maximumQuicksavesComboBox->setValue(Settings::Manager::getInt("max quicksaves", "Saves"));
// Other Settings // Other Settings
QString screenshotFormatString = QString::fromStdString(mEngineSettings.getString("screenshot format", "General")).toUpper(); QString screenshotFormatString = QString::fromStdString(Settings::Manager::getString("screenshot format", "General")).toUpper();
if (screenshotFormatComboBox->findText(screenshotFormatString) == -1) if (screenshotFormatComboBox->findText(screenshotFormatString) == -1)
screenshotFormatComboBox->addItem(screenshotFormatString); screenshotFormatComboBox->addItem(screenshotFormatString);
screenshotFormatComboBox->setCurrentIndex(screenshotFormatComboBox->findText(screenshotFormatString)); screenshotFormatComboBox->setCurrentIndex(screenshotFormatComboBox->findText(screenshotFormatString));
@ -258,13 +256,13 @@ void Launcher::AdvancedPage::saveSettings()
saveSettingBool(swimUpwardCorrectionCheckBox, "swim upward correction", "Game"); saveSettingBool(swimUpwardCorrectionCheckBox, "swim upward correction", "Game");
saveSettingBool(avoidCollisionsCheckBox, "NPCs avoid collisions", "Game"); saveSettingBool(avoidCollisionsCheckBox, "NPCs avoid collisions", "Game");
int unarmedFactorsStrengthIndex = unarmedFactorsStrengthComboBox->currentIndex(); int unarmedFactorsStrengthIndex = unarmedFactorsStrengthComboBox->currentIndex();
if (unarmedFactorsStrengthIndex != mEngineSettings.getInt("strength influences hand to hand", "Game")) if (unarmedFactorsStrengthIndex != Settings::Manager::getInt("strength influences hand to hand", "Game"))
mEngineSettings.setInt("strength influences hand to hand", "Game", unarmedFactorsStrengthIndex); Settings::Manager::setInt("strength influences hand to hand", "Game", unarmedFactorsStrengthIndex);
saveSettingBool(stealingFromKnockedOutCheckBox, "always allow stealing from knocked out actors", "Game"); saveSettingBool(stealingFromKnockedOutCheckBox, "always allow stealing from knocked out actors", "Game");
saveSettingBool(enableNavigatorCheckBox, "enable", "Navigator"); saveSettingBool(enableNavigatorCheckBox, "enable", "Navigator");
int numPhysicsThreads = physicsThreadsSpinBox->value(); int numPhysicsThreads = physicsThreadsSpinBox->value();
if (numPhysicsThreads != mEngineSettings.getInt("async num threads", "Physics")) if (numPhysicsThreads != Settings::Manager::getInt("async num threads", "Physics"))
mEngineSettings.setInt("async num threads", "Physics", numPhysicsThreads); Settings::Manager::setInt("async num threads", "Physics", numPhysicsThreads);
} }
// Visuals // Visuals
@ -282,23 +280,23 @@ void Launcher::AdvancedPage::saveSettings()
saveSettingBool(turnToMovementDirectionCheckBox, "turn to movement direction", "Game"); saveSettingBool(turnToMovementDirectionCheckBox, "turn to movement direction", "Game");
saveSettingBool(smoothMovementCheckBox, "smooth movement", "Game"); saveSettingBool(smoothMovementCheckBox, "smooth movement", "Game");
const bool distantTerrain = mEngineSettings.getBool("distant terrain", "Terrain"); const bool distantTerrain = Settings::Manager::getBool("distant terrain", "Terrain");
const bool objectPaging = mEngineSettings.getBool("object paging", "Terrain"); const bool objectPaging = Settings::Manager::getBool("object paging", "Terrain");
const bool wantDistantLand = distantLandCheckBox->checkState(); const bool wantDistantLand = distantLandCheckBox->checkState();
if (wantDistantLand != (distantTerrain && objectPaging)) { if (wantDistantLand != (distantTerrain && objectPaging)) {
mEngineSettings.setBool("distant terrain", "Terrain", wantDistantLand); Settings::Manager::setBool("distant terrain", "Terrain", wantDistantLand);
mEngineSettings.setBool("object paging", "Terrain", wantDistantLand); Settings::Manager::setBool("object paging", "Terrain", wantDistantLand);
} }
saveSettingBool(activeGridObjectPagingCheckBox, "object paging active grid", "Terrain"); saveSettingBool(activeGridObjectPagingCheckBox, "object paging active grid", "Terrain");
double viewingDistance = viewingDistanceComboBox->value(); double viewingDistance = viewingDistanceComboBox->value();
if (viewingDistance != convertToCells(mEngineSettings.getInt("viewing distance", "Camera"))) if (viewingDistance != convertToCells(Settings::Manager::getInt("viewing distance", "Camera")))
{ {
mEngineSettings.setInt("viewing distance", "Camera", convertToUnits(viewingDistance)); Settings::Manager::setInt("viewing distance", "Camera", convertToUnits(viewingDistance));
} }
static std::array<std::string, 3> lightingMethodMap = {"legacy", "shaders compatibility", "shaders"}; static std::array<std::string, 3> lightingMethodMap = {"legacy", "shaders compatibility", "shaders"};
mEngineSettings.setString("lighting method", "Shaders", lightingMethodMap[lightingMethodComboBox->currentIndex()]); Settings::Manager::setString("lighting method", "Shaders", lightingMethodMap[lightingMethodComboBox->currentIndex()]);
} }
// Audio // Audio
@ -306,25 +304,25 @@ void Launcher::AdvancedPage::saveSettings()
int audioDeviceIndex = audioDeviceSelectorComboBox->currentIndex(); int audioDeviceIndex = audioDeviceSelectorComboBox->currentIndex();
if (audioDeviceIndex != 0) if (audioDeviceIndex != 0)
{ {
mEngineSettings.setString("device", "Sound", audioDeviceSelectorComboBox->currentText().toUtf8().constData()); Settings::Manager::setString("device", "Sound", audioDeviceSelectorComboBox->currentText().toUtf8().constData());
} }
else else
{ {
mEngineSettings.setString("device", "Sound", ""); Settings::Manager::setString("device", "Sound", "");
} }
int hrtfEnabledIndex = enableHRTFComboBox->currentIndex() - 1; int hrtfEnabledIndex = enableHRTFComboBox->currentIndex() - 1;
if (hrtfEnabledIndex != mEngineSettings.getInt("hrtf enable", "Sound")) if (hrtfEnabledIndex != Settings::Manager::getInt("hrtf enable", "Sound"))
{ {
mEngineSettings.setInt("hrtf enable", "Sound", hrtfEnabledIndex); Settings::Manager::setInt("hrtf enable", "Sound", hrtfEnabledIndex);
} }
int selectedHRTFProfileIndex = hrtfProfileSelectorComboBox->currentIndex(); int selectedHRTFProfileIndex = hrtfProfileSelectorComboBox->currentIndex();
if (selectedHRTFProfileIndex != 0) if (selectedHRTFProfileIndex != 0)
{ {
mEngineSettings.setString("hrtf", "Sound", hrtfProfileSelectorComboBox->currentText().toUtf8().constData()); Settings::Manager::setString("hrtf", "Sound", hrtfProfileSelectorComboBox->currentText().toUtf8().constData());
} }
else else
{ {
mEngineSettings.setString("hrtf", "Sound", ""); Settings::Manager::setString("hrtf", "Sound", "");
} }
} }
@ -336,14 +334,14 @@ void Launcher::AdvancedPage::saveSettings()
saveSettingBool(deferredPreviewRotationCheckBox, "deferred preview rotation", "Camera"); saveSettingBool(deferredPreviewRotationCheckBox, "deferred preview rotation", "Camera");
saveSettingBool(headBobbingCheckBox, "head bobbing", "Camera"); saveSettingBool(headBobbingCheckBox, "head bobbing", "Camera");
osg::Vec2f shoulderOffset = mEngineSettings.getVector2("view over shoulder offset", "Camera"); osg::Vec2f shoulderOffset = Settings::Manager::getVector2("view over shoulder offset", "Camera");
if (defaultShoulderComboBox->currentIndex() != (shoulderOffset.x() >= 0 ? 0 : 1)) if (defaultShoulderComboBox->currentIndex() != (shoulderOffset.x() >= 0 ? 0 : 1))
{ {
if (defaultShoulderComboBox->currentIndex() == 0) if (defaultShoulderComboBox->currentIndex() == 0)
shoulderOffset.x() = std::abs(shoulderOffset.x()); shoulderOffset.x() = std::abs(shoulderOffset.x());
else else
shoulderOffset.x() = -std::abs(shoulderOffset.x()); shoulderOffset.x() = -std::abs(shoulderOffset.x());
mEngineSettings.setVector2("view over shoulder offset", "Camera", shoulderOffset); Settings::Manager::setVector2("view over shoulder offset", "Camera", shoulderOffset);
} }
} }
@ -355,13 +353,13 @@ void Launcher::AdvancedPage::saveSettings()
saveSettingBool(showProjectileDamageCheckBox, "show projectile damage", "Game"); saveSettingBool(showProjectileDamageCheckBox, "show projectile damage", "Game");
saveSettingBool(changeDialogTopicsCheckBox, "color topic enable", "GUI"); saveSettingBool(changeDialogTopicsCheckBox, "color topic enable", "GUI");
int showOwnedCurrentIndex = showOwnedComboBox->currentIndex(); int showOwnedCurrentIndex = showOwnedComboBox->currentIndex();
if (showOwnedCurrentIndex != mEngineSettings.getInt("show owned", "Game")) if (showOwnedCurrentIndex != Settings::Manager::getInt("show owned", "Game"))
mEngineSettings.setInt("show owned", "Game", showOwnedCurrentIndex); Settings::Manager::setInt("show owned", "Game", showOwnedCurrentIndex);
saveSettingBool(stretchBackgroundCheckBox, "stretch menu background", "GUI"); saveSettingBool(stretchBackgroundCheckBox, "stretch menu background", "GUI");
saveSettingBool(graphicHerbalismCheckBox, "graphic herbalism", "Game"); saveSettingBool(graphicHerbalismCheckBox, "graphic herbalism", "Game");
float uiScalingFactor = scalingSpinBox->value(); float uiScalingFactor = scalingSpinBox->value();
if (uiScalingFactor != mEngineSettings.getFloat("scaling factor", "GUI")) if (uiScalingFactor != Settings::Manager::getFloat("scaling factor", "GUI"))
mEngineSettings.setFloat("scaling factor", "GUI", uiScalingFactor); Settings::Manager::setFloat("scaling factor", "GUI", uiScalingFactor);
} }
// Bug fixes // Bug fixes
@ -375,15 +373,15 @@ void Launcher::AdvancedPage::saveSettings()
// Saves Settings // Saves Settings
saveSettingBool(timePlayedCheckbox, "timeplayed", "Saves"); saveSettingBool(timePlayedCheckbox, "timeplayed", "Saves");
int maximumQuicksaves = maximumQuicksavesComboBox->value(); int maximumQuicksaves = maximumQuicksavesComboBox->value();
if (maximumQuicksaves != mEngineSettings.getInt("max quicksaves", "Saves")) if (maximumQuicksaves != Settings::Manager::getInt("max quicksaves", "Saves"))
{ {
mEngineSettings.setInt("max quicksaves", "Saves", maximumQuicksaves); Settings::Manager::setInt("max quicksaves", "Saves", maximumQuicksaves);
} }
// Other Settings // Other Settings
std::string screenshotFormatString = screenshotFormatComboBox->currentText().toLower().toStdString(); std::string screenshotFormatString = screenshotFormatComboBox->currentText().toLower().toStdString();
if (screenshotFormatString != mEngineSettings.getString("screenshot format", "General")) if (screenshotFormatString != Settings::Manager::getString("screenshot format", "General"))
mEngineSettings.setString("screenshot format", "General", screenshotFormatString); Settings::Manager::setString("screenshot format", "General", screenshotFormatString);
} }
// Testing // Testing
@ -407,15 +405,15 @@ void Launcher::AdvancedPage::saveSettings()
void Launcher::AdvancedPage::loadSettingBool(QCheckBox *checkbox, const std::string &setting, const std::string &group) void Launcher::AdvancedPage::loadSettingBool(QCheckBox *checkbox, const std::string &setting, const std::string &group)
{ {
if (mEngineSettings.getBool(setting, group)) if (Settings::Manager::getBool(setting, group))
checkbox->setCheckState(Qt::Checked); checkbox->setCheckState(Qt::Checked);
} }
void Launcher::AdvancedPage::saveSettingBool(QCheckBox *checkbox, const std::string &setting, const std::string &group) void Launcher::AdvancedPage::saveSettingBool(QCheckBox *checkbox, const std::string &setting, const std::string &group)
{ {
bool cValue = checkbox->checkState(); bool cValue = checkbox->checkState();
if (cValue != mEngineSettings.getBool(setting, group)) if (cValue != Settings::Manager::getBool(setting, group))
mEngineSettings.setBool(setting, group, cValue); Settings::Manager::setBool(setting, group, cValue);
} }
void Launcher::AdvancedPage::slotLoadedCellsChanged(QStringList cellNames) void Launcher::AdvancedPage::slotLoadedCellsChanged(QStringList cellNames)

View file

@ -17,8 +17,7 @@ namespace Launcher
Q_OBJECT Q_OBJECT
public: public:
AdvancedPage(Config::GameSettings &gameSettings, explicit AdvancedPage(Config::GameSettings &gameSettings, QWidget *parent = nullptr);
Settings::Manager &engineSettings, QWidget *parent = nullptr);
bool loadSettings(); bool loadSettings();
void saveSettings(); void saveSettings();
@ -34,7 +33,6 @@ namespace Launcher
private: private:
Config::GameSettings &mGameSettings; Config::GameSettings &mGameSettings;
Settings::Manager &mEngineSettings;
QCompleter mCellNameCompleter; QCompleter mCellNameCompleter;
QStringListModel mCellNameCompleterModel; QStringListModel mCellNameCompleterModel;

View file

@ -32,9 +32,8 @@ QString getAspect(int x, int y)
return QString(QString::number(xaspect) + ":" + QString::number(yaspect)); return QString(QString::number(xaspect) + ":" + QString::number(yaspect));
} }
Launcher::GraphicsPage::GraphicsPage(Settings::Manager &engineSettings, QWidget *parent) Launcher::GraphicsPage::GraphicsPage(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, mEngineSettings(engineSettings)
{ {
setObjectName ("GraphicsPage"); setObjectName ("GraphicsPage");
setupUi(this); setupUi(this);
@ -93,26 +92,26 @@ bool Launcher::GraphicsPage::loadSettings()
if (!setupSDL()) if (!setupSDL())
return false; return false;
if (mEngineSettings.getBool("vsync", "Video")) if (Settings::Manager::getBool("vsync", "Video"))
vSyncCheckBox->setCheckState(Qt::Checked); vSyncCheckBox->setCheckState(Qt::Checked);
if (mEngineSettings.getBool("fullscreen", "Video")) if (Settings::Manager::getBool("fullscreen", "Video"))
fullScreenCheckBox->setCheckState(Qt::Checked); fullScreenCheckBox->setCheckState(Qt::Checked);
if (mEngineSettings.getBool("window border", "Video")) if (Settings::Manager::getBool("window border", "Video"))
windowBorderCheckBox->setCheckState(Qt::Checked); windowBorderCheckBox->setCheckState(Qt::Checked);
// aaValue is the actual value (0, 1, 2, 4, 8, 16) // aaValue is the actual value (0, 1, 2, 4, 8, 16)
int aaValue = mEngineSettings.getInt("antialiasing", "Video"); int aaValue = Settings::Manager::getInt("antialiasing", "Video");
// aaIndex is the index into the allowed values in the pull down. // aaIndex is the index into the allowed values in the pull down.
int aaIndex = antiAliasingComboBox->findText(QString::number(aaValue)); int aaIndex = antiAliasingComboBox->findText(QString::number(aaValue));
if (aaIndex != -1) if (aaIndex != -1)
antiAliasingComboBox->setCurrentIndex(aaIndex); antiAliasingComboBox->setCurrentIndex(aaIndex);
int width = mEngineSettings.getInt("resolution x", "Video"); int width = Settings::Manager::getInt("resolution x", "Video");
int height = mEngineSettings.getInt("resolution y", "Video"); int height = Settings::Manager::getInt("resolution y", "Video");
QString resolution = QString::number(width) + QString(" x ") + QString::number(height); QString resolution = QString::number(width) + QString(" x ") + QString::number(height);
screenComboBox->setCurrentIndex(mEngineSettings.getInt("screen", "Video")); screenComboBox->setCurrentIndex(Settings::Manager::getInt("screen", "Video"));
int resIndex = resolutionComboBox->findText(resolution, Qt::MatchStartsWith); int resIndex = resolutionComboBox->findText(resolution, Qt::MatchStartsWith);
@ -125,40 +124,40 @@ bool Launcher::GraphicsPage::loadSettings()
customHeightSpinBox->setValue(height); customHeightSpinBox->setValue(height);
} }
float fpsLimit = mEngineSettings.getFloat("framerate limit", "Video"); float fpsLimit = Settings::Manager::getFloat("framerate limit", "Video");
if (fpsLimit != 0) if (fpsLimit != 0)
{ {
framerateLimitCheckBox->setCheckState(Qt::Checked); framerateLimitCheckBox->setCheckState(Qt::Checked);
framerateLimitSpinBox->setValue(fpsLimit); framerateLimitSpinBox->setValue(fpsLimit);
} }
if (mEngineSettings.getBool("actor shadows", "Shadows")) if (Settings::Manager::getBool("actor shadows", "Shadows"))
actorShadowsCheckBox->setCheckState(Qt::Checked); actorShadowsCheckBox->setCheckState(Qt::Checked);
if (mEngineSettings.getBool("player shadows", "Shadows")) if (Settings::Manager::getBool("player shadows", "Shadows"))
playerShadowsCheckBox->setCheckState(Qt::Checked); playerShadowsCheckBox->setCheckState(Qt::Checked);
if (mEngineSettings.getBool("terrain shadows", "Shadows")) if (Settings::Manager::getBool("terrain shadows", "Shadows"))
terrainShadowsCheckBox->setCheckState(Qt::Checked); terrainShadowsCheckBox->setCheckState(Qt::Checked);
if (mEngineSettings.getBool("object shadows", "Shadows")) if (Settings::Manager::getBool("object shadows", "Shadows"))
objectShadowsCheckBox->setCheckState(Qt::Checked); objectShadowsCheckBox->setCheckState(Qt::Checked);
if (mEngineSettings.getBool("enable indoor shadows", "Shadows")) if (Settings::Manager::getBool("enable indoor shadows", "Shadows"))
indoorShadowsCheckBox->setCheckState(Qt::Checked); indoorShadowsCheckBox->setCheckState(Qt::Checked);
shadowComputeSceneBoundsComboBox->setCurrentIndex( shadowComputeSceneBoundsComboBox->setCurrentIndex(
shadowComputeSceneBoundsComboBox->findText( shadowComputeSceneBoundsComboBox->findText(
QString(tr(mEngineSettings.getString("compute scene bounds", "Shadows").c_str())))); QString(tr(Settings::Manager::getString("compute scene bounds", "Shadows").c_str()))));
int shadowDistLimit = mEngineSettings.getInt("maximum shadow map distance", "Shadows"); int shadowDistLimit = Settings::Manager::getInt("maximum shadow map distance", "Shadows");
if (shadowDistLimit > 0) if (shadowDistLimit > 0)
{ {
shadowDistanceCheckBox->setCheckState(Qt::Checked); shadowDistanceCheckBox->setCheckState(Qt::Checked);
shadowDistanceSpinBox->setValue(shadowDistLimit); shadowDistanceSpinBox->setValue(shadowDistLimit);
} }
float shadowFadeStart = mEngineSettings.getFloat("shadow fade start", "Shadows"); float shadowFadeStart = Settings::Manager::getFloat("shadow fade start", "Shadows");
if (shadowFadeStart != 0) if (shadowFadeStart != 0)
fadeStartSpinBox->setValue(shadowFadeStart); fadeStartSpinBox->setValue(shadowFadeStart);
int shadowRes = mEngineSettings.getInt("shadow map resolution", "Shadows"); int shadowRes = Settings::Manager::getInt("shadow map resolution", "Shadows");
int shadowResIndex = shadowResolutionComboBox->findText(QString::number(shadowRes)); int shadowResIndex = shadowResolutionComboBox->findText(QString::number(shadowRes));
if (shadowResIndex != -1) if (shadowResIndex != -1)
shadowResolutionComboBox->setCurrentIndex(shadowResIndex); shadowResolutionComboBox->setCurrentIndex(shadowResIndex);
@ -171,20 +170,20 @@ void Launcher::GraphicsPage::saveSettings()
// Ensure we only set the new settings if they changed. This is to avoid cluttering the // Ensure we only set the new settings if they changed. This is to avoid cluttering the
// user settings file (which by definition should only contain settings the user has touched) // user settings file (which by definition should only contain settings the user has touched)
bool cVSync = vSyncCheckBox->checkState(); bool cVSync = vSyncCheckBox->checkState();
if (cVSync != mEngineSettings.getBool("vsync", "Video")) if (cVSync != Settings::Manager::getBool("vsync", "Video"))
mEngineSettings.setBool("vsync", "Video", cVSync); Settings::Manager::setBool("vsync", "Video", cVSync);
bool cFullScreen = fullScreenCheckBox->checkState(); bool cFullScreen = fullScreenCheckBox->checkState();
if (cFullScreen != mEngineSettings.getBool("fullscreen", "Video")) if (cFullScreen != Settings::Manager::getBool("fullscreen", "Video"))
mEngineSettings.setBool("fullscreen", "Video", cFullScreen); Settings::Manager::setBool("fullscreen", "Video", cFullScreen);
bool cWindowBorder = windowBorderCheckBox->checkState(); bool cWindowBorder = windowBorderCheckBox->checkState();
if (cWindowBorder != mEngineSettings.getBool("window border", "Video")) if (cWindowBorder != Settings::Manager::getBool("window border", "Video"))
mEngineSettings.setBool("window border", "Video", cWindowBorder); Settings::Manager::setBool("window border", "Video", cWindowBorder);
int cAAValue = antiAliasingComboBox->currentText().toInt(); int cAAValue = antiAliasingComboBox->currentText().toInt();
if (cAAValue != mEngineSettings.getInt("antialiasing", "Video")) if (cAAValue != Settings::Manager::getInt("antialiasing", "Video"))
mEngineSettings.setInt("antialiasing", "Video", cAAValue); Settings::Manager::setInt("antialiasing", "Video", cAAValue);
int cWidth = 0; int cWidth = 0;
int cHeight = 0; int cHeight = 0;
@ -199,33 +198,33 @@ void Launcher::GraphicsPage::saveSettings()
cHeight = customHeightSpinBox->value(); cHeight = customHeightSpinBox->value();
} }
if (cWidth != mEngineSettings.getInt("resolution x", "Video")) if (cWidth != Settings::Manager::getInt("resolution x", "Video"))
mEngineSettings.setInt("resolution x", "Video", cWidth); Settings::Manager::setInt("resolution x", "Video", cWidth);
if (cHeight != mEngineSettings.getInt("resolution y", "Video")) if (cHeight != Settings::Manager::getInt("resolution y", "Video"))
mEngineSettings.setInt("resolution y", "Video", cHeight); Settings::Manager::setInt("resolution y", "Video", cHeight);
int cScreen = screenComboBox->currentIndex(); int cScreen = screenComboBox->currentIndex();
if (cScreen != mEngineSettings.getInt("screen", "Video")) if (cScreen != Settings::Manager::getInt("screen", "Video"))
mEngineSettings.setInt("screen", "Video", cScreen); Settings::Manager::setInt("screen", "Video", cScreen);
if (framerateLimitCheckBox->checkState() != Qt::Unchecked) if (framerateLimitCheckBox->checkState() != Qt::Unchecked)
{ {
float cFpsLimit = framerateLimitSpinBox->value(); float cFpsLimit = framerateLimitSpinBox->value();
if (cFpsLimit != mEngineSettings.getFloat("framerate limit", "Video")) if (cFpsLimit != Settings::Manager::getFloat("framerate limit", "Video"))
mEngineSettings.setFloat("framerate limit", "Video", cFpsLimit); Settings::Manager::setFloat("framerate limit", "Video", cFpsLimit);
} }
else if (mEngineSettings.getFloat("framerate limit", "Video") != 0) else if (Settings::Manager::getFloat("framerate limit", "Video") != 0)
{ {
mEngineSettings.setFloat("framerate limit", "Video", 0); Settings::Manager::setFloat("framerate limit", "Video", 0);
} }
int cShadowDist = shadowDistanceCheckBox->checkState() != Qt::Unchecked ? shadowDistanceSpinBox->value() : 0; int cShadowDist = shadowDistanceCheckBox->checkState() != Qt::Unchecked ? shadowDistanceSpinBox->value() : 0;
if (mEngineSettings.getInt("maximum shadow map distance", "Shadows") != cShadowDist) if (Settings::Manager::getInt("maximum shadow map distance", "Shadows") != cShadowDist)
mEngineSettings.setInt("maximum shadow map distance", "Shadows", cShadowDist); Settings::Manager::setInt("maximum shadow map distance", "Shadows", cShadowDist);
float cFadeStart = fadeStartSpinBox->value(); float cFadeStart = fadeStartSpinBox->value();
if (cShadowDist > 0 && mEngineSettings.getFloat("shadow fade start", "Shadows") != cFadeStart) if (cShadowDist > 0 && Settings::Manager::getFloat("shadow fade start", "Shadows") != cFadeStart)
mEngineSettings.setFloat("shadow fade start", "Shadows", cFadeStart); Settings::Manager::setFloat("shadow fade start", "Shadows", cFadeStart);
bool cActorShadows = actorShadowsCheckBox->checkState(); bool cActorShadows = actorShadowsCheckBox->checkState();
bool cObjectShadows = objectShadowsCheckBox->checkState(); bool cObjectShadows = objectShadowsCheckBox->checkState();
@ -233,42 +232,42 @@ void Launcher::GraphicsPage::saveSettings()
bool cPlayerShadows = playerShadowsCheckBox->checkState(); bool cPlayerShadows = playerShadowsCheckBox->checkState();
if (cActorShadows || cObjectShadows || cTerrainShadows || cPlayerShadows) if (cActorShadows || cObjectShadows || cTerrainShadows || cPlayerShadows)
{ {
if (!mEngineSettings.getBool("enable shadows", "Shadows")) if (!Settings::Manager::getBool("enable shadows", "Shadows"))
mEngineSettings.setBool("enable shadows", "Shadows", true); Settings::Manager::setBool("enable shadows", "Shadows", true);
if (mEngineSettings.getBool("actor shadows", "Shadows") != cActorShadows) if (Settings::Manager::getBool("actor shadows", "Shadows") != cActorShadows)
mEngineSettings.setBool("actor shadows", "Shadows", cActorShadows); Settings::Manager::setBool("actor shadows", "Shadows", cActorShadows);
if (mEngineSettings.getBool("player shadows", "Shadows") != cPlayerShadows) if (Settings::Manager::getBool("player shadows", "Shadows") != cPlayerShadows)
mEngineSettings.setBool("player shadows", "Shadows", cPlayerShadows); Settings::Manager::setBool("player shadows", "Shadows", cPlayerShadows);
if (mEngineSettings.getBool("object shadows", "Shadows") != cObjectShadows) if (Settings::Manager::getBool("object shadows", "Shadows") != cObjectShadows)
mEngineSettings.setBool("object shadows", "Shadows", cObjectShadows); Settings::Manager::setBool("object shadows", "Shadows", cObjectShadows);
if (mEngineSettings.getBool("terrain shadows", "Shadows") != cTerrainShadows) if (Settings::Manager::getBool("terrain shadows", "Shadows") != cTerrainShadows)
mEngineSettings.setBool("terrain shadows", "Shadows", cTerrainShadows); Settings::Manager::setBool("terrain shadows", "Shadows", cTerrainShadows);
} }
else else
{ {
if (mEngineSettings.getBool("enable shadows", "Shadows")) if (Settings::Manager::getBool("enable shadows", "Shadows"))
mEngineSettings.setBool("enable shadows", "Shadows", false); Settings::Manager::setBool("enable shadows", "Shadows", false);
if (mEngineSettings.getBool("actor shadows", "Shadows")) if (Settings::Manager::getBool("actor shadows", "Shadows"))
mEngineSettings.setBool("actor shadows", "Shadows", false); Settings::Manager::setBool("actor shadows", "Shadows", false);
if (mEngineSettings.getBool("player shadows", "Shadows")) if (Settings::Manager::getBool("player shadows", "Shadows"))
mEngineSettings.setBool("player shadows", "Shadows", false); Settings::Manager::setBool("player shadows", "Shadows", false);
if (mEngineSettings.getBool("object shadows", "Shadows")) if (Settings::Manager::getBool("object shadows", "Shadows"))
mEngineSettings.setBool("object shadows", "Shadows", false); Settings::Manager::setBool("object shadows", "Shadows", false);
if (mEngineSettings.getBool("terrain shadows", "Shadows")) if (Settings::Manager::getBool("terrain shadows", "Shadows"))
mEngineSettings.setBool("terrain shadows", "Shadows", false); Settings::Manager::setBool("terrain shadows", "Shadows", false);
} }
bool cIndoorShadows = indoorShadowsCheckBox->checkState(); bool cIndoorShadows = indoorShadowsCheckBox->checkState();
if (mEngineSettings.getBool("enable indoor shadows", "Shadows") != cIndoorShadows) if (Settings::Manager::getBool("enable indoor shadows", "Shadows") != cIndoorShadows)
mEngineSettings.setBool("enable indoor shadows", "Shadows", cIndoorShadows); Settings::Manager::setBool("enable indoor shadows", "Shadows", cIndoorShadows);
int cShadowRes = shadowResolutionComboBox->currentText().toInt(); int cShadowRes = shadowResolutionComboBox->currentText().toInt();
if (cShadowRes != mEngineSettings.getInt("shadow map resolution", "Shadows")) if (cShadowRes != Settings::Manager::getInt("shadow map resolution", "Shadows"))
mEngineSettings.setInt("shadow map resolution", "Shadows", cShadowRes); Settings::Manager::setInt("shadow map resolution", "Shadows", cShadowRes);
auto cComputeSceneBounds = shadowComputeSceneBoundsComboBox->currentText().toStdString(); auto cComputeSceneBounds = shadowComputeSceneBoundsComboBox->currentText().toStdString();
if (cComputeSceneBounds != mEngineSettings.getString("compute scene bounds", "Shadows")) if (cComputeSceneBounds != Settings::Manager::getString("compute scene bounds", "Shadows"))
mEngineSettings.setString("compute scene bounds", "Shadows", cComputeSceneBounds); Settings::Manager::setString("compute scene bounds", "Shadows", cComputeSceneBounds);
} }
QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen) QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen)

View file

@ -18,7 +18,7 @@ namespace Launcher
Q_OBJECT Q_OBJECT
public: public:
GraphicsPage(Settings::Manager &engineSettings, QWidget *parent = nullptr); explicit GraphicsPage(QWidget *parent = nullptr);
void saveSettings(); void saveSettings();
bool loadSettings(); bool loadSettings();
@ -33,8 +33,6 @@ namespace Launcher
void slotShadowDistLimitToggled(bool checked); void slotShadowDistLimitToggled(bool checked);
private: private:
Settings::Manager &mEngineSettings;
QVector<QStringList> mResolutionsPerScreen; QVector<QStringList> mResolutionsPerScreen;
static QStringList getAvailableResolutions(int screen); static QStringList getAvailableResolutions(int screen);

View file

@ -123,9 +123,9 @@ void Launcher::MainDialog::createPages()
mPlayPage = new PlayPage(this); mPlayPage = new PlayPage(this);
mDataFilesPage = new DataFilesPage(mCfgMgr, mGameSettings, mLauncherSettings, this); mDataFilesPage = new DataFilesPage(mCfgMgr, mGameSettings, mLauncherSettings, this);
mGraphicsPage = new GraphicsPage(mEngineSettings, this); mGraphicsPage = new GraphicsPage(this);
mSettingsPage = new SettingsPage(mCfgMgr, mGameSettings, mLauncherSettings, this); mSettingsPage = new SettingsPage(mCfgMgr, mGameSettings, mLauncherSettings, this);
mAdvancedPage = new AdvancedPage(mGameSettings, mEngineSettings, this); mAdvancedPage = new AdvancedPage(mGameSettings, this);
// Set the combobox of the play page to imitate the combobox on the datafilespage // Set the combobox of the play page to imitate the combobox on the datafilespage
mPlayPage->setProfilesModel(mDataFilesPage->profilesModel()); mPlayPage->setProfilesModel(mDataFilesPage->profilesModel());