summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-02-06 16:58:18 +0300
committerAndrei Karas <akaras@inbox.ru>2017-02-06 16:58:18 +0300
commitd557ce63e240960746e48c678b4a08ba66f7fe40 (patch)
tree8dfa33e155d7ea2145df9056895f0c1293155349 /src
parent8e243bbcdae592e1c003e5d2c37c8f0e8f1304e7 (diff)
downloadmanaverse-d557ce63e240960746e48c678b4a08ba66f7fe40.tar.gz
manaverse-d557ce63e240960746e48c678b4a08ba66f7fe40.tar.bz2
manaverse-d557ce63e240960746e48c678b4a08ba66f7fe40.tar.xz
manaverse-d557ce63e240960746e48c678b4a08ba66f7fe40.zip
Add custom currency also into shop items list.
Diffstat (limited to 'src')
-rw-r--r--src/gui/models/shopitems.cpp28
-rw-r--r--src/gui/models/shopitems.h5
-rw-r--r--src/gui/widgets/selldialog.cpp5
-rw-r--r--src/gui/windows/buydialog.cpp3
-rw-r--r--src/gui/windows/shopwindow.cpp7
-rw-r--r--src/resources/item/shopitem.cpp10
-rw-r--r--src/resources/item/shopitem.h7
7 files changed, 50 insertions, 15 deletions
diff --git a/src/gui/models/shopitems.cpp b/src/gui/models/shopitems.cpp
index 061da5110..94bba3be4 100644
--- a/src/gui/models/shopitems.cpp
+++ b/src/gui/models/shopitems.cpp
@@ -28,10 +28,12 @@
#include "debug.h"
-ShopItems::ShopItems(const bool mergeDuplicates) :
+ShopItems::ShopItems(const bool mergeDuplicates,
+ const std::string &currency) :
ListModel(),
mAllShopItems(),
mShopItems(),
+ mCurrency(currency),
mMergeDuplicates(mergeDuplicates)
{
}
@@ -58,7 +60,13 @@ ShopItem *ShopItems::addItem(const int id,
const int amount,
const int price)
{
- ShopItem *const item = new ShopItem(-1, id, type, color, amount, price);
+ ShopItem *const item = new ShopItem(-1,
+ id,
+ type,
+ color,
+ amount,
+ price,
+ mCurrency);
mShopItems.push_back(item);
mAllShopItems.push_back(item);
return item;
@@ -73,7 +81,13 @@ ShopItem *ShopItems::addItemNoDup(const int id,
ShopItem *item = findItem(id, color);
if (!item)
{
- item = new ShopItem(-1, id, type, color, amount, price);
+ item = new ShopItem(-1,
+ id,
+ type,
+ color,
+ amount,
+ price,
+ mCurrency);
mShopItems.push_back(item);
mAllShopItems.push_back(item);
}
@@ -97,7 +111,13 @@ ShopItem *ShopItems::addItem2(const int inventoryIndex,
}
else
{
- item = new ShopItem(inventoryIndex, id, type, color, quantity, price);
+ item = new ShopItem(inventoryIndex,
+ id,
+ type,
+ color,
+ quantity,
+ price,
+ mCurrency);
mShopItems.push_back(item);
mAllShopItems.push_back(item);
}
diff --git a/src/gui/models/shopitems.h b/src/gui/models/shopitems.h
index 42594a7c6..3b6d611cb 100644
--- a/src/gui/models/shopitems.h
+++ b/src/gui/models/shopitems.h
@@ -53,7 +53,8 @@ class ShopItems final : public ListModel
* @param mergeDuplicates lets the Shop look for duplicate entries and
* merges them to one item.
*/
- explicit ShopItems(const bool mergeDuplicates = false);
+ ShopItems(const bool mergeDuplicates,
+ const std::string &currency);
A_DELETE_COPY(ShopItems)
@@ -159,6 +160,8 @@ class ShopItems final : public ListModel
std::vector<ShopItem*> mShopItems;
+ std::string mCurrency;
+
/** Look for duplicate entries on addition. */
bool mMergeDuplicates;
};
diff --git a/src/gui/widgets/selldialog.cpp b/src/gui/widgets/selldialog.cpp
index 7f96e14ff..b455597a2 100644
--- a/src/gui/widgets/selldialog.cpp
+++ b/src/gui/widgets/selldialog.cpp
@@ -22,6 +22,8 @@
#include "gui/widgets/selldialog.h"
+#include "const/resources/currency.h"
+
#include "enums/gui/layouttype.h"
#include "gui/windows/setupwindow.h"
@@ -89,7 +91,8 @@ void SellDialog::postInit()
setupWindow->registerWindowForReset(this);
// Create a ShopItems instance, that is aware of duplicate entries.
- mShopItems = new ShopItems(true);
+ mShopItems = new ShopItems(true,
+ DEFAULT_CURRENCY);
if (mAdvanced == Advanced_true)
mShopItems->setMergeDuplicates(false);
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index a0ec8d05c..bddd8bba6 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -296,7 +296,8 @@ void BuyDialog::init()
if (setupWindow)
setupWindow->registerWindowForReset(this);
- mShopItems = new ShopItems;
+ mShopItems = new ShopItems(false,
+ mCurrency);
CREATEWIDGETV(mShopItemList, ShopListBox, this,
mShopItems, mShopItems, ShopListBoxType::Unknown);
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index b09b44a46..f308cb5b5 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -107,8 +107,8 @@ ShopWindow::ShopWindow() :
SelectionListener(),
// TRANSLATORS: shop window button
mCloseButton(new Button(this, _("Close"), "close", this)),
- mBuyShopItems(new ShopItems),
- mSellShopItems(new ShopItems),
+ mBuyShopItems(new ShopItems(false, DEFAULT_CURRENCY)),
+ mSellShopItems(new ShopItems(false, DEFAULT_CURRENCY)),
mTradeItem(nullptr),
mBuyShopItemList(CREATEWIDGETR(ShopListBox,
this, mBuyShopItems, mBuyShopItems, ShopListBoxType::BuyShop)),
@@ -952,7 +952,8 @@ void ShopWindow::processRequest(const std::string &nick, std::string data,
ItemType::Unknown,
ItemColor_one,
amount,
- price);
+ price,
+ DEFAULT_CURRENCY);
if (mode == BUY)
{
diff --git a/src/resources/item/shopitem.cpp b/src/resources/item/shopitem.cpp
index b3d088b36..27a496814 100644
--- a/src/resources/item/shopitem.cpp
+++ b/src/resources/item/shopitem.cpp
@@ -37,7 +37,8 @@ ShopItem::ShopItem(const int inventoryIndex,
const ItemTypeT type,
const ItemColor color,
const int quantity,
- const int price) :
+ const int price,
+ const std::string &currency) :
Item(id, type, 0, 0, color,
Identified_true,
Damaged_false,
@@ -45,6 +46,7 @@ ShopItem::ShopItem(const int inventoryIndex,
Equipm_false,
Equipped_false),
mDisplayName(),
+ mCurrency(currency),
mDuplicates(),
mPrice(price),
mUsedQuantity(0),
@@ -60,7 +62,8 @@ ShopItem::ShopItem(const int inventoryIndex,
ShopItem::ShopItem(const int id,
const ItemTypeT type,
const ItemColor color,
- const int price) :
+ const int price,
+ const std::string &currency) :
Item(id, type, 0, 0, color,
Identified_true,
Damaged_false,
@@ -68,6 +71,7 @@ ShopItem::ShopItem(const int id,
Equipm_false,
Equipped_false),
mDisplayName(),
+ mCurrency(currency),
mDuplicates(),
mPrice(price),
mUsedQuantity(0),
@@ -99,7 +103,7 @@ void ShopItem::updateDisplayName(const int quantity)
if (mPrice)
{
mDisplayName.append(" (").append(
- UnitsDb::formatCurrency(mPrice)).append(") ");
+ UnitsDb::formatCurrency(mCurrency, mPrice)).append(") ");
}
if (mShowQuantity && quantity > 1)
mDisplayName.append("[").append(toString(quantity)).append("]");
diff --git a/src/resources/item/shopitem.h b/src/resources/item/shopitem.h
index 96b8fcbf9..7596d0269 100644
--- a/src/resources/item/shopitem.h
+++ b/src/resources/item/shopitem.h
@@ -49,7 +49,8 @@ class ShopItem final : public Item
const ItemTypeT type,
const ItemColor color,
const int quantity,
- const int price);
+ const int price,
+ const std::string &currency);
/**
* Constructor. Creates a new ShopItem. Inventory index will be set to
@@ -61,7 +62,8 @@ class ShopItem final : public Item
ShopItem(const int id,
const ItemTypeT type,
const ItemColor color,
- const int price);
+ const int price,
+ const std::string &currency);
A_DELETE_COPY(ShopItem)
@@ -158,6 +160,7 @@ class ShopItem final : public Item
void updateDisplayName(const int quantity);
std::string mDisplayName;
+ std::string mCurrency;
/**
* Struct to keep track of duplicates.