summaryrefslogtreecommitdiff
path: root/src/gui/itempopup.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-03-08 06:06:50 +0200
committerAndrei Karas <akaras@inbox.ru>2011-03-08 06:06:50 +0200
commit07c9e6360ac16c96b8624a4b0bf4557ae295699d (patch)
tree718cbc1e2cd21b13239d7bca4be9a04d811e4c48 /src/gui/itempopup.cpp
parentc17acf93cb4ebe698b0af8a38a1fd6d49a6be3cc (diff)
downloadmv-07c9e6360ac16c96b8624a4b0bf4557ae295699d.tar.gz
mv-07c9e6360ac16c96b8624a4b0bf4557ae295699d.tar.bz2
mv-07c9e6360ac16c96b8624a4b0bf4557ae295699d.tar.xz
mv-07c9e6360ac16c96b8624a4b0bf4557ae295699d.zip
Replace %color% and %Color% constants in item names/descriptions.
Diffstat (limited to 'src/gui/itempopup.cpp')
-rw-r--r--src/gui/itempopup.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index d7f67ff0c..1a8dcc35d 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -23,6 +23,7 @@
#include "gui/itempopup.h"
+#include "client.h"
#include "graphics.h"
#include "item.h"
#include "units.h"
@@ -46,7 +47,9 @@
ItemPopup::ItemPopup():
Popup("ItemPopup"),
- mIcon(0)
+ mIcon(0),
+ mLastName(""),
+ mLastColor(1)
{
// Item Name
mItemName = new gcn::Label;
@@ -100,8 +103,18 @@ void ItemPopup::setItem(const Item *item, bool showImage)
setItem(ii, item->getColor(), showImage);
if (item->getRefine() > 0)
{
- mItemName->setCaption(strprintf("%s (+%d), %d", ii.getName().c_str(),
- item->getRefine(), ii.getId()));
+ mLastName = item->getId();
+ mLastColor = item->getColor();
+ if (serverVersion > 0)
+ {
+ mItemName->setCaption(strprintf("%s (+%d), %d", ii.getName(
+ item->getColor()).c_str(), item->getRefine(), ii.getId()));
+ }
+ else
+ {
+ mItemName->setCaption(strprintf("%s (+%d), %d",
+ ii.getName().c_str(), item->getRefine(), ii.getId()));
+ }
mItemName->adjustSize();
int minWidth = mItemName->getWidth() + 8;
if (getWidth() < minWidth)
@@ -112,7 +125,7 @@ void ItemPopup::setItem(const Item *item, bool showImage)
void ItemPopup::setItem(const ItemInfo &item, unsigned char color,
bool showImage)
{
- if (!mIcon || item.getName() == mItemName->getCaption())
+ if (!mIcon || (item.getName() == mLastName && color == mLastColor))
return;
int space = 0;
@@ -147,12 +160,26 @@ void ItemPopup::setItem(const ItemInfo &item, unsigned char color,
mItemType = item.getType();
- mItemName->setCaption(item.getName() + _(", ") + toString(item.getId()));
+ mLastName = item.getName();
+ mLastColor = color;
+
+ if (serverVersion > 0)
+ {
+ mItemName->setCaption(item.getName(color) + _(", ")
+ + toString(item.getId()));
+ mItemDesc->setTextWrapped(item.getDescription(color), 196);
+ }
+ else
+ {
+ mItemName->setCaption(item.getName() + _(", ")
+ + toString(item.getId()));
+ mItemDesc->setTextWrapped(item.getDescription(), 196);
+ }
+
mItemName->adjustSize();
mItemName->setForegroundColor(getColor(mItemType));
mItemName->setPosition(getPadding() + space, getPadding());
- mItemDesc->setTextWrapped(item.getDescription(), 196);
mItemEffect->setTextWrapped(item.getEffect(), 196);
mItemWeight->setTextWrapped(strprintf(_("Weight: %s"),
Units::formatWeight(item.getWeight()).c_str()),
@@ -240,4 +267,6 @@ void ItemPopup::mouseMoved(gcn::MouseEvent &event)
// When the mouse moved on top of the popup, hide it
setVisible(false);
+ mLastName = "";
+ mLastColor = 1;
} \ No newline at end of file