diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-12-02 19:05:34 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-12-02 19:05:34 +0300 |
commit | f924674239571a40b0806136a49b4da3edcadbbf (patch) | |
tree | 5a5cd954acf5832e6cf01c59b8960d6b06657fa3 /src/gui/dialogsmanager.cpp | |
parent | 1003a7a74f72f17f59f4a74eacf95a1744a64506 (diff) | |
download | manaverse-f924674239571a40b0806136a49b4da3edcadbbf.tar.gz manaverse-f924674239571a40b0806136a49b4da3edcadbbf.tar.bz2 manaverse-f924674239571a40b0806136a49b4da3edcadbbf.tar.xz manaverse-f924674239571a40b0806136a49b4da3edcadbbf.zip |
Move weight notification from playerhander.
Diffstat (limited to 'src/gui/dialogsmanager.cpp')
-rw-r--r-- | src/gui/dialogsmanager.cpp | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp index 0ef8a1582..eb60a574a 100644 --- a/src/gui/dialogsmanager.cpp +++ b/src/gui/dialogsmanager.cpp @@ -25,6 +25,8 @@ #include "configuration.h" #include "settings.h" +#include "being/attributes.h" + #include "gui/dialogtype.h" #include "gui/widgets/selldialog.h" @@ -37,6 +39,7 @@ #include "gui/windows/updaterwindow.h" #include "listeners/playerpostdeathlistener.h" +#include "listeners/weightlistener.h" #include "net/inventoryhandler.h" @@ -50,15 +53,19 @@ #undef ERROR #endif -OkDialog *deathNotice; +OkDialog *deathNotice = nullptr; DialogsManager *dialogsManager = nullptr; +OkDialog *weightNotice = nullptr; +int weightNoticeTime = 0; namespace { PlayerPostDeathListener postDeathListener; + WeightListener weightListener; } // namespace DialogsManager::DialogsManager() : + AttributeListener(), PlayerDeathListener() { } @@ -124,3 +131,50 @@ void DialogsManager::playerDeath() false, true, nullptr, 260); deathNotice->addActionListener(&postDeathListener); } + +void DialogsManager::attributeChanged(const int id, + const int oldVal, + const int newVal) +{ + if (id == Attributes::TOTAL_WEIGHT) + { + if (!weightNotice && config.getBoolValue("weightMsg")) + { + const int max = PlayerInfo::getAttribute( + Attributes::MAX_WEIGHT) / 2; + const int total = oldVal; + if (newVal >= max && total < max) + { + weightNoticeTime = cur_time + 5; + // TRANSLATORS: message header + weightNotice = new OkDialog(_("Message"), + // TRANSLATORS: weight message + _("You are carrying more than " + "half your weight. You are " + "unable to regain health."), + // TRANSLATORS: ok dialog button + _("OK"), + DialogType::OK, + false, true, nullptr, 260); + weightNotice->addActionListener( + &weightListener); + } + else if (newVal < max && total >= max) + { + weightNoticeTime = cur_time + 5; + // TRANSLATORS: message header + weightNotice = new OkDialog(_("Message"), + // TRANSLATORS: weight message + _("You are carrying less than " + "half your weight. You " + "can regain health."), + // TRANSLATORS: ok dialog button + _("OK"), + DialogType::OK, + false, true, nullptr, 260); + weightNotice->addActionListener( + &weightListener); + } + } + } +} |