diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 463562a38a..3412e7e701 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -225,12 +225,10 @@ namespace MWBase virtual const MWWorld::Ptr& getSelectedEnchantItem() const = 0; virtual void setSelectedWeapon(const MWWorld::Ptr& item) = 0; virtual const MWWorld::Ptr& getSelectedWeapon() const = 0; - virtual int getFontHeight() const = 0; virtual void unsetSelectedSpell() = 0; virtual void unsetSelectedWeapon() = 0; virtual void showCrosshair(bool show) = 0; - virtual bool getSubtitlesEnabled() = 0; virtual bool toggleHud() = 0; virtual void disallowMouse() = 0; diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 04d84d12c0..28611da4be 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -647,7 +647,7 @@ namespace MWDialogue if (info != nullptr) { MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager(); - if (winMgr->getSubtitlesEnabled()) + if (Settings::gui().mSubtitles) winMgr->messageBox(info->mResponse); if (!info->mSound.empty()) sndMgr->say(actor, info->mSound); diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index d9f78366ab..617c373b0b 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" @@ -188,7 +189,7 @@ namespace MWGui return; Widgets::MWSpellPtr spellWidget; - const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int lineHeight = Settings::gui().mFontSize + 2; MyGUI::IntCoord coord(0, 0, mSpellArea->getWidth(), lineHeight); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); diff --git a/apps/openmw/mwgui/bookpage.cpp b/apps/openmw/mwgui/bookpage.cpp index 11be4b0740..63b6573985 100644 --- a/apps/openmw/mwgui/bookpage.cpp +++ b/apps/openmw/mwgui/bookpage.cpp @@ -10,6 +10,7 @@ #include #include +#include namespace MWGui { @@ -551,7 +552,7 @@ namespace MWGui if (mPartialWhitespace.empty() && mPartialWord.empty()) return; - int fontHeight = MWBase::Environment::get().getWindowManager()->getFontHeight(); + const int fontHeight = Settings::gui().mFontSize; int space_width = 0; int word_width = 0; diff --git a/apps/openmw/mwgui/bookpage.hpp b/apps/openmw/mwgui/bookpage.hpp index af6d33ff2b..d42fb4783f 100644 --- a/apps/openmw/mwgui/bookpage.hpp +++ b/apps/openmw/mwgui/bookpage.hpp @@ -9,10 +9,7 @@ #include #include -#include - -#include "../mwbase/environment.hpp" -#include "../mwbase/windowmanager.hpp" +#include namespace MWGui { @@ -50,12 +47,10 @@ namespace MWGui GlyphInfo(MyGUI::IFont* font, MyGUI::Char ch) { - static const int fontHeight = MWBase::Environment::get().getWindowManager()->getFontHeight(); - const MyGUI::GlyphInfo* gi = font->getGlyphInfo(ch); if (gi) { - const float scale = font->getDefaultHeight() / (float)fontHeight; + const float scale = font->getDefaultHeight() / static_cast(Settings::gui().mFontSize); codePoint = gi->codePoint; bearingX = (int)gi->bearingX / scale; diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 6b69404d29..237985b204 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -88,7 +89,7 @@ namespace MWGui void PersuasionDialog::adjustAction(MyGUI::Widget* action, int& totalHeight) { - const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int lineHeight = Settings::gui().mFontSize + 2; auto currentCoords = action->getCoord(); action->setCoord(currentCoords.left, totalHeight, currentCoords.width, lineHeight); totalHeight += lineHeight; @@ -782,21 +783,21 @@ namespace MWGui void DialogueWindow::updateTopicFormat() { - if (!Settings::Manager::getBool("color topic enable", "GUI")) + if (!Settings::gui().mColorTopicEnable) return; - const std::string& specialColour = Settings::Manager::getString("color topic specific", "GUI"); - const std::string& oldColour = Settings::Manager::getString("color topic exhausted", "GUI"); + const MyGUI::Colour& specialColour = Settings::gui().mColorTopicSpecific; + const MyGUI::Colour& oldColour = Settings::gui().mColorTopicExhausted; for (const std::string& keyword : mKeywords) { int flag = MWBase::Environment::get().getDialogueManager()->getTopicFlag(ESM::RefId::stringRefId(keyword)); MyGUI::Button* button = mTopicsList->getItemWidget(keyword); - if (!specialColour.empty() && flag & MWBase::DialogueManager::TopicType::Specific) - button->getSubWidgetText()->setTextColour(MyGUI::Colour::parse(specialColour)); - else if (!oldColour.empty() && flag & MWBase::DialogueManager::TopicType::Exhausted) - button->getSubWidgetText()->setTextColour(MyGUI::Colour::parse(oldColour)); + if (flag & MWBase::DialogueManager::TopicType::Specific) + button->getSubWidgetText()->setTextColour(specialColour); + else if (flag & MWBase::DialogueManager::TopicType::Exhausted) + button->getSubWidgetText()->setTextColour(oldColour); } } diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index 0c193b4987..8479379976 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -14,10 +14,10 @@ #include #include #include +#include #include #include "../mwbase/environment.hpp" -#include "../mwbase/windowmanager.hpp" #include "../mwscript/interpretercontext.hpp" namespace MWGui::Formatting @@ -452,7 +452,7 @@ namespace MWGui::Formatting int TextElement::pageSplit() { // split lines - const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight(); + const int lineHeight = Settings::gui().mFontSize; unsigned int lastLine = (mPaginator.getStartTop() + mPaginator.getPageHeight() - mPaginator.getCurrentTop()); if (lineHeight > 0) lastLine /= lineHeight; diff --git a/apps/openmw/mwgui/itemwidget.cpp b/apps/openmw/mwgui/itemwidget.cpp index 49d47a8d54..5ee74c6e87 100644 --- a/apps/openmw/mwgui/itemwidget.cpp +++ b/apps/openmw/mwgui/itemwidget.cpp @@ -6,13 +6,12 @@ #include #include -// correctIconPath #include #include +#include #include #include "../mwbase/environment.hpp" -#include "../mwbase/windowmanager.hpp" #include "../mwworld/class.hpp" @@ -20,13 +19,11 @@ namespace { std::string getCountString(int count) { - static const int fontHeight = MWBase::Environment::get().getWindowManager()->getFontHeight(); - if (count == 1) return {}; // With small text size we can use up to 4 characters, while with large ones - only up to 3. - if (fontHeight > 16) + if (Settings::gui().mFontSize > 16) { if (count > 999999999) return MyGUI::utility::toString(count / 1000000000) + "b"; diff --git a/apps/openmw/mwgui/journalbooks.cpp b/apps/openmw/mwgui/journalbooks.cpp index 5163135cf9..f64a2ec1f0 100644 --- a/apps/openmw/mwgui/journalbooks.cpp +++ b/apps/openmw/mwgui/journalbooks.cpp @@ -4,6 +4,7 @@ #include "../mwbase/windowmanager.hpp" #include +#include #include "textcolours.hpp" @@ -274,13 +275,11 @@ namespace MWGui BookTypesetter::Style* body = typesetter->createStyle({}, MyGUI::Colour::Black); - int fontHeight = MWBase::Environment::get().getWindowManager()->getFontHeight(); - // for small font size split alphabet to two columns (2x15 characers), for big font size split it to three // colums (3x10 characters). int sectionBreak = 10; mIndexPagesCount = 3; - if (fontHeight < 18) + if (Settings::gui().mFontSize < 18) { sectionBreak = 15; mIndexPagesCount = 2; diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 3574333fda..fd7afa2d8a 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include "../mwbase/environment.hpp" @@ -222,9 +222,8 @@ namespace MWGui // TODO: add option (filename pattern?) to use image aspect ratio instead of 4:3 // we can't do this by default, because the Morrowind splash screens are 1024x1024, but should be displayed // as 4:3 - bool stretch = Settings::Manager::getBool("stretch menu background", "GUI"); mSplashImage->setVisible(true); - mSplashImage->setBackgroundImage(randomSplash, true, stretch); + mSplashImage->setBackgroundImage(randomSplash, true, Settings::gui().mStretchMenuBackground); } mSceneImage->setBackgroundImage({}); mSceneImage->setVisible(false); diff --git a/apps/openmw/mwgui/mainmenu.cpp b/apps/openmw/mwgui/mainmenu.cpp index 2ca4530b97..37e835f1a4 100644 --- a/apps/openmw/mwgui/mainmenu.cpp +++ b/apps/openmw/mwgui/mainmenu.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include @@ -156,7 +156,7 @@ namespace MWGui if (!show) return; - bool stretch = Settings::Manager::getBool("stretch menu background", "GUI"); + const bool stretch = Settings::gui().mStretchMenuBackground; if (mHasAnimatedMenu) { diff --git a/apps/openmw/mwgui/merchantrepair.cpp b/apps/openmw/mwgui/merchantrepair.cpp index 00d7b7f638..239a5461dd 100644 --- a/apps/openmw/mwgui/merchantrepair.cpp +++ b/apps/openmw/mwgui/merchantrepair.cpp @@ -1,6 +1,7 @@ #include "merchantrepair.hpp" #include +#include #include #include @@ -36,7 +37,7 @@ namespace MWGui while (mList->getChildCount()) MyGUI::Gui::getInstance().destroyWidget(mList->getChildAt(0)); - int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int lineHeight = Settings::gui().mFontSize + 2; int currentY = 0; MWWorld::Ptr player = MWMechanics::getPlayer(); diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index afccae471f..da5c0c9ca8 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -8,10 +8,10 @@ #include #include -#include - #include #include +#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" @@ -406,7 +406,7 @@ namespace MWGui return; Widgets::MWSkillPtr skillWidget; - const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int lineHeight = Settings::gui().mFontSize + 2; MyGUI::IntCoord coord1(0, 0, mSkillList->getWidth(), 18); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); @@ -439,7 +439,7 @@ namespace MWGui if (mCurrentRaceId.empty()) return; - const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int lineHeight = Settings::gui().mFontSize + 2; MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), lineHeight); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index 39ab84246d..f0fa93b993 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" @@ -274,7 +275,7 @@ namespace MWGui groupWidget->setCaption(toUString(label)); mSkillWidgets.push_back(groupWidget); - int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int lineHeight = Settings::gui().mFontSize + 2; coord1.top += lineHeight; coord2.top += lineHeight; } @@ -297,7 +298,7 @@ namespace MWGui mSkillWidgets.push_back(skillNameWidget); mSkillWidgets.push_back(skillValueWidget); - int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int lineHeight = Settings::gui().mFontSize + 2; coord1.top += lineHeight; coord2.top += lineHeight; @@ -315,7 +316,7 @@ namespace MWGui mSkillWidgets.push_back(skillNameWidget); - int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int lineHeight = Settings::gui().mFontSize + 2; coord1.top += lineHeight; coord2.top += lineHeight; } @@ -331,7 +332,7 @@ namespace MWGui mSkillWidgets.push_back(widget); - int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int lineHeight = Settings::gui().mFontSize + 2; coord1.top += lineHeight; coord2.top += lineHeight; } diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index e624f8e692..b077d9f640 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -909,7 +909,7 @@ namespace MWGui void SettingsWindow::layoutControlsBox() { - const int h = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int h = Settings::gui().mFontSize + 2; const int w = mControlsBox->getWidth() - 28; const int noWidgetsInRow = 2; const int totalH = mControlsBox->getChildCount() / noWidgetsInRow * h; diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index 79a0f517da..0e67cfe836 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -6,6 +6,7 @@ #include #include +#include #include "../mwbase/environment.hpp" #include "../mwbase/mechanicsmanager.hpp" @@ -51,7 +52,7 @@ namespace MWGui // TODO: refactor to use MyGUI::ListBox - int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int lineHeight = Settings::gui().mFontSize + 2; MyGUI::Button* toAdd = mSpellsView->createWidget(price <= playerGold ? "SandTextButton" diff --git a/apps/openmw/mwgui/spellview.cpp b/apps/openmw/mwgui/spellview.cpp index b60ec24440..678f6ffe1f 100644 --- a/apps/openmw/mwgui/spellview.cpp +++ b/apps/openmw/mwgui/spellview.cpp @@ -5,9 +5,7 @@ #include #include -#include "../mwbase/environment.hpp" -#include "../mwbase/windowmanager.hpp" - +#include #include #include @@ -87,7 +85,7 @@ namespace MWGui int curType = -1; - const int spellHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int spellHeight = Settings::gui().mFontSize + 2; mLines.clear(); diff --git a/apps/openmw/mwgui/statswindow.cpp b/apps/openmw/mwgui/statswindow.cpp index 76c1b065dd..fbd72227e6 100644 --- a/apps/openmw/mwgui/statswindow.cpp +++ b/apps/openmw/mwgui/statswindow.cpp @@ -419,7 +419,7 @@ namespace MWGui groupWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); mSkillWidgets.push_back(groupWidget); - int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int lineHeight = Settings::gui().mFontSize + 2; coord1.top += lineHeight; coord2.top += lineHeight; } @@ -449,7 +449,7 @@ namespace MWGui mSkillWidgets.push_back(skillNameWidget); mSkillWidgets.push_back(skillValueWidget); - int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int lineHeight = Settings::gui().mFontSize + 2; coord1.top += lineHeight; coord2.top += lineHeight; @@ -470,7 +470,7 @@ namespace MWGui mSkillWidgets.push_back(skillNameWidget); - int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int lineHeight = Settings::gui().mFontSize + 2; coord1.top += lineHeight; coord2.top += lineHeight; diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 17018db6df..e46aa2fc0f 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -35,8 +35,7 @@ namespace MWGui , mFocusToolTipX(0.0) , mFocusToolTipY(0.0) , mHorizontalScrollIndex(0) - , mDelay(0.0) - , mRemainingDelay(0.0) + , mRemainingDelay(Settings::gui().mTooltipDelay) , mLastMouseX(0) , mLastMouseY(0) , mEnabled(true) @@ -52,9 +51,6 @@ namespace MWGui mDynamicToolTipBox->setNeedMouseFocus(false); mMainWidget->setNeedMouseFocus(false); - mDelay = Settings::Manager::getFloat("tooltip delay", "GUI"); - mRemainingDelay = mDelay; - for (unsigned int i = 0; i < mMainWidget->getChildCount(); ++i) { mMainWidget->getChildAt(i)->setVisible(false); @@ -140,7 +136,7 @@ namespace MWGui else { mHorizontalScrollIndex = 0; - mRemainingDelay = mDelay; + mRemainingDelay = Settings::gui().mTooltipDelay; } mLastMouseX = mousePos.left; mLastMouseY = mousePos.top; @@ -960,11 +956,4 @@ namespace MWGui .asUTF8()); widget->setUserString("ImageTexture_MagicEffectImage", icon); } - - void ToolTips::setDelay(float delay) - { - mDelay = delay; - mRemainingDelay = mDelay; - } - } diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp index aa03c8a31b..c1a6e4ef68 100644 --- a/apps/openmw/mwgui/tooltips.hpp +++ b/apps/openmw/mwgui/tooltips.hpp @@ -60,8 +60,6 @@ namespace MWGui bool toggleFullHelp(); ///< show extra info in item tooltips (owner, script) bool getFullHelp() const; - void setDelay(float delay); - void clear(); void setFocusObject(const MWWorld::Ptr& focus); @@ -124,7 +122,6 @@ namespace MWGui int mHorizontalScrollIndex; - float mDelay; float mRemainingDelay; // remaining time until tooltip will show int mLastMouseX; diff --git a/apps/openmw/mwgui/trainingwindow.cpp b/apps/openmw/mwgui/trainingwindow.cpp index 73d8e02be7..5ed22df487 100644 --- a/apps/openmw/mwgui/trainingwindow.cpp +++ b/apps/openmw/mwgui/trainingwindow.cpp @@ -84,7 +84,7 @@ namespace MWGui MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats(player); - const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int lineHeight = Settings::gui().mFontSize + 2; for (int i = 0; i < 3; ++i) { diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index b371d979f9..40ccafbce8 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "../mwbase/environment.hpp" #include "../mwbase/mechanicsmanager.hpp" @@ -79,7 +80,7 @@ namespace MWGui // Apply followers cost, unlike vanilla the first follower doesn't travel for free price *= 1 + static_cast(followers.size()); - int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; + const int lineHeight = Settings::gui().mFontSize + 2; MyGUI::Button* toAdd = mDestinationsView->createWidget( "SandTextButton", 0, mCurrentY, 200, lineHeight, MyGUI::Align::Default); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index ee16cd2a46..2e9ab2473c 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -54,6 +54,7 @@ #include +#include "../mwbase/environment.hpp" #include "../mwbase/inputmanager.hpp" #include "../mwbase/luamanager.hpp" #include "../mwbase/soundmanager.hpp" @@ -183,9 +184,6 @@ namespace MWGui , mTranslationDataStorage(translationDataStorage) , mInputBlocker(nullptr) , mCrosshairEnabled(Settings::Manager::getBool("crosshair", "HUD")) - , mSubtitlesEnabled(Settings::Manager::getBool("subtitles", "GUI")) - , mHitFaderEnabled(Settings::Manager::getBool("hit fader", "GUI")) - , mWerewolfOverlayEnabled(Settings::Manager::getBool("werewolf overlay", "GUI")) , mHudEnabled(true) , mCursorVisible(true) , mCursorActive(true) @@ -206,7 +204,7 @@ namespace MWGui int dw, dh; SDL_GL_GetDrawableSize(window, &dw, &dh); - mScalingFactor = std::clamp(Settings::Manager::getFloat("scaling factor", "GUI"), 0.5f, 8.f) * (dw / w); + mScalingFactor = Settings::gui().mScalingFactor * (dw / w); mGuiPlatform = std::make_unique(viewer, guiRoot, resourceSystem->getImageManager(), resourceSystem->getVFS(), mScalingFactor, "mygui", logpath / "MyGUI.log"); @@ -249,7 +247,7 @@ namespace MWGui "Resource", "AutoSizedResourceSkin"); MyGUI::ResourceManager::getInstance().load("core.xml"); - bool keyboardNav = Settings::Manager::getBool("keyboard navigation", "GUI"); + const bool keyboardNav = Settings::gui().mKeyboardNavigation; mKeyboardNavigation = std::make_unique(); mKeyboardNavigation->setEnabled(keyboardNav); Gui::ImageButton::setDefaultNeedKeyFocus(keyboardNav); @@ -530,11 +528,6 @@ namespace MWGui mStatsWatcher->addListener(mCharGen.get()); } - int WindowManager::getFontHeight() const - { - return mFontLoader->getFontHeight(); - } - void WindowManager::setNewGame(bool newgame) { if (newgame) @@ -1152,17 +1145,13 @@ namespace MWGui void WindowManager::processChangedSettings(const Settings::CategorySettingVector& changed) { - mToolTips->setDelay(Settings::Manager::getFloat("tooltip delay", "GUI")); - bool changeRes = false; for (const auto& setting : changed) { if (setting.first == "HUD" && setting.second == "crosshair") mCrosshairEnabled = Settings::Manager::getBool("crosshair", "HUD"); - else if (setting.first == "GUI" && setting.second == "subtitles") - mSubtitlesEnabled = Settings::Manager::getBool("subtitles", "GUI"); else if (setting.first == "GUI" && setting.second == "menu transparency") - setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI")); + setMenuTransparency(Settings::gui().mMenuTransparency); else if (setting.first == "Video" && (setting.second == "resolution x" || setting.second == "resolution y" || setting.second == "window mode" || setting.second == "window border")) @@ -1604,11 +1593,6 @@ namespace MWGui mQuickKeysMenu->activateQuickKey(index); } - bool WindowManager::getSubtitlesEnabled() - { - return mSubtitlesEnabled; - } - bool WindowManager::toggleHud() { mHudEnabled = !mHudEnabled; @@ -1923,9 +1907,8 @@ namespace MWGui void WindowManager::sizeVideo(int screenWidth, int screenHeight) { // Use black bars to correct aspect ratio - bool stretch = Settings::Manager::getBool("stretch menu background", "GUI"); mVideoBackground->setSize(screenWidth, screenHeight); - mVideoWidget->autoResize(stretch); + mVideoWidget->autoResize(Settings::gui().mStretchMenuBackground); } void WindowManager::exitCurrentModal() @@ -2054,7 +2037,7 @@ namespace MWGui void WindowManager::activateHitOverlay(bool interrupt) { - if (!mHitFaderEnabled) + if (!Settings::gui().mHitFader) return; if (!interrupt && !mHitFader->isEmpty()) @@ -2067,7 +2050,7 @@ namespace MWGui void WindowManager::setWerewolfOverlay(bool set) { - if (!mWerewolfOverlayEnabled) + if (!Settings::gui().mWerewolfOverlay) return; if (mWerewolfFader) @@ -2240,7 +2223,7 @@ namespace MWGui { MyGUI::ITexture* tex = MyGUI::RenderManager::getInstance().createTexture("transparent"); tex->createManual(8, 8, MyGUI::TextureUsage::Write, MyGUI::PixelFormat::R8G8B8A8); - setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI")); + setMenuTransparency(Settings::gui().mMenuTransparency); } } diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 8bb3d1f8b0..0ed8a2e1d0 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -239,14 +239,12 @@ namespace MWGui const MWWorld::Ptr& getSelectedEnchantItem() const override; void setSelectedWeapon(const MWWorld::Ptr& item) override; const MWWorld::Ptr& getSelectedWeapon() const override; - int getFontHeight() const override; void unsetSelectedSpell() override; void unsetSelectedWeapon() override; void updateConsoleObjectPtr(const MWWorld::Ptr& currentPtr, const MWWorld::Ptr& newPtr) override; void showCrosshair(bool show) override; - bool getSubtitlesEnabled() override; /// Turn visibility of HUD on or off bool toggleHud() override; @@ -460,9 +458,6 @@ namespace MWGui MyGUI::Widget* mInputBlocker; bool mCrosshairEnabled; - bool mSubtitlesEnabled; - bool mHitFaderEnabled; - bool mWerewolfOverlayEnabled; bool mHudEnabled; bool mCursorVisible; bool mCursorActive; diff --git a/apps/openmw/mwlua/uibindings.cpp b/apps/openmw/mwlua/uibindings.cpp index 56bbe0d73e..b5212c566e 100644 --- a/apps/openmw/mwlua/uibindings.cpp +++ b/apps/openmw/mwlua/uibindings.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include "context.hpp" #include "luamanagerimp.hpp" @@ -103,7 +103,7 @@ namespace MWLua context.mLuaManager->addAction( []() { LuaUi::Element::forEach([](LuaUi::Element* e) { e->update(); }); }, "Update all UI elements"); }; - api["_getMenuTransparency"] = []() { return Settings::Manager::getFloat("menu transparency", "GUI"); }; + api["_getMenuTransparency"] = []() -> float { return Settings::gui().mMenuTransparency; }; auto uiLayer = context.mLua->sol().new_usertype("UiLayer"); uiLayer["name"] = sol::property([](LuaUi::Layer& self) { return self.name(); }); diff --git a/apps/openmw/mwscript/soundextensions.cpp b/apps/openmw/mwscript/soundextensions.cpp index 957331d2cb..918a0c0001 100644 --- a/apps/openmw/mwscript/soundextensions.cpp +++ b/apps/openmw/mwscript/soundextensions.cpp @@ -5,10 +5,10 @@ #include #include #include +#include #include "../mwbase/environment.hpp" #include "../mwbase/soundmanager.hpp" -#include "../mwbase/windowmanager.hpp" #include "../mwbase/world.hpp" #include "../mwworld/class.hpp" @@ -40,7 +40,7 @@ namespace MWScript MWBase::Environment::get().getSoundManager()->say(ptr, file); - if (MWBase::Environment::get().getWindowManager()->getSubtitlesEnabled()) + if (Settings::gui().mSubtitles) context.messageBox(text); } }; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index d0e8ab2301..1fd16a9915 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -3661,7 +3661,7 @@ namespace MWWorld void World::spawnBloodEffect(const Ptr& ptr, const osg::Vec3f& worldPosition) { - if (ptr == getPlayerPtr() && Settings::Manager::getBool("hit fader", "GUI")) + if (ptr == getPlayerPtr() && Settings::gui().mHitFader) return; std::string_view texture diff --git a/components/fontloader/fontloader.cpp b/components/fontloader/fontloader.cpp index 923e699d43..6016daca64 100644 --- a/components/fontloader/fontloader.cpp +++ b/components/fontloader/fontloader.cpp @@ -25,7 +25,7 @@ #include -#include +#include namespace { @@ -229,7 +229,6 @@ namespace Gui FontLoader::FontLoader(ToUTF8::FromType encoding, const VFS::Manager* vfs, float scalingFactor) : mVFS(vfs) - , mFontHeight(std::clamp(Settings::Manager::getInt("font size", "GUI"), 12, 18)) , mScalingFactor(scalingFactor) { if (encoding == ToUTF8::WINDOWS_1252) @@ -325,7 +324,7 @@ namespace Gui MyGUI::xml::ElementPtr sizeNode = resourceNode->createChild("Property"); sizeNode->addAttribute("key", "Size"); - sizeNode->addAttribute("value", std::to_string(mFontHeight)); + sizeNode->addAttribute("value", std::to_string(Settings::gui().mFontSize)); MyGUI::ResourceTrueTypeFont* font = static_cast( MyGUI::FactoryManager::getInstance().createObject("Resource", "ResourceTrueTypeFont")); @@ -623,18 +622,13 @@ namespace Gui // We should adjust line height for MyGUI widgets depending on font size MyGUI::xml::ElementPtr heightNode = resourceNode->createChild("Property"); heightNode->addAttribute("key", "HeightLine"); - heightNode->addAttribute("value", std::to_string(mFontHeight + 2)); + heightNode->addAttribute("value", std::to_string(Settings::gui().mFontSize + 2)); } } MyGUI::ResourceManager::getInstance().loadFromXmlNode(_node, _file, _version); } - int FontLoader::getFontHeight() - { - return mFontHeight; - } - std::string_view FontLoader::getFontForFace(std::string_view face) { if (Misc::StringUtils::ciEqual(face, "daedric")) diff --git a/components/fontloader/fontloader.hpp b/components/fontloader/fontloader.hpp index a5cb67b033..8c1312ff97 100644 --- a/components/fontloader/fontloader.hpp +++ b/components/fontloader/fontloader.hpp @@ -29,14 +29,11 @@ namespace Gui void overrideLineHeight(MyGUI::xml::ElementPtr _node, const std::string& _file, MyGUI::Version _version); - int getFontHeight(); - static std::string_view getFontForFace(std::string_view face); private: ToUTF8::FromType mEncoding; const VFS::Manager* mVFS; - int mFontHeight; float mScalingFactor; void loadFonts(); diff --git a/components/settings/categories/gui.hpp b/components/settings/categories/gui.hpp index 6c5b97556e..1d3a56af39 100644 --- a/components/settings/categories/gui.hpp +++ b/components/settings/categories/gui.hpp @@ -8,6 +8,8 @@ #include #include +#include + #include #include #include @@ -32,9 +34,8 @@ namespace Settings makeClampSanitizerFloat(0, 1) }; SettingValue mKeyboardNavigation{ mIndex, "GUI", "keyboard navigation" }; SettingValue mColorTopicEnable{ mIndex, "GUI", "color topic enable" }; - SettingValue mColorTopicSpecific{ mIndex, "GUI", "color topic specific", makeClampSanitizerFloat(0, 1) }; - SettingValue mColorTopicExhausted{ mIndex, "GUI", "color topic exhausted", - makeClampSanitizerFloat(0, 1) }; + SettingValue mColorTopicSpecific{ mIndex, "GUI", "color topic specific" }; + SettingValue mColorTopicExhausted{ mIndex, "GUI", "color topic exhausted" }; }; } diff --git a/components/settings/settings.cpp b/components/settings/settings.cpp index ce50d59ae1..bd6b10a1fb 100644 --- a/components/settings/settings.cpp +++ b/components/settings/settings.cpp @@ -454,6 +454,11 @@ namespace Settings setStringArray(setting, category, value); } + void Manager::set(std::string_view setting, std::string_view category, const MyGUI::Colour& value) + { + setString(setting, category, value.print()); + } + void Manager::recordInit(std::string_view setting, std::string_view category) { sInitialized.emplace(category, setting); diff --git a/components/settings/settings.hpp b/components/settings/settings.hpp index d8b10782ad..c5efe3b358 100644 --- a/components/settings/settings.hpp +++ b/components/settings/settings.hpp @@ -5,15 +5,17 @@ #include "components/detournavigator/collisionshapetype.hpp" +#include #include #include #include #include -#include #include #include +#include + namespace Files { struct ConfigurationManager; @@ -105,6 +107,7 @@ namespace Settings static void set(std::string_view setting, std::string_view category, const osg::Vec3f& value); static void set(std::string_view setting, std::string_view category, DetourNavigator::CollisionShapeType value); static void set(std::string_view setting, std::string_view category, const std::vector& value); + static void set(std::string_view setting, std::string_view category, const MyGUI::Colour& value); private: static std::set> sInitialized; @@ -188,6 +191,12 @@ namespace Settings { return getStringArray(setting, category); } + + template <> + inline MyGUI::Colour Manager::getImpl(std::string_view setting, std::string_view category) + { + return MyGUI::Colour::parse(getString(setting, category)); + } } #endif // COMPONENTS_SETTINGS_H diff --git a/components/settings/settingvalue.hpp b/components/settings/settingvalue.hpp index cd04dbc820..e15ba18d1c 100644 --- a/components/settings/settingvalue.hpp +++ b/components/settings/settingvalue.hpp @@ -35,6 +35,7 @@ namespace Settings Vec3f, CollisionShapeType, StringArray, + MyGuiColour, }; template @@ -124,6 +125,12 @@ namespace Settings return SettingValueType::StringArray; } + template <> + inline constexpr SettingValueType getSettingValueType() + { + return SettingValueType::MyGuiColour; + } + inline constexpr std::string_view getSettingValueTypeName(SettingValueType type) { switch (type) @@ -156,6 +163,8 @@ namespace Settings return "collision shape type"; case SettingValueType::StringArray: return "string array"; + case SettingValueType::MyGuiColour: + return "colour"; } return "unsupported"; } diff --git a/components/widgets/fontwrapper.hpp b/components/widgets/fontwrapper.hpp index 452014a5ed..f2c30376b9 100644 --- a/components/widgets/fontwrapper.hpp +++ b/components/widgets/fontwrapper.hpp @@ -2,7 +2,8 @@ #define OPENMW_WIDGETS_WRAPPER_H #include -#include + +#include "components/settings/values.hpp" #include @@ -16,7 +17,7 @@ namespace Gui void setFontName(const std::string& name) override { T::setFontName(name); - T::setPropertyOverride("FontHeight", getFontSize()); + T::setPropertyOverride("FontHeight", std::to_string(Settings::gui().mFontSize)); } protected: @@ -29,18 +30,9 @@ namespace Gui // We should restore it. if (_key == "FontName") { - T::setPropertyOverride("FontHeight", getFontSize()); + T::setPropertyOverride("FontHeight", std::to_string(Settings::gui().mFontSize)); } } - - private: - const std::string& getFontSize() - { - // Note: we can not use the FontLoader here, so there is a code duplication a bit. - static const std::string fontSize - = std::to_string(std::clamp(Settings::Manager::getInt("font size", "GUI"), 12, 18)); - return fontSize; - } #endif }; }