diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2025-01-21 09:55:52 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2025-01-21 09:55:52 +0100 |
commit | 80a77b6563e64119748e59af3d2ea2fdef6488c6 (patch) | |
tree | 79ff1bf0d1456617e2b1c368ef3f83280270442f /src/gui | |
parent | e224a015dbb69db35a9403f40ede7fc397d549fc (diff) | |
download | mana-80a77b6563e64119748e59af3d2ea2fdef6488c6.tar.gz mana-80a77b6563e64119748e59af3d2ea2fdef6488c6.tar.bz2 mana-80a77b6563e64119748e59af3d2ea2fdef6488c6.tar.xz mana-80a77b6563e64119748e59af3d2ea2fdef6488c6.zip |
Update names as soon as the "Show gender" option is changed
No need to wait for Apply for this option.
Using `ConfigOptionChanged` event rather than direct call into
`ActorSpriteManager::updatePlayerNames`.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/setup_players.cpp | 20 | ||||
-rw-r--r-- | src/gui/setup_players.h | 1 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index 501fc83a..67fe79da 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -21,7 +21,6 @@ #include "gui/setup_players.h" -#include "actorspritemanager.h" #include "configuration.h" #include "gui/widgets/button.h" @@ -203,6 +202,7 @@ public: #define ACTION_STRATEGY "strategy" Setup_Players::Setup_Players(): + mShowGender(config.showGender), mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)), mPlayerTableModel(new PlayerTableModel), mPlayerTable(new GuiTable(mPlayerTableModel)), @@ -244,6 +244,8 @@ Setup_Players::Setup_Players(): gcn::Label *ignore_action_label = new Label(_("When ignoring:")); + mShowGenderCheckBox->setActionEventId("showgender"); + mShowGenderCheckBox->addActionListener(this); mIgnoreActionChoicesBox->setActionEventId(ACTION_STRATEGY); mIgnoreActionChoicesBox->addActionListener(this); @@ -309,21 +311,19 @@ void Setup_Players::apply() | (mDefaultWhisper->isSelected() ? PlayerPermissions::WHISPER : 0)); - const bool showGenderChanged = config.showGender != mShowGenderCheckBox->isSelected(); - config.whisperTab = mWhisperTabCheckBox->isSelected(); - config.showGender = mShowGenderCheckBox->isSelected(); config.enableChatLog = mEnableChatLogCheckBox->isSelected(); - if (actorSpriteManager && showGenderChanged) - actorSpriteManager->updatePlayerNames(); + mShowGender = config.showGender; } void Setup_Players::cancel() { mWhisperTabCheckBox->setSelected(config.whisperTab); - mShowGenderCheckBox->setSelected(config.showGender); + mShowGenderCheckBox->setSelected(mShowGender); mEnableChatLogCheckBox->setSelected(config.enableChatLog); + + setConfigValue(&Config::showGender, mShowGender); } void Setup_Players::action(const gcn::ActionEvent &event) @@ -341,7 +341,6 @@ void Setup_Players::action(const gcn::ActionEvent &event) mPlayerTableModel->updateModelInRow(row); player_relations.addListener(this); - } else if (event.getId() == ACTION_DELETE) { @@ -351,7 +350,6 @@ void Setup_Players::action(const gcn::ActionEvent &event) const std::string &name = mPlayerTableModel->getPlayerAt(player_index); player_relations.removePlayer(name); - } else if (event.getId() == ACTION_STRATEGY) { @@ -361,6 +359,10 @@ void Setup_Players::action(const gcn::ActionEvent &event) player_relations.setPlayerIgnoreStrategy(s); } + else if (event.getId() == "showgender") + { + setConfigValue(&Config::showGender, mShowGenderCheckBox->isSelected()); + } } void Setup_Players::playerRelationsUpdated() diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h index 48a08e83..126d621b 100644 --- a/src/gui/setup_players.h +++ b/src/gui/setup_players.h @@ -51,6 +51,7 @@ public: void playerRelationsUpdated() override; private: + bool mShowGender; StaticTableModel *mPlayerTableTitleModel; PlayerTableModel *mPlayerTableModel; GuiTable *mPlayerTable; |