summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorChuck Miller <shadowmil@gmail.com>2010-07-18 23:02:25 -0400
committerChuck Miller <shadowmil@gmail.com>2010-07-18 23:10:02 -0400
commit41a23cb4511e9ba3985990e2703fb3d680a23d14 (patch)
tree2bf03217e3c3b0f28aed5649e2e43cf2b965bd1d /src/gui
parent782158dfd719fb6d196f79075f275fb8599d393c (diff)
downloadmana-41a23cb4511e9ba3985990e2703fb3d680a23d14.tar.gz
mana-41a23cb4511e9ba3985990e2703fb3d680a23d14.tar.bz2
mana-41a23cb4511e9ba3985990e2703fb3d680a23d14.tar.xz
mana-41a23cb4511e9ba3985990e2703fb3d680a23d14.zip
Move the majority of the netcode's server messages to the event system
There is still a good way to go, but this should get us started Reviewed-by: Jared Adams
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chat.cpp14
-rw-r--r--src/gui/chat.h6
2 files changed, 19 insertions, 1 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index f11f23ef..31f6e279 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -23,6 +23,7 @@
#include "actorspritemanager.h"
#include "configuration.h"
+#include "event.h"
#include "localplayer.h"
#include "party.h"
@@ -77,6 +78,8 @@ ChatWindow::ChatWindow():
Window(_("Chat")),
mTmpVisible(false)
{
+ listen("Notices");
+
setWindowName("Chat");
setupWindow->registerWindowForReset(this);
@@ -393,6 +396,17 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
}
}
+void ChatWindow::event(const std::string &channel, const Mana::Event &event)
+{
+ if (channel == "Notices")
+ {
+ if (event.getName() == "ServerNotice")
+ {
+ localChatTab->chatLog(event.getString("message"), BY_SERVER);
+ }
+ }
+}
+
void ChatWindow::addInputText(const std::string &text)
{
const int caretPos = mChatInput->getCaretPosition();
diff --git a/src/gui/chat.h b/src/gui/chat.h
index aeba2ece..d6378907 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -22,6 +22,8 @@
#ifndef CHAT_H
#define CHAT_H
+#include "listener.h"
+
#include "gui/widgets/window.h"
#include <guichan/actionlistener.hpp>
@@ -74,7 +76,8 @@ struct CHATLOG
*/
class ChatWindow : public Window,
public gcn::ActionListener,
- public gcn::KeyListener
+ public gcn::KeyListener,
+ public Mana::Listener
{
public:
/**
@@ -159,6 +162,7 @@ class ChatWindow : public Window,
void mousePressed(gcn::MouseEvent &event);
void mouseDragged(gcn::MouseEvent &event);
+ void event(const std::string &channel, const Mana::Event &event);
/**
* Scrolls the chat window