From f8d22e47ac3b6392d68f1a8a45383798f5751101 Mon Sep 17 00:00:00 2001 From: Chuck Miller Date: Sat, 13 Nov 2010 17:00:46 -0500 Subject: Replace config listeners with the event system Reviewed-by: Jared Adams --- src/gui/gui.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/gui/gui.cpp') diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index c8568b0f..c0d1babf 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -29,8 +29,8 @@ #include "gui/widgets/window.h" #include "gui/widgets/windowcontainer.h" -#include "configlistener.h" #include "configuration.h" +#include "listener.h" #include "graphics.h" #include "log.h" @@ -50,19 +50,23 @@ SDLInput *guiInput = 0; // Bolded font gcn::Font *boldFont = 0; -class GuiConfigListener : public ConfigListener +class GuiConfigListener : public Mana::Listener { public: GuiConfigListener(Gui *g): mGui(g) {} - void optionChanged(const std::string &name) + void event(Channels channel, const Mana::Event &event) { - if (name == "customcursor") + if (channel == CHANNEL_CONFIG) { - bool bCustomCursor = config.getBoolValue("customcursor"); - mGui->setUseCustomCursor(bCustomCursor); + if (event.getName() == EVENT_CONFIGOPTIONCHANGED && + event.getString("option") == "customcursor") + { + bool bCustomCursor = config.getBoolValue("customcursor"); + mGui->setUseCustomCursor(bCustomCursor); + } } } private: @@ -137,12 +141,11 @@ Gui::Gui(Graphics *graphics): // Initialize mouse cursor and listen for changes to the option setUseCustomCursor(config.getBoolValue("customcursor")); mConfigListener = new GuiConfigListener(this); - config.addListener("customcursor", mConfigListener); + mConfigListener->listen(CHANNEL_CONFIG); } Gui::~Gui() { - config.removeListener("customcursor", mConfigListener); delete mConfigListener; if (mMouseCursors) -- cgit v1.2.3-70-g09d2