summaryrefslogtreecommitdiff
path: root/src/net/tmwa
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/tmwa')
-rw-r--r--src/net/tmwa/gamehandler.cpp28
-rw-r--r--src/net/tmwa/gamehandler.h13
-rw-r--r--src/net/tmwa/generalhandler.cpp81
-rw-r--r--src/net/tmwa/generalhandler.h12
4 files changed, 73 insertions, 61 deletions
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp
index 179d98e4..4810a3ea 100644
--- a/src/net/tmwa/gamehandler.cpp
+++ b/src/net/tmwa/gamehandler.cpp
@@ -22,6 +22,7 @@
#include "net/tmwa/gamehandler.h"
#include "client.h"
+#include "event.h"
#include "game.h"
#include "localplayer.h"
#include "log.h"
@@ -58,6 +59,8 @@ GameHandler::GameHandler()
};
handledMessages = _messages;
gameHandler = this;
+
+ listen("Game");
}
void GameHandler::handleMessage(Net::MessageIn &msg)
@@ -104,6 +107,21 @@ void GameHandler::handleMessage(Net::MessageIn &msg)
}
}
+void GameHandler::event(const std::string &channel, const Mana::Event &event)
+{
+ if (channel == "Game")
+ {
+ if (event.getName() == "EnginesInitalized")
+ {
+ Game::instance()->changeMap(mMap);
+ }
+ else if (event.getName() == "MapLoaded")
+ {
+ MessageOut outMsg(CMSG_MAP_LOADED);
+ }
+ }
+}
+
void GameHandler::connect()
{
mNetwork->connect(mapServer);
@@ -141,16 +159,6 @@ void GameHandler::disconnect()
mNetwork->disconnect();
}
-void GameHandler::inGame()
-{
- Game::instance()->changeMap(mMap);
-}
-
-void GameHandler::mapLoaded(const std::string &mapName)
-{
- MessageOut outMsg(CMSG_MAP_LOADED);
-}
-
void GameHandler::who()
{
}
diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h
index 101e7972..6bdcbaef 100644
--- a/src/net/tmwa/gamehandler.h
+++ b/src/net/tmwa/gamehandler.h
@@ -22,6 +22,8 @@
#ifndef NET_TA_MAPHANDLER_H
#define NET_TA_MAPHANDLER_H
+#include "listener.h"
+
#include "net/gamehandler.h"
#include "net/net.h"
#include "net/serverinfo.h"
@@ -31,23 +33,22 @@
namespace TmwAthena {
-class GameHandler : public MessageHandler, public Net::GameHandler
+class GameHandler : public MessageHandler, public Net::GameHandler,
+ public Mana::Listener
{
public:
GameHandler();
void handleMessage(Net::MessageIn &msg);
+ void event(const std::string &channel, const Mana::Event &event);
+
void connect();
bool isConnected();
void disconnect();
- void inGame();
-
- void mapLoaded(const std::string &mapName);
-
void who();
void quit();
@@ -60,7 +61,7 @@ class GameHandler : public MessageHandler, public Net::GameHandler
void setMap(const std::string map);
- /** The tmwa protocol is making use of the Mp Main status bar. */
+ /** The tmwAthena protocol is making use of the MP status bar. */
bool canUseMagicBar() const { return true; }
private:
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 14f48055..ba9b329e 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -23,6 +23,7 @@
#include "client.h"
#include "configuration.h"
+#include "event.h"
#include "log.h"
#include "gui/charselectdialog.h"
@@ -32,6 +33,10 @@
#include "gui/socialwindow.h"
#include "gui/statuswindow.h"
+#include "net/messagein.h"
+#include "net/messageout.h"
+#include "net/serverinfo.h"
+
#include "net/tmwa/adminhandler.h"
#include "net/tmwa/beinghandler.h"
#include "net/tmwa/buysellhandler.h"
@@ -53,9 +58,6 @@
#include "net/tmwa/gui/guildtab.h"
#include "net/tmwa/gui/partytab.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
-
#include "resources/itemdb.h"
#include "utils/gettext.h"
@@ -106,6 +108,8 @@ GeneralHandler::GeneralHandler():
stats.push_back(ItemDB::Stat("luck", _("Luck %+d")));
ItemDB::setStatsList(stats);
+
+ listen("Game");
}
GeneralHandler::~GeneralHandler()
@@ -209,47 +213,48 @@ void GeneralHandler::flushNetwork()
}
}
-void GeneralHandler::guiWindowsLoaded()
-{
- inventoryWindow->setSplitAllowed(false);
- skillDialog->loadSkills("ea-skills.xml");
-
- statusWindow->addAttribute(STR, _("Strength"), true, "");
- statusWindow->addAttribute(AGI, _("Agility"), true, "");
- statusWindow->addAttribute(VIT, _("Vitality"), true, "");
- statusWindow->addAttribute(INT, _("Intelligence"), true, "");
- statusWindow->addAttribute(DEX, _("Dexterity"), true, "");
- statusWindow->addAttribute(LUK, _("Luck"), true, "");
-
- statusWindow->addAttribute(ATK, _("Attack"), false, "");
- statusWindow->addAttribute(DEF, _("Defense"), false, "");
- statusWindow->addAttribute(MATK, _("M.Attack"), false, "");
- statusWindow->addAttribute(MDEF, _("M.Defense"), false, "");
- statusWindow->addAttribute(HIT, _("% Accuracy"), false, "");
- statusWindow->addAttribute(FLEE, _("% Evade"), false, "");
- statusWindow->addAttribute(CRIT, _("% Critical"), false, "");
-}
-
-void GeneralHandler::guiWindowsUnloaded()
-{
- socialWindow->removeTab(taGuild);
- socialWindow->removeTab(taParty);
-
- delete guildTab;
- guildTab = 0;
-
- delete partyTab;
- partyTab = 0;
-}
-
void GeneralHandler::clearHandlers()
{
mNetwork->clearHandlers();
}
-void GeneralHandler::stateChanged(State oldState, State newState)
+void GeneralHandler::event(const std::string &channel,
+ const Mana::Event &event)
{
- //
+ if (channel == "Game")
+ {
+ if (event.getName() == "GuiWindowsLoaded")
+ {
+ inventoryWindow->setSplitAllowed(false);
+ skillDialog->loadSkills("ea-skills.xml");
+
+ statusWindow->addAttribute(STR, _("Strength"), true, "");
+ statusWindow->addAttribute(AGI, _("Agility"), true, "");
+ statusWindow->addAttribute(VIT, _("Vitality"), true, "");
+ statusWindow->addAttribute(INT, _("Intelligence"), true, "");
+ statusWindow->addAttribute(DEX, _("Dexterity"), true, "");
+ statusWindow->addAttribute(LUK, _("Luck"), true, "");
+
+ statusWindow->addAttribute(ATK, _("Attack"), false, "");
+ statusWindow->addAttribute(DEF, _("Defense"), false, "");
+ statusWindow->addAttribute(MATK, _("M.Attack"), false, "");
+ statusWindow->addAttribute(MDEF, _("M.Defense"), false, "");
+ statusWindow->addAttribute(HIT, _("% Accuracy"), false, "");
+ statusWindow->addAttribute(FLEE, _("% Evade"), false, "");
+ statusWindow->addAttribute(CRIT, _("% Critical"), false, "");
+ }
+ else if (event.getName() == "GuiWindowsUnloading")
+ {
+ socialWindow->removeTab(taGuild);
+ socialWindow->removeTab(taParty);
+
+ delete guildTab;
+ guildTab = 0;
+
+ delete partyTab;
+ partyTab = 0;
+ }
+ }
}
} // namespace TmwAthena
diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h
index d680f215..f7f78759 100644
--- a/src/net/tmwa/generalhandler.h
+++ b/src/net/tmwa/generalhandler.h
@@ -22,15 +22,17 @@
#ifndef NET_TMWA_GENERALHANDLER_H
#define NET_TMWA_GENERALHANDLER_H
+#include "listener.h"
+
#include "net/generalhandler.h"
#include "net/net.h"
-#include "net/serverinfo.h"
#include "net/tmwa/messagehandler.h"
namespace TmwAthena {
-class GeneralHandler : public MessageHandler, public Net::GeneralHandler
+class GeneralHandler : public MessageHandler, public Net::GeneralHandler,
+ public Mana::Listener
{
public:
GeneralHandler();
@@ -47,13 +49,9 @@ class GeneralHandler : public MessageHandler, public Net::GeneralHandler
void flushNetwork();
- void guiWindowsLoaded();
-
- void guiWindowsUnloaded();
-
void clearHandlers();
- void stateChanged(State oldState, State newState);
+ void event(const std::string &channel, const Mana::Event &event);
protected:
MessageHandlerPtr mAdminHandler;