summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/actorsprite.cpp12
-rw-r--r--src/being.cpp19
-rw-r--r--src/being.h6
-rw-r--r--src/chatlog.h7
-rw-r--r--src/client.cpp118
-rw-r--r--src/client.h28
-rw-r--r--src/commandhandler.h6
-rw-r--r--src/compoundsprite.cpp5
-rw-r--r--src/configuration.cpp30
-rw-r--r--src/configuration.h4
-rw-r--r--src/defaults.cpp2
-rw-r--r--src/defaults.h2
-rw-r--r--src/emoteshortcut.h6
-rw-r--r--src/equipment.h6
-rw-r--r--src/event.cpp17
-rw-r--r--src/event.h191
-rw-r--r--src/eventlistener.cpp (renamed from src/listener.cpp)13
-rw-r--r--src/eventlistener.h (renamed from src/listener.h)21
-rw-r--r--src/flooritem.h2
-rw-r--r--src/game.cpp44
-rw-r--r--src/graphics.h6
-rw-r--r--src/gui/beingpopup.h6
-rw-r--r--src/gui/buy.h8
-rw-r--r--src/gui/changeemaildialog.h8
-rw-r--r--src/gui/changepassworddialog.h8
-rw-r--r--src/gui/charcreatedialog.h6
-rw-r--r--src/gui/charselectdialog.h3
-rw-r--r--src/gui/chat.cpp22
-rw-r--r--src/gui/chat.h9
-rw-r--r--src/gui/confirmdialog.h5
-rw-r--r--src/gui/debugwindow.h3
-rw-r--r--src/gui/equipmentwindow.cpp2
-rw-r--r--src/gui/equipmentwindow.h18
-rw-r--r--src/gui/gui.cpp12
-rw-r--r--src/gui/gui.h6
-rw-r--r--src/gui/help.h3
-rw-r--r--src/gui/inventorywindow.cpp84
-rw-r--r--src/gui/inventorywindow.h21
-rw-r--r--src/gui/itemamount.cpp12
-rw-r--r--src/gui/login.h5
-rw-r--r--src/gui/ministatus.cpp13
-rw-r--r--src/gui/ministatus.h6
-rw-r--r--src/gui/npcdialog.cpp42
-rw-r--r--src/gui/npcdialog.h11
-rw-r--r--src/gui/npcpostdialog.h3
-rw-r--r--src/gui/okdialog.h5
-rw-r--r--src/gui/outfitwindow.cpp4
-rw-r--r--src/gui/outfitwindow.h6
-rw-r--r--src/gui/palette.h6
-rw-r--r--src/gui/popupmenu.cpp6
-rw-r--r--src/gui/popupmenu.h3
-rw-r--r--src/gui/quitdialog.h3
-rw-r--r--src/gui/register.h3
-rw-r--r--src/gui/sell.h8
-rw-r--r--src/gui/serverdialog.cpp55
-rw-r--r--src/gui/serverdialog.h13
-rw-r--r--src/gui/setup_keyboard.h6
-rw-r--r--src/gui/setup_video.cpp44
-rw-r--r--src/gui/setup_video.h6
-rw-r--r--src/gui/shortcutwindow.h6
-rw-r--r--src/gui/skilldialog.cpp14
-rw-r--r--src/gui/skilldialog.h5
-rw-r--r--src/gui/socialwindow.cpp7
-rw-r--r--src/gui/speechbubble.h3
-rw-r--r--src/gui/statuswindow.cpp9
-rw-r--r--src/gui/statuswindow.h9
-rw-r--r--src/gui/textdialog.h5
-rw-r--r--src/gui/textpopup.h8
-rw-r--r--src/gui/trade.h6
-rw-r--r--src/gui/truetypefont.h3
-rw-r--r--src/gui/unregisterdialog.h5
-rw-r--r--src/gui/updatewindow.h7
-rw-r--r--src/gui/viewport.cpp51
-rw-r--r--src/gui/viewport.h40
-rw-r--r--src/gui/widgets/browserbox.h6
-rw-r--r--src/gui/widgets/button.h3
-rw-r--r--src/gui/widgets/channeltab.h6
-rw-r--r--src/gui/widgets/chattab.h3
-rw-r--r--src/gui/widgets/checkbox.h6
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.h6
-rw-r--r--src/gui/widgets/flowcontainer.h8
-rw-r--r--src/gui/widgets/icon.h4
-rw-r--r--src/gui/widgets/itemcontainer.cpp60
-rw-r--r--src/gui/widgets/itemcontainer.h16
-rw-r--r--src/gui/widgets/itemshortcutcontainer.h6
-rw-r--r--src/gui/widgets/label.h5
-rw-r--r--src/gui/widgets/layouthelper.h6
-rw-r--r--src/gui/widgets/listbox.h3
-rw-r--r--src/gui/widgets/passwordfield.h2
-rw-r--r--src/gui/widgets/playerbox.h3
-rw-r--r--src/gui/widgets/radiobutton.h6
-rw-r--r--src/gui/widgets/resizegrip.h6
-rw-r--r--src/gui/widgets/shoplistbox.h6
-rw-r--r--src/gui/widgets/shortcutcontainer.h6
-rw-r--r--src/gui/widgets/slider.h9
-rw-r--r--src/gui/widgets/tabbedarea.h3
-rw-r--r--src/gui/widgets/textbox.h3
-rw-r--r--src/gui/worldselectdialog.h8
-rw-r--r--src/imageparticle.h3
-rw-r--r--src/inventory.h3
-rw-r--r--src/item.cpp12
-rw-r--r--src/item.h13
-rw-r--r--src/itemshortcut.cpp6
-rw-r--r--src/itemshortcut.h6
-rw-r--r--src/localplayer.cpp24
-rw-r--r--src/localplayer.h12
-rw-r--r--src/log.h7
-rw-r--r--src/main.h2
-rw-r--r--src/map.cpp3
-rw-r--r--src/map.h9
-rw-r--r--src/net/logindata.h5
-rw-r--r--src/net/manaserv/beinghandler.cpp31
-rw-r--r--src/net/manaserv/charhandler.cpp23
-rw-r--r--src/net/manaserv/chathandler.cpp13
-rw-r--r--src/net/manaserv/connection.cpp4
-rw-r--r--src/net/manaserv/connection.h6
-rw-r--r--src/net/manaserv/effecthandler.cpp38
-rw-r--r--src/net/manaserv/effecthandler.h1
-rw-r--r--src/net/manaserv/generalhandler.cpp18
-rw-r--r--src/net/manaserv/generalhandler.h6
-rw-r--r--src/net/manaserv/inventoryhandler.cpp20
-rw-r--r--src/net/manaserv/inventoryhandler.h6
-rw-r--r--src/net/manaserv/manaserv_protocol.h8
-rw-r--r--src/net/manaserv/messagein.h3
-rw-r--r--src/net/manaserv/messageout.h6
-rw-r--r--src/net/manaserv/network.cpp4
-rw-r--r--src/net/manaserv/npchandler.cpp62
-rw-r--r--src/net/manaserv/npchandler.h2
-rw-r--r--src/net/manaserv/playerhandler.cpp2
-rw-r--r--src/net/messagein.h3
-rw-r--r--src/net/messageout.h3
-rw-r--r--src/net/tmwa/chathandler.cpp24
-rw-r--r--src/net/tmwa/gamehandler.cpp10
-rw-r--r--src/net/tmwa/gamehandler.h6
-rw-r--r--src/net/tmwa/generalhandler.cpp12
-rw-r--r--src/net/tmwa/generalhandler.h6
-rw-r--r--src/net/tmwa/inventoryhandler.cpp20
-rw-r--r--src/net/tmwa/inventoryhandler.h9
-rw-r--r--src/net/tmwa/messagein.h3
-rw-r--r--src/net/tmwa/messageout.h3
-rw-r--r--src/net/tmwa/npchandler.cpp52
-rw-r--r--src/net/tmwa/npchandler.h2
-rw-r--r--src/net/tmwa/playerhandler.cpp3
-rw-r--r--src/net/tmwa/tradehandler.cpp2
-rw-r--r--src/particle.h3
-rw-r--r--src/particleemitter.h6
-rw-r--r--src/playerinfo.cpp46
-rw-r--r--src/properties.h3
-rw-r--r--src/resources/image.h9
-rw-r--r--src/resources/imageset.h3
-rw-r--r--src/resources/itemdb.cpp2
-rw-r--r--src/resources/iteminfo.h17
-rw-r--r--src/resources/music.h6
-rw-r--r--src/resources/resource.h6
-rw-r--r--src/resources/soundeffect.h6
-rw-r--r--src/resources/spritedef.h6
-rw-r--r--src/resources/theme.cpp8
-rw-r--r--src/resources/theme.h6
-rw-r--r--src/resources/userpalette.h6
-rw-r--r--src/shopitem.h7
-rw-r--r--src/sound.cpp59
-rw-r--r--src/sound.h28
-rw-r--r--src/textmanager.h3
-rw-r--r--src/textparticle.h3
-rw-r--r--src/tileset.h3
-rw-r--r--src/utils/mkdir.cpp8
-rw-r--r--src/utils/mkdir.h4
-rw-r--r--src/utils/specialfolder.cpp6
-rw-r--r--src/utils/specialfolder.h4
-rw-r--r--src/variabledata.h7
-rw-r--r--src/vector.h9
172 files changed, 1041 insertions, 1150 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 79dd72cc..f8ae39fd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -453,6 +453,8 @@ SET(SRCS
equipment.h
event.cpp
event.h
+ eventlistener.cpp
+ eventlistener.h
flooritem.cpp
flooritem.h
game.cpp
@@ -476,8 +478,6 @@ SET(SRCS
joystick.h
keyboardconfig.cpp
keyboardconfig.h
- listener.cpp
- listener.h
localplayer.cpp
localplayer.h
log.cpp
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index b2f921cd..988a25e5 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -60,9 +60,9 @@ ActorSprite::~ActorSprite()
mUsedTargetCursor = NULL;
// Notify listeners of the destruction.
- Mana::Event event(EVENT_DESTROYED);
+ Event event(Event::Destroyed);
event.setActor("source", this);
- event.trigger(CHANNEL_ACTORSPRITE);
+ event.trigger(Event::ActorSpriteChannel);
}
bool ActorSprite::draw(Graphics *graphics, int offsetX, int offsetY) const
@@ -254,10 +254,10 @@ void ActorSprite::updateStunMode(int oldMode, int newMode)
{
if (this == player_node)
{
- Mana::Event event(EVENT_STUN);
+ Event event(Event::Stun);
event.setInt("oldMode", oldMode);
event.setInt("newMode", newMode);
- event.trigger(CHANNEL_ACTORSPRITE);
+ event.trigger(Event::ActorSpriteChannel);
}
handleStatusEffect(StatusEffect::getStatusEffect(oldMode, false), -1);
@@ -268,10 +268,10 @@ void ActorSprite::updateStatusEffect(int index, bool newStatus)
{
if (this == player_node)
{
- Mana::Event event(EVENT_UPDATESTATUSEFFECT);
+ Event event(Event::UpdateStatusEffect);
event.setInt("index", index);
event.setBool("newStatus", newStatus);
- event.trigger(CHANNEL_ACTORSPRITE);
+ event.trigger(Event::ActorSpriteChannel);
}
handleStatusEffect(StatusEffect::getStatusEffect(index, newStatus), index);
diff --git a/src/being.cpp b/src/being.cpp
index 9dbff7f4..5911b03c 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -108,8 +108,8 @@ Being::Being(int id, Type type, int subtype, Map *map):
setShowName(true);
updateColors();
- listen(CHANNEL_CONFIG);
- listen(CHANNEL_CHAT);
+ listen(Event::ConfigChannel);
+ listen(Event::ChatChannel);
}
Being::~Being()
@@ -1170,11 +1170,12 @@ void Being::talkTo()
Net::getNpcHandler()->talk(mId);
}
-void Being::event(Channels channel, const Mana::Event &event)
+void Being::event(Event::Channel channel, const Event &event)
{
- if (channel == CHANNEL_CHAT &&
- (event.getName() == EVENT_BEING || event.getName() == EVENT_PLAYER)
- && event.getInt("permissions") & PlayerRelation::SPEECH_FLOAT)
+ if (channel == Event::ChatChannel &&
+ (event.getType() == Event::Being
+ || event.getType() == Event::Player) &&
+ event.getInt("permissions") & PlayerRelation::SPEECH_FLOAT)
{
try
{
@@ -1183,11 +1184,11 @@ void Being::event(Channels channel, const Mana::Event &event)
setSpeech(event.getString("text"));
}
}
- catch (Mana::BadEvent badEvent)
+ catch (BadEvent badEvent)
{}
}
- else if (channel == CHANNEL_CONFIG &&
- event.getName() == EVENT_CONFIGOPTIONCHANGED)
+ else if (channel == Event::ConfigChannel &&
+ event.getType() == Event::ConfigOptionChanged)
{
if (getType() == PLAYER && event.getString("option") == "visiblenames")
{
diff --git a/src/being.h b/src/being.h
index 6831d5ad..a4e2e443 100644
--- a/src/being.h
+++ b/src/being.h
@@ -23,7 +23,7 @@
#define BEING_H
#include "actorsprite.h"
-#include "listener.h"
+#include "eventlistener.h"
#include "map.h"
#include "position.h"
#include "vector.h"
@@ -61,7 +61,7 @@ enum Gender
GENDER_UNSPECIFIED = 2
};
-class Being : public ActorSprite, public Mana::Listener
+class Being : public ActorSprite, public EventListener
{
public:
/**
@@ -446,7 +446,7 @@ class Being : public ActorSprite, public Mana::Listener
void talkTo();
- void event(Channels channel, const Mana::Event &event);
+ void event(Event::Channel channel, const Event &event);
void setMap(Map *map);
diff --git a/src/chatlog.h b/src/chatlog.h
index c359e953..df0af800 100644
--- a/src/chatlog.h
+++ b/src/chatlog.h
@@ -19,17 +19,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _CHATLOG_H
-#define _CHATLOG_H
+#ifndef CHATLOG_H
+#define CHATLOG_H
#include <fstream>
class ChatLogger
{
public:
- /**
- * Constructor.
- */
ChatLogger();
/**
diff --git a/src/client.cpp b/src/client.cpp
index 7dbbdc88..bac3684f 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -107,7 +107,6 @@ static const int defaultMusicVolume = 60;
// TODO: Get rid fo these globals
std::string errorMessage;
-ErrorListener errorListener;
LoginData loginData;
Configuration config; /**< XML file configuration reader */
@@ -124,11 +123,6 @@ ItemDB *itemDb;
Sound sound;
-void ErrorListener::action(const gcn::ActionEvent &)
-{
- Client::setState(STATE_CHOOSE_SERVER);
-}
-
volatile int tick_time; /**< Tick counter */
volatile int fps = 0; /**< Frames counted in the last second */
volatile int frame_count = 0; /**< Counts the frames during one second */
@@ -189,37 +183,6 @@ bool isDoubleClick(int selected)
return false;
}
-// This anonymous namespace hides whatever is inside from other modules.
-namespace {
-
-class AccountListener : public gcn::ActionListener
-{
-public:
- void action(const gcn::ActionEvent &)
- {
- Client::setState(STATE_CHAR_SELECT);
- }
-} accountListener;
-
-class LoginListener : public gcn::ActionListener
-{
-public:
- void action(const gcn::ActionEvent &)
- {
- Client::setState(STATE_LOGIN);
- }
-} loginListener;
-
-class ServerChoiceListener : public gcn::ActionListener
-{
-public:
- void action(const gcn::ActionEvent &)
- {
- Client::setState(STATE_CHOOSE_SERVER);
- }
-} serverChoiceListener;
-
-} // anonymous namespace
Client *Client::mInstance = 0;
@@ -232,6 +195,7 @@ Client::Client(const Options &options):
mSetupButton(0),
mState(STATE_CHOOSE_SERVER),
mOldState(STATE_START),
+ mStateAfterOkDialog(mState),
mIcon(0),
mLogicCounterId(0),
mSecondsCounterId(0),
@@ -471,12 +435,12 @@ Client::Client(const Options &options):
// Initialize frame limiting
SDL_initFramerate(&mFpsManager);
- listen(CHANNEL_CONFIG);
+ listen(Event::ConfigChannel);
//TODO: fix having to fake a option changed event
- Mana::Event fakeevent(EVENT_CONFIGOPTIONCHANGED);
+ Event fakeevent(Event::ConfigOptionChanged);
fakeevent.setString("option", "fpslimit");
- event(CHANNEL_CONFIG, fakeevent);
+ event(Event::ConfigChannel, fakeevent);
// Initialize PlayerInfo
PlayerInfo::init();
@@ -568,6 +532,8 @@ int Client::exec()
if (game)
game->logic();
+ sound.logic();
+
++lastTickTime;
}
@@ -634,10 +600,10 @@ int Client::exec()
if (mState != mOldState)
{
{
- Mana::Event event(EVENT_STATECHANGE);
+ Event event(Event::StateChange);
event.setInt("oldState", mOldState);
event.setInt("newState", mState);
- event.trigger(CHANNEL_CLIENT);
+ event.trigger(Event::ClientChannel);
}
if (mOldState == STATE_GAME)
@@ -797,7 +763,7 @@ int Client::exec()
paths.init("paths.xml", true);
paths.setDefaultValues(getPathsDefaults());
- Mana::Event::trigger(CHANNEL_CLIENT, EVENT_DBSLOADING);
+ Event::trigger(Event::ClientChannel, Event::LoadingDatabases);
// Load XML databases
ColorDB::load();
@@ -820,11 +786,9 @@ int Client::exec()
errorMessage =
_("This server is missing needed world data. "
"Please contact the administrator(s).");
- mCurrentDialog = new OkDialog(
- _("ItemDB: Error while loading " ITEMS_DB_FILE "!"),
- errorMessage);
- mCurrentDialog->addActionListener(&serverChoiceListener);
- mCurrentDialog = NULL; // OkDialog deletes itself
+ showOkDialog(_("ItemDB: Error while loading "
+ ITEMS_DB_FILE "!"), errorMessage,
+ STATE_CHOOSE_SERVER);
break;
}
Being::load(); // Hairstyles
@@ -914,16 +878,12 @@ int Client::exec()
case STATE_LOGIN_ERROR:
logger->log("State: LOGIN ERROR");
- mCurrentDialog = new OkDialog(_("Error"), errorMessage);
- mCurrentDialog->addActionListener(&loginListener);
- mCurrentDialog = NULL; // OkDialog deletes itself
+ showErrorDialog(errorMessage, STATE_LOGIN);
break;
case STATE_ACCOUNTCHANGE_ERROR:
logger->log("State: ACCOUNT CHANGE ERROR");
- mCurrentDialog = new OkDialog(_("Error"), errorMessage);
- mCurrentDialog->addActionListener(&accountListener);
- mCurrentDialog = NULL; // OkDialog deletes itself
+ showErrorDialog(errorMessage, STATE_CHAR_SELECT);
break;
case STATE_REGISTER_PREP:
@@ -957,10 +917,9 @@ int Client::exec()
case STATE_CHANGEPASSWORD_SUCCESS:
logger->log("State: CHANGE PASSWORD SUCCESS");
- mCurrentDialog = new OkDialog(_("Password Change"),
- _("Password changed successfully!"));
- mCurrentDialog->addActionListener(&accountListener);
- mCurrentDialog = NULL; // OkDialog deletes itself
+ showOkDialog(_("Password Change"),
+ _("Password changed successfully!"),
+ STATE_CHAR_SELECT);
loginData.password = loginData.newPassword;
loginData.newPassword = "";
break;
@@ -977,10 +936,9 @@ int Client::exec()
case STATE_CHANGEEMAIL_SUCCESS:
logger->log("State: CHANGE EMAIL SUCCESS");
- mCurrentDialog = new OkDialog(_("Email Change"),
- _("Email changed successfully!"));
- mCurrentDialog->addActionListener(&accountListener);
- mCurrentDialog = NULL; // OkDialog deletes itself
+ showOkDialog(_("Email Change"),
+ _("Email changed successfully!"),
+ STATE_CHAR_SELECT);
break;
case STATE_UNREGISTER:
@@ -998,12 +956,10 @@ int Client::exec()
logger->log("State: UNREGISTER SUCCESS");
Net::getLoginHandler()->disconnect();
- mCurrentDialog = new OkDialog(_("Unregister Successful"),
- _("Farewell, come back any time..."));
+ showOkDialog(_("Unregister Successful"),
+ _("Farewell, come back any time..."),
+ STATE_CHOOSE_SERVER);
loginData.clear();
- //The errorlistener sets the state to STATE_CHOOSE_SERVER
- mCurrentDialog->addActionListener(&errorListener);
- mCurrentDialog = NULL; // OkDialog deletes itself
break;
case STATE_SWITCH_SERVER:
@@ -1056,9 +1012,7 @@ int Client::exec()
case STATE_ERROR:
logger->log("State: ERROR");
logger->log("Error: %s", errorMessage.c_str());
- mCurrentDialog = new OkDialog(_("Error"), errorMessage);
- mCurrentDialog->addActionListener(&errorListener);
- mCurrentDialog = NULL; // OkDialog deletes itself
+ showErrorDialog(errorMessage, STATE_CHOOSE_SERVER);
Net::getGameHandler()->disconnect();
break;
@@ -1072,10 +1026,24 @@ int Client::exec()
return 0;
}
-void Client::event(Channels channel, const Mana::Event &event)
+void Client::showOkDialog(const std::string &title,
+ const std::string &message,
+ State state)
+{
+ OkDialog *okDialog = new OkDialog(title, message);
+ okDialog->addActionListener(this);
+ mStateAfterOkDialog = state;
+}
+
+void Client::showErrorDialog(const std::string &message, State state)
+{
+ showOkDialog(_("Error"), message, state);
+}
+
+void Client::event(Event::Channel channel, const Event &event)
{
- if (channel == CHANNEL_CONFIG &&
- event.getName() == EVENT_CONFIGOPTIONCHANGED &&
+ if (channel == Event::ConfigChannel &&
+ event.getType() == Event::ConfigOptionChanged &&
event.getString("option") == "fpslimit")
{
const int fpsLimit = config.getIntValue("fpslimit");
@@ -1099,6 +1067,10 @@ void Client::action(const gcn::ActionEvent &event)
if (window->isVisible())
window->requestMoveToTop();
}
+
+ // If this came from the OkDialog used by showOkDialog
+ if (event.getId() == "ok")
+ mState = mStateAfterOkDialog;
}
void Client::initRootDir()
diff --git a/src/client.h b/src/client.h
index 8d2c23d5..4a0bc750 100644
--- a/src/client.h
+++ b/src/client.h
@@ -22,7 +22,7 @@
#ifndef CLIENT_H
#define CLIENT_H
-#include "listener.h"
+#include "eventlistener.h"
#include "net/serverinfo.h"
@@ -52,14 +52,7 @@ extern volatile int fps;
extern volatile int tick_time;
extern volatile int cur_time;
-class ErrorListener : public gcn::ActionListener
-{
- public:
- void action(const gcn::ActionEvent &event);
-};
-
extern std::string errorMessage;
-extern ErrorListener errorListener;
extern LoginData loginData;
/**
@@ -119,7 +112,7 @@ enum State {
* The core part of the client. This class initializes all subsystems, runs
* the event loop, and shuts everything down again.
*/
-class Client : public Mana::Listener, public gcn::ActionListener
+class Client : public EventListener, public gcn::ActionListener
{
public:
/**
@@ -167,6 +160,20 @@ public:
int exec();
+ /**
+ * Pops up an OkDialog with the given \a title and \a message, and
+ * switches to the given \a state when Ok is pressed.
+ */
+ void showOkDialog(const std::string &title,
+ const std::string &message,
+ State state);
+
+ /**
+ * Pops up an error dialog with the given \a message, and switches to the
+ * given \a state when Ok is pressed.
+ */
+ void showErrorDialog(const std::string &message, State state);
+
static void setState(State state)
{ instance()->mState = state; }
@@ -185,7 +192,7 @@ public:
static const std::string &getScreenshotDirectory()
{ return instance()->mScreenshotDir; }
- void event(Channels channel, const Mana::Event &event);
+ void event(Event::Channel channel, const Event &event);
void action(const gcn::ActionEvent &event);
private:
@@ -218,6 +225,7 @@ private:
State mState;
State mOldState;
+ State mStateAfterOkDialog;
SDL_Surface *mIcon;
diff --git a/src/commandhandler.h b/src/commandhandler.h
index c14305e1..97055318 100644
--- a/src/commandhandler.h
+++ b/src/commandhandler.h
@@ -37,14 +37,8 @@ extern ChatTab *localChatTab;
class CommandHandler
{
public:
- /**
- * Constructor
- */
CommandHandler();
- /**
- * Destructor
- */
~CommandHandler() {}
/**
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index ec45825f..e88a518a 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -285,6 +285,11 @@ size_t CompoundSprite::getFrameCount(size_t layer)
void CompoundSprite::redraw() const
{
+ // TODO Detect image size needed to avoid cutting off large sprites, and
+ // reduce memory for smaller ones
+ mNeedsRedraw = false;
+ return;
+
// TODO OpenGL support
if (Image::getLoadAsOpenGL())
{
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 44fb6e2e..44621eb3 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -38,9 +38,9 @@ void Configuration::setValue(const std::string &key, const std::string &value)
ConfigurationObject::setValue(key, value);
// Notify listeners
- Mana::Event event(EVENT_CONFIGOPTIONCHANGED);
+ Event event(Event::ConfigOptionChanged);
event.setString("option", key);
- event.trigger(CHANNEL_CONFIG);
+ event.trigger(Event::ConfigChannel);
}
std::string ConfigurationObject::getValue(const std::string &key,
@@ -125,8 +125,8 @@ void Configuration::setDefaultValues(DefaultsData *defaultsData)
mDefaultsData = defaultsData;
}
-Mana::VariableData* Configuration::getDefault(const std::string &key,
- Mana::VariableData::DataType type
+VariableData* Configuration::getDefault(const std::string &key,
+ VariableData::DataType type
) const
{
if (mDefaultsData)
@@ -153,9 +153,9 @@ int Configuration::getIntValue(const std::string &key) const
Options::const_iterator iter = mOptions.find(key);
if (iter == mOptions.end())
{
- Mana::VariableData* vd = getDefault(key, Mana::VariableData::DATA_INT);
+ VariableData* vd = getDefault(key, VariableData::DATA_INT);
if (vd)
- defaultValue = ((Mana::IntData*)vd)->getData();
+ defaultValue = ((IntData*)vd)->getData();
}
else
{
@@ -170,11 +170,11 @@ std::string Configuration::getStringValue(const std::string &key) const
Options::const_iterator iter = mOptions.find(key);
if (iter == mOptions.end())
{
- Mana::VariableData* vd = getDefault(key,
- Mana::VariableData::DATA_STRING);
+ VariableData* vd = getDefault(key,
+ VariableData::DATA_STRING);
if (vd)
- defaultValue = ((Mana::StringData*)vd)->getData();
+ defaultValue = ((StringData*)vd)->getData();
}
else
{
@@ -190,11 +190,11 @@ float Configuration::getFloatValue(const std::string &key) const
Options::const_iterator iter = mOptions.find(key);
if (iter == mOptions.end())
{
- Mana::VariableData* vd = getDefault(key,
- Mana::VariableData::DATA_FLOAT);
+ VariableData* vd = getDefault(key,
+ VariableData::DATA_FLOAT);
if (vd)
- defaultValue = ((Mana::FloatData*)vd)->getData();
+ defaultValue = ((FloatData*)vd)->getData();
}
else
{
@@ -209,11 +209,11 @@ bool Configuration::getBoolValue(const std::string &key) const
Options::const_iterator iter = mOptions.find(key);
if (iter == mOptions.end())
{
- Mana::VariableData* vd = getDefault(key,
- Mana::VariableData::DATA_BOOL);
+ VariableData* vd = getDefault(key,
+ VariableData::DATA_BOOL);
if (vd)
- defaultValue = ((Mana::BoolData*)vd)->getData();
+ defaultValue = ((BoolData*)vd)->getData();
}
else
{
diff --git a/src/configuration.h b/src/configuration.h
index a46b0718..bf8cffde 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -247,8 +247,8 @@ class Configuration : public ConfigurationObject
bool getBoolValue(const std::string &key) const;
- Mana::VariableData* getDefault(const std::string &key,
- Mana::VariableData::DataType type) const;
+ VariableData* getDefault(const std::string &key,
+ VariableData::DataType type) const;
private:
/**
* Clean up the default values member.
diff --git a/src/defaults.cpp b/src/defaults.cpp
index e0e48d60..54e39c1f 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -26,8 +26,6 @@
#include <stdlib.h>
-using namespace Mana;
-
VariableData* createData(int defData)
{
return new IntData(defData);
diff --git a/src/defaults.h b/src/defaults.h
index b9dfa511..34a5402c 100644
--- a/src/defaults.h
+++ b/src/defaults.h
@@ -25,7 +25,7 @@
#include <string>
#include "variabledata.h"
-typedef std::map<std::string, Mana::VariableData*> DefaultsData;
+typedef std::map<std::string, VariableData*> DefaultsData;
DefaultsData* getConfigDefaults();
DefaultsData* getBrandingDefaults();
diff --git a/src/emoteshortcut.h b/src/emoteshortcut.h
index a95bb264..ea1b73c8 100644
--- a/src/emoteshortcut.h
+++ b/src/emoteshortcut.h
@@ -29,14 +29,8 @@
class EmoteShortcut
{
public:
- /**
- * Constructor.
- */
EmoteShortcut();
- /**
- * Destructor.
- */
~EmoteShortcut();
/**
diff --git a/src/equipment.h b/src/equipment.h
index 0aa10fb0..2ef970ea 100644
--- a/src/equipment.h
+++ b/src/equipment.h
@@ -29,14 +29,8 @@ class Item;
class Equipment
{
public:
- /**
- * Constructor.
- */
Equipment(): mBackend(0) {}
- /**
- * Destructor.
- */
~Equipment() { mBackend = 0; }
class Backend {
diff --git a/src/event.cpp b/src/event.cpp
index c8de2ffd..18091643 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -20,13 +20,10 @@
#include "event.h"
-#include "listener.h"
+#include "eventlistener.h"
#include "variabledata.h"
-namespace Mana
-{
-
-ListenMap Event::mBindings;
+Event::ListenMap Event::mBindings;
Event::~Event()
{
@@ -215,7 +212,7 @@ bool Event::hasActor(const std::string &key) const
// Triggers
-void Event::trigger(Channels channel, const Event &event)
+void Event::trigger(Channel channel, const Event &event)
{
ListenMap::iterator it = mBindings.find(channel);
@@ -232,17 +229,17 @@ void Event::trigger(Channels channel, const Event &event)
}
}
-void Event::bind(Listener *listener, Channels channel)
+void Event::bind(EventListener *listener, Channel channel)
{
mBindings[channel].insert(listener);
}
-void Event::unbind(Listener *listener, Channels channel)
+void Event::unbind(EventListener *listener, Channel channel)
{
mBindings[channel].erase(listener);
}
-void Event::remove(Listener *listener)
+void Event::remove(EventListener *listener)
{
ListenMap::iterator it = mBindings.begin();
while (it != mBindings.end())
@@ -251,5 +248,3 @@ void Event::remove(Listener *listener)
it++;
}
}
-
-} // namespace Mana
diff --git a/src/event.h b/src/event.h
index 758d6b34..c4dcfc9b 100644
--- a/src/event.h
+++ b/src/event.h
@@ -28,80 +28,6 @@
class ActorSprite;
class Item;
-enum Channels
-{
- CHANNEL_ACTORSPRITE,
- CHANNEL_ATTRIBUTES,
- CHANNEL_BUYSELL,
- CHANNEL_CHAT,
- CHANNEL_CLIENT,
- CHANNEL_CONFIG,
- CHANNEL_GAME,
- CHANNEL_ITEM,
- CHANNEL_NOTICES,
- CHANNEL_NPC,
- CHANNEL_STATUS,
- CHANNEL_STORAGE
-};
-
-enum Events
-{
- EVENT_ANNOUNCEMENT,
- EVENT_BEING,
- EVENT_CLOSE,
- EVENT_CLOSEALL,
- EVENT_CLOSESENT,
- EVENT_CONFIGOPTIONCHANGED,
- EVENT_CONSTRUCTED,
- EVENT_DBSLOADING,
- EVENT_DESTROYED,
- EVENT_DESTRUCTED,
- EVENT_DESTRUCTING,
- EVENT_DOCLOSEINVENTORY,
- EVENT_DODROP,
- EVENT_DOEQUIP,
- EVENT_DOMOVE,
- EVENT_DOSPLIT,
- EVENT_DOUNEQUIP,
- EVENT_DOUSE,
- EVENT_END,
- EVENT_ENGINESINITALIZED,
- EVENT_ENGINESINITALIZING,
- EVENT_GUIWINDOWSLOADED,
- EVENT_GUIWINDOWSLOADING,
- EVENT_GUIWINDOWSUNLOADED,
- EVENT_GUIWINDOWSUNLOADING,
- EVENT_INTEGERINPUT,
- EVENT_INTEGERINPUTSENT,
- EVENT_MAPLOADED,
- EVENT_MENU,
- EVENT_MENUSENT,
- EVENT_MESSAGE,
- EVENT_NEXT,
- EVENT_NEXTSENT,
- EVENT_NPCCOUNT,
- EVENT_PLAYER,
- EVENT_POST,
- EVENT_POSTCOUNT,
- EVENT_SENDLETTERSENT,
- EVENT_SERVERNOTICE,
- EVENT_STATECHANGE,
- EVENT_STORAGECOUNT,
- EVENT_STRINGINPUT,
- EVENT_STRINGINPUTSENT,
- EVENT_STUN,
- EVENT_TALKSENT,
- EVENT_TRADING,
- EVENT_UPDATEATTRIBUTE,
- EVENT_UPDATESTAT,
- EVENT_UPDATESTATUSEFFECT,
- EVENT_WHISPER,
- EVENT_WHISPERERROR
-};
-
-namespace Mana
-{
-
// Possible exception that can be thrown
enum BadEvent {
BAD_KEY,
@@ -109,35 +35,99 @@ enum BadEvent {
KEY_ALREADY_EXISTS
};
-class Listener;
-
-typedef std::set<Listener *> ListenerSet;
-typedef std::map<Channels, ListenerSet > ListenMap;
+class EventListener;
+typedef std::set<EventListener *> ListenerSet;
class VariableData;
typedef std::map<std::string, VariableData *> VariableMap;
-#define SERVER_NOTICE(message) { \
-Mana::Event event(EVENT_SERVERNOTICE); \
-event.setString("message", message); \
-event.trigger(CHANNEL_NOTICES, event); }
-
class Event
{
public:
+ enum Channel
+ {
+ ActorSpriteChannel,
+ AttributesChannel,
+ BuySellChannel,
+ ChatChannel,
+ ClientChannel,
+ ConfigChannel,
+ GameChannel,
+ ItemChannel,
+ NoticesChannel,
+ NpcChannel,
+ StatusChannel,
+ StorageChannel
+ };
+
+ enum Type
+ {
+ Announcement,
+ Being,
+ Close,
+ CloseAll,
+ CloseSent,
+ ConfigOptionChanged,
+ Constructed,
+ LoadingDatabases,
+ Destroyed,
+ Destructed,
+ Destructing,
+ DoCloseInventory,
+ DoDrop,
+ DoEquip,
+ DoMove,
+ DoSplit,
+ DoUnequip,
+ DoUse,
+ End,
+ EnginesInitialized,
+ EnginesInitializing,
+ GuiWindowsLoaded,
+ GuiWindowsLoading,
+ GuiWindowsUnloaded,
+ GuiWindowsUnloading,
+ IntegerInput,
+ IntegerInputSent,
+ MapLoaded,
+ Menu,
+ MenuSent,
+ Message,
+ Next,
+ NextSent,
+ NpcCount,
+ Player,
+ Post,
+ PostCount,
+ SendLetterSent,
+ ServerNotice,
+ StateChange,
+ StorageCount,
+ StringInput,
+ StringInputSent,
+ Stun,
+ TalkSent,
+ Trading,
+ UpdateAttribute,
+ UpdateStat,
+ UpdateStatusEffect,
+ Whisper,
+ WhisperError
+ };
+
/**
* Makes an event with the given name.
*/
- Event(Events name)
- { mEventName = name; }
+ Event(Type type)
+ { mType = type; }
~Event();
/**
* Returns the name of the event.
*/
- Events getName() const
- { return mEventName; }
+ Type getType() const
+ { return mType; }
// Integers
@@ -291,49 +281,52 @@ public:
/**
* Sends this event to all classes listening to the given channel.
*/
- inline void trigger(Channels channel) const
+ inline void trigger(Channel channel) const
{ trigger(channel, *this); }
/**
* Sends the given event to all classes listening to the given channel.
*/
- static void trigger(Channels channel, const Event &event);
+ static void trigger(Channel channel, const Event &event);
/**
* Sends an empty event with the given name to all classes listening to the
* given channel.
*/
- static inline void trigger(Channels channel, Events name)
- { trigger(channel, Mana::Event(name)); }
+ static inline void trigger(Channel channel, Type type)
+ { trigger(channel, Event(type)); }
protected:
- friend class Listener;
+ friend class EventListener;
/**
* Binds the given listener to the given channel. The listener will receive
* all events triggered on the channel.
*/
- static void bind(Listener *listener, Channels channel);
+ static void bind(EventListener *listener, Channel channel);
/**
* Unbinds the given listener from the given channel. The listener will no
* longer receive any events from the channel.
*/
- static void unbind(Listener *listener, Channels channel);
+ static void unbind(EventListener *listener, Channel channel);
/**
* Unbinds the given listener from all channels.
*/
- static void remove(Listener *listener);
+ static void remove(EventListener *listener);
private:
+ typedef std::map<Channel, ListenerSet > ListenMap;
static ListenMap mBindings;
- Events mEventName;
-
+ Type mType;
VariableMap mData;
};
-} // namespace Mana
+#define SERVER_NOTICE(message) { \
+Event event(Event::ServerNotice); \
+event.setString("message", message); \
+event.trigger(Event::NoticesChannel, event); }
-#endif
+#endif // EVENT_H
diff --git a/src/listener.cpp b/src/eventlistener.cpp
index f9acac95..967ad3c1 100644
--- a/src/listener.cpp
+++ b/src/eventlistener.cpp
@@ -18,26 +18,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "listener.h"
+#include "eventlistener.h"
#include "event.h"
-namespace Mana
-{
-
-Listener::~Listener()
+EventListener::~EventListener()
{
Event::remove(this);
}
-void Listener::listen(Channels channel)
+void EventListener::listen(Event::Channel channel)
{
Event::bind(this, channel);
}
-void Listener::ignore(Channels channel)
+void EventListener::ignore(Event::Channel channel)
{
Event::unbind(this, channel);
}
-
-} // namespace Mana
diff --git a/src/listener.h b/src/eventlistener.h
index 84b613eb..0d998829 100644
--- a/src/listener.h
+++ b/src/eventlistener.h
@@ -18,28 +18,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef LISTENER_H
-#define LISTENER_H
+#ifndef EVENTLISTENER_H
+#define EVENTLISTENER_H
#include "event.h"
#include <string>
-namespace Mana
-{
-
-class Listener
+class EventListener
{
public:
- virtual ~Listener();
+ virtual ~EventListener();
- void listen(Channels channel);
+ void listen(Event::Channel channel);
- void ignore(Channels channel);
+ void ignore(Event::Channel channel);
- virtual void event(Channels channel, const Event &event) = 0;
+ virtual void event(Event::Channel channel, const Event &event) = 0;
};
-} // namespace Mana
-
-#endif
+#endif // EVENTLISTENER_H
diff --git a/src/flooritem.h b/src/flooritem.h
index 0bcc380f..37fed4b2 100644
--- a/src/flooritem.h
+++ b/src/flooritem.h
@@ -70,4 +70,4 @@ class FloorItem : public ActorSprite
int mX, mY;
};
-#endif
+#endif // FLOORITEM_H
diff --git a/src/game.cpp b/src/game.cpp
index c54f7abe..bcfd9ac2 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -96,7 +96,6 @@ Joystick *joystick = NULL;
OkDialog *weightNotice = NULL;
OkDialog *deathNotice = NULL;
QuitDialog *quitDialog = NULL;
-OkDialog *disconnectedDialog = NULL;
ChatWindow *chatWindow;
StatusWindow *statusWindow;
@@ -128,7 +127,7 @@ ChatTab *localChatTab = NULL;
*/
static void initEngines()
{
- Mana::Event::trigger(CHANNEL_GAME, EVENT_ENGINESINITALIZING);
+ Event::trigger(Event::GameChannel, Event::EnginesInitializing);
actorSpriteManager = new ActorSpriteManager;
commandHandler = new CommandHandler;
@@ -138,7 +137,7 @@ static void initEngines()
particleEngine = new Particle(NULL);
particleEngine->setupEngine();
- Mana::Event::trigger(CHANNEL_GAME, EVENT_ENGINESINITALIZED);
+ Event::trigger(Event::GameChannel, Event::EnginesInitialized);
}
/**
@@ -146,7 +145,7 @@ static void initEngines()
*/
static void createGuiWindows()
{
- Mana::Event::trigger(CHANNEL_GAME, EVENT_GUIWINDOWSLOADING);
+ Event::trigger(Event::GameChannel, Event::GuiWindowsLoading);
setupWindow->clearWindowsForReset();
@@ -183,7 +182,7 @@ static void createGuiWindows()
NpcDialog::setup();
- Mana::Event::trigger(CHANNEL_GAME, EVENT_GUIWINDOWSLOADED);
+ Event::trigger(Event::GameChannel, Event::GuiWindowsLoaded);
}
#define del_0(X) { delete X; X = 0; }
@@ -193,7 +192,7 @@ static void createGuiWindows()
*/
static void destroyGuiWindows()
{
- Mana::Event::trigger(CHANNEL_GAME, EVENT_GUIWINDOWSUNLOADING);
+ Event::trigger(Event::GameChannel, Event::GuiWindowsUnloading);
del_0(localChatTab) // Need to do this first, so it can remove itself
del_0(chatWindow)
@@ -212,9 +211,9 @@ static void destroyGuiWindows()
del_0(specialsWindow)
del_0(socialWindow)
- Mana::Event::trigger(CHANNEL_NPC, EVENT_CLOSEALL); // Cleanup remaining NPC dialogs
+ Event::trigger(Event::NpcChannel, Event::CloseAll); // Cleanup remaining NPC dialogs
- Mana::Event::trigger(CHANNEL_GAME, EVENT_GUIWINDOWSUNLOADED);
+ Event::trigger(Event::GameChannel, Event::GuiWindowsUnloaded);
}
Game *Game::mInstance = 0;
@@ -226,8 +225,6 @@ Game::Game():
assert(!mInstance);
mInstance = this;
- disconnectedDialog = NULL;
-
// Create the viewport
viewport = new Viewport;
viewport->setDimension(gcn::Rectangle(0, 0, graphics->getWidth(),
@@ -266,12 +263,12 @@ Game::Game():
setupWindow->setInGame(true);
- Mana::Event::trigger(CHANNEL_GAME, EVENT_CONSTRUCTED);
+ Event::trigger(Event::GameChannel, Event::Constructed);
}
Game::~Game()
{
- Mana::Event::trigger(CHANNEL_GAME, EVENT_DESTRUCTING);
+ Event::trigger(Event::GameChannel, Event::Destructing);
delete mWindowMenu;
@@ -289,7 +286,7 @@ Game::~Game()
mInstance = 0;
- Mana::Event::trigger(CHANNEL_GAME, EVENT_DESTRUCTED);
+ Event::trigger(Event::GameChannel, Event::Destructed);
}
static bool saveScreenshot()
@@ -386,14 +383,9 @@ void Game::logic()
return; // Disconnect gets handled by STATE_ERROR
errorMessage = _("The connection to the server was lost.");
-
- if (!disconnectedDialog)
- {
- disconnectedDialog = new OkDialog(_("Network Error"),
- errorMessage);
- disconnectedDialog->addActionListener(&errorListener);
- disconnectedDialog->requestMoveToTop();
- }
+ Client::instance()->showOkDialog(_("Network Error"),
+ errorMessage,
+ STATE_CHOOSE_SERVER);
}
}
@@ -638,7 +630,7 @@ void Game::handleInput()
break;
}
if (keyboard.isEnabled() && !chatWindow->isInputFocused() &&
- !NpcDialog::isAnyInputFocused())
+ !NpcDialog::isAnyInputFocused() && !InventoryWindow::isAnyInputFocused())
{
const int tKey = keyboard.getKeyIndex(event.key.keysym.sym);
@@ -991,15 +983,15 @@ void Game::changeMap(const std::string &mapPath)
if (newMusic != oldMusic)
{
if (newMusic.empty())
- sound.stopMusic();
+ sound.fadeOutMusic();
else
- sound.playMusic(newMusic);
+ sound.fadeOutAndPlayMusic(newMusic);
}
delete mCurrentMap;
mCurrentMap = newMap;
- Mana::Event event(EVENT_MAPLOADED);
+ Event event(Event::MapLoaded);
event.setString("mapPath", mapPath);
- event.trigger(CHANNEL_GAME);
+ event.trigger(Event::GameChannel);
}
diff --git a/src/graphics.h b/src/graphics.h
index 344c31c3..4fec02f8 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -78,14 +78,8 @@ class Graphics : public gcn::SDLGraphics
BLIT_GFX
};
- /**
- * Constructor.
- */
Graphics();
- /**
- * Destructor.
- */
virtual ~Graphics();
/**
diff --git a/src/gui/beingpopup.h b/src/gui/beingpopup.h
index 514a6e7e..7058d783 100644
--- a/src/gui/beingpopup.h
+++ b/src/gui/beingpopup.h
@@ -32,14 +32,8 @@ class Label;
class BeingPopup : public Popup
{
public:
- /**
- * Constructor. Initializes the being popup.
- */
BeingPopup();
- /**
- * Destructor. Cleans up the being popup on deletion.
- */
~BeingPopup();
/**
diff --git a/src/gui/buy.h b/src/gui/buy.h
index c3cb3229..68d318eb 100644
--- a/src/gui/buy.h
+++ b/src/gui/buy.h
@@ -42,16 +42,8 @@ class BuyDialog : public Window, public gcn::ActionListener,
public gcn::SelectionListener
{
public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
BuyDialog(int npcId);
- /**
- * Destructor
- */
~BuyDialog();
/**
diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h
index 84838d15..04fca908 100644
--- a/src/gui/changeemaildialog.h
+++ b/src/gui/changeemaildialog.h
@@ -38,16 +38,8 @@ class WrongDataNoticeListener;
class ChangeEmailDialog : public Window, public gcn::ActionListener
{
public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
ChangeEmailDialog(LoginData *loginData);
- /**
- * Destructor.
- */
~ChangeEmailDialog();
/**
diff --git a/src/gui/changepassworddialog.h b/src/gui/changepassworddialog.h
index d356a5df..0b28a11d 100644
--- a/src/gui/changepassworddialog.h
+++ b/src/gui/changepassworddialog.h
@@ -38,16 +38,8 @@ class WrongDataNoticeListener;
class ChangePasswordDialog : public Window, public gcn::ActionListener
{
public:
- /**
- * Constructor
- *
- * @see Window::Window
- */
ChangePasswordDialog(LoginData *loginData);
- /**
- * Destructor
- */
~ChangePasswordDialog();
/**
diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h
index d6b6d390..ff59b30a 100644
--- a/src/gui/charcreatedialog.h
+++ b/src/gui/charcreatedialog.h
@@ -45,14 +45,8 @@ class PlayerBox;
class CharCreateDialog : public Window, public gcn::ActionListener
{
public:
- /**
- * Constructor.
- */
CharCreateDialog(CharSelectDialog *parent, int slot);
- /**
- * Destructor.
- */
~CharCreateDialog();
void action(const gcn::ActionEvent &event);
diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h
index 455ec2df..e180b2c2 100644
--- a/src/gui/charselectdialog.h
+++ b/src/gui/charselectdialog.h
@@ -50,9 +50,6 @@ class CharSelectDialog : public Window, public gcn::ActionListener,
friend class CharDeleteConfirm;
friend class Net::CharHandler;
- /**
- * Constructor.
- */
CharSelectDialog(LoginData *loginData);
~CharSelectDialog();
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 2ac5100d..491542a8 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -90,8 +90,8 @@ ChatWindow::ChatWindow():
mAutoComplete(new ChatAutoComplete),
mTmpVisible(false)
{
- listen(CHANNEL_CHAT);
- listen(CHANNEL_NOTICES);
+ listen(Event::ChatChannel);
+ listen(Event::NoticesChannel);
setWindowName("Chat");
@@ -375,33 +375,33 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event)
}
}
-void ChatWindow::event(Channels channel, const Mana::Event &event)
+void ChatWindow::event(Event::Channel channel, const Event &event)
{
- if (channel == CHANNEL_NOTICES)
+ if (channel == Event::NoticesChannel)
{
- if (event.getName() == EVENT_SERVERNOTICE)
+ if (event.getType() == Event::ServerNotice)
localChatTab->chatLog(event.getString("message"), BY_SERVER);
}
- else if (channel == CHANNEL_CHAT)
+ else if (channel == Event::ChatChannel)
{
- if (event.getName() == EVENT_WHISPER)
+ if (event.getType() == Event::Whisper)
{
whisper(event.getString("nick"), event.getString("message"));
}
- else if (event.getName() == EVENT_WHISPERERROR)
+ else if (event.getType() == Event::WhisperError)
{
whisper(event.getString("nick"),
event.getString("error"), BY_SERVER);
}
- else if (event.getName() == EVENT_PLAYER)
+ else if (event.getType() == Event::Player)
{
localChatTab->chatLog(event.getString("message"), BY_PLAYER);
}
- else if (event.getName() == EVENT_ANNOUNCEMENT)
+ else if (event.getType() == Event::Announcement)
{
localChatTab->chatLog(event.getString("message"), BY_GM);
}
- else if (event.getName() == EVENT_BEING)
+ else if (event.getType() == Event::Being)
{
if (event.getInt("permissions") & PlayerRelation::SPEECH_LOG)
localChatTab->chatLog(event.getString("message"), BY_OTHER);
diff --git a/src/gui/chat.h b/src/gui/chat.h
index f546502c..c6acf532 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -22,7 +22,7 @@
#ifndef CHAT_H
#define CHAT_H
-#include "listener.h"
+#include "eventlistener.h"
#include "gui/widgets/window.h"
#include "gui/widgets/textfield.h"
@@ -77,12 +77,9 @@ struct CHATLOG
*/
class ChatWindow : public Window,
public gcn::ActionListener,
- public Mana::Listener
+ public EventListener
{
public:
- /**
- * Constructor.
- */
ChatWindow();
/**
@@ -158,7 +155,7 @@ class ChatWindow : public Window,
void mousePressed(gcn::MouseEvent &event);
void mouseDragged(gcn::MouseEvent &event);
- void event(Channels channel, const Mana::Event &event);
+ void event(Event::Channel channel, const Event &event);
/**
* Scrolls the chat window
diff --git a/src/gui/confirmdialog.h b/src/gui/confirmdialog.h
index 074b970d..49e9c127 100644
--- a/src/gui/confirmdialog.h
+++ b/src/gui/confirmdialog.h
@@ -36,11 +36,6 @@ class TextBox;
class ConfirmDialog : public Window, public gcn::ActionListener
{
public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
ConfirmDialog(const std::string &title, const std::string &msg,
Window *parent = NULL);
diff --git a/src/gui/debugwindow.h b/src/gui/debugwindow.h
index 53828422..6fd34420 100644
--- a/src/gui/debugwindow.h
+++ b/src/gui/debugwindow.h
@@ -34,9 +34,6 @@ class Label;
class DebugWindow : public Window
{
public:
- /**
- * Constructor.
- */
DebugWindow();
/**
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 02fc2a96..339cf717 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -113,7 +113,7 @@ void EquipmentWindow::action(const gcn::ActionEvent &event)
if (event.getId() == "unequip" && mSelected > -1)
{
Item *item = mEquipment->getEquipment(mSelected);
- item->doEvent(EVENT_DOUNEQUIP);
+ item->doEvent(Event::DoUnequip);
setSelected(-1);
}
}
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index a0fa6acb..5ba15ae3 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -40,14 +40,8 @@ class ItemPopup;
class EquipmentWindow : public Window, public gcn::ActionListener
{
public:
- /**
- * Constructor.
- */
EquipmentWindow(Equipment *equipment);
- /**
- * Destructor.
- */
~EquipmentWindow();
/**
@@ -91,25 +85,17 @@ namespace TmwAthena {
class TaEquipmentWindow : public EquipmentWindow
{
public:
- /**
- * Constructor.
- */
TaEquipmentWindow(Equipment *equipment);
-
- /**
- * Destructor.
- */
~TaEquipmentWindow();
/**
* Draws the equipment window using TmwAthena routine.
*/
void draw(gcn::Graphics *graphics);
-
};
-}; // namespace TmwAthena
+} // namespace TmwAthena
extern EquipmentWindow *equipmentWindow;
-#endif
+#endif // EQUIPMENTWINDOW_H
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index c0d1babf..d1c18ab2 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -30,7 +30,7 @@
#include "gui/widgets/windowcontainer.h"
#include "configuration.h"
-#include "listener.h"
+#include "eventlistener.h"
#include "graphics.h"
#include "log.h"
@@ -50,18 +50,18 @@ SDLInput *guiInput = 0;
// Bolded font
gcn::Font *boldFont = 0;
-class GuiConfigListener : public Mana::Listener
+class GuiConfigListener : public EventListener
{
public:
GuiConfigListener(Gui *g):
mGui(g)
{}
- void event(Channels channel, const Mana::Event &event)
+ void event(Event::Channel channel, const Event &event)
{
- if (channel == CHANNEL_CONFIG)
+ if (channel == Event::ConfigChannel)
{
- if (event.getName() == EVENT_CONFIGOPTIONCHANGED &&
+ if (event.getType() == Event::ConfigOptionChanged &&
event.getString("option") == "customcursor")
{
bool bCustomCursor = config.getBoolValue("customcursor");
@@ -141,7 +141,7 @@ Gui::Gui(Graphics *graphics):
// Initialize mouse cursor and listen for changes to the option
setUseCustomCursor(config.getBoolValue("customcursor"));
mConfigListener = new GuiConfigListener(this);
- mConfigListener->listen(CHANNEL_CONFIG);
+ mConfigListener->listen(Event::ConfigChannel);
}
Gui::~Gui()
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 112abcee..fa7102fe 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -47,14 +47,8 @@ class SDLInput;
class Gui : public gcn::Gui
{
public:
- /**
- * Constructor.
- */
Gui(Graphics *screen);
- /**
- * Destructor.
- */
~Gui();
/**
diff --git a/src/gui/help.h b/src/gui/help.h
index 581a971e..add49ced 100644
--- a/src/gui/help.h
+++ b/src/gui/help.h
@@ -37,9 +37,6 @@ class HelpWindow : public Window, public LinkHandler,
public gcn::ActionListener
{
public:
- /**
- * Constructor.
- */
HelpWindow();
/**
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 31743c57..4ebcce8b 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -58,9 +58,10 @@ InventoryWindow::WindowList InventoryWindow::instances;
InventoryWindow::InventoryWindow(Inventory *inventory):
Window(inventory->isMainInventory() ? _("Inventory") : _("Storage")),
mInventory(inventory),
+ mFilterText(new TextField),
mSplit(false)
{
- listen(CHANNEL_ATTRIBUTES);
+ listen(Event::AttributesChannel);
setWindowName(isMainInventory() ? "Inventory" : "Storage");
setupWindow->registerWindowForReset(this);
@@ -73,6 +74,9 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
setMinHeight(179);
addKeyListener(this);
+ mFilterText->setWidth(150);
+ mFilterText->addKeyListener(this);
+
mItems = new ItemContainer(mInventory);
mItems->addSelectionListener(this);
@@ -80,6 +84,7 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mSlotsLabel = new Label(_("Slots:"));
+ mFilterLabel = new Label(_("Search:"));
mSlotsBar = new ProgressBar(0.0f, 100, 20, Theme::PROG_INVY_SLOTS);
if (isMainInventory())
@@ -109,13 +114,15 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
place(0, 0, mWeightLabel).setPadding(3);
place(1, 0, mWeightBar, 3);
place(4, 0, mSlotsLabel).setPadding(3);
- place(5, 0, mSlotsBar, 2);
- place(0, 1, invenScroll, 7).setPadding(3);
- place(0, 2, mUseButton);
- place(1, 2, mEquipButton);
- place(2, 2, mDropButton);
- place(3, 2, mSplitButton);
- place(6, 2, mOutfitButton);
+ place(5, 0, mSlotsBar, 3);
+ place(0, 1, mFilterLabel, 4);
+ place(1, 1, mFilterText, 4);
+ place(0, 2, invenScroll, 8).setPadding(3);
+ place(0, 3, mUseButton);
+ place(1, 3, mEquipButton);
+ place(2, 3, mDropButton);
+ place(3, 3, mSplitButton);
+ place(7, 3, mOutfitButton);
updateWeight();
}
@@ -126,13 +133,15 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
place(0, 0, mSlotsLabel).setPadding(3);
place(1, 0, mSlotsBar, 3);
- place(0, 1, invenScroll, 4, 4);
- place(0, 5, mStoreButton);
- place(1, 5, mRetrieveButton);
+ place(0, 1, mFilterLabel).setPadding(3);
+ place(1, 1, mFilterText, 3);
+ place(0, 2, invenScroll, 4, 4);
+ place(0, 6, mStoreButton);
+ place(1, 6, mRetrieveButton);
}
Layout &layout = getLayout();
- layout.setRowHeight(1, Layout::AUTO_SET);
+ layout.setRowHeight(2, Layout::AUTO_SET);
mInventory->addInventoyListener(this);
@@ -186,19 +195,19 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
return;
if (event.getId() == "activate")
- item->doEvent(EVENT_DOUSE);
+ item->doEvent(Event::DoUse);
else if (event.getId() == "equip")
{
if (item->isEquippable())
{
if (item->isEquipped())
- item->doEvent(EVENT_DOUNEQUIP);
+ item->doEvent(Event::DoUnequip);
else
- item->doEvent(EVENT_DOEQUIP);
+ item->doEvent(Event::DoEquip);
}
else
{
- item->doEvent(EVENT_DOUSE);
+ item->doEvent(Event::DoUse);
}
}
else if (event.getId() == "drop")
@@ -256,21 +265,21 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
return;
if (mInventory->isMainInventory())
{
- Mana::Event event(EVENT_DOMOVE);
+ Event event(Event::DoMove);
event.setItem("item", item);
event.setInt("amount", item->getQuantity());
event.setInt("source", Inventory::INVENTORY);
event.setInt("destination", Inventory::STORAGE);
- event.trigger(CHANNEL_ITEM);
+ event.trigger(Event::ItemChannel);
}
else
{
- Mana::Event event(EVENT_DOMOVE);
+ Event event(Event::DoMove);
event.setItem("item", item);
event.setInt("amount", item->getQuantity());
event.setInt("source", Inventory::STORAGE);
event.setInt("destination", Inventory::INVENTORY);
- event.trigger(CHANNEL_ITEM);
+ event.trigger(Event::ItemChannel);
}
}
}
@@ -289,6 +298,12 @@ void InventoryWindow::keyPressed(gcn::KeyEvent &event)
void InventoryWindow::keyReleased(gcn::KeyEvent &event)
{
+ if (isInputFocused())
+ {
+ mItems->setFilter(mFilterText->getText());
+ return;
+ }
+
switch (event.getKey().getValue())
{
case Key::LEFT_SHIFT:
@@ -368,16 +383,16 @@ void InventoryWindow::close()
}
else
{
- Mana::Event event(EVENT_DOCLOSEINVENTORY);
+ Event event(Event::DoCloseInventory);
event.setInt("type", mInventory->getType());
- event.trigger(CHANNEL_ITEM);
+ event.trigger(Event::ItemChannel);
scheduleDelete();
}
}
-void InventoryWindow::event(Channels channel, const Mana::Event &event)
+void InventoryWindow::event(Event::Channel channel, const Event &event)
{
- if (event.getName() == EVENT_UPDATEATTRIBUTE)
+ if (event.getType() == Event::UpdateAttribute)
{
int id = event.getInt("id");
if (id == TOTAL_WEIGHT ||
@@ -405,6 +420,27 @@ void InventoryWindow::updateWeight()
Units::formatWeight(max).c_str()));
}
+bool InventoryWindow::isInputFocused() const
+{
+ return mFilterText->isFocused();
+}
+
+bool InventoryWindow::isAnyInputFocused()
+{
+ WindowList::iterator it = instances.begin();
+ WindowList::iterator it_end = instances.end();
+
+ for (; it != it_end; it++)
+ {
+ if ((*it)->isInputFocused())
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
void InventoryWindow::slotsChanged(Inventory* inventory)
{
if (inventory == mInventory)
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 0ddd13f7..ebd2be22 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -23,9 +23,10 @@
#define INVENTORYWINDOW_H
#include "inventory.h"
-#include "listener.h"
+#include "eventlistener.h"
#include "gui/widgets/window.h"
+#include "gui/widgets/textfield.h"
#include "net/inventoryhandler.h"
@@ -48,17 +49,11 @@ class InventoryWindow : public Window,
public gcn::KeyListener,
public gcn::SelectionListener,
public InventoryListener,
- public Mana::Listener
+ public EventListener
{
public:
- /**
- * Constructor.
- */
InventoryWindow(Inventory *inventory);
- /**
- * Destructor.
- */
~InventoryWindow();
/**
@@ -107,11 +102,15 @@ class InventoryWindow : public Window,
*/
void updateButtons();
+ bool isInputFocused() const;
+
+ static bool isAnyInputFocused();
+
void slotsChanged(Inventory* inventory);
bool isMainInventory() { return mInventory->isMainInventory(); }
- void event(Channels channel, const Mana::Event &event);
+ void event(Event::Channel channel, const Event &event);
private:
/**
@@ -126,12 +125,14 @@ class InventoryWindow : public Window,
Inventory *mInventory;
ItemContainer *mItems;
+ TextField *mFilterText;
+
std::string mWeight, mSlots;
gcn::Button *mUseButton, *mEquipButton, *mDropButton, *mSplitButton,
*mOutfitButton, *mStoreButton, *mRetrieveButton;
- gcn::Label *mWeightLabel, *mSlotsLabel;
+ gcn::Label *mWeightLabel, *mSlotsLabel, *mFilterLabel;
ProgressBar *mWeightBar, *mSlotsBar;
diff --git a/src/gui/itemamount.cpp b/src/gui/itemamount.cpp
index 85325c66..43cdf1cf 100644
--- a/src/gui/itemamount.cpp
+++ b/src/gui/itemamount.cpp
@@ -47,29 +47,29 @@ void ItemAmountWindow::finish(Item *item, int amount, Usage usage)
tradeWindow->tradeItem(item, amount);
break;
case ItemDrop:
- item->doEvent(EVENT_DODROP, amount);
+ item->doEvent(Event::DoDrop, amount);
break;
case ItemSplit:
- item->doEvent(EVENT_DOSPLIT, amount);
+ item->doEvent(Event::DoSplit, amount);
break;
case StoreAdd:
{
- Mana::Event event(EVENT_DOMOVE);
+ Event event(Event::DoMove);
event.setItem("item", item);
event.setInt("amount", amount);
event.setInt("source", Inventory::INVENTORY);
event.setInt("destination", Inventory::STORAGE);
- event.trigger(CHANNEL_ITEM);
+ event.trigger(Event::ItemChannel);
}
break;
case StoreRemove:
{
- Mana::Event event(EVENT_DOMOVE);
+ Event event(Event::DoMove);
event.setItem("item", item);
event.setInt("amount", amount);
event.setInt("source", Inventory::STORAGE);
event.setInt("destination", Inventory::INVENTORY);
- event.trigger(CHANNEL_ITEM);
+ event.trigger(Event::ItemChannel);
}
break;
default:
diff --git a/src/gui/login.h b/src/gui/login.h
index 93bae338..38e858f6 100644
--- a/src/gui/login.h
+++ b/src/gui/login.h
@@ -42,11 +42,6 @@ class LoginDialog : public Window, public gcn::ActionListener,
public gcn::KeyListener
{
public:
- /**
- * Constructor
- *
- * @see Window::Window
- */
LoginDialog(LoginData *loginData);
~LoginDialog();
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index fae40d03..0fdf59b1 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -47,7 +47,7 @@ extern volatile int tick_time;
MiniStatusWindow::MiniStatusWindow():
Popup("MiniStatus")
{
- listen(CHANNEL_ATTRIBUTES);
+ listen(Event::AttributesChannel);
mHpBar = new ProgressBar(0, 100, 20, Theme::PROG_HP);
StatusWindow::updateHPBar(mHpBar);
@@ -119,11 +119,12 @@ void MiniStatusWindow::drawIcons(Graphics *graphics)
}
}
-void MiniStatusWindow::event(Channels channel, const Mana::Event &event)
+void MiniStatusWindow::event(Event::Channel channel,
+ const Event &event)
{
- if (channel == CHANNEL_ATTRIBUTES)
+ if (channel == Event::AttributesChannel)
{
- if (event.getName() == EVENT_UPDATEATTRIBUTE)
+ if (event.getType() == Event::UpdateAttribute)
{
int id = event.getInt("id");
if (id == HP || id == MAX_HP)
@@ -140,9 +141,9 @@ void MiniStatusWindow::event(Channels channel, const Mana::Event &event)
}
}
}
- else if (channel == CHANNEL_ACTORSPRITE)
+ else if (channel == Event::ActorSpriteChannel)
{
- if (event.getName() == EVENT_UPDATESTATUSEFFECT)
+ if (event.getType() == Event::UpdateStatusEffect)
{
int index = event.getInt("index");
bool newStatus = event.getBool("newStatus");
diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h
index 9dfcaeae..38025202 100644
--- a/src/gui/ministatus.h
+++ b/src/gui/ministatus.h
@@ -22,7 +22,7 @@
#ifndef MINISTATUS_H
#define MINISTATUS_H
-#include "listener.h"
+#include "eventlistener.h"
#include "gui/widgets/popup.h"
@@ -38,14 +38,14 @@ class TextPopup;
*
* \ingroup Interface
*/
-class MiniStatusWindow : public Popup, public Mana::Listener
+class MiniStatusWindow : public Popup, public EventListener
{
public:
MiniStatusWindow();
void drawIcons(Graphics *graphics);
- void event(Channels channel, const Mana::Event &event);
+ void event(Event::Channel channel, const Event &event);
void logic(); // Updates icons
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 590001b0..bb508184 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -23,7 +23,7 @@
#include "configuration.h"
#include "event.h"
-#include "listener.h"
+#include "eventlistener.h"
#include "playerinfo.h"
#include "gui/npcpostdialog.h"
@@ -52,10 +52,10 @@
typedef std::map<int, NpcDialog*> NpcDialogs;
-class NpcEventListener : public Mana::Listener
+class NpcEventListener : public EventListener
{
public:
- void event(Channels channel, const Mana::Event &event);
+ void event(Event::Channel channel, const Event &event);
NpcDialog *getDialog(int id, bool make = true);
@@ -143,7 +143,7 @@ NpcDialog::NpcDialog(int npcId)
setVisible(true);
requestFocus();
- listen(CHANNEL_CONFIG);
+ listen(Event::ConfigChannel);
PlayerInfo::setNPCInteractionCount(PlayerInfo::getNPCInteractionCount()
+ 1);
}
@@ -387,12 +387,12 @@ void NpcDialog::setVisible(bool visible)
}
}
-void NpcDialog::event(Channels channel, const Mana::Event &event)
+void NpcDialog::event(Event::Channel channel, const Event &event)
{
- if (channel != CHANNEL_CONFIG)
+ if (channel != Event::ConfigChannel)
return;
- if (event.getName() == EVENT_CONFIGOPTIONCHANGED &&
+ if (event.getType() == Event::ConfigOptionChanged &&
event.getString("option") == "logNpcInGui")
{
mLogInteraction = config.getBoolValue("logNpcInGui");
@@ -436,7 +436,7 @@ void NpcDialog::setup()
npcListener = new NpcEventListener();
- npcListener->listen(CHANNEL_NPC);
+ npcListener->listen(Event::NpcChannel);
}
void NpcDialog::buildLayout()
@@ -506,19 +506,19 @@ void NpcDialog::buildLayout()
mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
}
-void NpcEventListener::event(Channels channel,
- const Mana::Event &event)
+void NpcEventListener::event(Event::Channel channel,
+ const Event &event)
{
- if (channel != CHANNEL_NPC)
+ if (channel != Event::NpcChannel)
return;
- if (event.getName() == EVENT_MESSAGE)
+ if (event.getType() == Event::Message)
{
NpcDialog *dialog = getDialog(event.getInt("id"));
dialog->addText(event.getString("text"));
}
- else if (event.getName() == EVENT_MENU)
+ else if (event.getType() == Event::Menu)
{
NpcDialog *dialog = getDialog(event.getInt("id"));
@@ -528,7 +528,7 @@ void NpcEventListener::event(Channels channel,
for (int i = 1; i <= count; i++)
dialog->addChoice(event.getString("choice" + toString(i)));
}
- else if (event.getName() == EVENT_INTEGERINPUT)
+ else if (event.getType() == Event::IntegerInput)
{
NpcDialog *dialog = getDialog(event.getInt("id"));
@@ -538,7 +538,7 @@ void NpcEventListener::event(Channels channel,
dialog->integerRequest(defaultValue, min, max);
}
- else if (event.getName() == EVENT_STRINGINPUT)
+ else if (event.getType() == Event::StringInput)
{
NpcDialog *dialog = getDialog(event.getInt("id"));
@@ -546,12 +546,12 @@ void NpcEventListener::event(Channels channel,
{
dialog->textRequest(event.getString("default"));
}
- catch (Mana::BadEvent)
+ catch (BadEvent)
{
dialog->textRequest("");
}
}
- else if (event.getName() == EVENT_NEXT)
+ else if (event.getType() == Event::Next)
{
int id = event.getInt("id");
NpcDialog *dialog = getDialog(id, false);
@@ -565,7 +565,7 @@ void NpcEventListener::event(Channels channel,
dialog->showNextButton();
}
- else if (event.getName() == EVENT_CLOSE)
+ else if (event.getType() == Event::Close)
{
int id = event.getInt("id");
NpcDialog *dialog = getDialog(id, false);
@@ -579,11 +579,11 @@ void NpcEventListener::event(Channels channel,
dialog->showCloseButton();
}
- else if (event.getName() == EVENT_CLOSEALL)
+ else if (event.getType() == Event::CloseAll)
{
NpcDialog::closeAll();
}
- else if (event.getName() == EVENT_END)
+ else if (event.getType() == Event::End)
{
int id = event.getInt("id");
NpcDialog *dialog = getDialog(id, false);
@@ -591,7 +591,7 @@ void NpcEventListener::event(Channels channel,
if (dialog)
dialog->close();
}
- else if (event.getName() == EVENT_POST)
+ else if (event.getType() == Event::Post)
{
new NpcPostDialog(event.getInt("id"));
}
diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h
index d0131d0e..433c045e 100644
--- a/src/gui/npcdialog.h
+++ b/src/gui/npcdialog.h
@@ -22,7 +22,7 @@
#ifndef NPCDIALOG_H
#define NPCDIALOG_H
-#include "listener.h"
+#include "eventlistener.h"
#include "gui/widgets/window.h"
@@ -45,14 +45,9 @@ class Button;
* \ingroup Interface
*/
class NpcDialog : public Window, public gcn::ActionListener,
- public gcn::ListModel, public Mana::Listener
+ public gcn::ListModel, public EventListener
{
public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
NpcDialog(int npcId);
~NpcDialog();
@@ -145,7 +140,7 @@ class NpcDialog : public Window, public gcn::ActionListener,
void setVisible(bool visible);
- void event(Channels channel, const Mana::Event &event);
+ void event(Event::Channel channel, const Event &event);
/**
* Returns the first active instance. Useful for pushing user
diff --git a/src/gui/npcpostdialog.h b/src/gui/npcpostdialog.h
index 248e4515..db8d1a68 100644
--- a/src/gui/npcpostdialog.h
+++ b/src/gui/npcpostdialog.h
@@ -32,9 +32,6 @@ class TextField;
class NpcPostDialog : public Window, public gcn::ActionListener
{
public:
- /**
- * Constructor
- */
NpcPostDialog(int npcId);
~NpcPostDialog();
diff --git a/src/gui/okdialog.h b/src/gui/okdialog.h
index 9974e235..68841566 100644
--- a/src/gui/okdialog.h
+++ b/src/gui/okdialog.h
@@ -36,11 +36,6 @@ class TextBox;
class OkDialog : public Window, public gcn::ActionListener
{
public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
OkDialog(const std::string &title, const std::string &msg,
bool modal = true, Window *parent = NULL);
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index 8da8914a..efa0e08b 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -172,7 +172,7 @@ void OutfitWindow::wearOutfit(int outfit)
if (item && !item->isEquipped() && item->getQuantity())
{
if (item->isEquippable())
- item->doEvent(EVENT_DOEQUIP);
+ item->doEvent(Event::DoEquip);
}
}
}
@@ -341,7 +341,7 @@ void OutfitWindow::unequipNotInOutfit(int outfit)
Item *item = inventory->getItem(i);
if (item)
- item->doEvent(EVENT_DOUNEQUIP);
+ item->doEvent(Event::DoUnequip);
}
}
}
diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h
index a6051ecb..21cf6940 100644
--- a/src/gui/outfitwindow.h
+++ b/src/gui/outfitwindow.h
@@ -37,14 +37,8 @@ class Label;
class OutfitWindow : public Window, gcn::ActionListener
{
public:
- /**
- * Constructor.
- */
OutfitWindow();
- /**
- * Destructor.
- */
~OutfitWindow();
void action(const gcn::ActionEvent &event);
diff --git a/src/gui/palette.h b/src/gui/palette.h
index ee748e74..51cf7d5f 100644
--- a/src/gui/palette.h
+++ b/src/gui/palette.h
@@ -127,14 +127,8 @@ class Palette
typedef std::set<Palette*> Palettes;
static Palettes mInstances;
- /**
- * Constructor
- */
Palette(int size);
- /**
- * Destructor
- */
~Palette();
void advanceGradient();
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index f5259c35..7e648311 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -269,13 +269,13 @@ void PopupMenu::handleLink(const std::string &link)
if (mItem->isEquippable())
{
if (mItem->isEquipped())
- mItem->doEvent(EVENT_DOUNEQUIP);
+ mItem->doEvent(Event::DoUnequip);
else
- mItem->doEvent(EVENT_DOEQUIP);
+ mItem->doEvent(Event::DoEquip);
}
else
{
- mItem->doEvent(EVENT_DOUSE);
+ mItem->doEvent(Event::DoUse);
}
}
else if (link == "chat")
diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h
index 3bb49967..969c5c20 100644
--- a/src/gui/popupmenu.h
+++ b/src/gui/popupmenu.h
@@ -37,9 +37,6 @@ class Window;
class PopupMenu : public Popup, public LinkHandler
{
public:
- /**
- * Constructor.
- */
PopupMenu();
/**
diff --git a/src/gui/quitdialog.h b/src/gui/quitdialog.h
index d0dc2c69..65a325b8 100644
--- a/src/gui/quitdialog.h
+++ b/src/gui/quitdialog.h
@@ -45,9 +45,6 @@ class QuitDialog : public Window, public gcn::ActionListener,
*/
QuitDialog(QuitDialog **pointerToMe);
- /**
- * Destructor
- */
~QuitDialog();
/**
diff --git a/src/gui/register.h b/src/gui/register.h
index 3c65695b..fe54812b 100644
--- a/src/gui/register.h
+++ b/src/gui/register.h
@@ -63,9 +63,6 @@ class RegisterDialog : public Window, public gcn::ActionListener,
*/
RegisterDialog(LoginData *loginData);
- /**
- * Destructor
- */
~RegisterDialog();
/**
diff --git a/src/gui/sell.h b/src/gui/sell.h
index c286dcc2..8db0b573 100644
--- a/src/gui/sell.h
+++ b/src/gui/sell.h
@@ -41,16 +41,8 @@ class ShopListBox;
class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener
{
public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
SellDialog(int npcId);
- /**
- * Destructor
- */
virtual ~SellDialog();
/**
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index ca8da9b4..d68e2eca 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -52,6 +52,7 @@
#include <cstdlib>
#include <iostream>
#include <string>
+#include <algorithm>
static const int MAX_SERVERLIST = 6;
@@ -366,8 +367,8 @@ void ServerDialog::action(const gcn::ActionEvent &event)
else if (event.getId() == "remove")
{
int index = mServersList->getSelected();
- mServersList->setSelected(0);
mServers.erase(mServers.begin() + index);
+ mServersList->setSelected(0);
saveCustomServers();
}
@@ -591,6 +592,58 @@ void ServerDialog::loadServers()
if (!found)
mServers.push_back(server);
}
+
+ reorderList(config.getIntValue("serverListOrder"));
+}
+
+/**
+ * Returns true if serv1 must appear before serv2
+ */
+bool ServerDialog::sortByLastUsage(const ServerInfo& serv1, const ServerInfo& serv2)
+{
+ int rank1 = -1;
+ int rank2 = -1;
+
+ for (int i = 0; i < MAX_SERVERLIST; ++i)
+ {
+ const std::string index = toString(i);
+ const std::string nameKey = "MostUsedServerName" + index;
+ std::string serv = config.getValue(nameKey, "");
+ if (serv == serv1.hostname)
+ rank1 = i;
+ else if (serv == serv2.hostname)
+ rank2 = i;
+ }
+
+ if (rank1 > rank2)
+ return true;
+
+ if (rank2 > rank1)
+ return false;
+
+ return ServerDialog::sortByName(serv1, serv2);
+}
+
+/**
+ * Returns true if serv1 must appear before serv2
+ */
+bool ServerDialog::sortByName(const ServerInfo& serv1, const ServerInfo& serv2)
+{
+ return compareStrI(serv1.name, serv2.name) < 0;
+}
+
+/**
+ * Reorders the server list
+ * @param orderBy
+ * - 0 : Order by last change (default)
+ * - 1 : Order by name
+ */
+void ServerDialog::reorderList(int orderBy)
+{
+ if (orderBy == 0)
+ std::sort(mServers.begin(), mServers.end(), ServerDialog::sortByLastUsage);
+ else
+ std::sort(mServers.begin(), mServers.end(), ServerDialog::sortByName);
}
void ServerDialog::loadCustomServers()
diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h
index f1d9c9b8..d34fbb9f 100644
--- a/src/gui/serverdialog.h
+++ b/src/gui/serverdialog.h
@@ -111,16 +111,8 @@ class ServerDialog : public Window,
public gcn::SelectionListener
{
public:
- /**
- * Constructor
- *
- * @see Window::Window
- */
ServerDialog(ServerInfo *serverInfo, const std::string &dir);
- /**
- * Destructor
- */
~ServerDialog();
/**
@@ -158,6 +150,11 @@ class ServerDialog : public Window,
void setFieldsReadOnly(bool readOnly);
+ static bool sortByLastUsage(const ServerInfo& serv1, const ServerInfo& serv2);
+ static bool sortByName(const ServerInfo& serv1, const ServerInfo& serv2);
+
+ void reorderList(int orderBy);
+
TextField *mServerNameField;
TextField *mPortField;
Label *mDescription;
diff --git a/src/gui/setup_keyboard.h b/src/gui/setup_keyboard.h
index 4c916705..5a455adb 100644
--- a/src/gui/setup_keyboard.h
+++ b/src/gui/setup_keyboard.h
@@ -32,14 +32,8 @@
class Setup_Keyboard : public SetupTab, public gcn::ActionListener
{
public:
- /**
- * Constructor
- */
Setup_Keyboard();
- /**
- * Destructor
- */
~Setup_Keyboard();
void apply();
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index c8af218f..0c2ebf83 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -61,14 +61,8 @@ extern Graphics *graphics;
class ModeListModel : public gcn::ListModel
{
public:
- /**
- * Constructor.
- */
ModeListModel();
- /**
- * Destructor.
- */
virtual ~ModeListModel() { }
/**
@@ -156,6 +150,31 @@ public:
}
};
+const char *SERVLIST_ORDER_BY[2] =
+{
+ N_("Last usage"),
+ N_("Name")
+};
+
+class ServerListOrderListModel : public gcn::ListModel
+{
+public:
+ virtual ~ServerListOrderListModel() { }
+
+ virtual int getNumberOfElements()
+ {
+ return 2;
+ }
+
+ virtual std::string getElementAt(int i)
+ {
+ if (i >= getNumberOfElements())
+ return _("???");
+
+ return SERVLIST_ORDER_BY[i];
+ }
+};
+
static const char *speechModeToString(Being::Speech mode)
{
switch (mode)
@@ -243,6 +262,7 @@ Setup_Video::Setup_Video():
mParticleDetailSlider(new Slider(0, 3)),
mParticleDetailField(new Label),
mFontSize(config.getIntValue("fontSize")),
+ mServerListOrder(config.getIntValue("serverListOrder")),
mDisableSDLTransparencyCheckBox(
new CheckBox(_("Disable transparency (Low CPU mode)"),
mSDLTransparencyDisabled))
@@ -260,10 +280,14 @@ Setup_Video::Setup_Video():
overlayDetailLabel = new Label(_("Ambient FX"));
particleDetailLabel = new Label(_("Particle detail"));
fontSizeLabel = new Label(_("Font size"));
+ serverListOrderLabel = new Label(_("Order servers by"));
mFontSizeListModel = new FontSizeChoiceListModel;
mFontSizeDropDown = new DropDown(mFontSizeListModel);
+ mServerListOrderListModel = new ServerListOrderListModel;
+ mServerListOrderDropDown = new DropDown(mServerListOrderListModel);
+
mModeList->setEnabled(true);
#ifndef USE_OPENGL
@@ -341,6 +365,9 @@ Setup_Video::Setup_Video():
mFontSizeDropDown->setSelected(mFontSize - 10);
mFontSizeDropDown->adjustHeight();
+ mServerListOrderDropDown->setSelected(mServerListOrder);
+ mServerListOrderDropDown->adjustHeight();
+
// Do the layout
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
@@ -387,6 +414,9 @@ Setup_Video::Setup_Video():
place(0, 12, mDisableSDLTransparencyCheckBox, 4);
+ place(0, 13, serverListOrderLabel, 3);
+ place(1, 13, mServerListOrderDropDown, 2);
+
setDimension(gcn::Rectangle(0, 0, 365, 300));
}
@@ -395,6 +425,7 @@ Setup_Video::~Setup_Video()
delete mModeListModel;
delete mModeList;
delete mFontSizeListModel;
+ delete mServerListOrderListModel;
}
void Setup_Video::apply()
@@ -493,6 +524,7 @@ void Setup_Video::apply()
// FPS change
config.setValue("fpslimit", mFps);
config.setValue("fontSize", mFontSizeDropDown->getSelected() + 10);
+ config.setValue("serverListOrder", mServerListOrderDropDown->getSelected());
// We sync old and new values at apply time
mFullScreenEnabled = config.getBoolValue("screen");
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index d0e2c492..15a0387e 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -32,6 +32,7 @@
class ModeListModel;
class FontSizeChoiceListModel;
+class ServerListOrderListModel;
class Setup_Video : public SetupTab, public gcn::ActionListener,
public gcn::KeyListener
@@ -67,6 +68,7 @@ class Setup_Video : public SetupTab, public gcn::ActionListener,
ModeListModel *mModeListModel;
FontSizeChoiceListModel *mFontSizeListModel;
+ ServerListOrderListModel *mServerListOrderListModel;
gcn::Label *speechLabel;
gcn::Label *alphaLabel;
@@ -75,6 +77,7 @@ class Setup_Video : public SetupTab, public gcn::ActionListener,
gcn::Label *overlayDetailLabel;
gcn::Label *particleDetailLabel;
gcn::Label *fontSizeLabel;
+ gcn::Label *serverListOrderLabel;
gcn::ListBox *mModeList;
gcn::CheckBox *mFsCheckBox;
@@ -108,6 +111,9 @@ class Setup_Video : public SetupTab, public gcn::ActionListener,
int mFontSize;
gcn::DropDown *mFontSizeDropDown;
+ int mServerListOrder;
+ gcn::DropDown *mServerListOrderDropDown;
+
gcn::CheckBox *mDisableSDLTransparencyCheckBox;
};
diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h
index a0f82541..f5905e31 100644
--- a/src/gui/shortcutwindow.h
+++ b/src/gui/shortcutwindow.h
@@ -35,14 +35,8 @@ class ShortcutContainer;
class ShortcutWindow : public Window
{
public:
- /**
- * Constructor.
- */
ShortcutWindow(const std::string &title, ShortcutContainer *content);
- /**
- * Destructor.
- */
~ShortcutWindow();
private:
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index be46132e..c7976caa 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -24,6 +24,7 @@
#include "log.h"
#include "playerinfo.h"
#include "configuration.h"
+#include "eventlistener.h"
#include "gui/setup.h"
@@ -211,6 +212,8 @@ private:
SkillDialog::SkillDialog():
Window(_("Skills"))
{
+ listen(Event::AttributesChannel);
+
setWindowName("Skills");
setCloseButton(true);
setResizable(true);
@@ -277,6 +280,17 @@ void SkillDialog::update()
}
}
+void SkillDialog::event(Event::Channel channel, const Event &event)
+{
+ if (event.getType() == Event::UpdateAttribute)
+ {
+ if (event.getInt("id") == SKILL_POINTS)
+ {
+ update();
+ }
+ }
+}
+
void SkillDialog::loadSkills(const std::string &file)
{
// Fixes issues with removing tabs
diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h
index 3b1b1832..a49c537b 100644
--- a/src/gui/skilldialog.h
+++ b/src/gui/skilldialog.h
@@ -23,6 +23,7 @@
#define SKILLDIALOG_H
#include "gui/widgets/window.h"
+#include "eventlistener.h"
#include <guichan/actionlistener.hpp>
@@ -41,13 +42,15 @@ struct SkillInfo;
*
* \ingroup Interface
*/
-class SkillDialog : public Window, public gcn::ActionListener
+class SkillDialog : public Window, public gcn::ActionListener, public EventListener
{
public:
SkillDialog();
~SkillDialog();
+ void event(Event::Channel channel, const Event &event);
+
/**
* Called when receiving actions from widget.
*/
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index b4321b25..07f37eec 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -310,6 +310,7 @@ private:
SocialWindow::SocialWindow() :
Window(_("Social")),
+ mGuildInvited(0),
mGuildAcceptDialog(NULL),
mPartyAcceptDialog(NULL)
{
@@ -459,14 +460,12 @@ void SocialWindow::action(const gcn::ActionEvent &event)
// check if they accepted the invite
if (eventId == "yes")
{
- SERVER_NOTICE(strprintf(_("Accepted guild invite from %s."),
- mPartyInviter.c_str()))
+ SERVER_NOTICE(_("Accepted guild invite"))
Net::getGuildHandler()->inviteResponse(mGuildInvited, true);
}
else if (eventId == "no")
{
- SERVER_NOTICE(strprintf(_("Rejected guild invite from %s."),
- mPartyInviter.c_str()))
+ SERVER_NOTICE(_("Rejected guild invite."))
Net::getGuildHandler()->inviteResponse(mGuildInvited, false);
}
diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h
index 6017398a..7316cf96 100644
--- a/src/gui/speechbubble.h
+++ b/src/gui/speechbubble.h
@@ -32,9 +32,6 @@ class TextBox;
class SpeechBubble : public Popup
{
public:
- /**
- * Constructor. Initializes the speech bubble.
- */
SpeechBubble();
/**
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index a3420f06..28ed6c68 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -96,7 +96,7 @@ class ChangeDisplay : public AttrDisplay, gcn::ActionListener
StatusWindow::StatusWindow():
Window(player_node->getName())
{
- listen(CHANNEL_ATTRIBUTES);
+ listen(Event::AttributesChannel);
setWindowName("Status");
setupWindow->registerWindowForReset(this);
@@ -217,9 +217,10 @@ StatusWindow::StatusWindow():
mLvlLabel->adjustSize();
}
-void StatusWindow::event(Channels channel, const Mana::Event &event)
+void StatusWindow::event(Event::Channel channel,
+ const Event &event)
{
- if (event.getName() == EVENT_UPDATEATTRIBUTE)
+ if (event.getType() == Event::UpdateAttribute)
{
switch(event.getInt("id"))
{
@@ -265,7 +266,7 @@ void StatusWindow::event(Channels channel, const Mana::Event &event)
break;
}
}
- else if (event.getName() == EVENT_UPDATESTAT)
+ else if (event.getType() == Event::UpdateStat)
{
int id = event.getInt("id");
diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h
index 103111a7..9120d978 100644
--- a/src/gui/statuswindow.h
+++ b/src/gui/statuswindow.h
@@ -22,7 +22,7 @@
#ifndef STATUS_H
#define STATUS_H
-#include "listener.h"
+#include "eventlistener.h"
#include "gui/widgets/window.h"
@@ -40,15 +40,12 @@ class VertContainer;
*
* \ingroup Interface
*/
-class StatusWindow : public Window, public Mana::Listener
+class StatusWindow : public Window, public EventListener
{
public:
- /**
- * Constructor.
- */
StatusWindow();
- void event(Channels channel, const Mana::Event &event);
+ void event(Event::Channel channel, const Event &event);
void updateAttrs();
diff --git a/src/gui/textdialog.h b/src/gui/textdialog.h
index aa8fcf8f..ccaa69ce 100644
--- a/src/gui/textdialog.h
+++ b/src/gui/textdialog.h
@@ -36,11 +36,6 @@ class TextField;
class TextDialog : public Window, public gcn::ActionListener
{
public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
TextDialog(const std::string &title, const std::string &msg,
Window *parent = NULL, bool autoCompleteEnabled = false);
diff --git a/src/gui/textpopup.h b/src/gui/textpopup.h
index 51646590..04911d37 100644
--- a/src/gui/textpopup.h
+++ b/src/gui/textpopup.h
@@ -36,21 +36,15 @@ class TextBox;
class TextPopup : public Popup
{
public:
- /**
- * Constructor. Initializes the item popup.
- */
TextPopup();
- /**
- * Destructor. Cleans up the item popup on deletion.
- */
~TextPopup();
/**
* Sets the text to be displayed.
*/
void show(int x, int y, const std::string &str1)
- { show(x, y, str1, (const char*)""); };
+ { show(x, y, str1, (const char*)""); }
/**
* Sets the text to be displayed.
diff --git a/src/gui/trade.h b/src/gui/trade.h
index e22f8863..f854d698 100644
--- a/src/gui/trade.h
+++ b/src/gui/trade.h
@@ -42,14 +42,8 @@ class ScrollArea;
class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener
{
public:
- /**
- * Constructor.
- */
TradeWindow();
- /**
- * Destructor.
- */
~TradeWindow();
/**
diff --git a/src/gui/truetypefont.h b/src/gui/truetypefont.h
index 689f45bf..41db3f86 100644
--- a/src/gui/truetypefont.h
+++ b/src/gui/truetypefont.h
@@ -56,9 +56,6 @@ class TrueTypeFont : public gcn::Font
*/
TrueTypeFont(const std::string &filename, int size, int style = 0);
- /**
- * Destructor.
- */
~TrueTypeFont();
virtual int getWidth(const std::string &text) const;
diff --git a/src/gui/unregisterdialog.h b/src/gui/unregisterdialog.h
index 87999d5d..503e0258 100644
--- a/src/gui/unregisterdialog.h
+++ b/src/gui/unregisterdialog.h
@@ -38,11 +38,6 @@ class WrongDataNoticeListener;
class UnRegisterDialog : public Window, public gcn::ActionListener
{
public:
- /**
- * Constructor
- *
- * @see Window::Window
- */
UnRegisterDialog(LoginData *loginData);
~UnRegisterDialog();
diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h
index a62a2ad7..a4dbf674 100644
--- a/src/gui/updatewindow.h
+++ b/src/gui/updatewindow.h
@@ -19,8 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _UPDATERWINDOW_H
-#define _UPDATERWINDOW_H
+#ifndef UPDATERWINDOW_H
+#define UPDATERWINDOW_H
#include "gui/widgets/window.h"
@@ -71,9 +71,6 @@ class UpdaterWindow : public Window, public gcn::ActionListener,
const std::string &updatesDir,
bool applyUpdates);
- /**
- * Destructor
- */
~UpdaterWindow();
/**
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 19bed735..f6166c8f 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -43,6 +43,8 @@
#include "utils/stringutils.h"
+#include <cmath>
+
extern volatile int tick_time;
Viewport::Viewport():
@@ -70,8 +72,8 @@ Viewport::Viewport():
setFocusable(true);
- listen(CHANNEL_CONFIG);
- listen(CHANNEL_ACTORSPRITE);
+ listen(Event::ConfigChannel);
+ listen(Event::ActorSpriteChannel);
}
Viewport::~Viewport()
@@ -122,9 +124,9 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
if (mScrollLaziness < 1)
mScrollLaziness = 1; // Avoids division by zero
- // Apply lazy scrolling
while (lastTick < tick_time)
{
+ // Apply lazy scrolling
if (player_x > mPixelViewX + mScrollRadius)
{
mPixelViewX += (player_x - mPixelViewX - mScrollRadius) /
@@ -145,6 +147,22 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
mPixelViewY += (player_y - mPixelViewY + mScrollRadius) /
mScrollLaziness;
}
+
+ // manage shake effect
+ for (ShakeEffects::iterator i = mShakeEffects.begin();
+ i != mShakeEffects.end();
+ i++)
+ {
+ // apply the effect to viewport
+ mPixelViewX += i->x *= -i->decay;
+ mPixelViewY += i->y *= -i->decay;
+ // check death conditions
+ if (abs(i->x) + abs(i->y) < 1.0f ||
+ (i->duration > 0 && --i->duration == 0))
+ {
+ i = mShakeEffects.erase(i);
+ }
+ }
lastTick++;
}
@@ -223,6 +241,24 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
WindowContainer::draw(gcnGraphics);
}
+void Viewport::shakeScreen(int intensity)
+{
+ float direction = rand()%628 / 100.0f; // random value between 0 and 2PI
+ float x = std::sin(direction) * intensity;
+ float y = std::cos(direction) * intensity;
+ shakeScreen(x, y);
+}
+
+void Viewport::shakeScreen(float x, float y, float decay, unsigned duration)
+{
+ ShakeEffect effect;
+ effect.x = x;
+ effect.y = y;
+ effect.decay = decay;
+ effect.duration = duration;
+ mShakeEffects.push_back(effect);
+}
+
void Viewport::logic()
{
WindowContainer::logic();
@@ -526,9 +562,10 @@ void Viewport::hideBeingPopup()
mBeingPopup->setVisible(false);
}
-void Viewport::event(Channels channel, const Mana::Event &event)
+void Viewport::event(Event::Channel channel, const Event &event)
{
- if (channel == CHANNEL_ACTORSPRITE && event.getName() == EVENT_DESTROYED)
+ if (channel == Event::ActorSpriteChannel
+ && event.getType() == Event::Destroyed)
{
ActorSprite *actor = event.getActor("source");
@@ -538,8 +575,8 @@ void Viewport::event(Channels channel, const Mana::Event &event)
if (mHoverItem == actor)
mHoverItem = 0;
}
- else if (channel == CHANNEL_CONFIG &&
- event.getName() == EVENT_CONFIGOPTIONCHANGED)
+ else if (channel == Event::ConfigChannel &&
+ event.getType() == Event::ConfigOptionChanged)
{
const std::string option = event.getString("option");
if (option == "ScrollLaziness" || option == "ScrollRadius")
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index 93e36b5b..d8687219 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -22,13 +22,15 @@
#ifndef VIEWPORT_H
#define VIEWPORT_H
-#include "listener.h"
+#include "eventlistener.h"
#include "position.h"
#include "gui/widgets/windowcontainer.h"
#include <guichan/mouselistener.hpp>
+#include <list>
+
class ActorSprite;
class Being;
class BeingPopup;
@@ -52,17 +54,11 @@ const int walkingMouseDelay = 500;
* coordinates.
*/
class Viewport : public WindowContainer, public gcn::MouseListener,
- public Mana::Listener
+ public EventListener
{
public:
- /**
- * Constructor.
- */
Viewport();
- /**
- * Destructor.
- */
~Viewport();
/**
@@ -153,7 +149,23 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
*/
void hideBeingPopup();
- void event(Channels channel, const Mana::Event &event);
+ /**
+ * Makes the screen shake in a random direction
+ */
+ void shakeScreen(int intensity);
+
+ /**
+ * Makes the screen shake in a specific direction
+ */
+ void shakeScreen(float x, float y, float decay = 0.95f, unsigned duration = 0);
+
+ /**
+ * Stops all active screen shake effects
+ */
+ void shakeScreenStop()
+ { mShakeEffects.clear(); }
+
+ void event(Event::Channel channel, const Event &event);
private:
/**
@@ -190,6 +202,16 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
float mPixelViewY; /**< Current viewpoint in pixels. */
int mShowDebugPath; /**< Show a path from player to pointer. */
+ struct ShakeEffect
+ {
+ float x;
+ float y;
+ float decay;
+ unsigned duration;
+ };
+ typedef std::list<ShakeEffect> ShakeEffects;
+ ShakeEffects mShakeEffects;
+
bool mPlayerFollowMouse;
int mLocalWalkTime; /**< Timestamp before the next walk can be sent. */
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index 54a2a8cc..28ec734a 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -72,14 +72,8 @@ class BrowserBox : public gcn::Widget,
public gcn::MouseListener
{
public:
- /**
- * Constructor.
- */
BrowserBox(unsigned int mode = AUTO_SIZE, bool opaque = true);
- /**
- * Destructor.
- */
~BrowserBox();
/**
diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h
index aa37261e..b750d9bb 100644
--- a/src/gui/widgets/button.h
+++ b/src/gui/widgets/button.h
@@ -46,9 +46,6 @@ class Button : public gcn::Button
Button(const std::string &caption, const std::string &actionEventId,
gcn::ActionListener *listener);
- /**
- * Destructor.
- */
~Button();
/**
diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h
index 842b80f7..0272655b 100644
--- a/src/gui/widgets/channeltab.h
+++ b/src/gui/widgets/channeltab.h
@@ -43,14 +43,8 @@ class ChannelTab : public ChatTab
protected:
friend class Channel;
- /**
- * Constructor.
- */
ChannelTab(Channel *channel);
- /**
- * Destructor.
- */
~ChannelTab();
void handleInput(const std::string &msg);
diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h
index 1e187f23..6d262e11 100644
--- a/src/gui/widgets/chattab.h
+++ b/src/gui/widgets/chattab.h
@@ -37,9 +37,6 @@ class ScrollArea;
class ChatTab : public Tab, public AutoCompleteLister
{
public:
- /**
- * Constructor.
- */
ChatTab(const std::string &name);
~ChatTab();
diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h
index a7daa52d..27962f72 100644
--- a/src/gui/widgets/checkbox.h
+++ b/src/gui/widgets/checkbox.h
@@ -34,14 +34,8 @@ class Image;
class CheckBox : public gcn::CheckBox
{
public:
- /**
- * Constructor.
- */
CheckBox(const std::string &caption, bool selected = false);
- /**
- * Destructor.
- */
~CheckBox();
/**
diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h
index c3fb9d14..0021d838 100644
--- a/src/gui/widgets/emoteshortcutcontainer.h
+++ b/src/gui/widgets/emoteshortcutcontainer.h
@@ -35,14 +35,8 @@ class ImageSprite;
class EmoteShortcutContainer : public ShortcutContainer
{
public:
- /**
- * Constructor. Initializes the graphic.
- */
EmoteShortcutContainer();
- /**
- * Destructor.
- */
virtual ~EmoteShortcutContainer();
/**
diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h
index a0e8dbf5..ee9f634b 100644
--- a/src/gui/widgets/flowcontainer.h
+++ b/src/gui/widgets/flowcontainer.h
@@ -34,17 +34,9 @@ class FlowContainer : public Container,
public gcn::WidgetListener
{
public:
- /**
- * Constructor. Initializes the shortcut container.
- */
FlowContainer(int boxWidth, int boxHeight);
/**
- * Destructor.
- */
- ~FlowContainer() {}
-
- /**
* Invoked when a widget changes its size. This is used to determine
* the new height of the container.
*/
diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h
index 27ed0db8..7b297756 100644
--- a/src/gui/widgets/icon.h
+++ b/src/gui/widgets/icon.h
@@ -36,6 +36,8 @@ class Icon : public gcn::Widget
public:
/**
* Constructor.
+ *
+ * @param filename The file name of the image to display
*/
Icon(const std::string &filename);
@@ -44,7 +46,7 @@ class Icon : public gcn::Widget
*/
Icon(Image *image);
- /**
+ /**
* Gets the current Image.
*/
Image *getImage() const { return mImage; }
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 2e9b698d..0967055b 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -101,14 +101,38 @@ void ItemContainer::draw(gcn::Graphics *graphics)
g->setFont(getFont());
+ mFilteredMap.clear();
+ int currentIndex = 0;
+ //Filter checking
+ for (int i = 0; i < mGridColumns; i++)
+ {
+ for (int j = 0; j < mGridRows; j++)
+ {
+ int itemIndex = j * mGridColumns + i;
+ Item *item = mInventory->getItem(itemIndex);
+ if (!item || item->getId() == 0)
+ continue;
+
+ if (mFilter.size() > 0)
+ {
+ if (normalize(item->getInfo().getName()).find(mFilter) == std::string::npos)
+ continue;
+ }
+
+ mFilteredMap[currentIndex] = item;
+ currentIndex++;
+ }
+ }
+
for (int i = 0; i < mGridColumns; i++)
{
for (int j = 0; j < mGridRows; j++)
{
int itemX = i * BOX_WIDTH;
int itemY = j * BOX_HEIGHT;
- int itemIndex = (j * mGridColumns) + i;
- Item *item = mInventory->getItem(itemIndex);
+ int itemIndex = j * mGridColumns + i;
+
+ Item *item = getItemAt(itemIndex);
if (!item || item->getId() == 0)
continue;
@@ -178,7 +202,18 @@ void ItemContainer::setSelectedIndex(int newIndex)
Item *ItemContainer::getSelectedItem() const
{
- return mInventory->getItem(mSelectedIndex);
+ return getItemAt(mSelectedIndex);
+}
+
+Item *ItemContainer::getItemAt(int index) const
+{
+ std::map<int, Item*>::const_iterator i = mFilteredMap.find(index);
+ return i == mFilteredMap.end() ? 0 : i->second;
+}
+
+void ItemContainer::setFilter(const std::string &filter)
+{
+ mFilter = normalize(filter);
}
void ItemContainer::distributeValueChangedEvent()
@@ -245,7 +280,10 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event)
if (index == Inventory::NO_SLOT_INDEX)
return;
- Item *item = mInventory->getItem(index);
+ Item *item = getItemAt(index);
+
+ if (!item)
+ return;
// put item name into chat window
if (mDescItems)
@@ -308,10 +346,10 @@ void ItemContainer::mouseReleased(gcn::MouseEvent &event)
Item *item = getSelectedItem();
{
- Mana::Event event(EVENT_DOMOVE);
+ Event event(Event::DoMove);
event.setItem("item", item);
event.setInt("newIndex", index);
- event.trigger(CHANNEL_ITEM);
+ event.trigger(Event::ItemChannel);
}
selectNone();
}
@@ -320,7 +358,7 @@ void ItemContainer::mouseReleased(gcn::MouseEvent &event)
// Show ItemTooltip
void ItemContainer::mouseMoved(gcn::MouseEvent &event)
{
- Item *item = mInventory->getItem(getSlotIndex(event.getX(), event.getY()));
+ Item *item = getItemAt(getSlotIndex(event.getX(), event.getY()));
if (item)
{
@@ -380,10 +418,10 @@ void ItemContainer::keyAction()
mHighlightedIndex != -1)
{
Item *item = getSelectedItem();
- Mana::Event event(EVENT_DOMOVE);
+ Event event(Event::DoMove);
event.setItem("item", item);
event.setInt("newIndex", mHighlightedIndex);
- event.trigger(CHANNEL_ITEM);
+ event.trigger(Event::ItemChannel);
setSelectedIndex(mHighlightedIndex);
}
// If the highlight is on an item then select it.
@@ -396,10 +434,10 @@ void ItemContainer::keyAction()
else if (mSelectedIndex != -1)
{
Item *item = getSelectedItem();
- Mana::Event event(EVENT_DOMOVE);
+ Event event(Event::DoMove);
event.setItem("item", item);
event.setInt("newIndex", mHighlightedIndex);
- event.trigger(CHANNEL_ITEM);
+ event.trigger(Event::ItemChannel);
selectNone();
}
}
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index 38ccf9ca..ca21ad3f 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -27,6 +27,7 @@
#include <guichan/widget.hpp>
#include <guichan/widgetlistener.hpp>
+#include <map>
#include <list>
class Image;
@@ -59,9 +60,6 @@ class ItemContainer : public gcn::Widget,
*/
ItemContainer(Inventory *inventory, bool forceQuantity = false);
- /**
- * Destructor.
- */
virtual ~ItemContainer();
/**
@@ -98,6 +96,12 @@ class ItemContainer : public gcn::Widget,
*/
void selectNone();
+
+ /**
+ * Sets item filter
+ */
+ void setFilter(const std::string &filter);
+
/**
* Adds a listener to the list that's notified each time a change to
* the selection occurs.
@@ -170,6 +174,8 @@ class ItemContainer : public gcn::Widget,
*/
int getSlotIndex(int x, int y) const;
+ Item *getItemAt(int) const;
+
Inventory *mInventory;
int mGridColumns, mGridRows;
Image *mSelImg;
@@ -181,6 +187,10 @@ class ItemContainer : public gcn::Widget,
bool mDescItems;
int mDragPosX, mDragPosY;
+ std::map<int, Item*> mFilteredMap;
+
+ std::string mFilter;
+
ItemPopup *mItemPopup;
typedef std::list<gcn::SelectionListener*> SelectionListenerList;
diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h
index 9ec3f4c1..80f29c7b 100644
--- a/src/gui/widgets/itemshortcutcontainer.h
+++ b/src/gui/widgets/itemshortcutcontainer.h
@@ -38,14 +38,8 @@ class ItemPopup;
class ItemShortcutContainer : public ShortcutContainer
{
public:
- /**
- * Constructor. Initializes the graphic.
- */
ItemShortcutContainer();
- /**
- * Destructor.
- */
virtual ~ItemShortcutContainer();
/**
diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h
index 2dfa254c..6b9cd2a8 100644
--- a/src/gui/widgets/label.h
+++ b/src/gui/widgets/label.h
@@ -1,6 +1,6 @@
/*
* The Mana Client
- * Copyright (c) 2009 Aethyra Development Team
+ * Copyright (c) 2009 Aethyra Development Team
*
* This file is part of The Mana Client.
*
@@ -32,9 +32,6 @@
class Label : public gcn::Label
{
public:
- /**
- * Constructor.
- */
Label();
/**
diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h
index cf966029..0aeabb0d 100644
--- a/src/gui/widgets/layouthelper.h
+++ b/src/gui/widgets/layouthelper.h
@@ -34,14 +34,8 @@
class LayoutHelper : public gcn::WidgetListener
{
public:
- /**
- * Constructor.
- */
LayoutHelper(gcn::Container *container);
- /**
- * Destructor.
- */
~LayoutHelper();
/**
diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h
index 8b8c8b54..92505c15 100644
--- a/src/gui/widgets/listbox.h
+++ b/src/gui/widgets/listbox.h
@@ -36,9 +36,6 @@ class SelectionListener;
class ListBox : public gcn::ListBox
{
public:
- /**
- * Constructor.
- */
ListBox(gcn::ListModel *listModel);
~ListBox();
diff --git a/src/gui/widgets/passwordfield.h b/src/gui/widgets/passwordfield.h
index 619cd842..0058233c 100644
--- a/src/gui/widgets/passwordfield.h
+++ b/src/gui/widgets/passwordfield.h
@@ -35,7 +35,7 @@ class PasswordField : public TextField
/**
* Constructor, initializes the password field with the given string.
*/
- PasswordField(const std::string &text = "");
+ PasswordField(const std::string &text = std::string());
/**
* Draws the password field.
diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h
index 4ce6782d..f6e70ef7 100644
--- a/src/gui/widgets/playerbox.h
+++ b/src/gui/widgets/playerbox.h
@@ -41,9 +41,6 @@ class PlayerBox : public gcn::ScrollArea
*/
PlayerBox(const Being *being = 0);
- /**
- * Destructor.
- */
~PlayerBox();
/**
diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h
index 7f839ea5..f8aa40f1 100644
--- a/src/gui/widgets/radiobutton.h
+++ b/src/gui/widgets/radiobutton.h
@@ -32,15 +32,9 @@ class Image;
class RadioButton : public gcn::RadioButton
{
public:
- /**
- * Constructor.
- */
RadioButton(const std::string &caption,const std::string &group,
bool marked = false);
- /**
- * Destructor.
- */
~RadioButton();
/**
diff --git a/src/gui/widgets/resizegrip.h b/src/gui/widgets/resizegrip.h
index 5ef93f29..319b574f 100644
--- a/src/gui/widgets/resizegrip.h
+++ b/src/gui/widgets/resizegrip.h
@@ -36,14 +36,8 @@ class Image;
class ResizeGrip : public gcn::Widget
{
public:
- /**
- * Constructor.
- */
ResizeGrip(const std::string &image = "resize.png");
- /**
- * Destructor.
- */
~ResizeGrip();
/**
diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h
index 087bdd53..325cb562 100644
--- a/src/gui/widgets/shoplistbox.h
+++ b/src/gui/widgets/shoplistbox.h
@@ -37,9 +37,6 @@ class ItemPopup;
class ShopListBox : public ListBox
{
public:
- /**
- * Constructor.
- */
ShopListBox(gcn::ListModel *listModel);
/**
@@ -47,9 +44,6 @@ class ShopListBox : public ListBox
*/
ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel);
- /**
- * Destructor
- */
~ShopListBox();
/**
diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h
index 9404ffd2..e511d7f9 100644
--- a/src/gui/widgets/shortcutcontainer.h
+++ b/src/gui/widgets/shortcutcontainer.h
@@ -38,14 +38,8 @@ class ShortcutContainer : public gcn::Widget,
public gcn::MouseListener
{
public:
- /**
- * Constructor. Initializes the shortcut container.
- */
ShortcutContainer();
- /**
- * Destructor.
- */
~ShortcutContainer() {}
/**
diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h
index 9b26e404..408210ac 100644
--- a/src/gui/widgets/slider.h
+++ b/src/gui/widgets/slider.h
@@ -31,7 +31,8 @@ class Image;
*
* \ingroup GUI
*/
-class Slider : public gcn::Slider {
+class Slider : public gcn::Slider
+{
public:
/**
* Constructor with scale start equal to 0.
@@ -40,12 +41,12 @@ class Slider : public gcn::Slider {
/**
* Constructor.
+ *
+ * @param scaleStart The minimum value of the slider
+ * @param scaleEnd The maximum value of the slider
*/
Slider(double scaleStart, double scaleEnd);
- /**
- * Destructor.
- */
~Slider();
/**
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index 19393f8b..d364eac5 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -39,9 +39,6 @@ class Tab;
class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener
{
public:
- /**
- * Constructor.
- */
TabbedArea();
/**
diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h
index 3b6778d2..6b947e0b 100644
--- a/src/gui/widgets/textbox.h
+++ b/src/gui/widgets/textbox.h
@@ -34,9 +34,6 @@
class TextBox : public gcn::TextBox
{
public:
- /**
- * Constructor.
- */
TextBox();
inline void setTextColor(const gcn::Color *color)
diff --git a/src/gui/worldselectdialog.h b/src/gui/worldselectdialog.h
index b51110b4..624560c3 100644
--- a/src/gui/worldselectdialog.h
+++ b/src/gui/worldselectdialog.h
@@ -43,16 +43,8 @@ class WorldListModel;
class WorldSelectDialog : public Window, public gcn::ActionListener,
public gcn::KeyListener {
public:
- /**
- * Constructor
- *
- * @see Window::Window
- */
WorldSelectDialog(Worlds worlds);
- /**
- * Destructor.
- */
~WorldSelectDialog();
/**
diff --git a/src/imageparticle.h b/src/imageparticle.h
index 23909fa3..5c4e4bf1 100644
--- a/src/imageparticle.h
+++ b/src/imageparticle.h
@@ -41,9 +41,6 @@ class ImageParticle : public Particle
*/
ImageParticle(Map *map, Image *image);
- /**
- * Destructor.
- */
~ImageParticle();
/**
diff --git a/src/inventory.h b/src/inventory.h
index 7af9f160..5a1d2c0a 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -58,9 +58,6 @@ class Inventory
*/
Inventory(Type type, int size = -1);
- /**
- * Destructor.
- */
~Inventory();
/**
diff --git a/src/item.cpp b/src/item.cpp
index fee7e86f..821a178b 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -72,19 +72,19 @@ void Item::setId(int id)
"unknown-item.png"));
}
-void Item::doEvent(Events eventName)
+void Item::doEvent(Event::Type eventName)
{
- Mana::Event event(eventName);
+ Event event(eventName);
event.setItem("item", this);
- event.trigger(CHANNEL_ITEM);
+ event.trigger(Event::ItemChannel);
}
-void Item::doEvent(Events eventName, int amount)
+void Item::doEvent(Event::Type eventName, int amount)
{
- Mana::Event event(eventName);
+ Event event(eventName);
event.setItem("item", this);
event.setInt("amount", amount);
- event.trigger(CHANNEL_ITEM);
+ event.trigger(Event::ItemChannel);
}
bool Item::isEquippable() const
diff --git a/src/item.h b/src/item.h
index 24ee2fc5..f6574f8c 100644
--- a/src/item.h
+++ b/src/item.h
@@ -34,14 +34,8 @@ class Image;
class Item
{
public:
- /**
- * Constructor.
- */
Item(int id = -1, int quantity = 0, bool equipped = false);
- /**
- * Destructor.
- */
virtual ~Item();
/**
@@ -114,9 +108,9 @@ class Item
*/
int getInvIndex() const { return mInvIndex; }
- void doEvent(Events eventName);
+ void doEvent(Event::Type eventType);
- void doEvent(Events eventName, int amount);
+ void doEvent(Event::Type eventType, int amount);
/**
* Returns information about this item type.
@@ -131,7 +125,6 @@ class Item
bool mEquipped; /**< Item is equipped. */
bool mInEquipment; /**< Item is in equipment */
int mInvIndex; /**< Inventory index. */
-
};
-#endif
+#endif // ITEM_H
diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp
index 0e5abef8..dfcbb3b6 100644
--- a/src/itemshortcut.cpp
+++ b/src/itemshortcut.cpp
@@ -74,13 +74,13 @@ void ItemShortcut::useItem(int index)
if (item->getInfo().getEquippable())
{
if (item->isEquipped())
- item->doEvent(EVENT_DOUNEQUIP);
+ item->doEvent(Event::DoUnequip);
else
- item->doEvent(EVENT_DOEQUIP);
+ item->doEvent(Event::DoEquip);
}
else
{
- item->doEvent(EVENT_DOUSE);
+ item->doEvent(Event::DoUse);
}
}
}
diff --git a/src/itemshortcut.h b/src/itemshortcut.h
index 619d4054..b1566a61 100644
--- a/src/itemshortcut.h
+++ b/src/itemshortcut.h
@@ -32,14 +32,8 @@ class Item;
class ItemShortcut
{
public:
- /**
- * Constructor.
- */
ItemShortcut();
- /**
- * Destructor.
- */
~ItemShortcut();
/**
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index ad9d181a..99e42411 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -85,7 +85,7 @@ LocalPlayer::LocalPlayer(int id, int subtype):
mAfkTime(0),
mAwayMode(false)
{
- listen(CHANNEL_ATTRIBUTES);
+ listen(Event::AttributesChannel);
mAwayListener = new AwayListener();
@@ -93,8 +93,8 @@ LocalPlayer::LocalPlayer(int id, int subtype):
setShowName(config.getValue("showownname", 1));
- listen(CHANNEL_CONFIG);
- listen(CHANNEL_ACTORSPRITE);
+ listen(Event::ConfigChannel);
+ listen(Event::ActorSpriteChannel);
}
LocalPlayer::~LocalPlayer()
@@ -105,8 +105,8 @@ LocalPlayer::~LocalPlayer()
void LocalPlayer::logic()
{
- // Actions are allowed once per second
- if (get_elapsed_time(mLastAction) >= 1000)
+ // Actions are allowed at 5.5 per second
+ if (get_elapsed_time(mLastAction) >= 182)
mLastAction = -1;
// Show XP messages
@@ -980,11 +980,11 @@ void LocalPlayer::addMessageToQueue(const std::string &message, int color)
mMessages.push_back(MessagePair(message, color));
}
-void LocalPlayer::event(Channels channel, const Mana::Event &event)
+void LocalPlayer::event(Event::Channel channel, const Event &event)
{
- if (channel == CHANNEL_ACTORSPRITE)
+ if (channel == Event::ActorSpriteChannel)
{
- if (event.getName() == EVENT_DESTROYED)
+ if (event.getType() == Event::Destroyed)
{
ActorSprite *actor = event.getActor("source");
@@ -995,9 +995,9 @@ void LocalPlayer::event(Channels channel, const Mana::Event &event)
mTarget = 0;
}
}
- else if (channel == CHANNEL_ATTRIBUTES)
+ else if (channel == Event::AttributesChannel)
{
- if (event.getName() == EVENT_UPDATEATTRIBUTE)
+ if (event.getType() == Event::UpdateAttribute)
{
if (event.getInt("id") == EXP)
{
@@ -1008,9 +1008,9 @@ void LocalPlayer::event(Channels channel, const Mana::Event &event)
}
}
}
- else if (channel == CHANNEL_CONFIG)
+ else if (channel == Event::ConfigChannel)
{
- if (event.getName() == EVENT_CONFIGOPTIONCHANGED &&
+ if (event.getType() == Event::ConfigOptionChanged &&
event.getString("option") == "showownname")
{
setShowName(config.getValue("showownname", 1));
diff --git a/src/localplayer.h b/src/localplayer.h
index 01f31e01..4f7e32a6 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -55,7 +55,7 @@ enum
PICKUP_TOO_FAR,
PICKUP_INV_FULL,
PICKUP_STACK_FULL,
- PICKUP_DROP_STEAL,
+ PICKUP_DROP_STEAL
};
/**
@@ -70,14 +70,8 @@ enum { ATTACK_RANGE_NOT_SET = -1 };
class LocalPlayer : public Being
{
public:
- /**
- * Constructor.
- */
LocalPlayer(int id= 65535, int subtype = 0);
- /**
- * Destructor.
- */
~LocalPlayer();
virtual void logic();
@@ -219,7 +213,7 @@ class LocalPlayer : public Being
void addMessageToQueue(const std::string &message,
int color = UserPalette::EXP_INFO);
- void event(Channels channel, const Mana::Event &event);
+ void event(Event::Channel channel, const Event &event);
/**
* Tells the engine wether to check
@@ -274,4 +268,4 @@ class LocalPlayer : public Being
extern LocalPlayer *player_node;
-#endif
+#endif // LOCALPLAYER_H
diff --git a/src/log.h b/src/log.h
index 4615f626..a508d171 100644
--- a/src/log.h
+++ b/src/log.h
@@ -19,8 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _LOG_H
-#define _LOG_H
+#ifndef LOG_H
+#define LOG_H
#include <fstream>
@@ -30,9 +30,6 @@
class Logger
{
public:
- /**
- * Constructor.
- */
Logger();
/**
diff --git a/src/main.h b/src/main.h
index 38ab6337..3a644100 100644
--- a/src/main.h
+++ b/src/main.h
@@ -55,7 +55,7 @@
#elif defined WIN32
#include "winver.h"
#elif defined __APPLE__
-#define PACKAGE_VERSION "0.5.0"
+#define PACKAGE_VERSION "0.5.1"
#endif
#ifdef PACKAGE_VERSION
diff --git a/src/map.cpp b/src/map.cpp
index b660653d..da962253 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -46,9 +46,6 @@
*/
struct Location
{
- /**
- * Constructor.
- */
Location(int px, int py, MetaTile *ptile):
x(px), y(py), tile(ptile)
{}
diff --git a/src/map.h b/src/map.h
index d49cd920..67135a99 100644
--- a/src/map.h
+++ b/src/map.h
@@ -47,9 +47,6 @@ typedef std::vector<MapLayer*> Layers;
*/
struct MetaTile
{
- /**
- * Constructor.
- */
MetaTile() : whichList(0), blockmask(0) {}
// Pathfinding members
@@ -93,9 +90,6 @@ class MapLayer
*/
MapLayer(int x, int y, int width, int height, bool isFringeLayer);
- /**
- * Destructor.
- */
~MapLayer();
/**
@@ -176,9 +170,6 @@ class Map : public Properties
*/
Map(int width, int height, int tileWidth, int tileHeight);
- /**
- * Destructor.
- */
~Map();
/**
diff --git a/src/net/logindata.h b/src/net/logindata.h
index 4a1c1a9f..dc2ef52b 100644
--- a/src/net/logindata.h
+++ b/src/net/logindata.h
@@ -29,9 +29,6 @@
class LoginData
{
public:
- /**
- * Constructor
- */
LoginData()
{
resetCharacterSlots();
@@ -57,7 +54,7 @@ public:
*/
void resetCharacterSlots()
{
- characterSlots = 3; // Default value, used for TmwAthena.
+ characterSlots = 3; // Default value, used for TmwAthena.
}
void clear()
diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp
index 220ecfba..f8cefecf 100644
--- a/src/net/manaserv/beinghandler.cpp
+++ b/src/net/manaserv/beinghandler.cpp
@@ -40,6 +40,8 @@
#include "utils/gettext.h"
+#define POSITION_DIFF_TOLERANCE 48
+
namespace ManaServ {
BeingHandler::BeingHandler()
@@ -186,20 +188,27 @@ void BeingHandler::handleBeingsMoveMessage(Net::MessageIn &msg)
int id = msg.readInt16();
int flags = msg.readInt8();
Being *being = actorSpriteManager->findBeing(id);
- int sx = 0;
- int sy = 0;
- int speed = 0;
+ int sx, sy, dx, dy, speed = 0;
+
+ if ((!flags & (MOVING_POSITION | MOVING_DESTINATION)))
+ continue;
if (flags & MOVING_POSITION)
{
sx = msg.readInt16();
sy = msg.readInt16();
- speed = msg.readInt8();
}
- if (!being || !(flags & (MOVING_POSITION | MOVING_DESTINATION)))
+
+ if (flags & MOVING_DESTINATION)
{
- continue;
+ dx = msg.readInt16();
+ dy = msg.readInt16();
+ speed = msg.readInt8();
}
+
+ if (!being)
+ continue;
+
if (speed)
{
/*
@@ -216,10 +225,18 @@ void BeingHandler::handleBeingsMoveMessage(Net::MessageIn &msg)
if (being == player_node)
continue;
+ // If the position differs too much from the actual one, we resync
+ // the being position
if (flags & MOVING_POSITION)
{
- being->setDestination(sx, sy);
+ Vector serverPos(sx, sy);
+ if (serverPos.length()
+ - being->getPosition().length() > POSITION_DIFF_TOLERANCE)
+ being->setPosition(serverPos);
}
+
+ if (flags & MOVING_DESTINATION)
+ being->setDestination(dx, dy);
}
}
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp
index 961b364a..79f3b35a 100644
--- a/src/net/manaserv/charhandler.cpp
+++ b/src/net/manaserv/charhandler.cpp
@@ -196,6 +196,14 @@ void CharHandler::handleCharacterDeleteResponse(Net::MessageIn &msg)
if (errMsg == ERRMSG_OK)
{
// Character deletion successful
+ for (unsigned i = 0; i < mCachedCharacterInfos.size(); ++i)
+ {
+ if (mCachedCharacterInfos[i].slot == mSelectedCharacter->slot)
+ {
+ mCachedCharacterInfos.erase(mCachedCharacterInfos.begin() + i);
+ break;
+ }
+ }
delete mSelectedCharacter;
mCharacters.remove(mSelectedCharacter);
updateCharSelectDialog();
@@ -248,9 +256,20 @@ void CharHandler::handleCharacterSelectResponse(Net::MessageIn &msg)
Client::setState(STATE_CONNECT_GAME);
}
- else if (errMsg == ERRMSG_FAILURE)
+ else
{
- errorMessage = _("No gameservers are available.");
+ switch (errMsg)
+ {
+ case ERRMSG_FAILURE:
+ errorMessage = _("No gameservers are available.");
+ break;
+ case ERRMSG_INVALID_ARGUMENT:
+ errorMessage = _("Invalid character slot selected.");
+ break;
+ default:
+ errorMessage = strprintf(_("Unhandled character select "
+ "error message %i."), errMsg);
+ }
delete_all(mCharacters);
mCharacters.clear();
Client::setState(STATE_ERROR);
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index 705795f4..6c97fae3 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -165,7 +165,8 @@ void ChatHandler::handleGameChatMessage(Net::MessageIn &msg)
std::string mes = being->getName() + " : " + chatMsg;
- Mana::Event event(being == player_node ? EVENT_PLAYER : EVENT_BEING);
+ Event event(being == player_node ? Event::Player
+ : Event::Being);
event.setString("message", mes);
event.setString("text", chatMsg);
event.setString("nick", being->getName());
@@ -173,7 +174,7 @@ void ChatHandler::handleGameChatMessage(Net::MessageIn &msg)
event.setInt("permissions", player_relations
.checkPermissionSilently(being->getName(),
PlayerRelation::SPEECH_LOG | PlayerRelation::SPEECH_FLOAT));
- event.trigger(CHANNEL_CHAT);
+ event.trigger(Event::ChatChannel);
}
void ChatHandler::handleEnterChannelResponse(Net::MessageIn &msg)
@@ -233,18 +234,18 @@ void ChatHandler::handlePrivateMessage(Net::MessageIn &msg)
std::string userNick = msg.readString();
std::string chatMsg = msg.readString();
- Mana::Event event(EVENT_WHISPER);
+ Event event(Event::Whisper);
event.setString("nick", userNick);
event.setString("message", chatMsg);
- event.trigger(CHANNEL_CHAT);
+ event.trigger(Event::ChatChannel);
}
void ChatHandler::handleAnnouncement(Net::MessageIn &msg)
{
std::string chatMsg = msg.readString();
- Mana::Event event(EVENT_ANNOUNCEMENT);
+ Event event(Event::Announcement);
event.setString("message", chatMsg);
- event.trigger(CHANNEL_CHAT);
+ event.trigger(Event::ChatChannel);
}
void ChatHandler::handleChatMessage(Net::MessageIn &msg)
diff --git a/src/net/manaserv/connection.cpp b/src/net/manaserv/connection.cpp
index b404191f..4b421a04 100644
--- a/src/net/manaserv/connection.cpp
+++ b/src/net/manaserv/connection.cpp
@@ -60,11 +60,7 @@ bool Connection::connect(const std::string &address, short port)
enetAddress.port = port;
// Initiate the connection, allocating channel 0.
-#if defined(ENET_VERSION) && ENET_VERSION >= ENET_CUTOFF
mConnection = enet_host_connect(mClient, &enetAddress, 1, 0);
-#else
- mConnection = enet_host_connect(mClient, &enetAddress, 1);
-#endif
if (!mConnection)
{
diff --git a/src/net/manaserv/connection.h b/src/net/manaserv/connection.h
index 808a6d40..b39f8957 100644
--- a/src/net/manaserv/connection.h
+++ b/src/net/manaserv/connection.h
@@ -26,12 +26,6 @@
#include <iosfwd>
-#ifdef ENET_VERSION_CREATE
-#define ENET_CUTOFF ENET_VERSION_CREATE(1,3,0)
-#else
-#define ENET_CUTOFF 0xFFFFFFFF
-#endif
-
namespace ManaServ
{
class MessageOut;
diff --git a/src/net/manaserv/effecthandler.cpp b/src/net/manaserv/effecthandler.cpp
index 2df3fe0b..7051bedd 100644
--- a/src/net/manaserv/effecthandler.cpp
+++ b/src/net/manaserv/effecthandler.cpp
@@ -25,6 +25,8 @@
#include "effectmanager.h"
#include "log.h"
+#include "gui/viewport.h"
+
#include "net/messagein.h"
#include "net/manaserv/manaserv_protocol.h"
@@ -36,6 +38,7 @@ EffectHandler::EffectHandler()
static const Uint16 _messages[] = {
GPMSG_CREATE_EFFECT_POS,
GPMSG_CREATE_EFFECT_BEING,
+ GPMSG_SHAKE,
0
};
handledMessages = _messages;
@@ -51,6 +54,9 @@ void EffectHandler::handleMessage(Net::MessageIn &msg)
case GPMSG_CREATE_EFFECT_BEING:
handleCreateEffectBeing(msg);
break;
+ case GPMSG_SHAKE:
+ handleShake(msg);
+ break;
default:
break;
}
@@ -75,4 +81,36 @@ void EffectHandler::handleCreateEffectBeing(Net::MessageIn &msg)
logger->log("Warning: CreateEffect called for unknown being #%d", bid);
}
+void EffectHandler::handleShake(Net::MessageIn &msg)
+{
+ int16_t intensityX = 0;
+ int16_t intensityY = 0;
+ float decay;
+ int duration;
+
+ switch (msg.getUnreadLength())
+ {
+ case 4:
+ intensityX = msg.readInt16();
+ intensityY = msg.readInt16();
+ viewport->shakeScreen(intensityX, intensityY);
+ break;
+ case 6:
+ intensityX = msg.readInt16();
+ intensityY = msg.readInt16();
+ decay = msg.readInt16() / 10000.0f;
+ viewport->shakeScreen(intensityX, intensityY, decay);
+ break;
+ case 8:
+ intensityX = msg.readInt16();
+ intensityY = msg.readInt16();
+ decay = msg.readInt16() / 10000.0f;
+ duration = msg.readInt16();
+ viewport->shakeScreen(intensityX, intensityY, decay, duration);
+ break;
+ default:
+ logger->log("Warning: Received GPMSG_SHAKE message with unexpected length of %d bytes", msg.getUnreadLength());
+ }
+}
+
} // namespace ManaServ
diff --git a/src/net/manaserv/effecthandler.h b/src/net/manaserv/effecthandler.h
index a0445aad..d31c3421 100644
--- a/src/net/manaserv/effecthandler.h
+++ b/src/net/manaserv/effecthandler.h
@@ -36,6 +36,7 @@ class EffectHandler : public MessageHandler
private:
void handleCreateEffectPos(Net::MessageIn &msg);
void handleCreateEffectBeing(Net::MessageIn &msg);
+ void handleShake(Net::MessageIn &msg);
};
} // namespace ManaServ
diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp
index d2151307..68d5ee9e 100644
--- a/src/net/manaserv/generalhandler.cpp
+++ b/src/net/manaserv/generalhandler.cpp
@@ -91,8 +91,8 @@ GeneralHandler::GeneralHandler():
generalHandler = this;
- listen(CHANNEL_CLIENT);
- listen(CHANNEL_GAME);
+ listen(Event::ClientChannel);
+ listen(Event::GameChannel);
}
void GeneralHandler::load()
@@ -171,12 +171,12 @@ void GeneralHandler::clearHandlers()
clearNetworkHandlers();
}
-void GeneralHandler::event(Channels channel,
- const Mana::Event &event)
+void GeneralHandler::event(Event::Channel channel,
+ const Event &event)
{
- if (channel == CHANNEL_CLIENT)
+ if (channel == Event::ClientChannel)
{
- if (event.getName() == EVENT_STATECHANGE)
+ if (event.getType() == Event::StateChange)
{
int newState = event.getInt("newState");
@@ -186,15 +186,15 @@ void GeneralHandler::event(Channels channel,
game->gameLoading();
}
}
- else if (event.getName() == EVENT_DBSLOADING)
+ else if (event.getType() == Event::LoadingDatabases)
{
Attributes::load();
Attributes::informItemDB();
}
}
- else if (channel == CHANNEL_GAME)
+ else if (channel == Event::GameChannel)
{
- if (event.getName() == EVENT_GUIWINDOWSLOADED)
+ if (event.getType() == Event::GuiWindowsLoaded)
{
inventoryWindow->setSplitAllowed(true);
skillDialog->loadSkills("mana-skills.xml");
diff --git a/src/net/manaserv/generalhandler.h b/src/net/manaserv/generalhandler.h
index c8671ec1..45ded011 100644
--- a/src/net/manaserv/generalhandler.h
+++ b/src/net/manaserv/generalhandler.h
@@ -22,7 +22,7 @@
#ifndef NET_MANASERV_GENERALHANDLER_H
#define NET_MANASERV_GENERALHANDLER_H
-#include "listener.h"
+#include "eventlistener.h"
#include "net/generalhandler.h"
#include "net/net.h"
@@ -31,7 +31,7 @@
namespace ManaServ {
-class GeneralHandler : public Net::GeneralHandler, public Mana::Listener
+class GeneralHandler : public Net::GeneralHandler, public EventListener
{
public:
GeneralHandler();
@@ -46,7 +46,7 @@ class GeneralHandler : public Net::GeneralHandler, public Mana::Listener
void clearHandlers();
- void event(Channels channel, const Mana::Event &event);
+ void event(Event::Channel channel, const Event &event);
protected:
MessageHandlerPtr mBeingHandler;
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp
index 5edf3597..ff9b69e6 100644
--- a/src/net/manaserv/inventoryhandler.cpp
+++ b/src/net/manaserv/inventoryhandler.cpp
@@ -52,7 +52,7 @@ InventoryHandler::InventoryHandler()
handledMessages = _messages;
inventoryHandler = this;
- listen(CHANNEL_ITEM);
+ listen(Event::ItemChannel);
}
void InventoryHandler::handleMessage(Net::MessageIn &msg)
@@ -108,10 +108,10 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
}
}
-void InventoryHandler::event(Channels channel,
- const Mana::Event &event)
+void InventoryHandler::event(Event::Channel channel,
+ const Event &event)
{
- if (channel == CHANNEL_ITEM)
+ if (channel == Event::ItemChannel)
{
Item *item = event.getItem("item");
@@ -120,13 +120,13 @@ void InventoryHandler::event(Channels channel,
int index = item->getInvIndex();
- if (event.getName() == EVENT_DOEQUIP)
+ if (event.getType() == Event::DoEquip)
{
MessageOut msg(PGMSG_EQUIP);
msg.writeInt8(index);
gameServerConnection->send(msg);
}
- else if (event.getName() == EVENT_DOUNEQUIP)
+ else if (event.getType() == Event::DoUnequip)
{
MessageOut msg(PGMSG_UNEQUIP);
msg.writeInt8(index);
@@ -136,13 +136,13 @@ void InventoryHandler::event(Channels channel,
// for instance.
mEquips.setEquipment(index, 0, 0);
}
- else if (event.getName() == EVENT_DOUSE)
+ else if (event.getType() == Event::DoUse)
{
MessageOut msg(PGMSG_USE_ITEM);
msg.writeInt8(index);
gameServerConnection->send(msg);
}
- else if (event.getName() == EVENT_DODROP)
+ else if (event.getType() == Event::DoDrop)
{
int amount = event.getInt("amount", 1);
@@ -151,7 +151,7 @@ void InventoryHandler::event(Channels channel,
msg.writeInt8(amount);
gameServerConnection->send(msg);
}
- else if (event.getName() == EVENT_DOSPLIT)
+ else if (event.getType() == Event::DoSplit)
{
int amount = event.getInt("amount", 1);
@@ -165,7 +165,7 @@ void InventoryHandler::event(Channels channel,
gameServerConnection->send(msg);
}
}
- else if (event.getName() == EVENT_DOMOVE)
+ else if (event.getType() == Event::DoMove)
{
int newIndex = event.getInt("newIndex", -1);
diff --git a/src/net/manaserv/inventoryhandler.h b/src/net/manaserv/inventoryhandler.h
index bb68ceeb..2733f3da 100644
--- a/src/net/manaserv/inventoryhandler.h
+++ b/src/net/manaserv/inventoryhandler.h
@@ -23,7 +23,7 @@
#define NET_MANASERV_INVENTORYHANDLER_H
#include "equipment.h"
-#include "listener.h"
+#include "eventlistener.h"
#include "net/inventoryhandler.h"
@@ -59,14 +59,14 @@ class EquipBackend : public Equipment::Backend
};
class InventoryHandler : public MessageHandler, Net::InventoryHandler,
- public Mana::Listener
+ public EventListener
{
public:
InventoryHandler();
void handleMessage(Net::MessageIn &msg);
- void event(Channels channel, const Mana::Event &event);
+ void event(Event::Channel channel, const Event &event);
bool canSplit(const Item *item);
diff --git a/src/net/manaserv/manaserv_protocol.h b/src/net/manaserv/manaserv_protocol.h
index 84f1c1a5..b5023a42 100644
--- a/src/net/manaserv/manaserv_protocol.h
+++ b/src/net/manaserv/manaserv_protocol.h
@@ -118,7 +118,7 @@ enum {
PGMSG_DIRECTION_CHANGE = 0x0272, // B Direction
GPMSG_BEING_DIR_CHANGE = 0x0273, // W being id, B direction
GPMSG_BEING_HEALTH_CHANGE = 0x0274, // W being id, W hp, W max hp
- GPMSG_BEINGS_MOVE = 0x0280, // { W being id, B flags [, W*2 position, B speed] }*
+ GPMSG_BEINGS_MOVE = 0x0280, // { W being id, B flags [, [W*2 position,] W*2 destination, B speed] }*
GPMSG_ITEMS = 0x0281, // { W item id, W*2 position }*
PGMSG_ATTACK = 0x0290, // W being id
GPMSG_BEING_ATTACK = 0x0291, // W being id, B direction, B attacktype
@@ -163,6 +163,7 @@ enum {
GPMSG_BEINGS_DAMAGE = 0x0310, // { W being id, W amount }*
GPMSG_CREATE_EFFECT_POS = 0x0320, // W effect id, W*2 position
GPMSG_CREATE_EFFECT_BEING = 0x0321, // W effect id, W BeingID
+ GPMSG_SHAKE = 0x0330, // W intensityX, W intensityY, [W decay_times_10000, [W duration]]
// Guild
PCMSG_GUILD_CREATE = 0x0350, // S name
@@ -353,11 +354,6 @@ enum {
MOVING_DESTINATION = 2
};
-// Email change specific return values
-enum {
- EMAILCHG_EXISTS_EMAIL = 0x40
-};
-
// Chat errors return values
enum {
CHAT_USING_BAD_WORDS = 0x40,
diff --git a/src/net/manaserv/messagein.h b/src/net/manaserv/messagein.h
index fe77c436..6d0a4035 100644
--- a/src/net/manaserv/messagein.h
+++ b/src/net/manaserv/messagein.h
@@ -34,9 +34,6 @@ namespace ManaServ {
class MessageIn : public Net::MessageIn
{
public:
- /**
- * Constructor.
- */
MessageIn(const char *data, unsigned int length);
int readInt16(); /**< Reads a short. */
diff --git a/src/net/manaserv/messageout.h b/src/net/manaserv/messageout.h
index 7c474cda..451bc0aa 100644
--- a/src/net/manaserv/messageout.h
+++ b/src/net/manaserv/messageout.h
@@ -29,14 +29,8 @@ namespace ManaServ {
class MessageOut : public Net::MessageOut
{
public:
- /**
- * Constructor.
- */
MessageOut(short id);
- /**
- * Destructor.
- */
~MessageOut();
void writeInt16(Sint16 value); /**< Writes a short. */
diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp
index a5bf6186..03bd7b28 100644
--- a/src/net/manaserv/network.cpp
+++ b/src/net/manaserv/network.cpp
@@ -53,11 +53,7 @@ void initialize()
logger->error("Failed to initialize ENet.");
}
-#if defined(ENET_VERSION) && ENET_VERSION >= ENET_CUTOFF
client = enet_host_create(NULL, 3, 0, 0, 0);
-#else
- client = enet_host_create(NULL, 3, 0, 0);
-#endif
if (!client)
{
diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp
index ca7d7415..1c89f39f 100644
--- a/src/net/manaserv/npchandler.cpp
+++ b/src/net/manaserv/npchandler.cpp
@@ -62,12 +62,12 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
}
int npcId = being->getId(), count = 0;
- Mana::Event *event = 0;
+ Event *event = 0;
switch (msg.getId())
{
case GPMSG_NPC_CHOICE:
- event = new Mana::Event(EVENT_MENU);
+ event = new Event(Event::Menu);
event->setInt("id", npcId);
while (msg.getUnreadLength())
{
@@ -75,52 +75,52 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
event->setString("choice" + toString(count), msg.readString());
}
event->setInt("choiceCount", count);
- event->trigger(CHANNEL_NPC);
+ event->trigger(Event::NpcChannel);
break;
case GPMSG_NPC_NUMBER:
- event = new Mana::Event(EVENT_INTEGERINPUT);
+ event = new Event(Event::IntegerInput);
event->setInt("id", npcId);
event->setInt("min", msg.readInt32());
event->setInt("max", msg.readInt32());
event->setInt("default", msg.readInt32());
- event->trigger(CHANNEL_NPC);
+ event->trigger(Event::NpcChannel);
break;
case GPMSG_NPC_STRING:
- event = new Mana::Event(EVENT_STRINGINPUT);
+ event = new Event(Event::StringInput);
event->setInt("id", npcId);
- event->trigger(CHANNEL_NPC);
+ event->trigger(Event::NpcChannel);
break;
case GPMSG_NPC_POST:
- event = new Mana::Event(EVENT_POST);
+ event = new Event(Event::Post);
event->setInt("id", npcId);
- event->trigger(CHANNEL_NPC);
+ event->trigger(Event::NpcChannel);
break;
case GPMSG_NPC_ERROR:
- event = new Mana::Event(EVENT_END);
+ event = new Event(Event::End);
event->setInt("id", npcId);
- event->trigger(CHANNEL_NPC);
+ event->trigger(Event::NpcChannel);
break;
case GPMSG_NPC_MESSAGE:
- event = new Mana::Event(EVENT_MESSAGE);
+ event = new Event(Event::Message);
event->setInt("id", npcId);
event->setString("text", msg.readString(msg.getUnreadLength()));
- event->trigger(CHANNEL_NPC);
+ event->trigger(Event::NpcChannel);
delete event;
- event = new Mana::Event(EVENT_NEXT);
+ event = new Event(Event::Next);
event->setInt("id", npcId);
- event->trigger(CHANNEL_NPC);
+ event->trigger(Event::NpcChannel);
break;
case GPMSG_NPC_CLOSE:
- event = new Mana::Event(EVENT_CLOSE);
+ event = new Event(Event::Close);
event->setInt("id", npcId);
- event->trigger(CHANNEL_NPC);
+ event->trigger(Event::NpcChannel);
break;
}
@@ -169,9 +169,9 @@ void NpcHandler::talk(int npcId)
msg.writeInt16(npcId);
gameServerConnection->send(msg);
- Mana::Event event(EVENT_TALKSENT);
+ Event event(Event::TalkSent);
event.setInt("npcId", npcId);
- event.trigger(CHANNEL_NPC);
+ event.trigger(Event::NpcChannel);
}
void NpcHandler::nextDialog(int npcId)
@@ -180,9 +180,9 @@ void NpcHandler::nextDialog(int npcId)
msg.writeInt16(npcId);
gameServerConnection->send(msg);
- Mana::Event event(EVENT_NEXTSENT);
+ Event event(Event::NextSent);
event.setInt("npcId", npcId);
- event.trigger(CHANNEL_NPC);
+ event.trigger(Event::NpcChannel);
}
void NpcHandler::closeDialog(int npcId)
@@ -191,9 +191,9 @@ void NpcHandler::closeDialog(int npcId)
msg.writeInt16(npcId);
gameServerConnection->send(msg);
- Mana::Event event(EVENT_CLOSESENT);
+ Event event(Event::CloseSent);
event.setInt("npcId", npcId);
- event.trigger(CHANNEL_NPC);
+ event.trigger(Event::NpcChannel);
}
void NpcHandler::menuSelect(int npcId, int choice)
@@ -203,10 +203,10 @@ void NpcHandler::menuSelect(int npcId, int choice)
msg.writeInt8(choice);
gameServerConnection->send(msg);
- Mana::Event event(EVENT_MENUSENT);
+ Event event(Event::MenuSent);
event.setInt("npcId", npcId);
event.setInt("choice", choice);
- event.trigger(CHANNEL_NPC);
+ event.trigger(Event::NpcChannel);
}
void NpcHandler::integerInput(int npcId, int value)
@@ -216,10 +216,10 @@ void NpcHandler::integerInput(int npcId, int value)
msg.writeInt32(value);
gameServerConnection->send(msg);
- Mana::Event event(EVENT_INTEGERINPUTSENT);
+ Event event(Event::IntegerInputSent);
event.setInt("npcId", npcId);
event.setInt("value", value);
- event.trigger(CHANNEL_NPC);
+ event.trigger(Event::NpcChannel);
}
void NpcHandler::stringInput(int npcId, const std::string &value)
@@ -229,10 +229,10 @@ void NpcHandler::stringInput(int npcId, const std::string &value)
msg.writeString(value);
gameServerConnection->send(msg);
- Mana::Event event(EVENT_STRINGINPUTSENT);
+ Event event(Event::StringInputSent);
event.setInt("npcId", npcId);
event.setString("value", value);
- event.trigger(CHANNEL_NPC);
+ event.trigger(Event::NpcChannel);
}
void NpcHandler::sendLetter(int npcId, const std::string &recipient,
@@ -243,11 +243,11 @@ void NpcHandler::sendLetter(int npcId, const std::string &recipient,
msg.writeString(text);
gameServerConnection->send(msg);
- Mana::Event event(EVENT_SENDLETTERSENT);
+ Event event(Event::SendLetterSent);
event.setInt("npcId", npcId);
event.setString("recipient", recipient);
event.setString("text", text);
- event.trigger(CHANNEL_NPC);
+ event.trigger(Event::NpcChannel);
}
} // namespace ManaServ
diff --git a/src/net/manaserv/npchandler.h b/src/net/manaserv/npchandler.h
index cb8fd67d..bda4de31 100644
--- a/src/net/manaserv/npchandler.h
+++ b/src/net/manaserv/npchandler.h
@@ -22,7 +22,7 @@
#ifndef NET_MANASERV_NPCHANDLER_H
#define NET_MANASERV_NPCHANDLER_H
-#include "listener.h"
+#include "eventlistener.h"
#include "net/npchandler.h"
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index 0ac55d86..4249bac8 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -65,7 +65,7 @@ void RespawnRequestListener::action(const gcn::ActionEvent &event)
{
Net::getPlayerHandler()->respawn();
- Mana::Event::trigger(CHANNEL_NPC, EVENT_CLOSEALL);
+ Event::trigger(Event::NpcChannel, Event::CloseAll);
}
PlayerHandler::PlayerHandler()
diff --git a/src/net/messagein.h b/src/net/messagein.h
index e6118a04..29f5e930 100644
--- a/src/net/messagein.h
+++ b/src/net/messagein.h
@@ -89,9 +89,6 @@ class MessageIn
virtual ~MessageIn() {}
protected:
- /**
- * Constructor.
- */
MessageIn(const char *data, unsigned int length);
const char *mData; /**< The message data. */
diff --git a/src/net/messageout.h b/src/net/messageout.h
index 7fd6fbc5..05a55422 100644
--- a/src/net/messageout.h
+++ b/src/net/messageout.h
@@ -59,9 +59,6 @@ class MessageOut
virtual ~MessageOut() {}
protected:
- /**
- * Constructor.
- */
MessageOut(short id);
/**
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index 33826762..51974eb2 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -82,20 +82,20 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
break;
case 0x01:
{
- Mana::Event event(EVENT_WHISPERERROR);
+ Event event(Event::WhisperError);
event.setString("nick", nick);
event.setString("error", strprintf(_("Whisper could "
"not be sent, %s is offline."), nick.c_str()));
- event.trigger(CHANNEL_CHAT);
+ event.trigger(Event::ChatChannel);
}
break;
case 0x02:
{
- Mana::Event event(EVENT_WHISPERERROR);
+ Event event(Event::WhisperError);
event.setString("nick", nick);
event.setString("error", strprintf(_("Whisper could "
"not be sent, ignored by %s."), nick.c_str()));
- event.Event::trigger(CHANNEL_CHAT);
+ event.Event::trigger(Event::ChatChannel);
}
break;
}
@@ -115,10 +115,10 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
{
if (player_relations.hasPermission(nick, PlayerRelation::WHISPER))
{
- Mana::Event event(EVENT_WHISPER);
+ Event event(Event::Whisper);
event.setString("nick", nick);
event.setString("message", chatMsg);
- event.trigger(CHANNEL_CHAT);
+ event.trigger(Event::ChatChannel);
}
}
else
@@ -174,13 +174,13 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
std::string reducedMessage = chatMsg;
chatMsg = removeColors(sender_name) + " : " + reducedMessage;
- Mana::Event event(EVENT_BEING);
+ Event event(Event::Being);
event.setString("message", chatMsg);
event.setString("text", reducedMessage);
event.setString("nick", sender_name);
event.setInt("beingId", beingId);
event.setInt("permissions", perms);
- event.trigger(CHANNEL_CHAT);
+ event.trigger(Event::ChatChannel);
break;
}
@@ -205,7 +205,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
trim(chatMsg);
- Mana::Event event(EVENT_PLAYER);
+ Event event(Event::Player);
event.setString("message", mes);
event.setString("text", chatMsg);
event.setString("nick", player_node->getName());
@@ -213,13 +213,13 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
event.setInt("permissions", player_relations.getDefault()
& (PlayerRelation::SPEECH_LOG
| PlayerRelation::SPEECH_FLOAT));
- event.trigger(CHANNEL_CHAT);
+ event.trigger(Event::ChatChannel);
}
else
{
- Mana::Event event(EVENT_ANNOUNCEMENT);
+ Event event(Event::Announcement);
event.setString("message", chatMsg);
- event.trigger(CHANNEL_CHAT);
+ event.trigger(Event::ChatChannel);
}
break;
}
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp
index a72c12da..2194c77d 100644
--- a/src/net/tmwa/gamehandler.cpp
+++ b/src/net/tmwa/gamehandler.cpp
@@ -58,7 +58,7 @@ GameHandler::GameHandler()
handledMessages = _messages;
gameHandler = this;
- listen(CHANNEL_GAME);
+ listen(Event::GameChannel);
}
void GameHandler::handleMessage(Net::MessageIn &msg)
@@ -106,11 +106,11 @@ void GameHandler::handleMessage(Net::MessageIn &msg)
}
}
-void GameHandler::event(Channels channel, const Mana::Event &event)
+void GameHandler::event(Event::Channel channel, const Event &event)
{
- if (channel == CHANNEL_GAME)
+ if (channel == Event::GameChannel)
{
- if (event.getName() == EVENT_ENGINESINITALIZED)
+ if (event.getType() == Event::EnginesInitialized)
{
Game *game = Game::instance();
game->changeMap(mMap);
@@ -124,7 +124,7 @@ void GameHandler::event(Channels channel, const Mana::Event &event)
mTileX = mTileY = 0;
}
}
- else if (event.getName() == EVENT_MAPLOADED)
+ else if (event.getType() == Event::MapLoaded)
{
MessageOut outMsg(CMSG_MAP_LOADED);
}
diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h
index 7aa18b12..016df18e 100644
--- a/src/net/tmwa/gamehandler.h
+++ b/src/net/tmwa/gamehandler.h
@@ -22,7 +22,7 @@
#ifndef NET_TA_MAPHANDLER_H
#define NET_TA_MAPHANDLER_H
-#include "listener.h"
+#include "eventlistener.h"
#include "net/gamehandler.h"
#include "net/net.h"
@@ -34,14 +34,14 @@
namespace TmwAthena {
class GameHandler : public MessageHandler, public Net::GameHandler,
- public Mana::Listener
+ public EventListener
{
public:
GameHandler();
void handleMessage(Net::MessageIn &msg);
- void event(Channels channel, const Mana::Event &event);
+ void event(Event::Channel channel, const Event &event);
void connect();
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 1935ad72..ef59ee12 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -108,7 +108,7 @@ GeneralHandler::GeneralHandler():
setStatsList(stats);
- listen(CHANNEL_GAME);
+ listen(Event::GameChannel);
}
GeneralHandler::~GeneralHandler()
@@ -217,12 +217,12 @@ void GeneralHandler::clearHandlers()
mNetwork->clearHandlers();
}
-void GeneralHandler::event(Channels channel,
- const Mana::Event &event)
+void GeneralHandler::event(Event::Channel channel,
+ const Event &event)
{
- if (channel == CHANNEL_GAME)
+ if (channel == Event::GameChannel)
{
- if (event.getName() == EVENT_GUIWINDOWSLOADED)
+ if (event.getType() == Event::GuiWindowsLoaded)
{
inventoryWindow->setSplitAllowed(false);
skillDialog->loadSkills("ea-skills.xml");
@@ -242,7 +242,7 @@ void GeneralHandler::event(Channels channel,
statusWindow->addAttribute(FLEE, _("% Evade"), false, "");
statusWindow->addAttribute(CRIT, _("% Critical"), false, "");
}
- else if (event.getName() == EVENT_GUIWINDOWSUNLOADING)
+ else if (event.getType() == Event::GuiWindowsUnloading)
{
socialWindow->removeTab(taGuild);
socialWindow->removeTab(taParty);
diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h
index 722c3215..a4725b89 100644
--- a/src/net/tmwa/generalhandler.h
+++ b/src/net/tmwa/generalhandler.h
@@ -22,7 +22,7 @@
#ifndef NET_TMWA_GENERALHANDLER_H
#define NET_TMWA_GENERALHANDLER_H
-#include "listener.h"
+#include "eventlistener.h"
#include "net/generalhandler.h"
#include "net/net.h"
@@ -32,7 +32,7 @@
namespace TmwAthena {
class GeneralHandler : public MessageHandler, public Net::GeneralHandler,
- public Mana::Listener
+ public EventListener
{
public:
GeneralHandler();
@@ -51,7 +51,7 @@ class GeneralHandler : public MessageHandler, public Net::GeneralHandler,
void clearHandlers();
- void event(Channels channel, const Mana::Event &event);
+ void event(Event::Channel channel, const Event &event);
protected:
MessageHandlerPtr mAdminHandler;
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index 88c72ed6..1340a091 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -111,7 +111,7 @@ InventoryHandler::InventoryHandler()
mStorage = 0;
mStorageWindow = 0;
- listen(CHANNEL_ITEM);
+ listen(Event::ItemChannel);
}
InventoryHandler::~InventoryHandler()
@@ -452,12 +452,12 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
}
}
-void InventoryHandler::event(Channels channel,
- const Mana::Event &event)
+void InventoryHandler::event(Event::Channel channel,
+ const Event &event)
{
- if (channel == CHANNEL_ITEM)
+ if (channel == Event::ItemChannel)
{
- if (event.getName() == EVENT_DOCLOSEINVENTORY)
+ if (event.getType() == Event::DoCloseInventory)
{
// No need to worry about type
MessageOut outMsg(CMSG_CLOSE_STORAGE);
@@ -471,24 +471,24 @@ void InventoryHandler::event(Channels channel,
int index = item->getInvIndex() + INVENTORY_OFFSET;
- if (event.getName() == EVENT_DOEQUIP)
+ if (event.getType() == Event::DoEquip)
{
MessageOut outMsg(CMSG_PLAYER_EQUIP);
outMsg.writeInt16(index);
outMsg.writeInt16(0);
}
- else if (event.getName() == EVENT_DOUNEQUIP)
+ else if (event.getType() == Event::DoUnequip)
{
MessageOut outMsg(CMSG_PLAYER_UNEQUIP);
outMsg.writeInt16(index);
}
- else if (event.getName() == EVENT_DOUSE)
+ else if (event.getType() == Event::DoUse)
{
MessageOut outMsg(CMSG_PLAYER_INVENTORY_USE);
outMsg.writeInt16(index);
outMsg.writeInt32(item->getId()); // unused
}
- else if (event.getName() == EVENT_DODROP)
+ else if (event.getType() == Event::DoDrop)
{
int amount = event.getInt("amount", 1);
@@ -498,7 +498,7 @@ void InventoryHandler::event(Channels channel,
outMsg.writeInt16(index);
outMsg.writeInt16(amount);
}
- else if (event.getName() == EVENT_DOMOVE)
+ else if (event.getType() == Event::DoMove)
{
int newIndex = event.getInt("newIndex", -1);
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index dfbefaa8..315be16c 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -24,7 +24,7 @@
#include "equipment.h"
#include "inventory.h"
-#include "listener.h"
+#include "eventlistener.h"
#include "playerinfo.h"
#include "gui/inventorywindow.h"
@@ -38,7 +38,8 @@
namespace TmwAthena {
-class EquipBackend : public Equipment::Backend {
+class EquipBackend : public Equipment::Backend
+{
public:
EquipBackend()
{
@@ -119,7 +120,7 @@ class InventoryItem
typedef std::list<InventoryItem> InventoryItems;
class InventoryHandler : public MessageHandler, public Net::InventoryHandler,
- public Mana::Listener
+ public EventListener
{
public:
enum {
@@ -133,7 +134,7 @@ class InventoryHandler : public MessageHandler, public Net::InventoryHandler,
void handleMessage(Net::MessageIn &msg);
- void event(Channels channel, const Mana::Event &event);
+ void event(Event::Channel channel, const Event &event);
bool canSplit(const Item *item);
diff --git a/src/net/tmwa/messagein.h b/src/net/tmwa/messagein.h
index aa94bba1..13d6adf5 100644
--- a/src/net/tmwa/messagein.h
+++ b/src/net/tmwa/messagein.h
@@ -37,9 +37,6 @@ namespace TmwAthena {
class MessageIn : public Net::MessageIn
{
public:
- /**
- * Constructor.
- */
MessageIn(const char *data, unsigned int length);
int readInt16(); /**< Reads a short. */
diff --git a/src/net/tmwa/messageout.h b/src/net/tmwa/messageout.h
index c9d87a1b..34958e82 100644
--- a/src/net/tmwa/messageout.h
+++ b/src/net/tmwa/messageout.h
@@ -39,9 +39,6 @@ class Network;
class MessageOut : public Net::MessageOut
{
public:
- /**
- * Constructor.
- */
MessageOut(short id);
void writeInt16(Sint16 value); /**< Writes a short. */
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index 337226a9..092e3046 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -38,7 +38,7 @@
extern Net::NpcHandler *npcHandler;
-static void parseMenu(Mana::Event *event, const std::string &options)
+static void parseMenu(Event *event, const std::string &options)
{
std::istringstream iss(options);
@@ -78,50 +78,50 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
}
int npcId = msg.readInt32();
- Mana::Event *event = 0;
+ Event *event = 0;
switch (msg.getId())
{
case SMSG_NPC_CHOICE:
- event = new Mana::Event(EVENT_MENU);
+ event = new Event(Event::Menu);
event->setInt("id", npcId);
parseMenu(event, msg.readString(msg.getLength() - 8));
- event->trigger(CHANNEL_NPC);
+ event->trigger(Event::NpcChannel);
break;
case SMSG_NPC_MESSAGE:
- event = new Mana::Event(EVENT_MESSAGE);
+ event = new Event(Event::Message);
event->setInt("id", npcId);
event->setString("text", msg.readString(msg.getLength() - 8));
- event->trigger(CHANNEL_NPC);
+ event->trigger(Event::NpcChannel);
break;
case SMSG_NPC_CLOSE:
// Show the close button
- event = new Mana::Event(EVENT_CLOSE);
+ event = new Event(Event::Close);
event->setInt("id", npcId);
- event->trigger(CHANNEL_NPC);
+ event->trigger(Event::NpcChannel);
break;
case SMSG_NPC_NEXT:
// Show the next button
- event = new Mana::Event(EVENT_NEXT);
+ event = new Event(Event::Next);
event->setInt("id", npcId);
- event->trigger(CHANNEL_NPC);
+ event->trigger(Event::NpcChannel);
break;
case SMSG_NPC_INT_INPUT:
// Request for an integer
- event = new Mana::Event(EVENT_INTEGERINPUT);
+ event = new Event(Event::IntegerInput);
event->setInt("id", npcId);
- event->trigger(CHANNEL_NPC);
+ event->trigger(Event::NpcChannel);
break;
case SMSG_NPC_STR_INPUT:
// Request for a string
- event = new Mana::Event(EVENT_STRINGINPUT);
+ event = new Event(Event::StringInput);
event->setInt("id", npcId);
- event->trigger(CHANNEL_NPC);
+ event->trigger(Event::NpcChannel);
break;
}
@@ -177,9 +177,9 @@ void NpcHandler::talk(int npcId)
outMsg.writeInt32(npcId);
outMsg.writeInt8(0); // Unused
- Mana::Event event(EVENT_TALKSENT);
+ Event event(Event::TalkSent);
event.setInt("npcId", npcId);
- event.trigger(CHANNEL_NPC);
+ event.trigger(Event::NpcChannel);
}
void NpcHandler::nextDialog(int npcId)
@@ -187,9 +187,9 @@ void NpcHandler::nextDialog(int npcId)
MessageOut outMsg(CMSG_NPC_NEXT_REQUEST);
outMsg.writeInt32(npcId);
- Mana::Event event(EVENT_NEXTSENT);
+ Event event(Event::NextSent);
event.setInt("npcId", npcId);
- event.trigger(CHANNEL_NPC);
+ event.trigger(Event::NpcChannel);
}
void NpcHandler::closeDialog(int npcId)
@@ -197,9 +197,9 @@ void NpcHandler::closeDialog(int npcId)
MessageOut outMsg(CMSG_NPC_CLOSE);
outMsg.writeInt32(npcId);
- Mana::Event event(EVENT_CLOSESENT);
+ Event event(Event::CloseSent);
event.setInt("npcId", npcId);
- event.trigger(CHANNEL_NPC);
+ event.trigger(Event::NpcChannel);
}
void NpcHandler::menuSelect(int npcId, int choice)
@@ -208,10 +208,10 @@ void NpcHandler::menuSelect(int npcId, int choice)
outMsg.writeInt32(npcId);
outMsg.writeInt8(choice);
- Mana::Event event(EVENT_MENUSENT);
+ Event event(Event::MenuSent);
event.setInt("npcId", npcId);
event.setInt("choice", choice);
- event.trigger(CHANNEL_NPC);
+ event.trigger(Event::NpcChannel);
}
void NpcHandler::integerInput(int npcId, int value)
@@ -220,10 +220,10 @@ void NpcHandler::integerInput(int npcId, int value)
outMsg.writeInt32(npcId);
outMsg.writeInt32(value);
- Mana::Event event(EVENT_INTEGERINPUTSENT);
+ Event event(Event::IntegerInputSent);
event.setInt("npcId", npcId);
event.setInt("value", value);
- event.trigger(CHANNEL_NPC);
+ event.trigger(Event::NpcChannel);
}
void NpcHandler::stringInput(int npcId, const std::string &value)
@@ -234,10 +234,10 @@ void NpcHandler::stringInput(int npcId, const std::string &value)
outMsg.writeString(value, value.length());
outMsg.writeInt8(0); // Prevent problems with string reading
- Mana::Event event(EVENT_STRINGINPUTSENT);
+ Event event(Event::StringInputSent);
event.setInt("npcId", npcId);
event.setString("value", value);
- event.trigger(CHANNEL_NPC);
+ event.trigger(Event::NpcChannel);
}
void NpcHandler::sendLetter(int npcId, const std::string &recipient,
diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h
index 1e933418..7829924b 100644
--- a/src/net/tmwa/npchandler.h
+++ b/src/net/tmwa/npchandler.h
@@ -22,7 +22,7 @@
#ifndef NET_TA_NPCHANDLER_H
#define NET_TA_NPCHANDLER_H
-#include "listener.h"
+#include "eventlistener.h"
#include "net/npchandler.h"
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index f7a211d1..4bd637c3 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -83,7 +83,7 @@ namespace {
viewport->closePopupMenu();
- Mana::Event::trigger(CHANNEL_NPC, EVENT_CLOSEALL);
+ Event::trigger(Event::NpcChannel, Event::CloseAll);
}
} deathListener;
@@ -288,6 +288,7 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
if (PlayerInfo::getAttribute(HP) == 0 && !deathNotice)
{
+ viewport->shakeScreen(100);
deathNotice = new OkDialog(_("Message"),
randomDeathMessage(),
false);
diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
index 034b959d..69ba24af 100644
--- a/src/net/tmwa/tradehandler.cpp
+++ b/src/net/tmwa/tradehandler.cpp
@@ -191,7 +191,7 @@ void TradeHandler::handleMessage(Net::MessageIn &msg)
// Successfully added item
if (item->isEquippable() && item->isEquipped())
{
- item->doEvent(EVENT_DOUNEQUIP);
+ item->doEvent(Event::DoUnequip);
}
tradeWindow->addItem(item->getId(), true, quantity);
diff --git a/src/particle.h b/src/particle.h
index 0e39883b..bb8b17fe 100644
--- a/src/particle.h
+++ b/src/particle.h
@@ -68,9 +68,6 @@ class Particle : public Actor
*/
Particle(Map *map);
- /**
- * Destructor.
- */
~Particle();
/**
diff --git a/src/particleemitter.h b/src/particleemitter.h
index 9baaa73c..2dd6665e 100644
--- a/src/particleemitter.h
+++ b/src/particleemitter.h
@@ -41,9 +41,6 @@ class Particle;
class ParticleEmitter
{
public:
- /**
- * Constructor.
- */
ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *map, int rotation = 0);
/**
@@ -56,9 +53,6 @@ class ParticleEmitter
*/
ParticleEmitter & operator=(const ParticleEmitter &o);
- /**
- * Destructor.
- */
~ParticleEmitter();
/**
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index 1915822f..feb39413 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -24,7 +24,7 @@
#include "equipment.h"
#include "event.h"
#include "inventory.h"
-#include "listener.h"
+#include "eventlistener.h"
#include "log.h"
#include "resources/iteminfo.h"
@@ -57,17 +57,17 @@ int mLevelProgress = 0;
void triggerAttr(int id, int old)
{
- Mana::Event event(EVENT_UPDATEATTRIBUTE);
+ Event event(Event::UpdateAttribute);
event.setInt("id", id);
event.setInt("oldValue", old);
event.setInt("newValue", mData.mAttributes.find(id)->second);
- event.trigger(CHANNEL_ATTRIBUTES);
+ event.trigger(Event::AttributesChannel);
}
void triggerStat(int id, const std::string &changed, int old1, int old2 = 0)
{
StatMap::iterator it = mData.mStats.find(id);
- Mana::Event event(EVENT_UPDATESTAT);
+ Event event(Event::UpdateStat);
event.setInt("id", id);
event.setInt("base", it->second.base);
event.setInt("mod", it->second.mod);
@@ -76,7 +76,7 @@ void triggerStat(int id, const std::string &changed, int old1, int old2 = 0)
event.setString("changed", changed);
event.setInt("oldValue1", old1);
event.setInt("oldValue2", old2);
- event.trigger(CHANNEL_ATTRIBUTES);
+ event.trigger(Event::AttributesChannel);
}
// --- Attributes -------------------------------------------------------------
@@ -215,10 +215,10 @@ void setStorageCount(int count)
if (count != old)
{
- Mana::Event event(EVENT_STORAGECOUNT);
+ Event event(Event::StorageCount);
event.setInt("oldCount", old);
event.setInt("newCount", count);
- event.trigger(CHANNEL_STORAGE);
+ event.trigger(Event::StorageChannel);
}
}
@@ -236,10 +236,10 @@ void setNPCInteractionCount(int count)
if (count != old)
{
- Mana::Event event(EVENT_NPCCOUNT);
+ Event event(Event::NpcCount);
event.setInt("oldCount", old);
event.setInt("newCount", count);
- event.trigger(CHANNEL_NPC);
+ event.trigger(Event::NpcChannel);
}
}
@@ -255,10 +255,10 @@ void setNPCPostCount(int count)
if (count != old)
{
- Mana::Event event(EVENT_POSTCOUNT);
+ Event event(Event::PostCount);
event.setInt("oldCount", old);
event.setInt("newCount", count);
- event.trigger(CHANNEL_NPC);
+ event.trigger(Event::NpcChannel);
}
}
@@ -276,10 +276,10 @@ void setBuySellState(BuySellState buySellState)
if (buySellState != old)
{
- Mana::Event event(EVENT_STATECHANGE);
+ Event event(Event::StateChange);
event.setInt("oldState", old);
event.setInt("newState", buySellState);
- event.trigger(CHANNEL_BUYSELL);
+ event.trigger(Event::BuySellChannel);
}
}
@@ -295,9 +295,9 @@ void setTrading(bool trading)
if (notify)
{
- Mana::Event event(EVENT_TRADING);
+ Event event(Event::Trading);
event.setBool("trading", trading);
- event.trigger(CHANNEL_STATUS);
+ event.trigger(Event::StatusChannel);
}
}
@@ -348,20 +348,20 @@ void logic()
mSpecialRechargeUpdateNeeded++;
}
-class PlayerLogic : Mana::Listener
+class PlayerLogic : EventListener
{
public:
PlayerLogic()
{
- listen(CHANNEL_CLIENT);
- listen(CHANNEL_GAME);
+ listen(Event::ClientChannel);
+ listen(Event::GameChannel);
}
- void event(Channels channel, const Mana::Event &event)
+ void event(Event::Channel channel, const Event &event)
{
- if (channel == CHANNEL_CLIENT)
+ if (channel == Event::ClientChannel)
{
- if (event.getName() == EVENT_STATECHANGE)
+ if (event.getType() == Event::StateChange)
{
int newState = event.getInt("newState");
@@ -375,9 +375,9 @@ public:
}
}
}
- else if (channel == CHANNEL_GAME)
+ else if (channel == Event::GameChannel)
{
- if (event.getName() == EVENT_DESTRUCTED)
+ if (event.getType() == Event::Destructed)
{
delete mInventory;
delete mEquipment;
diff --git a/src/properties.h b/src/properties.h
index 1320b0c9..ce4904bf 100644
--- a/src/properties.h
+++ b/src/properties.h
@@ -32,9 +32,6 @@
class Properties
{
public:
- /**
- * Destructor.
- */
virtual ~Properties() {}
/**
diff --git a/src/resources/image.h b/src/resources/image.h
index 9fdc0997..5b361e1a 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -53,9 +53,6 @@ class Image : public Resource
#endif
public:
- /**
- * Destructor.
- */
virtual ~Image();
/**
@@ -274,9 +271,6 @@ class Image : public Resource
class SubImage : public Image
{
public:
- /**
- * Constructor.
- */
SubImage(Image *parent, SDL_Surface *image,
int x, int y, int width, int height);
#ifdef USE_OPENGL
@@ -284,9 +278,6 @@ class SubImage : public Image
int width, int height, int texWidth, int textHeight);
#endif
- /**
- * Destructor.
- */
~SubImage();
/**
diff --git a/src/resources/imageset.h b/src/resources/imageset.h
index 3289788f..7d2ce1f2 100644
--- a/src/resources/imageset.h
+++ b/src/resources/imageset.h
@@ -39,9 +39,6 @@ class ImageSet : public Resource
*/
ImageSet(Image *img, int w, int h, int margin = 0, int spacing = 0);
- /**
- * Destructor.
- */
~ImageSet();
/**
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 96cf8aef..1f17865f 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -275,7 +275,7 @@ static void checkParameter(int id, const T param, const T errorValue)
std::stringstream errMsg;
errMsg << "ItemDB: Missing " << param << " attribute for item id "
<< id << "!";
- logger->log(errMsg.str().c_str());
+ logger->log("%s", errMsg.str().c_str());
}
}
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 2fbcc228..76a74111 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -76,9 +76,6 @@ class ItemInfo
friend class ManaServ::ManaServItemDB;
public:
- /**
- * Constructor.
- */
ItemInfo():
mType(ITEM_UNUSABLE),
mWeight(0),
@@ -221,16 +218,13 @@ class TaItemInfo: public ItemInfo
friend class TaItemDB;
public:
- /**
- * Constructor.
- */
- TaItemInfo():ItemInfo()
+ TaItemInfo() : ItemInfo()
{}
// Declare TmwAthena Specific item info here
};
-}; // namespace TmwAthena
+} // namespace TmwAthena
namespace ManaServ {
@@ -241,16 +235,13 @@ namespace ManaServ {
class ManaServItemInfo: public ItemInfo
{
public:
- /**
- * Constructor.
- */
- ManaServItemInfo():ItemInfo()
+ ManaServItemInfo() : ItemInfo()
{}
// Declare Manaserv Specific item info here
};
-}; // namespace ManaServ
+} // namespace ManaServ
#endif
diff --git a/src/resources/music.h b/src/resources/music.h
index c0cf5abe..2556c1ee 100644
--- a/src/resources/music.h
+++ b/src/resources/music.h
@@ -36,9 +36,6 @@
class Music : public Resource
{
public:
- /**
- * Destructor.
- */
virtual ~Music();
/**
@@ -68,9 +65,6 @@ class Music : public Resource
virtual void stop();
protected:
- /**
- * Constructor.
- */
Music(Mix_Chunk *music);
//Mix_Music *music;
diff --git a/src/resources/resource.h b/src/resources/resource.h
index 28f390b5..69fa5dc9 100644
--- a/src/resources/resource.h
+++ b/src/resources/resource.h
@@ -33,9 +33,6 @@ class Resource
friend class ResourceManager;
public:
- /**
- * Constructor
- */
Resource(): mRefCount(0) {}
/**
@@ -59,9 +56,6 @@ class Resource
{ return mIdPath; }
protected:
- /**
- * Destructor.
- */
virtual ~Resource();
private:
diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h
index e7c832f4..bc499a96 100644
--- a/src/resources/soundeffect.h
+++ b/src/resources/soundeffect.h
@@ -36,9 +36,6 @@
class SoundEffect : public Resource
{
public:
- /**
- * Destructor.
- */
virtual ~SoundEffect();
/**
@@ -64,9 +61,6 @@ class SoundEffect : public Resource
virtual bool play(int loops, int volume);
protected:
- /**
- * Constructor.
- */
SoundEffect(Mix_Chunk *soundEffect): mChunk(soundEffect) {}
Mix_Chunk *mChunk;
diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h
index 18a70c9b..cef158fa 100644
--- a/src/resources/spritedef.h
+++ b/src/resources/spritedef.h
@@ -113,14 +113,8 @@ class SpriteDef : public Resource
makeSpriteDirection(const std::string &direction);
private:
- /**
- * Constructor.
- */
SpriteDef() {}
- /**
- * Destructor.
- */
~SpriteDef();
/**
diff --git a/src/resources/theme.cpp b/src/resources/theme.cpp
index 8de275ae..869f225c 100644
--- a/src/resources/theme.cpp
+++ b/src/resources/theme.cpp
@@ -111,7 +111,7 @@ Theme::Theme():
{
initDefaultThemePath();
- listen(CHANNEL_CONFIG);
+ listen(Event::ConfigChannel);
loadColors();
mColors[HIGHLIGHT].ch = 'H';
@@ -208,10 +208,10 @@ void Theme::updateAlpha()
iter->second->updateAlpha(mMinimumOpacity);
}
-void Theme::event(Channels channel, const Mana::Event &event)
+void Theme::event(Event::Channel channel, const Event &event)
{
- if (channel == CHANNEL_CONFIG &&
- event.getName() == EVENT_CONFIGOPTIONCHANGED &&
+ if (channel == Event::ConfigChannel &&
+ event.getType() == Event::ConfigOptionChanged &&
event.getString("option") == "guialpha")
{
updateAlpha();
diff --git a/src/resources/theme.h b/src/resources/theme.h
index f830c94f..d6d660e2 100644
--- a/src/resources/theme.h
+++ b/src/resources/theme.h
@@ -25,7 +25,7 @@
#define SKIN_H
#include "graphics.h"
-#include "listener.h"
+#include "eventlistener.h"
#include "gui/palette.h"
@@ -100,7 +100,7 @@ class Skin
Image *mStickyImageDown; /**< Sticky Button Image */
};
-class Theme : public Palette, public Mana::Listener
+class Theme : public Palette, public EventListener
{
public:
static Theme *instance();
@@ -218,7 +218,7 @@ class Theme : public Palette, public Mana::Listener
*/
void setMinimumOpacity(float minimumOpacity);
- void event(Channels channel, const Mana::Event &event);
+ void event(Event::Channel channel, const Event &event);
private:
Theme();
diff --git a/src/resources/userpalette.h b/src/resources/userpalette.h
index be02db10..01f66ca7 100644
--- a/src/resources/userpalette.h
+++ b/src/resources/userpalette.h
@@ -56,14 +56,8 @@ class UserPalette : public Palette, public gcn::ListModel
USER_COLOR_LAST
};
- /**
- * Constructor
- */
UserPalette();
- /**
- * Destructor
- */
~UserPalette();
/**
diff --git a/src/shopitem.h b/src/shopitem.h
index 7a86fedc..ecb99e72 100644
--- a/src/shopitem.h
+++ b/src/shopitem.h
@@ -19,8 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _SHOPITEM_H
-#define _SHOPITEM_H
+#ifndef SHOPITEM_H
+#define SHOPITEM_H
#include "item.h"
@@ -52,9 +52,6 @@ class ShopItem : public Item
*/
ShopItem(int id, int price);
- /**
- * Destructor.
- */
~ShopItem();
/**
diff --git a/src/sound.cpp b/src/sound.cpp
index 4f84d4b9..4216c8fa 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -30,16 +30,37 @@
#include "resources/resourcemanager.h"
#include "resources/soundeffect.h"
+/**
+ * This will be set to true, when a music can be freed after a fade out
+ * Currently used by fadeOutCallBack()
+ */
+static bool sFadingOutEnded = false;
+
+/**
+ * Callback used at end of fadeout.
+ * It is called by Mix_MusicFadeFinished().
+ */
+static void fadeOutCallBack()
+{
+ sFadingOutEnded = true;
+}
+
Sound::Sound():
mInstalled(false),
mSfxVolume(100),
mMusicVolume(60),
mMusic(NULL)
{
+ // This set up our callback function used to
+ // handle fade outs endings.
+ sFadingOutEnded = false;
+ Mix_HookMusicFinished(fadeOutCallBack);
}
Sound::~Sound()
{
+ // Unlink the callback function.
+ Mix_HookMusicFinished(NULL);
}
void Sound::init()
@@ -119,11 +140,6 @@ void Sound::info()
logger->log("Sound::info() Channels: %i", channels);
}
-int Sound::getMaxVolume() const
-{
- return MIX_MAX_VOLUME;
-}
-
void Sound::setMusicVolume(int volume)
{
mMusicVolume = volume;
@@ -224,8 +240,37 @@ void Sound::fadeOutMusic(int ms)
if (mMusic)
{
Mix_FadeOutMusic(ms);
- Mix_FreeMusic(mMusic);
- mMusic = NULL;
+ // Note: The fadeOutCallBack handler will take care about freeing
+ // the music file at fade out ending.
+ }
+ else
+ {
+ sFadingOutEnded = true;
+ }
+}
+
+void Sound::fadeOutAndPlayMusic(const std::string &path, int ms)
+{
+ mNextMusicPath = path;
+ fadeOutMusic(ms);
+}
+
+void Sound::logic()
+{
+ if (sFadingOutEnded)
+ {
+ if (mMusic)
+ {
+ Mix_FreeMusic(mMusic);
+ mMusic = NULL;
+ }
+ sFadingOutEnded = false;
+
+ if (!mNextMusicPath.empty())
+ {
+ playMusic(mNextMusicPath);
+ mNextMusicPath.clear();
+ }
}
}
diff --git a/src/sound.h b/src/sound.h
index b619ab6b..032ff62b 100644
--- a/src/sound.h
+++ b/src/sound.h
@@ -68,16 +68,25 @@ class Sound
* @param path The full path to the music file.
* @param ms Duration of fade-in effect (ms)
*/
- void fadeInMusic(const std::string &path, int ms = 2000);
+ void fadeInMusic(const std::string &path, int ms = 1000);
/**
* Fades out currently running background music track.
*
* @param ms Duration of fade-out effect (ms)
*/
- void fadeOutMusic(int ms);
+ void fadeOutMusic(int ms = 1000);
- int getMaxVolume() const;
+ /**
+ * Fades out a background music and play a new one.
+ *
+ * @param path The full path to the fade in music file.
+ * @param ms Duration of fade-out effect (ms)
+ */
+ void fadeOutAndPlayMusic(const std::string &path, int ms = 1000);
+
+ int getMaxVolume() const
+ { return MIX_MAX_VOLUME; }
void setMusicVolume(int volume);
void setSfxVolume(int volume);
@@ -91,6 +100,13 @@ class Sound
*/
void playSfx(const std::string &path, int x = 0, int y = 0);
+ /**
+ * The sound logic.
+ * Currently used to check whether the music file can be freed after
+ * a fade out, and whether new music has to be played.
+ */
+ void logic();
+
private:
/** Logs various info about sound device. */
void info();
@@ -98,6 +114,12 @@ class Sound
/** Halts and frees currently playing music. */
void haltMusic();
+ /**
+ * When calling fadeOutAndPlayMusic(),
+ * the music file below will then be played
+ */
+ std::string mNextMusicPath;
+
bool mInstalled;
int mSfxVolume;
diff --git a/src/textmanager.h b/src/textmanager.h
index 07aed2d5..13c30b14 100644
--- a/src/textmanager.h
+++ b/src/textmanager.h
@@ -30,9 +30,6 @@ class Text;
class TextManager
{
public:
- /**
- * Constructor
- */
TextManager();
/**
diff --git a/src/textparticle.h b/src/textparticle.h
index 79af7406..2791cb03 100644
--- a/src/textparticle.h
+++ b/src/textparticle.h
@@ -27,9 +27,6 @@
class TextParticle : public Particle
{
public:
- /**
- * Constructor.
- */
TextParticle(Map *map, const std::string &text,
const gcn::Color* color,
gcn::Font *font, bool outline = false);
diff --git a/src/tileset.h b/src/tileset.h
index 6c2ee394..387222b3 100644
--- a/src/tileset.h
+++ b/src/tileset.h
@@ -30,9 +30,6 @@
class Tileset : public ImageSet
{
public:
- /**
- * Constructor.
- */
Tileset(Image *img, int w, int h, int firstGid, int margin, int spacing):
ImageSet(img, w, h, margin, spacing),
mFirstGid(firstGid)
diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp
index 43f5264e..549e77a2 100644
--- a/src/utils/mkdir.cpp
+++ b/src/utils/mkdir.cpp
@@ -28,8 +28,8 @@
#include <sys/stat.h>
-#ifdef _MKDIR_TEST_
-// compile with -D_MKDIR_TEST_ to get a standalone binary
+#ifdef MKDIR_TEST
+// compile with -DMKDIR_TEST to get a standalone binary
#include <cstdio>
#include <cstdlib>
#endif
@@ -96,7 +96,7 @@ int mkdir_r(const char *pathname) {
return -1;
}
-#ifdef _MKDIR_TEST_
+#ifdef MKDIR_TEST
printf("%s\n", tmp);
#endif
*p = '/';
@@ -105,7 +105,7 @@ int mkdir_r(const char *pathname) {
return 0;
}
-#ifdef _MKDIR_TEST_
+#ifdef MKDIR_TEST
int main(int argc, char** argv) {
if (argc < 2) exit(1);
mkdir_r(argv[1]);
diff --git a/src/utils/mkdir.h b/src/utils/mkdir.h
index 9369b4e7..13cfc1c1 100644
--- a/src/utils/mkdir.h
+++ b/src/utils/mkdir.h
@@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _MKDIR_H
-#define _MKDIR_H
+#ifndef MKDIR_H
+#define MKDIR_H
int mkdir_r(const char *pathname);
diff --git a/src/utils/specialfolder.cpp b/src/utils/specialfolder.cpp
index 64607716..221aeac2 100644
--- a/src/utils/specialfolder.cpp
+++ b/src/utils/specialfolder.cpp
@@ -22,8 +22,8 @@
#include "specialfolder.h"
#include <windows.h>
-#ifdef _SPECIALFOLDERLOCATION_TEST_
-// compile with -D_SPECIALFOLDERLOCATION_TEST_ to get a standalone
+#ifdef SPECIALFOLDERLOCATION_TEST
+// compile with -DSPECIALFOLDERLOCATION_TEST to get a standalone
// binary for testing
#include <iostream>
#endif
@@ -59,7 +59,7 @@ std::string getSpecialFolderLocation(int folderId)
return ret;
}
-#ifdef _SPECIALFOLDERLOCATION_TEST_
+#ifdef SPECIALFOLDERLOCATION_TEST
int main()
{
std::cout << "APPDATA " << getSpecialFolderLocation(CSIDL_APPDATA)
diff --git a/src/utils/specialfolder.h b/src/utils/specialfolder.h
index c2c2e0be..eef6416b 100644
--- a/src/utils/specialfolder.h
+++ b/src/utils/specialfolder.h
@@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _SPECIALFOLDER_H
-#define _SPECIALFOLDER_H
+#ifndef SPECIALFOLDER_H
+#define SPECIALFOLDER_H
#ifdef WIN32
#include <shlobj.h>
diff --git a/src/variabledata.h b/src/variabledata.h
index 19e09795..0855a1d0 100644
--- a/src/variabledata.h
+++ b/src/variabledata.h
@@ -26,9 +26,6 @@
class ActorSprite;
class Item;
-namespace Mana
-{
-
class VariableData
{
public:
@@ -43,7 +40,7 @@ class VariableData
DATA_ACTOR
};
- virtual ~VariableData() {};
+ virtual ~VariableData() {}
virtual int getType() const = 0;
};
@@ -126,6 +123,4 @@ private:
ActorSprite *mData;
};
-} // namespace Mana
-
#endif
diff --git a/src/vector.h b/src/vector.h
index 163dcdbd..3360c20b 100644
--- a/src/vector.h
+++ b/src/vector.h
@@ -33,27 +33,18 @@
class Vector
{
public:
- /**
- * Constructor.
- */
Vector():
x(0.0f),
y(0.0f),
z(0.0f)
{}
- /**
- * Constructor.
- */
Vector(float x, float y, float z = 0.0f):
x(x),
y(y),
z(z)
{}
- /**
- * Copy constructor.
- */
Vector(const Vector &v):
x(v.x),
y(v.y),