summaryrefslogtreecommitdiff
path: root/src/gui/popups
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-22 21:58:33 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-22 22:06:08 +0300
commit9a50b90628eb61e1e48db35a36e9ad5c2a9a2bd5 (patch)
tree24ab6a1f2e367a15e2ac9b994e7060767068b8e5 /src/gui/popups
parente3f651e65f5a486f47ae81fe3ba5e68e8c48f79e (diff)
downloadplus-9a50b90628eb61e1e48db35a36e9ad5c2a9a2bd5.tar.gz
plus-9a50b90628eb61e1e48db35a36e9ad5c2a9a2bd5.tar.bz2
plus-9a50b90628eb61e1e48db35a36e9ad5c2a9a2bd5.tar.xz
plus-9a50b90628eb61e1e48db35a36e9ad5c2a9a2bd5.zip
Show selected and max skill levels in skill popup.
Diffstat (limited to 'src/gui/popups')
-rw-r--r--src/gui/popups/skillpopup.cpp60
-rw-r--r--src/gui/popups/skillpopup.h5
2 files changed, 59 insertions, 6 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);
diff --git a/src/gui/popups/skillpopup.h b/src/gui/popups/skillpopup.h
index 25d4058f7..8bc6e385d 100644
--- a/src/gui/popups/skillpopup.h
+++ b/src/gui/popups/skillpopup.h
@@ -54,7 +54,8 @@ class SkillPopup final : public Popup
/**
* Sets the info to be displayed given a particular item.
*/
- void show(const SkillInfo *const skill);
+ void show(const SkillInfo *const skill,
+ int level);
void mouseMoved(MouseEvent &event) override final;
@@ -62,7 +63,9 @@ class SkillPopup final : public Popup
Label *mSkillName A_NONNULLPOINTER;
TextBox *mSkillDesc A_NONNULLPOINTER;
TextBox *mSkillEffect A_NONNULLPOINTER;
+ TextBox *mSkillLevel A_NONNULLPOINTER;
unsigned int mLastId;
+ int mLastLevel;
};
extern SkillPopup *skillPopup;