diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-11-22 21:58:33 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-11-22 22:06:08 +0300 |
commit | 9a50b90628eb61e1e48db35a36e9ad5c2a9a2bd5 (patch) | |
tree | 24ab6a1f2e367a15e2ac9b994e7060767068b8e5 /src/gui/popups/skillpopup.cpp | |
parent | e3f651e65f5a486f47ae81fe3ba5e68e8c48f79e (diff) | |
download | manaverse-9a50b90628eb61e1e48db35a36e9ad5c2a9a2bd5.tar.gz manaverse-9a50b90628eb61e1e48db35a36e9ad5c2a9a2bd5.tar.bz2 manaverse-9a50b90628eb61e1e48db35a36e9ad5c2a9a2bd5.tar.xz manaverse-9a50b90628eb61e1e48db35a36e9ad5c2a9a2bd5.zip |
Show selected and max skill levels in skill popup.
Diffstat (limited to 'src/gui/popups/skillpopup.cpp')
-rw-r--r-- | src/gui/popups/skillpopup.cpp | 60 |
1 files changed, 55 insertions, 5 deletions
diff --git a/src/gui/popups/skillpopup.cpp b/src/gui/popups/skillpopup.cpp index a3da22acd..f631ea939 100644 --- a/src/gui/popups/skillpopup.cpp +++ b/src/gui/popups/skillpopup.cpp @@ -32,6 +32,9 @@ #include "gui/widgets/skillinfo.h" #include "gui/widgets/textbox.h" +#include "utils/gettext.h" +#include "utils/stringutils.h" + #include "debug.h" SkillPopup *skillPopup = nullptr; @@ -41,7 +44,9 @@ SkillPopup::SkillPopup() : mSkillName(new Label(this)), mSkillDesc(new TextBox(this)), mSkillEffect(new TextBox(this)), - mLastId(0U) + mSkillLevel(new TextBox(this)), + mLastId(0U), + mLastLevel(-1) { mSkillName->setFont(boldFont); mSkillName->setPosition(0, 0); @@ -57,6 +62,11 @@ SkillPopup::SkillPopup() : mSkillEffect->setPosition(0, 2 * fontHeight); mSkillEffect->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP), getThemeColor(ThemeColorId::POPUP_OUTLINE)); + + mSkillLevel->setEditable(false); + mSkillLevel->setPosition(0, 3 * fontHeight); + mSkillLevel->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP), + getThemeColor(ThemeColorId::POPUP_OUTLINE)); } void SkillPopup::postInit() @@ -65,6 +75,7 @@ void SkillPopup::postInit() add(mSkillName); add(mSkillDesc); add(mSkillEffect); + add(mSkillLevel); addMouseListener(this); } @@ -73,12 +84,19 @@ SkillPopup::~SkillPopup() { } -void SkillPopup::show(const SkillInfo *const skill) +void SkillPopup::show(const SkillInfo *const skill, + int level) { - if (!skill || !skill->data || skill->id == mLastId) + if (!skill || + !skill->data || + (skill->id == mLastId && + level == mLastLevel)) + { return; + } mLastId = skill->id; + mLastLevel = level; mSkillName->setCaption(skill->data->dispName); mSkillName->adjustSize(); @@ -93,6 +111,30 @@ void SkillPopup::show(const SkillInfo *const skill) } mSkillDesc->setTextWrapped(description, 196); mSkillEffect->setTextWrapped(effect, 196); + if (level != 0) + { + // TRANSLATORS: skill level + mSkillLevel->setTextWrapped(strprintf( + _("Level: %d / %d"), level, skill->level), + 196); + } + else + { + if (skill->level != 0) + { + // TRANSLATORS: skill level + mSkillLevel->setTextWrapped(strprintf( + _("Level: %d"), skill->level), + 196); + } + else + { + // TRANSLATORS: skill level for tmw fake skills + mSkillLevel->setTextWrapped( + _("Level: Unknown"), + 196); + } + } int minWidth = mSkillName->getWidth(); @@ -102,19 +144,27 @@ void SkillPopup::show(const SkillInfo *const skill) minWidth = mSkillDesc->getMinWidth(); if (mSkillEffect->getMinWidth() > minWidth) minWidth = mSkillEffect->getMinWidth(); + if (mSkillLevel->getMinWidth() > minWidth) + minWidth = mSkillLevel->getMinWidth(); const int numRowsDesc = mSkillDesc->getNumberOfRows(); const int numRowsEffect = mSkillEffect->getNumberOfRows(); + const int numRowsLevel = mSkillLevel->getNumberOfRows(); const int height = getFont()->getHeight(); if (skill->skillEffect.empty()) { - setContentSize(minWidth, (numRowsDesc + 1) * height); + setContentSize(minWidth, + (numRowsDesc + numRowsLevel + 1) * height); + mSkillLevel->setPosition(0, (numRowsDesc + 1) * height); } else { - setContentSize(minWidth, (numRowsDesc + numRowsEffect + 1) * height); + setContentSize(minWidth, + (numRowsDesc + numRowsLevel + numRowsEffect + 1) * height); mSkillEffect->setPosition(0, (numRowsDesc + 1) * height); + mSkillLevel->setPosition(0, + (numRowsDesc + numRowsEffect + 1) * height); } mSkillDesc->setPosition(0, 1 * height); |