summaryrefslogtreecommitdiff
path: root/src
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
parent226f98e12755b50cafe17d65a4c0aafd3994cd05 (diff)
downloadmanaverse-1ee562da80ee76787823f5e18c9463c05e2bb524.tar.gz
manaverse-1ee562da80ee76787823f5e18c9463c05e2bb524.tar.bz2
manaverse-1ee562da80ee76787823f5e18c9463c05e2bb524.tar.xz
manaverse-1ee562da80ee76787823f5e18c9463c05e2bb524.zip
In shop items hide amount if one
Diffstat (limited to 'src')
-rw-r--r--src/shopitem.cpp54
-rw-r--r--src/shopitem.h2
2 files changed, 21 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)
diff --git a/src/shopitem.h b/src/shopitem.h
index 449d9f91c..42616d389 100644
--- a/src/shopitem.h
+++ b/src/shopitem.h
@@ -132,6 +132,8 @@ class ShopItem final : public Item
{ return mDisplayName; }
protected:
+ void updateDisplayName(const int quantity);
+
std::string mDisplayName;
/**