diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-08-28 19:05:13 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-08-28 19:05:13 +0000 |
commit | 4b94d5bf99b0ca29f45f3e0688e29e43f4a05f7a (patch) | |
tree | 7cc9d951edfc15c103f856ad7aaa256937ca7ee4 /src/gui/gui.cpp | |
parent | 767aa0301a6b16fb4950e6d1eef21346269aa3d1 (diff) | |
download | mana-4b94d5bf99b0ca29f45f3e0688e29e43f4a05f7a.tar.gz mana-4b94d5bf99b0ca29f45f3e0688e29e43f4a05f7a.tar.bz2 mana-4b94d5bf99b0ca29f45f3e0688e29e43f4a05f7a.tar.xz mana-4b94d5bf99b0ca29f45f3e0688e29e43f4a05f7a.zip |
Create a GuiConfigListener class.
Diffstat (limited to 'src/gui/gui.cpp')
-rw-r--r-- | src/gui/gui.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 612ca7a1..97bc8153 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -38,6 +38,7 @@ #include "windowcontainer.h" #include "../being.h" +#include "../configlistener.h" #include "../configuration.h" #include "../engine.h" #include "../game.h" @@ -64,6 +65,21 @@ gcn::ImageFont *hitYellowFont; // Font used to display speech and player names gcn::ImageFont *speechFont; +class GuiConfigListener : public ConfigListener +{ + public: + GuiConfigListener(Gui *gui):mGui(gui) {} + + void optionChanged(const std::string &name) + { + if (name == "customcursor") { + mGui->setUseCustomCursor(config.getValue("customcursor", 1) == 1); + } + } + private: + Gui *mGui; +}; + Gui::Gui(Graphics *graphics): mHostImageLoader(NULL), mMouseCursor(NULL), @@ -152,11 +168,15 @@ Gui::Gui(Graphics *graphics): // Initialize mouse cursor and listen for changes to the option setUseCustomCursor(config.getValue("customcursor", 1) == 1); - config.addListener("customcursor", this); + mConfigListener = new GuiConfigListener(this); + config.addListener("customcursor", mConfigListener); } Gui::~Gui() { + config.removeListener("customcursor", mConfigListener); + delete mConfigListener; + // Fonts used in showing hits delete hitRedFont; delete hitBlueFont; @@ -261,11 +281,3 @@ Gui::setUseCustomCursor(bool customCursor) } } } - -void -Gui::optionChanged(const std::string &name) -{ - if (name == "customcursor") { - setUseCustomCursor(config.getValue("customcursor", 1) == 1); - } -} |