summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorChuck Miller <shadowmil@gmail.com>2010-11-11 21:55:25 -0500
committerChuck Miller <shadowmil@gmail.com>2010-11-11 22:45:58 -0500
commit5727a2d9eeb0688a16e5b7fe32f6d9836c4f7a4e (patch)
tree994cdeb1187a94996ca38c5e274aabaa5f1fec76 /src/gui
parent3dd1baab3fb00a3aa99447430f16a431a205c614 (diff)
downloadMana-5727a2d9eeb0688a16e5b7fe32f6d9836c4f7a4e.tar.gz
Mana-5727a2d9eeb0688a16e5b7fe32f6d9836c4f7a4e.tar.bz2
Mana-5727a2d9eeb0688a16e5b7fe32f6d9836c4f7a4e.tar.xz
Mana-5727a2d9eeb0688a16e5b7fe32f6d9836c4f7a4e.zip
Have the event system channels use enums instead of strings
Reviewed-by: Freeyorp
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chat.cpp10
-rw-r--r--src/gui/chat.h2
-rw-r--r--src/gui/inventorywindow.cpp10
-rw-r--r--src/gui/inventorywindow.h2
-rw-r--r--src/gui/itemamount.cpp4
-rw-r--r--src/gui/ministatus.cpp8
-rw-r--r--src/gui/ministatus.h2
-rw-r--r--src/gui/npcdialog.cpp22
-rw-r--r--src/gui/npcpostdialog.cpp2
-rw-r--r--src/gui/statuswindow.cpp4
-rw-r--r--src/gui/statuswindow.h2
-rw-r--r--src/gui/viewport.cpp6
-rw-r--r--src/gui/viewport.h2
-rw-r--r--src/gui/widgets/itemcontainer.cpp6
14 files changed, 41 insertions, 41 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 36125e60..280d4d15 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -90,8 +90,8 @@ ChatWindow::ChatWindow():
mAutoComplete(new ChatAutoComplete),
mTmpVisible(false)
{
- listen("Chat");
- listen("Notices");
+ listen(CHANNEL_CHAT);
+ listen(CHANNEL_NOTICES);
setWindowName("Chat");
@@ -375,14 +375,14 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event)
}
}
-void ChatWindow::event(const std::string &channel, const Mana::Event &event)
+void ChatWindow::event(Channels channel, const Mana::Event &event)
{
- if (channel == "Notices")
+ if (channel == CHANNEL_NOTICES)
{
if (event.getName() == "ServerNotice")
localChatTab->chatLog(event.getString("message"), BY_SERVER);
}
- else if (channel == "Chat")
+ else if (channel == CHANNEL_CHAT)
{
if (event.getName() == "Whisper")
{
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 3a001432..f546502c 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -158,7 +158,7 @@ class ChatWindow : public Window,
void mousePressed(gcn::MouseEvent &event);
void mouseDragged(gcn::MouseEvent &event);
- void event(const std::string &channel, const Mana::Event &event);
+ void event(Channels channel, const Mana::Event &event);
/**
* Scrolls the chat window
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 62b63f24..fab87844 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -60,7 +60,7 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
mInventory(inventory),
mSplit(false)
{
- listen("Attributes");
+ listen(CHANNEL_ATTRIBUTES);
setWindowName(isMainInventory() ? "Inventory" : "Storage");
setupWindow->registerWindowForReset(this);
@@ -261,7 +261,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
event.setInt("amount", item->getQuantity());
event.setInt("source", Inventory::INVENTORY);
event.setInt("destination", Inventory::STORAGE);
- event.trigger("Item");
+ event.trigger(CHANNEL_ITEM);
}
else
{
@@ -270,7 +270,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
event.setInt("amount", item->getQuantity());
event.setInt("source", Inventory::STORAGE);
event.setInt("destination", Inventory::INVENTORY);
- event.trigger("Item");
+ event.trigger(CHANNEL_ITEM);
}
}
}
@@ -370,12 +370,12 @@ void InventoryWindow::close()
{
Mana::Event event("doCloseInventory");
event.setInt("type", mInventory->getType());
- event.trigger("Item");
+ event.trigger(CHANNEL_ITEM);
scheduleDelete();
}
}
-void InventoryWindow::event(const std::string &channel, const Mana::Event &event)
+void InventoryWindow::event(Channels channel, const Mana::Event &event)
{
if (event.getName() == "UpdateAttribute")
{
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 99fc1c03..4ae80309 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -112,7 +112,7 @@ class InventoryWindow : public Window,
bool isMainInventory() { return mInventory->isMainInventory(); }
- void event(const std::string &channel, const Mana::Event &event);
+ void event(Channels channel, const Mana::Event &event);
private:
/**
diff --git a/src/gui/itemamount.cpp b/src/gui/itemamount.cpp
index aed8d11d..bb8f95d0 100644
--- a/src/gui/itemamount.cpp
+++ b/src/gui/itemamount.cpp
@@ -59,7 +59,7 @@ void ItemAmountWindow::finish(Item *item, int amount, Usage usage)
event.setInt("amount", amount);
event.setInt("source", Inventory::INVENTORY);
event.setInt("destination", Inventory::STORAGE);
- event.trigger("Item");
+ event.trigger(CHANNEL_ITEM);
}
break;
case StoreRemove:
@@ -69,7 +69,7 @@ void ItemAmountWindow::finish(Item *item, int amount, Usage usage)
event.setInt("amount", amount);
event.setInt("source", Inventory::STORAGE);
event.setInt("destination", Inventory::INVENTORY);
- event.trigger("Item");
+ event.trigger(CHANNEL_ITEM);
}
break;
default:
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index 1642d1b0..ab01dbbd 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("Attributes");
+ listen(CHANNEL_ATTRIBUTES);
mHpBar = new ProgressBar(0, 100, 20, Theme::PROG_HP);
StatusWindow::updateHPBar(mHpBar);
@@ -119,9 +119,9 @@ void MiniStatusWindow::drawIcons(Graphics *graphics)
}
}
-void MiniStatusWindow::event(const std::string &channel, const Mana::Event &event)
+void MiniStatusWindow::event(Channels channel, const Mana::Event &event)
{
- if (channel == "Attributes")
+ if (channel == CHANNEL_ATTRIBUTES)
{
if (event.getName() == "UpdateAttribute")
{
@@ -140,7 +140,7 @@ void MiniStatusWindow::event(const std::string &channel, const Mana::Event &even
}
}
}
- else if (channel == "ActorSprite")
+ else if (channel == CHANNEL_ACTORSPRITE)
{
if (event.getName() == "UpdateStatusEffect")
{
diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h
index 077eedeb..9dfcaeae 100644
--- a/src/gui/ministatus.h
+++ b/src/gui/ministatus.h
@@ -45,7 +45,7 @@ class MiniStatusWindow : public Popup, public Mana::Listener
void drawIcons(Graphics *graphics);
- void event(const std::string &channel, const Mana::Event &event);
+ void event(Channels channel, const Mana::Event &event);
void logic(); // Updates icons
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 935962a0..f565a13f 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -55,7 +55,7 @@ typedef std::map<int, NpcDialog*> NpcDialogs;
class NpcEventListener : public Mana::Listener
{
public:
- void event(const std::string &channel, const Mana::Event &event);
+ void event(Channels channel, const Mana::Event &event);
NpcDialog *getDialog(int id, bool make = true);
@@ -227,7 +227,7 @@ void NpcDialog::action(const gcn::ActionEvent &event)
NpcEvent("doMenu")
event.setInt("choice", selectedIndex + 1);
- event.trigger("NPC");
+ event.trigger(CHANNEL_NPC);
}
else if (mInputState == NPC_INPUT_STRING)
{
@@ -235,7 +235,7 @@ void NpcDialog::action(const gcn::ActionEvent &event)
NpcEvent("doStringInput")
event.setString("value", printText);
- event.trigger("NPC");
+ event.trigger(CHANNEL_NPC);
}
else if (mInputState == NPC_INPUT_INTEGER)
{
@@ -243,7 +243,7 @@ void NpcDialog::action(const gcn::ActionEvent &event)
NpcEvent("doIntegerInput")
event.setInt("value", mIntField->getValue());
- event.trigger("NPC");
+ event.trigger(CHANNEL_NPC);
}
// addText will auto remove the input layout
addText(strprintf("\n> \"%s\"\n", printText.c_str()), false);
@@ -282,13 +282,13 @@ void NpcDialog::action(const gcn::ActionEvent &event)
void NpcDialog::nextDialog()
{
NpcEvent("doNext");
- event.trigger("NPC");
+ event.trigger(CHANNEL_NPC);
}
void NpcDialog::closeDialog()
{
NpcEvent("doClose");
- event.trigger("NPC");
+ event.trigger(CHANNEL_NPC);
close();
}
@@ -436,7 +436,7 @@ void NpcDialog::setup()
npcListener = new NpcEventListener();
- npcListener->listen("NPC");
+ npcListener->listen(CHANNEL_NPC);
}
void NpcDialog::buildLayout()
@@ -506,10 +506,10 @@ void NpcDialog::buildLayout()
mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
}
-void NpcEventListener::event(const std::string &channel,
+void NpcEventListener::event(Channels channel,
const Mana::Event &event)
{
- if (channel != "NPC")
+ if (channel != CHANNEL_NPC)
return;
if (event.getName() == "Message")
@@ -560,7 +560,7 @@ void NpcEventListener::event(const std::string &channel,
{
int mNpcId = id;
NpcEvent("doNext");
- event.trigger("NPC");
+ event.trigger(CHANNEL_NPC);
return;
}
@@ -575,7 +575,7 @@ void NpcEventListener::event(const std::string &channel,
{
int mNpcId = id;
NpcEvent("doClose");
- event.trigger("NPC");
+ event.trigger(CHANNEL_NPC);
return;
}
diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp
index 0662515e..a4740027 100644
--- a/src/gui/npcpostdialog.cpp
+++ b/src/gui/npcpostdialog.cpp
@@ -101,7 +101,7 @@ void NpcPostDialog::action(const gcn::ActionEvent &event)
event.setInt("npcId", mNpcId);
event.setString("recipient", mSender->getText());
event.setString("text", mText->getText());
- event.trigger("NPC");
+ event.trigger(CHANNEL_NPC);
}
setVisible(false);
}
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 022a97c7..654d2bf3 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("Attributes");
+ listen(CHANNEL_ATTRIBUTES);
setWindowName("Status");
setupWindow->registerWindowForReset(this);
@@ -217,7 +217,7 @@ StatusWindow::StatusWindow():
mLvlLabel->adjustSize();
}
-void StatusWindow::event(const std::string &channel, const Mana::Event &event)
+void StatusWindow::event(Channels channel, const Mana::Event &event)
{
if (event.getName() == "UpdateAttribute")
{
diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h
index fd8c6319..275dd8c9 100644
--- a/src/gui/statuswindow.h
+++ b/src/gui/statuswindow.h
@@ -49,7 +49,7 @@ class StatusWindow : public Window, public Mana::Listener
*/
StatusWindow();
- void event(const std::string &channel, const Mana::Event &event);
+ void event(Channels channel, const Mana::Event &event);
void updateAttrs();
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 06dbd43e..6cef33a1 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -72,7 +72,7 @@ Viewport::Viewport():
setFocusable(true);
- listen("ActorSprite");
+ listen(CHANNEL_ACTORSPRITE);
}
Viewport::~Viewport()
@@ -556,9 +556,9 @@ void Viewport::hideBeingPopup()
mBeingPopup->setVisible(false);
}
-void Viewport::event(const std::string &channel, const Mana::Event &event)
+void Viewport::event(Channels channel, const Mana::Event &event)
{
- if (channel == "ActorSprite" && event.getName() == "Destroyed")
+ if (channel == CHANNEL_ACTORSPRITE && event.getName() == "Destroyed")
{
ActorSprite *actor = event.getActor("source");
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index 55db3676..9fbdf496 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -160,7 +160,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
*/
void hideBeingPopup();
- void event(const std::string &channel, const Mana::Event &event);
+ void event(Channels channel, const Mana::Event &event);
private:
/**
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index d448c3c2..bf0272ee 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -311,7 +311,7 @@ void ItemContainer::mouseReleased(gcn::MouseEvent &event)
Mana::Event event("doMove");
event.setItem("item", item);
event.setInt("newIndex", index);
- event.trigger("Item");
+ event.trigger(CHANNEL_ITEM);
}
selectNone();
}
@@ -383,7 +383,7 @@ void ItemContainer::keyAction()
Mana::Event event("doMove");
event.setItem("item", item);
event.setInt("newIndex", mHighlightedIndex);
- event.trigger("Item");
+ event.trigger(CHANNEL_ITEM);
setSelectedIndex(mHighlightedIndex);
}
// If the highlight is on an item then select it.
@@ -399,7 +399,7 @@ void ItemContainer::keyAction()
Mana::Event event("doMove");
event.setItem("item", item);
event.setInt("newIndex", mHighlightedIndex);
- event.trigger("Item");
+ event.trigger(CHANNEL_ITEM);
selectNone();
}
}