diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2025-01-21 09:25:46 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2025-01-21 09:29:23 +0100 |
commit | e224a015dbb69db35a9403f40ede7fc397d549fc (patch) | |
tree | 97bb25d8302ef3cc60077383abd3076753f34b71 /src/gui | |
parent | db9b9f316d7bdcb9504092908bb18e82fc21de2f (diff) | |
download | mana-e224a015dbb69db35a9403f40ede7fc397d549fc.tar.gz mana-e224a015dbb69db35a9403f40ede7fc397d549fc.tar.bz2 mana-e224a015dbb69db35a9403f40ede7fc397d549fc.tar.xz mana-e224a015dbb69db35a9403f40ede7fc397d549fc.zip |
Fixed ConfigOptionChanged events
With the statically typed config we no longer get an event for each
changed config value. Where relevant, this is now done through
`setConfigValue`.
The `Event` now uses a `std::any`, which for `ConfigOptionChanged`
events is set to the changed `Config` member. This allows for a
type-safe check on which config value was changed.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui.cpp | 2 | ||||
-rw-r--r-- | src/gui/setup_interface.cpp | 12 | ||||
-rw-r--r-- | src/gui/setup_video.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/chattab.cpp | 2 |
4 files changed, 10 insertions, 10 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 39314fcf..a59242dc 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -177,7 +177,7 @@ void Gui::event(Event::Channel channel, const Event &event) if (channel == Event::ConfigChannel) { if (event.getType() == Event::ConfigOptionChanged && - event.getString("option") == "customcursor") + event.hasValue(&Config::customCursor)) { setUseCustomCursor(config.customCursor); } diff --git a/src/gui/setup_interface.cpp b/src/gui/setup_interface.cpp index 229898c7..7eef974c 100644 --- a/src/gui/setup_interface.cpp +++ b/src/gui/setup_interface.cpp @@ -205,11 +205,11 @@ void Setup_Interface::cancel() //mAlphaSlider->setEnabled(!mSDLTransparencyDisabled); config.showMonstersTakedDamage = mShowMonsterDamageEnabled; - config.visibleNames = mVisibleNamesEnabled; + setConfigValue(&Config::visibleNames, mVisibleNamesEnabled); config.speech = mSpeechMode; - config.showOwnName = mNameEnabled; + setConfigValue(&Config::showOwnName, mNameEnabled); config.logNpcInGui = mNPCLogEnabled; - config.guiAlpha = mOpacity; + setConfigValue<float>(&Config::guiAlpha, mOpacity); config.showPickupChat = mPickupChatEnabled; config.showPickupParticle = mPickupParticleEnabled; } @@ -220,7 +220,7 @@ void Setup_Interface::action(const gcn::ActionEvent &event) if (id == "guialpha") { - config.guiAlpha = mAlphaSlider->getValue(); + setConfigValue<float>(&Config::guiAlpha, mAlphaSlider->getValue()); } else if (id == "monsterdamage") { @@ -228,7 +228,7 @@ void Setup_Interface::action(const gcn::ActionEvent &event) } else if (id == "visiblenames") { - config.visibleNames = mVisibleNamesCheckBox->isSelected(); + setConfigValue(&Config::visibleNames, mVisibleNamesCheckBox->isSelected()); } else if (id == "pickupchat") { @@ -247,7 +247,7 @@ void Setup_Interface::action(const gcn::ActionEvent &event) } else if (id == "showownname") { - config.showOwnName = mNameCheckBox->isSelected(); + setConfigValue(&Config::showOwnName, mNameCheckBox->isSelected()); } else if (id == "lognpc") { diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index efa56cb8..38602a5c 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -453,7 +453,7 @@ void Setup_Video::cancel() config.windowMode = mVideoSettings.windowMode; - config.customCursor = mCustomCursorEnabled; + setConfigValue(&Config::customCursor, mCustomCursorEnabled); config.particleEffects = mParticleEffectsEnabled; config.opengl = mVideoSettings.openGL; config.disableTransparency = mSDLTransparencyDisabled; @@ -489,7 +489,7 @@ void Setup_Video::action(const gcn::ActionEvent &event) } else if (id == "customcursor") { - config.customCursor = mCustomCursorCheckBox->isSelected(); + setConfigValue(&Config::customCursor, mCustomCursorCheckBox->isSelected()); } else if (id == "particleeffects") { diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 1584eb0a..485de566 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -102,7 +102,7 @@ void ChatTab::event(Event::Channel channel, const Event &event) // Update the text outline and shadow according to the gui opacity. if (channel == Event::ConfigChannel && event.getType() == Event::ConfigOptionChanged && - event.getString("option") == "guialpha") + event.hasValue(&Config::guiAlpha)) { updateTextFormat(Window::getGuiAlpha()); } |