diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/windows/chatwindow.cpp | 45 | ||||
-rw-r--r-- | src/gui/windows/chatwindow.h | 18 | ||||
-rw-r--r-- | src/gui/windows/ministatuswindow.cpp | 13 | ||||
-rw-r--r-- | src/gui/windows/ministatuswindow.h | 13 | ||||
-rw-r--r-- | src/gui/windows/statuswindow.cpp | 88 | ||||
-rw-r--r-- | src/gui/windows/statuswindow.h | 13 |
6 files changed, 84 insertions, 106 deletions
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index dbda471c4..5b1eba199 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -185,8 +185,6 @@ ChatWindow::ChatWindow(): { mChatTabs->postInit(); - listen(CHANNEL_ATTRIBUTES); - setWindowName("Chat"); if (setupWindow) @@ -957,38 +955,25 @@ void ChatWindow::keyPressed(KeyEvent &event) #undef ifKey -void ChatWindow::processEvent(const Channels channel, - const DepricatedEvent &event) +void ChatWindow::statChanged(const int id, + const int oldVal1, + const int oldVal2) { - if (channel == CHANNEL_ATTRIBUTES) - { - if (!mShowBattleEvents) - return; + if (!mShowBattleEvents || !config.getBoolValue("showJobExp")) + return; - if (event.getName() == EVENT_UPDATESTAT) - { - if (!config.getBoolValue("showJobExp")) - return; + if (id != Net::getPlayerHandler()->getJobLocation()) + return; - const int id = event.getInt("id"); - if (id == Net::getPlayerHandler()->getJobLocation()) - { - const std::pair<int, int> exp - = PlayerInfo::getStatExperience(id); - if (event.getInt("oldValue1") > exp.first - || !event.getInt("oldValue2")) - { - return; - } + const std::pair<int, int> exp = PlayerInfo::getStatExperience(id); + if (oldVal1 > exp.first || !oldVal2) + return; - const int change = exp.first - event.getInt("oldValue1"); - if (change != 0) - { - battleChatLog(std::string("+").append( - toString(change)).append(" job")); - } - } - } + const int change = exp.first - oldVal1; + if (change != 0) + { + battleChatLog(std::string("+").append(toString( + change)).append(" job")); } } diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index d345b5abc..3999d6b8a 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -23,14 +23,13 @@ #ifndef GUI_WINDOWS_CHATWINDOW_H #define GUI_WINDOWS_CHATWINDOW_H -#include "listeners/attributelistener.h" -#include "listeners/configlistener.h" -#include "listeners/depricatedlistener.h" - #include "gui/widgets/window.h" #include "listeners/actionlistener.h" +#include "listeners/attributelistener.h" +#include "listeners/configlistener.h" #include "listeners/keylistener.h" +#include "listeners/statlistener.h" #include <list> #include <map> @@ -85,9 +84,9 @@ struct CHATLOG final class ChatWindow final : public Window, public ActionListener, public KeyListener, - public DepricatedListener, public ConfigListener, - public AttributeListener + public AttributeListener, + public StatListener { public: /** @@ -194,9 +193,6 @@ class ChatWindow final : public Window, */ void mousePressed(MouseEvent &event) override final; - void processEvent(const Channels channel, - const DepricatedEvent &event) override final; - /** * Scrolls the chat window * @@ -299,6 +295,10 @@ class ChatWindow final : public Window, const int oldVal, const int newVal) override final; + void statChanged(const int id, + const int oldVal1, + const int oldVal2) override final; + static void localPetSay(const std::string &nick, const std::string &text); diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp index 6fb330bbf..2320ac08a 100644 --- a/src/gui/windows/ministatuswindow.cpp +++ b/src/gui/windows/ministatuswindow.cpp @@ -112,8 +112,6 @@ MiniStatusWindow::MiniStatusWindow() : mTextPopup->postInit(); mStatusPopup->postInit(); - listen(CHANNEL_ATTRIBUTES); - StatusWindow::updateHPBar(mHpBar); if (Net::getGameHandler()->canUseMagicBar() && statusWindow) @@ -251,14 +249,13 @@ void MiniStatusWindow::drawIcons(Graphics *const graphics) } } -void MiniStatusWindow::processEvent(const Channels channel A_UNUSED, - const DepricatedEvent &event) +void MiniStatusWindow::statChanged(const int id, + const int oldVal1 A_UNUSED, + const int oldVal2 A_UNUSED) { - if (event.getName() == EVENT_UPDATESTAT) - { + if (statusWindow) statusWindow->updateMPBar(mMpBar); - StatusWindow::updateJobBar(mJobBar); - } + StatusWindow::updateJobBar(mJobBar); } void MiniStatusWindow::attributeChanged(const int id, diff --git a/src/gui/windows/ministatuswindow.h b/src/gui/windows/ministatuswindow.h index bab117c19..171e1fe2f 100644 --- a/src/gui/windows/ministatuswindow.h +++ b/src/gui/windows/ministatuswindow.h @@ -26,7 +26,7 @@ #include "inventory.h" #include "listeners/attributelistener.h" -#include "listeners/depricatedlistener.h" +#include "listeners/statlistener.h" #include "gui/widgets/window.h" @@ -45,8 +45,8 @@ class TextPopup; */ class MiniStatusWindow final : public Window, public InventoryListener, - public DepricatedListener, - public AttributeListener + public AttributeListener, + public StatListener { public: MiniStatusWindow(); @@ -64,9 +64,6 @@ class MiniStatusWindow final : public Window, void drawIcons(Graphics *const graphics); - void processEvent(const Channels channel, - const DepricatedEvent &event) override final; - void updateStatus(); void logic() override final; @@ -96,6 +93,10 @@ class MiniStatusWindow final : public Window, const int oldVal, const int newVal) override final; + void statChanged(const int id, + const int oldVal1, + const int oldVal2) override final; + #ifdef USE_PROFILER void logicChildren(); #endif diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index 5897ae64b..53abb7fdf 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -145,6 +145,7 @@ StatusWindow::StatusWindow() : "?", false, nullptr, "status.xml"), ActionListener(), AttributeListener(), + StatListener(), // TRANSLATORS: status window label mLvlLabel(new Label(this, strprintf(_("Level: %d"), 0))), // TRANSLATORS: status window label @@ -170,8 +171,6 @@ StatusWindow::StatusWindow() : mCopyButton(new Button(this, _("Copy to chat"), "copy", this)), mAttrs() { - listen(CHANNEL_ATTRIBUTES); - setWindowName("Status"); if (setupWindow) setupWindow->registerWindowForReset(this); @@ -335,68 +334,63 @@ StatusWindow::StatusWindow() : mLvlLabel->adjustSize(); } -void StatusWindow::processEvent(const Channels channel A_UNUSED, - const DepricatedEvent &event) +void StatusWindow::statChanged(const int id, + const int oldVal1, + const int oldVal2 A_UNUSED) { static bool blocked = false; if (blocked) return; - const DepricatedEvents &eventName = event.getName(); - if (eventName == EVENT_UPDATESTAT) + if (id == Net::getPlayerHandler()->getJobLocation()) { - const int id = event.getInt("id"); - if (id == Net::getPlayerHandler()->getJobLocation()) + if (mJobLvlLabel) { - if (mJobLvlLabel) - { - int lvl = PlayerInfo::getStatBase(id); - const int oldExp = event.getInt("oldValue1"); - const std::pair<int, int> exp - = PlayerInfo::getStatExperience(id); + int lvl = PlayerInfo::getStatBase(id); + const int oldExp = oldVal1; + const std::pair<int, int> exp = PlayerInfo::getStatExperience(id); - if (!lvl) + if (!lvl) + { + // possible server broken and don't send job level, + // then we fixing it :) + if (exp.second < 20000) { - // possible server broken and don't send job level, - // then we fixing it :) - if (exp.second < 20000) - { - lvl = 0; - } - else - { - lvl = (exp.second - 20000) / 150; - blocked = true; - PlayerInfo::setStatBase(id, lvl); - blocked = false; - } + lvl = 0; } - - if (exp.first < oldExp && exp.second >= 20000) - { // possible job level up. but server broken and don't send - // new job exp limit, we fixing it - lvl ++; + else + { + lvl = (exp.second - 20000) / 150; blocked = true; - PlayerInfo::setStatExperience( - id, exp.first, 20000 + lvl * 150); PlayerInfo::setStatBase(id, lvl); blocked = false; } + } - // TRANSLATORS: status window label - mJobLvlLabel->setCaption(strprintf(_("Job: %d"), lvl)); - mJobLvlLabel->adjustSize(); - - updateProgressBar(mJobBar, id, false); + if (exp.first < oldExp && exp.second >= 20000) + { // possible job level up. but server broken and don't send + // new job exp limit, we fixing it + lvl ++; + blocked = true; + PlayerInfo::setStatExperience( + id, exp.first, 20000 + lvl * 150); + PlayerInfo::setStatBase(id, lvl); + blocked = false; } + + // TRANSLATORS: status window label + mJobLvlLabel->setCaption(strprintf(_("Job: %d"), lvl)); + mJobLvlLabel->adjustSize(); + + updateProgressBar(mJobBar, id, false); } - else - { - updateMPBar(mMpBar, true); - const Attrs::const_iterator it = mAttrs.find(id); - if (it != mAttrs.end() && it->second) - it->second->update(); - } + } + else + { + updateMPBar(mMpBar, true); + const Attrs::const_iterator it = mAttrs.find(id); + if (it != mAttrs.end() && it->second) + it->second->update(); } } diff --git a/src/gui/windows/statuswindow.h b/src/gui/windows/statuswindow.h index 11aa2ad05..797e7647f 100644 --- a/src/gui/windows/statuswindow.h +++ b/src/gui/windows/statuswindow.h @@ -27,7 +27,7 @@ #include "listeners/actionlistener.h" #include "listeners/attributelistener.h" -#include "listeners/depricatedlistener.h" +#include "listeners/statlistener.h" #include <map> @@ -45,8 +45,8 @@ class VertContainer; */ class StatusWindow final : public Window, public ActionListener, - public DepricatedListener, - public AttributeListener + public AttributeListener, + public StatListener { public: /** @@ -56,9 +56,6 @@ class StatusWindow final : public Window, A_DELETE_COPY(StatusWindow) - void processEvent(const Channels channel, - const DepricatedEvent &event) override; - void setPointsNeeded(const int id, const int needed); void addAttribute(const int id, const std::string &restrict name, @@ -92,6 +89,10 @@ class StatusWindow final : public Window, const int oldVal, const int newVal) override final; + void statChanged(const int id, + const int oldVal1, + const int oldVal2) override final; + private: static std::string translateLetter(const char *const letters); static std::string translateLetter2(std::string letters); |