summaryrefslogtreecommitdiff
path: root/src/shopitem.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-22 21:04:58 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-22 21:04:58 +0300
commit1ee562da80ee76787823f5e18c9463c05e2bb524 (patch)
tree2b0190f8ddfd1a10c27a7890cc682e81bbfe7b1f /src/shopitem.cpp
parent226f98e12755b50cafe17d65a4c0aafd3994cd05 (diff)
downloadplus-1ee562da80ee76787823f5e18c9463c05e2bb524.tar.gz
plus-1ee562da80ee76787823f5e18c9463c05e2bb524.tar.bz2
plus-1ee562da80ee76787823f5e18c9463c05e2bb524.tar.xz
plus-1ee562da80ee76787823f5e18c9463c05e2bb524.zip
In shop items hide amount if one
Diffstat (limited to 'src/shopitem.cpp')
-rw-r--r--src/shopitem.cpp54
1 files changed, 19 insertions, 35 deletions
diff --git a/src/shopitem.cpp b/src/shopitem.cpp
index 10491ef2d..386583170 100644
--- a/src/shopitem.cpp
+++ b/src/shopitem.cpp
@@ -42,17 +42,8 @@ ShopItem::ShopItem(const int inventoryIndex, const int id,
mPrice(price),
mShowQuantity(true)
{
- if (serverFeatures->haveItemColors())
- {
- mDisplayName = std::string(getInfo().getName(color)).append(" (")
- .append(Units::formatCurrency(mPrice)).append(") ");
- }
- else
- {
- mDisplayName = std::string(getInfo().getName()).append(" (")
- .append(Units::formatCurrency(mPrice)).append(") ");
- }
- if (quantity > 0)
+ updateDisplayName(quantity);
+ if (quantity > 1)
mDisplayName.append("[").append(toString(quantity)).append("]");
setInvIndex(inventoryIndex);
@@ -66,16 +57,7 @@ ShopItem::ShopItem(const int id, const unsigned char color, const int price) :
mPrice(price),
mShowQuantity(false)
{
- if (serverFeatures->haveItemColors())
- {
- mDisplayName = std::string(getInfo().getName(color)).append(" (")
- .append(Units::formatCurrency(mPrice)).append(")");
- }
- else
- {
- mDisplayName = std::string(getInfo().getName()).append(" (")
- .append(Units::formatCurrency(mPrice)).append(")");
- }
+ updateDisplayName(0);
setInvIndex(-1);
addDuplicate(-1, 0);
}
@@ -90,23 +72,25 @@ ShopItem::~ShopItem()
}
}
-void ShopItem::update()
+void ShopItem::updateDisplayName(const int quantity)
{
- if (mShowQuantity)
+ if (serverFeatures->haveItemColors())
+ mDisplayName = std::string(getInfo().getName(mColor));
+ else
+ mDisplayName = std::string(getInfo().getName());
+ if (mPrice)
{
- if (serverFeatures->haveItemColors())
- {
- mDisplayName = std::string(getInfo().getName(mColor)).append(" (")
- .append(Units::formatCurrency(mPrice)).append(") ");
- }
- else
- {
- mDisplayName = std::string(getInfo().getName()).append(" (")
- .append(Units::formatCurrency(mPrice)).append(") ");
- }
- if (mQuantity > 0)
- mDisplayName.append("[").append(toString(mQuantity)).append("]");
+ mDisplayName.append(" (").append(
+ Units::formatCurrency(mPrice)).append(") ");
}
+ if (quantity > 1)
+ mDisplayName.append("[").append(toString(quantity)).append("]");
+}
+
+void ShopItem::update()
+{
+ if (mShowQuantity)
+ updateDisplayName(mQuantity);
}
void ShopItem::addDuplicate(const int inventoryIndex, const int quantity)