summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.cpp19
-rw-r--r--src/gui/npcdialog.cpp11
-rw-r--r--src/gui/npcdialog.h6
-rw-r--r--src/gui/viewport.cpp20
-rw-r--r--src/gui/viewport.h8
5 files changed, 33 insertions, 31 deletions
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)
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 5b1939a6..1a5186ff 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -143,7 +143,7 @@ NpcDialog::NpcDialog(int npcId)
setVisible(true);
requestFocus();
- config.addListener("logNpcInGui", this);
+ listen(CHANNEL_CONFIG);
PlayerInfo::setNPCInteractionCount(PlayerInfo::getNPCInteractionCount()
+ 1);
}
@@ -161,7 +161,6 @@ NpcDialog::~NpcDialog()
instances.remove(this);
- config.removeListener("logNpcInGui", this);
PlayerInfo::setNPCInteractionCount(PlayerInfo::getNPCInteractionCount()
- 1);
@@ -383,9 +382,13 @@ void NpcDialog::setVisible(bool visible)
}
}
-void NpcDialog::optionChanged(const std::string &name)
+void NpcDialog::event(Channels channel, const Mana::Event &event)
{
- if (name == "logNpcInGui")
+ if (channel != CHANNEL_CONFIG)
+ return;
+
+ if (event.getName() == EVENT_CONFIGOPTIONCHANGED &&
+ event.getString("option") == "logNpcInGui")
{
mLogInteraction = config.getBoolValue("logNpcInGui");
}
diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h
index 5850ecca..1906d725 100644
--- a/src/gui/npcdialog.h
+++ b/src/gui/npcdialog.h
@@ -22,7 +22,7 @@
#ifndef NPCDIALOG_H
#define NPCDIALOG_H
-#include "configlistener.h"
+#include "listener.h"
#include "gui/widgets/window.h"
@@ -45,7 +45,7 @@ class Button;
* \ingroup Interface
*/
class NpcDialog : public Window, public gcn::ActionListener,
- public gcn::ListModel, public ConfigListener
+ public gcn::ListModel, public Mana::Listener
{
public:
/**
@@ -143,7 +143,7 @@ class NpcDialog : public Window, public gcn::ActionListener,
void setVisible(bool visible);
- void optionChanged(const std::string &name);
+ void event(Channels channel, const Mana::Event &event);
/**
* Returns the first active instance. Useful for pushing user
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 4152bd95..ac910d5f 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -64,14 +64,12 @@ Viewport::Viewport():
mScrollCenterOffsetX = config.getIntValue("ScrollCenterOffsetX");
mScrollCenterOffsetY = config.getIntValue("ScrollCenterOffsetY");
- config.addListener("ScrollLaziness", this);
- config.addListener("ScrollRadius", this);
-
mPopupMenu = new PopupMenu;
mBeingPopup = new BeingPopup;
setFocusable(true);
+ listen(CHANNEL_CONFIG);
listen(CHANNEL_ACTORSPRITE);
}
@@ -485,12 +483,6 @@ void Viewport::closePopupMenu()
mPopupMenu->handleLink("cancel");
}
-void Viewport::optionChanged(const std::string &name)
-{
- mScrollLaziness = config.getIntValue("ScrollLaziness");
- mScrollRadius = config.getIntValue("ScrollRadius");
-}
-
void Viewport::mouseMoved(gcn::MouseEvent &event)
{
// Check if we are on the map
@@ -568,4 +560,14 @@ void Viewport::event(Channels channel, const Mana::Event &event)
if (mHoverItem == actor)
mHoverItem = 0;
}
+ else if (channel == CHANNEL_CONFIG &&
+ event.getName() == EVENT_CONFIGOPTIONCHANGED)
+ {
+ const std::string option = event.getString("option");
+ if (option == "ScrollLaziness" || option == "ScrollRadius")
+ {
+ mScrollLaziness = config.getIntValue("ScrollLaziness");
+ mScrollRadius = config.getIntValue("ScrollRadius");
+ }
+ }
}
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index 9fbdf496..3b449371 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -23,7 +23,6 @@
#define VIEWPORT_H
#include "actorspritemanager.h"
-#include "configlistener.h"
#include "listener.h"
#include "position.h"
@@ -54,7 +53,7 @@ const int walkingMouseDelay = 500;
* coordinates.
*/
class Viewport : public WindowContainer, public gcn::MouseListener,
- public ConfigListener, public Mana::Listener
+ public Mana::Listener
{
public:
/**
@@ -121,11 +120,6 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
void closePopupMenu();
/**
- * A relevant config option changed.
- */
- void optionChanged(const std::string &name);
-
- /**
* Returns camera x offset in pixels.
*/
int getCameraX() const { return (int) mPixelViewX; }