Use settings values for GUI settings

revert-6246b479
elsid 1 year ago
parent 98bb9fc125
commit d113f0fc44
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -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;

@ -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);

@ -9,6 +9,7 @@
#include <components/esm3/loadspel.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/settings/values.hpp>
#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();

@ -10,6 +10,7 @@
#include <components/misc/utf8stream.hpp>
#include <components/sceneutil/depth.hpp>
#include <components/settings/values.hpp>
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;

@ -9,10 +9,7 @@
#include <functional>
#include <memory>
#include <components/settings/settings.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include <components/settings/values.hpp>
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<float>(Settings::gui().mFontSize);
codePoint = gi->codePoint;
bearingX = (int)gi->bearingX / scale;

@ -8,6 +8,7 @@
#include <components/debug/debuglog.hpp>
#include <components/esm3/loadcrea.hpp>
#include <components/settings/values.hpp>
#include <components/translation/translation.hpp>
#include <components/widgets/box.hpp>
#include <components/widgets/list.hpp>
@ -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);
}
}

@ -14,10 +14,10 @@
#include <components/misc/resourcehelpers.hpp>
#include <components/misc/strings/algorithm.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/settings/values.hpp>
#include <components/vfs/manager.hpp>
#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;

@ -6,13 +6,12 @@
#include <MyGUI_TextBox.h>
#include <components/debug/debuglog.hpp>
// correctIconPath
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/settings/values.hpp>
#include <components/vfs/manager.hpp>
#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";

@ -4,6 +4,7 @@
#include "../mwbase/windowmanager.hpp"
#include <components/misc/utf8stream.hpp>
#include <components/settings/values.hpp>
#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;

@ -15,7 +15,7 @@
#include <components/misc/rng.hpp>
#include <components/myguiplatform/myguitexture.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/settings/settings.hpp>
#include <components/settings/values.hpp>
#include <components/vfs/manager.hpp>
#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);

@ -4,7 +4,7 @@
#include <MyGUI_RenderManager.h>
#include <MyGUI_TextBox.h>
#include <components/settings/settings.hpp>
#include <components/settings/values.hpp>
#include <components/vfs/manager.hpp>
#include <components/widgets/imagebutton.hpp>
@ -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)
{

@ -1,6 +1,7 @@
#include "merchantrepair.hpp"
#include <components/esm3/loadgmst.hpp>
#include <components/settings/values.hpp>
#include <MyGUI_Button.h>
#include <MyGUI_Gui.h>
@ -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();

@ -8,10 +8,10 @@
#include <osg/Texture2D>
#include <components/debug/debuglog.hpp>
#include <components/myguiplatform/myguitexture.hpp>
#include <components/esm3/loadbody.hpp>
#include <components/esm3/loadrace.hpp>
#include <components/myguiplatform/myguitexture.hpp>
#include <components/settings/values.hpp>
#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();

@ -10,6 +10,7 @@
#include <components/esm3/loadbsgn.hpp>
#include <components/esm3/loadrace.hpp>
#include <components/esm3/loadspel.hpp>
#include <components/settings/values.hpp>
#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;
}

@ -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;

@ -6,6 +6,7 @@
#include <components/esm3/loadgmst.hpp>
#include <components/esm3/loadrace.hpp>
#include <components/settings/values.hpp>
#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<MyGUI::Button>(price <= playerGold
? "SandTextButton"

@ -5,9 +5,7 @@
#include <MyGUI_ImageBox.h>
#include <MyGUI_ScrollView.h>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include <components/settings/values.hpp>
#include <components/widgets/box.hpp>
#include <components/widgets/sharedstatebutton.hpp>
@ -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();

@ -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;

@ -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;
}
}

@ -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;

@ -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)
{

@ -7,6 +7,7 @@
#include <components/esm3/loadcrea.hpp>
#include <components/esm3/loadgmst.hpp>
#include <components/misc/strings/conversion.hpp>
#include <components/settings/values.hpp>
#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<int>(followers.size());
int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
const int lineHeight = Settings::gui().mFontSize + 2;
MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>(
"SandTextButton", 0, mCurrentY, 200, lineHeight, MyGUI::Align::Default);

@ -54,6 +54,7 @@
#include <components/settings/values.hpp>
#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<osgMyGUI::Platform>(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<KeyboardNavigation>();
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);
}
}

@ -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;

@ -9,7 +9,7 @@
#include <components/lua_ui/util.hpp>
#include <components/misc/strings/format.hpp>
#include <components/settings/settings.hpp>
#include <components/settings/values.hpp>
#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<LuaUi::Layer>("UiLayer");
uiLayer["name"] = sol::property([](LuaUi::Layer& self) { return self.name(); });

@ -5,10 +5,10 @@
#include <components/interpreter/interpreter.hpp>
#include <components/interpreter/opcodes.hpp>
#include <components/interpreter/runtime.hpp>
#include <components/settings/values.hpp>
#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);
}
};

@ -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

@ -25,7 +25,7 @@
#include <components/myguiplatform/scalinglayer.hpp>
#include <components/settings/settings.hpp>
#include <components/settings/values.hpp>
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::ResourceTrueTypeFont*>(
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"))

@ -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();

@ -8,6 +8,8 @@
#include <osg/Vec2f>
#include <osg/Vec3f>
#include <MyGUI_Colour.h>
#include <cstdint>
#include <string>
#include <string_view>
@ -32,9 +34,8 @@ namespace Settings
makeClampSanitizerFloat(0, 1) };
SettingValue<bool> mKeyboardNavigation{ mIndex, "GUI", "keyboard navigation" };
SettingValue<bool> mColorTopicEnable{ mIndex, "GUI", "color topic enable" };
SettingValue<float> mColorTopicSpecific{ mIndex, "GUI", "color topic specific", makeClampSanitizerFloat(0, 1) };
SettingValue<float> mColorTopicExhausted{ mIndex, "GUI", "color topic exhausted",
makeClampSanitizerFloat(0, 1) };
SettingValue<MyGUI::Colour> mColorTopicSpecific{ mIndex, "GUI", "color topic specific" };
SettingValue<MyGUI::Colour> mColorTopicExhausted{ mIndex, "GUI", "color topic exhausted" };
};
}

@ -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);

@ -5,15 +5,17 @@
#include "components/detournavigator/collisionshapetype.hpp"
#include <filesystem>
#include <set>
#include <string>
#include <string_view>
#include <vector>
#include <filesystem>
#include <osg/Vec2f>
#include <osg/Vec3f>
#include <MyGUI_Colour.h>
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<std::string>& value);
static void set(std::string_view setting, std::string_view category, const MyGUI::Colour& value);
private:
static std::set<std::pair<std::string_view, std::string_view>> sInitialized;
@ -188,6 +191,12 @@ namespace Settings
{
return getStringArray(setting, category);
}
template <>
inline MyGUI::Colour Manager::getImpl<MyGUI::Colour>(std::string_view setting, std::string_view category)
{
return MyGUI::Colour::parse(getString(setting, category));
}
}
#endif // COMPONENTS_SETTINGS_H

@ -35,6 +35,7 @@ namespace Settings
Vec3f,
CollisionShapeType,
StringArray,
MyGuiColour,
};
template <class T>
@ -124,6 +125,12 @@ namespace Settings
return SettingValueType::StringArray;
}
template <>
inline constexpr SettingValueType getSettingValueType<MyGUI::Colour>()
{
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";
}

@ -2,7 +2,8 @@
#define OPENMW_WIDGETS_WRAPPER_H
#include <MyGUI_Prerequest.h>
#include <components/settings/settings.hpp>
#include "components/settings/values.hpp"
#include <algorithm>
@ -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
};
}

Loading…
Cancel
Save