From 0e2380d471b3aa74e3c4b5d321e5729460167246 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Thu, 31 Oct 2019 15:31:54 +0300 Subject: [PATCH] Add the most basic shadow settings into the launcher --- apps/launcher/graphicspage.cpp | 81 ++++++++++++++++++ apps/launcher/graphicspage.hpp | 1 + files/ui/graphicspage.ui | 147 +++++++++++++++++++++++++++++++-- 3 files changed, 221 insertions(+), 8 deletions(-) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index c991e79f4d..4e54cbe1d6 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -45,6 +45,7 @@ Launcher::GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, Settings: 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))); + connect(shadowDistanceCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotShadowDistLimitToggled(bool))); } @@ -129,6 +130,33 @@ bool Launcher::GraphicsPage::loadSettings() framerateLimitSpinBox->setValue(fpsLimit); } + if (mEngineSettings.getBool("actor shadows", "Shadows")) + actorShadowsCheckBox->setCheckState(Qt::Checked); + if (mEngineSettings.getBool("player shadows", "Shadows")) + playerShadowsCheckBox->setCheckState(Qt::Checked); + if (mEngineSettings.getBool("terrain shadows", "Shadows")) + objectShadowsCheckBox->setCheckState(Qt::Checked); + if (mEngineSettings.getBool("object shadows", "Shadows")) + objectShadowsCheckBox->setCheckState(Qt::Checked); + if (mEngineSettings.getBool("enable indoor shadows", "Shadows")) + indoorShadowsCheckBox->setCheckState(Qt::Checked); + + int shadowDistLimit = mEngineSettings.getInt("maximum shadow map distance", "Shadows"); + if (shadowDistLimit > 0) + { + shadowDistanceCheckBox->setCheckState(Qt::Checked); + shadowDistanceSpinBox->setValue(shadowDistLimit); + } + + float shadowFadeStart = mEngineSettings.getFloat("shadow fade start", "Shadows"); + if (shadowFadeStart != 0) + fadeStartSpinBox->setValue(shadowFadeStart); + + int shadowRes = mEngineSettings.getInt("shadow map resolution", "Shadows"); + int shadowResIndex = shadowResolutionComboBox->findText(QString::number(shadowRes)); + if (shadowResIndex != -1) + shadowResolutionComboBox->setCurrentIndex(shadowResIndex); + return true; } @@ -185,6 +213,52 @@ void Launcher::GraphicsPage::saveSettings() { mEngineSettings.setFloat("framerate limit", "Video", 0); } + + int cShadowDist = shadowDistanceCheckBox->checkState() ? shadowDistanceSpinBox->value() : 0; + if (mEngineSettings.getInt("maximum shadow map distance", "Shadows") != cShadowDist) + mEngineSettings.setInt("maximum shadow map distance", "Shadows", cShadowDist); + float cFadeStart = fadeStartSpinBox->value(); + if (cShadowDist > 0 && mEngineSettings.getFloat("shadow fade start", "Shadows") != cFadeStart) + mEngineSettings.setFloat("shadow fade start", "Shadows", cFadeStart); + + bool cActorShadows = actorShadowsCheckBox->checkState(); + bool cObjectShadows = objectShadowsCheckBox->checkState(); + bool cTerrainShadows = terrainShadowsCheckBox->checkState(); + bool cPlayerShadows = playerShadowsCheckBox->checkState(); + if (cActorShadows || cObjectShadows || cTerrainShadows || cPlayerShadows) + { + if (mEngineSettings.getBool("enable shadows", "Shadows") != true) + mEngineSettings.setBool("enable shadows", "Shadows", true); + if (mEngineSettings.getBool("actor shadows", "Shadows") != cActorShadows) + mEngineSettings.setBool("actor shadows", "Shadows", cActorShadows); + if (mEngineSettings.getBool("player shadows", "Shadows") != cPlayerShadows) + mEngineSettings.setBool("player shadows", "Shadows", cPlayerShadows); + if (mEngineSettings.getBool("object shadows", "Shadows") != cObjectShadows) + mEngineSettings.setBool("object shadows", "Shadows", cObjectShadows); + if (mEngineSettings.getBool("terrain shadows", "Shadows") != cTerrainShadows) + mEngineSettings.setBool("terrain shadows", "Shadows", cTerrainShadows); + } + else + { + if (mEngineSettings.getBool("enable shadows", "Shadows")) + mEngineSettings.setBool("enable shadows", "Shadows", false); + if (mEngineSettings.getBool("actor shadows", "Shadows")) + mEngineSettings.setBool("actor shadows", "Shadows", false); + if (mEngineSettings.getBool("player shadows", "Shadows")) + mEngineSettings.setBool("player shadows", "Shadows", false); + if (mEngineSettings.getBool("object shadows", "Shadows")) + mEngineSettings.setBool("object shadows", "Shadows", false); + if (mEngineSettings.getBool("terrain shadows", "Shadows")) + mEngineSettings.setBool("terrain shadows", "Shadows", false); + } + + bool cIndoorShadows = indoorShadowsCheckBox->checkState(); + if (mEngineSettings.getBool("enable indoor shadows", "Shadows") != cIndoorShadows) + mEngineSettings.setBool("enable indoor shadows", "Shadows", cIndoorShadows); + + int cShadowRes = shadowResolutionComboBox->currentText().toInt(); + if (cShadowRes != mEngineSettings.getInt("shadow map resolution", "Shadows")) + mEngineSettings.setInt("shadow map resolution", "Shadows", cShadowRes); } QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen) @@ -290,3 +364,10 @@ void Launcher::GraphicsPage::slotFramerateLimitToggled(bool checked) { framerateLimitSpinBox->setEnabled(checked); } + + +void Launcher::GraphicsPage::slotShadowDistLimitToggled(bool checked) +{ + shadowDistanceSpinBox->setEnabled(checked); + fadeStartSpinBox->setEnabled(checked); +} diff --git a/apps/launcher/graphicspage.hpp b/apps/launcher/graphicspage.hpp index 05915e6805..b230625fc6 100644 --- a/apps/launcher/graphicspage.hpp +++ b/apps/launcher/graphicspage.hpp @@ -32,6 +32,7 @@ namespace Launcher void slotFullScreenChanged(int state); void slotStandardToggled(bool checked); void slotFramerateLimitToggled(bool checked); + void slotShadowDistLimitToggled(bool checked); private: Files::ConfigurationManager &mCfgMgr; diff --git a/files/ui/graphicspage.ui b/files/ui/graphicspage.ui index eba913b919..db52be84fb 100644 --- a/files/ui/graphicspage.ui +++ b/files/ui/graphicspage.ui @@ -2,14 +2,6 @@ GraphicsPage - - - 0 - 0 - 437 - 343 - - @@ -178,6 +170,145 @@ + + + + Shadows + + + + + + Enable Actor Shadows + + + + + + + Enable Terrain Shadows + + + + + + + Enable Object Shadows + + + + + + + <html><head/><body><p>The distance from the camera at which shadows completely disappear</p></body></html> + + + Shadow Distance Limit: + + + + + + + Shadow Map Resolution: + + + + + + + + 512 + + + + + 1024 + + + + + 2048 + + + + + 4096 + + + + + + + + Enable Player Shadows + + + + + + + false + + + <html><head/><body><p>64 game units is 1 real life yard or about 0.9 m</p></body></html> + + + unit(s) + + + 512 + + + 81920 + + + 8192 + + + + + + + <html><head/><body><p>The fraction of the limit above at which shadows begin to gradually fade away</p></body></html> + + + Fade Start Multiplier: + + + + + + + false + + + 2 + + + 0.05 + + + 1 + + + 0.90 + + + + + + + <html><head/><body><p>Due to limitations with Morrowind's data, only actors can cast shadows indoors, which some might feel is distracting.</p><p>Has no effect if at least one of the options above is not enabled.</p></body></html> + + + Enable Indoor Shadows + + + + + +