summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-06-28 20:43:32 +0300
committerAndrei Karas <akaras@inbox.ru>2017-06-28 20:43:58 +0300
commitd6094cc50fad47eb7071f077e4e630cbec6c5b18 (patch)
tree263213ed5865279bf2d45397c9d1943ea130352e /src/gui
parent4541175c81e5de39a3118729b7f5997d251b3d35 (diff)
downloadmanaverse-d6094cc50fad47eb7071f077e4e630cbec6c5b18.tar.gz
manaverse-d6094cc50fad47eb7071f077e4e630cbec6c5b18.tar.bz2
manaverse-d6094cc50fad47eb7071f077e4e630cbec6c5b18.tar.xz
manaverse-d6094cc50fad47eb7071f077e4e630cbec6c5b18.zip
Fix showing cached additional fields in item popups.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/popups/itempopup.cpp32
-rw-r--r--src/gui/popups/itempopup.h2
2 files changed, 29 insertions, 5 deletions
diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp
index 9800455ca..55f77350d 100644
--- a/src/gui/popups/itempopup.cpp
+++ b/src/gui/popups/itempopup.cpp
@@ -69,6 +69,8 @@ ItemPopup::ItemPopup() :
mItemType(ItemDbType::UNUSABLE),
mIcon(new Icon(this, nullptr)),
mLastName(),
+ mCardsStr(),
+ mItemOptionsStr(),
mLastId(0),
mLastColor(ItemColor_one)
{
@@ -181,11 +183,31 @@ void ItemPopup::setItem(const ItemInfo &item,
const int *const cards,
const ItemOptionsList *const options)
{
- if (mIcon == nullptr ||
- (item.getName() == mLastName && color == mLastColor && id == mLastId))
- {
+ if (mIcon == nullptr)
return;
+
+ std::string cardsStr;
+ std::string optionsStr;
+
+ if (item.getName() == mLastName &&
+ color == mLastColor &&
+ id == mLastId)
+ {
+ cardsStr = getCardsString(cards);
+ optionsStr = getOptionsString(options);
+ if (mItemOptionsStr == optionsStr &&
+ mCardsStr == cardsStr)
+ {
+ return;
+ }
+ }
+ else
+ {
+ cardsStr = getCardsString(cards);
+ optionsStr = getOptionsString(options);
}
+ mItemOptionsStr = optionsStr;
+ mCardsStr = cardsStr;
if (id == -1)
id = item.getId();
@@ -244,8 +266,8 @@ void ItemPopup::setItem(const ItemInfo &item,
// TRANSLATORS: popup label
mItemWeight->setTextWrapped(strprintf(_("Weight: %s"),
UnitsDb::formatWeight(item.getWeight()).c_str()), 196);
- mItemCards->setTextWrapped(getCardsString(cards), 196);
- mItemOptions->setTextWrapped(getOptionsString(options), 196);
+ mItemCards->setTextWrapped(mCardsStr, 196);
+ mItemOptions->setTextWrapped(optionsStr, 196);
int minWidth = mItemName->getWidth() + space;
diff --git a/src/gui/popups/itempopup.h b/src/gui/popups/itempopup.h
index de552eca7..fff3b817d 100644
--- a/src/gui/popups/itempopup.h
+++ b/src/gui/popups/itempopup.h
@@ -89,6 +89,8 @@ class ItemPopup final : public Popup
ItemDbTypeT mItemType;
Icon *mIcon A_NONNULLPOINTER;
std::string mLastName;
+ std::string mCardsStr;
+ std::string mItemOptionsStr;
int mLastId;
ItemColor mLastColor;