summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-02-10 04:36:19 +0200
committerAndrei Karas <akaras@inbox.ru>2011-02-10 04:36:19 +0200
commiteb1428dded5d2be98eff034fd26a08c109d2376c (patch)
tree3672f9023151e496d1066a1fcdf9ae03ec478917 /src
parentf74cf5eb61deccc478d2a4cbc7a352748d96c65e (diff)
downloadmv-eb1428dded5d2be98eff034fd26a08c109d2376c.tar.gz
mv-eb1428dded5d2be98eff034fd26a08c109d2376c.tar.bz2
mv-eb1428dded5d2be98eff034fd26a08c109d2376c.tar.xz
mv-eb1428dded5d2be98eff034fd26a08c109d2376c.zip
Add to text popups bar name in top left corner.
Diffstat (limited to 'src')
-rw-r--r--src/gui/ministatus.cpp28
-rw-r--r--src/gui/textpopup.cpp19
-rw-r--r--src/gui/textpopup.h13
3 files changed, 54 insertions, 6 deletions
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index ab894b3a8..8308fe15b 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -263,12 +263,14 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
> PlayerInfo::getAttribute(EXP_NEEDED))
{
mTextPopup->show(x + getX(), y + getY(),
+ event.getSource()->getId(),
strprintf("%u/%u", PlayerInfo::getAttribute(EXP),
PlayerInfo::getAttribute(EXP_NEEDED)));
}
else
{
mTextPopup->show(x + getX(), y + getY(),
+ event.getSource()->getId(),
strprintf("%u/%u", PlayerInfo::getAttribute(EXP),
PlayerInfo::getAttribute(EXP_NEEDED)),
strprintf("%s: %u", _("Need"),
@@ -280,6 +282,7 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
else if (event.getSource() == mHpBar)
{
mTextPopup->show(x + getX(), y + getY(),
+ event.getSource()->getId(),
strprintf("%u/%u", PlayerInfo::getAttribute(HP),
PlayerInfo::getAttribute(MAX_HP)));
mStatusPopup->hide();
@@ -287,6 +290,7 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
else if (event.getSource() == mMpBar)
{
mTextPopup->show(x + getX(), y + getY(),
+ event.getSource()->getId(),
strprintf("%u/%u", PlayerInfo::getAttribute(MP),
PlayerInfo::getAttribute(MAX_MP)));
mStatusPopup->hide();
@@ -299,12 +303,14 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
if (exp.first > exp.second)
{
mTextPopup->show(x + getX(), y + getY(),
+ event.getSource()->getId(),
strprintf("%u/%u", exp.first,
exp.second));
}
else
{
mTextPopup->show(x + getX(), y + getY(),
+ event.getSource()->getId(),
strprintf("%u/%u", exp.first,
exp.second),
strprintf("%s: %u", _("Need"),
@@ -313,6 +319,28 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
}
mStatusPopup->hide();
}
+ else if (event.getSource() == mWeightBar)
+ {
+ mTextPopup->show(x + getX(), y + getY(),
+ event.getSource()->getId(),
+ strprintf("%u/%u", PlayerInfo::getAttribute(TOTAL_WEIGHT),
+ PlayerInfo::getAttribute(MAX_WEIGHT)));
+ mStatusPopup->hide();
+ }
+ else if (event.getSource() == mInvSlotsBar)
+ {
+ Inventory *inv = PlayerInfo::getInventory();
+ if (inv)
+ {
+ const int usedSlots = inv->getNumberOfSlotsUsed();
+ const int maxSlots = inv->getSize();
+
+ mTextPopup->show(x + getX(), y + getY(),
+ event.getSource()->getId(),
+ strprintf("%u/%u", usedSlots, maxSlots));
+ }
+ mStatusPopup->hide();
+ }
else
{
mTextPopup->hide();
diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp
index 270b0f759..695319647 100644
--- a/src/gui/textpopup.cpp
+++ b/src/gui/textpopup.cpp
@@ -46,8 +46,12 @@ TextPopup::TextPopup():
mText2 = new gcn::Label;
mText2->setPosition(getPadding(), fontHeight + 2 * getPadding());
+ mText3 = new gcn::Label;
+ mText3->setPosition(getPadding(), (2 * fontHeight) + 2 * getPadding());
+
add(mText1);
add(mText2);
+ add(mText3);
addMouseListener(this);
}
@@ -56,24 +60,31 @@ TextPopup::~TextPopup()
}
void TextPopup::show(int x, int y, const std::string &str1,
- const std::string &str2)
+ const std::string &str2, const std::string &str3)
{
mText1->setCaption(str1);
mText1->adjustSize();
mText2->setCaption(str2);
mText2->adjustSize();
+ mText3->setCaption(str3);
+ mText3->adjustSize();
int minWidth = mText1->getWidth();
if (mText2->getWidth() > minWidth)
minWidth = mText2->getWidth();
+ if (mText3->getWidth() > minWidth)
+ minWidth = mText3->getWidth();
minWidth += 4 * getPadding();
setWidth(minWidth);
+ int cnt = 1;
if (!str2.empty())
- setHeight((2 * getPadding() + mText1->getFont()->getHeight()) * 2);
- else
- setHeight(2 * getPadding() + mText1->getFont()->getHeight());
+ cnt ++;
+ if (!str3.empty())
+ cnt ++;
+
+ setHeight((2 * getPadding() + mText1->getFont()->getHeight()) * cnt);
const int distance = 20;
diff --git a/src/gui/textpopup.h b/src/gui/textpopup.h
index 3b4158f6e..f13a0484c 100644
--- a/src/gui/textpopup.h
+++ b/src/gui/textpopup.h
@@ -50,19 +50,28 @@ class TextPopup : public Popup
* Sets the text to be displayed.
*/
void show(int x, int y, const std::string &str1)
- { show(x, y, str1, static_cast<const char*>("")); };
+ { show(x, y, str1, static_cast<const char*>(""),
+ static_cast<const char*>("")); };
/**
* Sets the text to be displayed.
*/
void show(int x, int y, const std::string &str1,
- const std::string &str2);
+ const std::string &str2)
+ { show(x, y, str1, str2, static_cast<const char*>("")); }
+
+ /**
+ * Sets the text to be displayed.
+ */
+ void show(int x, int y, const std::string &str1,
+ const std::string &str2, const std::string &str3);
void mouseMoved(gcn::MouseEvent &mouseEvent);
private:
gcn::Label *mText1;
gcn::Label *mText2;
+ gcn::Label *mText3;
};
#endif // TEXTPOPUP_H