From 744b6e62e1252ca50445b21f671ad8d81dd28ea1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 27 Apr 2014 14:50:47 +0300 Subject: Add AttributeListener. --- src/gui/windows/chatwindow.cpp | 56 +++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'src/gui/windows/chatwindow.cpp') diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index be2daf6a9..dbda471c4 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -156,6 +156,7 @@ ChatWindow::ChatWindow(): Window(_("Chat"), false, nullptr, "chat.xml"), ActionListener(), KeyListener(), + AttributeListener(), mItemLinkHandler(new ItemLinkHandler), mChatTabs(new TabbedArea(this)), mChatInput(new ChatInput(this)), @@ -964,34 +965,7 @@ void ChatWindow::processEvent(const Channels channel, if (!mShowBattleEvents) return; - if (event.getName() == EVENT_UPDATEATTRIBUTE) - { - switch (event.getInt("id")) - { - case PlayerInfo::EXP: - { - if (event.getInt("oldValue") > event.getInt("newValue")) - break; - - const int change = event.getInt("newValue") - - event.getInt("oldValue"); - - if (change != 0) - { - battleChatLog(std::string("+").append(toString( - change)).append(" xp")); - } - break; - } - case PlayerInfo::LEVEL: - battleChatLog(std::string("Level: ").append(toString( - event.getInt("newValue")))); - break; - default: - break; - }; - } - else if (event.getName() == EVENT_UPDATESTAT) + if (event.getName() == EVENT_UPDATESTAT) { if (!config.getBoolValue("showJobExp")) return; @@ -1018,6 +992,32 @@ void ChatWindow::processEvent(const Channels channel, } } +void ChatWindow::attributeChanged(const int id, + const int oldVal, + const int newVal) +{ + switch (id) + { + case PlayerInfo::EXP: + { + if (oldVal > newVal) + break; + const int change = newVal - oldVal; + if (change != 0) + { + battleChatLog(std::string("+").append(toString( + change)).append(" xp")); + } + break; + } + case PlayerInfo::LEVEL: + battleChatLog(std::string("Level: ").append(toString(newVal))); + break; + default: + break; + }; +} + void ChatWindow::addInputText(const std::string &text, const bool space) { const int caretPos = mChatInput->getCaretPosition(); -- cgit v1.2.3-60-g2f50