diff options
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); - } -} |