summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-08-28 19:05:13 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-08-28 19:05:13 +0000
commit4b94d5bf99b0ca29f45f3e0688e29e43f4a05f7a (patch)
tree7cc9d951edfc15c103f856ad7aaa256937ca7ee4 /src
parent767aa0301a6b16fb4950e6d1eef21346269aa3d1 (diff)
downloadmana-4b94d5bf99b0ca29f45f3e0688e29e43f4a05f7a.tar.gz
mana-4b94d5bf99b0ca29f45f3e0688e29e43f4a05f7a.tar.bz2
mana-4b94d5bf99b0ca29f45f3e0688e29e43f4a05f7a.tar.xz
mana-4b94d5bf99b0ca29f45f3e0688e29e43f4a05f7a.zip
Create a GuiConfigListener class.
Diffstat (limited to 'src')
-rw-r--r--src/gui/gui.cpp30
-rw-r--r--src/gui/gui.h5
2 files changed, 24 insertions, 11 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);
- }
-}
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 80a4ee7d..959fa2ed 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -26,9 +26,9 @@
#include <guichan/gui.hpp>
-#include "../configlistener.h"
#include "../guichanfwd.h"
+class GuiConfigListener;
class Graphics;
class Image;
class WindowContainer;
@@ -46,7 +46,7 @@ class WindowContainer;
*
* \ingroup GUI
*/
-class Gui : public gcn::Gui, public gcn::MouseListener, ConfigListener
+class Gui : public gcn::Gui, public gcn::MouseListener
{
public:
/**
@@ -97,6 +97,7 @@ class Gui : public gcn::Gui, public gcn::MouseListener, ConfigListener
optionChanged(const std::string &name);
private:
+ GuiConfigListener *mConfigListener;
gcn::ImageLoader *mHostImageLoader; /**< For loading images in GL */
gcn::ImageLoader *mImageLoader; /**< For loading images */
gcn::ImageFont *mGuiFont; /**< The global GUI font */