summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-23 01:27:45 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-23 01:27:45 +0300
commit9be90b76adb1518c4ffe0e365a18c5afcc3158f2 (patch)
treebbfea959321e05c329f18ac37757be91f38b9df8 /src/gui
parent7f1053c5ce9e80485730290d002f7ae25db83996 (diff)
downloadplus-9be90b76adb1518c4ffe0e365a18c5afcc3158f2.tar.gz
plus-9be90b76adb1518c4ffe0e365a18c5afcc3158f2.tar.bz2
plus-9be90b76adb1518c4ffe0e365a18c5afcc3158f2.tar.xz
plus-9be90b76adb1518c4ffe0e365a18c5afcc3158f2.zip
Add item type to item object.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/models/shopitems.cpp27
-rw-r--r--src/gui/models/shopitems.h23
-rw-r--r--src/gui/widgets/itemcontainer.cpp3
-rw-r--r--src/gui/widgets/selldialog.cpp21
-rw-r--r--src/gui/widgets/selldialog.h7
-rw-r--r--src/gui/windows/buydialog.cpp9
-rw-r--r--src/gui/windows/buydialog.h7
-rw-r--r--src/gui/windows/itemamountwindow.cpp2
-rw-r--r--src/gui/windows/npcdialog.cpp3
-rw-r--r--src/gui/windows/shopwindow.cpp22
-rw-r--r--src/gui/windows/tradewindow.cpp6
-rw-r--r--src/gui/windows/tradewindow.h2
12 files changed, 91 insertions, 41 deletions
diff --git a/src/gui/models/shopitems.cpp b/src/gui/models/shopitems.cpp
index 58bfe0023..e6bbeb787 100644
--- a/src/gui/models/shopitems.cpp
+++ b/src/gui/models/shopitems.cpp
@@ -50,23 +50,32 @@ std::string ShopItems::getElementAt(int i)
return mShopItems.at(i)->getDisplayName();
}
-void ShopItems::addItem(const int id, const unsigned char color,
- const int amount, const int price)
+void ShopItems::addItem(const int id,
+ const int type,
+ const unsigned char color,
+ const int amount,
+ const int price)
{
- mShopItems.push_back(new ShopItem(-1, id, color, amount, price));
+ mShopItems.push_back(new ShopItem(-1, id, type, color, amount, price));
}
-void ShopItems::addItemNoDup(const int id, const unsigned char color,
- const int amount, const int price)
+void ShopItems::addItemNoDup(const int id,
+ const int type,
+ const unsigned char color,
+ const int amount,
+ const int price)
{
const ShopItem *const item = findItem(id, color);
if (!item)
- mShopItems.push_back(new ShopItem(-1, id, color, amount, price));
+ mShopItems.push_back(new ShopItem(-1, id, type, color, amount, price));
}
-void ShopItems::addItem2(const int inventoryIndex, const int id,
+void ShopItems::addItem2(const int inventoryIndex,
+ const int id,
+ const int type,
const unsigned char color,
- const int quantity, const int price)
+ const int quantity,
+ const int price)
{
ShopItem *item = nullptr;
if (mMergeDuplicates)
@@ -78,7 +87,7 @@ void ShopItems::addItem2(const int inventoryIndex, const int id,
}
else
{
- item = new ShopItem(inventoryIndex, id, color, quantity, price);
+ item = new ShopItem(inventoryIndex, id, type, color, quantity, price);
mShopItems.push_back(item);
}
}
diff --git a/src/gui/models/shopitems.h b/src/gui/models/shopitems.h
index 5e8fb2b97..68048c65c 100644
--- a/src/gui/models/shopitems.h
+++ b/src/gui/models/shopitems.h
@@ -59,8 +59,11 @@ class ShopItems final : public ListModel
/**
* Adds an item to the list.
*/
- void addItem(const int id, const unsigned char color,
- const int amount, const int price);
+ void addItem(const int id,
+ const int type,
+ const unsigned char color,
+ const int amount,
+ const int price);
/**
* Adds an item to the list (used by sell dialog). Looks for
@@ -71,12 +74,18 @@ class ShopItems final : public ListModel
* @param quantity number of available copies of the item
* @param price price of the item
*/
- void addItem2(const int inventoryIndex, const int id,
+ void addItem2(const int inventoryIndex,
+ const int id,
+ const int type,
const unsigned char color,
- const int amount, const int price);
-
- void addItemNoDup(const int id, const unsigned char color,
- const int amount, const int price);
+ const int amount,
+ const int price);
+
+ void addItemNoDup(const int id,
+ const int type,
+ const unsigned char color,
+ const int amount,
+ const int price);
/**
* Returns the number of items in the shop.
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 732e9e738..952da11c2 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -552,7 +552,8 @@ void ItemContainer::mouseReleased(MouseEvent &event)
const Item *const item = inventory->getItem(dragDrop.getTag());
if (item && !PlayerInfo::isItemProtected(item->getId()))
{
- mInventory->addItem(item->getId(), 1, 1, item->getColor(),
+ mInventory->addItem(item->getId(), item->getType(),
+ 1, 1, item->getColor(),
item->getIdentified(), item->getDamaged(),
item->getFavorite(),
false, false);
diff --git a/src/gui/widgets/selldialog.cpp b/src/gui/widgets/selldialog.cpp
index 2d45c39f8..4e289e93e 100644
--- a/src/gui/widgets/selldialog.cpp
+++ b/src/gui/widgets/selldialog.cpp
@@ -182,16 +182,27 @@ void SellDialog::addItem(const Item *const item, const int price)
if (!item)
return;
- mShopItems->addItem2(item->getInvIndex(), item->getId(),
- item->getColor(), item->getQuantity(), price);
+ mShopItems->addItem2(item->getInvIndex(),
+ item->getId(),
+ item->getType(),
+ item->getColor(),
+ item->getQuantity(),
+ price);
mShopItemList->adjustSize();
}
-void SellDialog::addItem(const int id, const unsigned char color,
- const int amount, const int price)
+void SellDialog::addItem(const int id,
+ const int type,
+ const unsigned char color,
+ const int amount,
+ const int price)
{
- mShopItems->addItem(id, color, amount, price);
+ mShopItems->addItem(id,
+ type,
+ color,
+ amount,
+ price);
mShopItemList->adjustSize();
}
diff --git a/src/gui/widgets/selldialog.h b/src/gui/widgets/selldialog.h
index d147947b5..a3f6137fb 100644
--- a/src/gui/widgets/selldialog.h
+++ b/src/gui/widgets/selldialog.h
@@ -90,8 +90,11 @@ class SellDialog notfinal : public Window,
*/
void setVisible(bool visible) override final;
- void addItem(const int id, const unsigned char color,
- const int amount, const int price);
+ void addItem(const int id,
+ const int type,
+ const unsigned char color,
+ const int amount,
+ const int price);
/**
* Returns true if any instances exist.
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index 61b5d7233..4340a671f 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -335,10 +335,13 @@ void BuyDialog::reset()
setMoney(0);
}
-void BuyDialog::addItem(const int id, const unsigned char color,
- const int amount, const int price)
+void BuyDialog::addItem(const int id,
+ const int type,
+ const unsigned char color,
+ const int amount,
+ const int price)
{
- mShopItems->addItem(id, color, amount, price);
+ mShopItems->addItem(id, type, color, amount, price);
mShopItemList->adjustSize();
}
diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h
index 02862187c..af63432f7 100644
--- a/src/gui/windows/buydialog.h
+++ b/src/gui/windows/buydialog.h
@@ -91,8 +91,11 @@ class BuyDialog final : public Window,
/**
* Adds an item to the shop inventory.
*/
- void addItem(const int id, const unsigned char color,
- const int amount, const int price);
+ void addItem(const int id,
+ const int type,
+ const unsigned char color,
+ const int amount,
+ const int price);
/**
* Called when receiving actions from the widgets.
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index 6eb51de98..548baa01d 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -319,7 +319,7 @@ void ItemAmountWindow::action(const ActionEvent &event)
const int id = ItemDB::get(mItemsModal->getElementAt(
mItemDropDown->getSelected())).getId();
- mItem = new Item(id, 10000, 0, 1, true, false, false, false, false);
+ mItem = new Item(id, 0, 10000, 0, 1, true, false, false, false, false);
if (mUsage == ShopBuyAdd)
mMax = 10000;
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index 71290ef22..c99a4898d 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -468,7 +468,8 @@ void NpcDialog::action(const ActionEvent &event)
const Item *const item = inventoryWindow->getSelectedItem();
if (item)
{
- mInventory->addItem(item->getId(), 1, 1, item->getColor(),
+ mInventory->addItem(item->getId(), item->getType(),
+ 1, 1, item->getColor(),
item->getIdentified(), item->getDamaged(),
item->getFavorite(),
false, false);
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index d72dab6b8..534218601 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -328,7 +328,10 @@ void ShopWindow::addBuyItem(const Item *const item, const int amount,
return;
const bool emp = isShopEmpty();
mBuyShopItems->addItemNoDup(item->getId(),
- item->getColor(), amount, price);
+ item->getType(),
+ item->getColor(),
+ amount,
+ price);
if (emp && localPlayer)
localPlayer->updateStatus();
@@ -342,7 +345,10 @@ void ShopWindow::addSellItem(const Item *const item, const int amount,
return;
const bool emp = isShopEmpty();
mSellShopItems->addItemNoDup(item->getId(),
- item->getColor(), amount, price);
+ item->getType(),
+ item->getColor(),
+ amount,
+ price);
if (emp && localPlayer)
localPlayer->updateStatus();
@@ -390,12 +396,12 @@ void ShopWindow::loadList()
if (tokens[1] && tokens[2] && mBuyShopItems)
{
mBuyShopItems->addItem(
- tokens[0], 1, tokens[1], tokens[2]);
+ tokens[0], 0, 1, tokens[1], tokens[2]);
}
if (tokens[3] && tokens[4] && mSellShopItems)
{
mSellShopItems->addItem(
- tokens[0], 1, tokens[3], tokens[4]);
+ tokens[0], 0, 1, tokens[3], tokens[4]);
}
}
}
@@ -663,7 +669,7 @@ void ShopWindow::showList(const std::string &nick, std::string data)
int amount = decodeStr(data.substr(f + 6, 3));
// +++ need impliment colors?
if (buyDialog && amount > 0)
- buyDialog->addItem(id, 1, amount, price);
+ buyDialog->addItem(id, 0, 1, amount, price);
if (sellDialog)
{
// +++ need support for colors
@@ -673,9 +679,9 @@ void ShopWindow::showList(const std::string &nick, std::string data)
if (item->getQuantity() < amount)
amount = item->getQuantity();
if (amount > 0)
- sellDialog->addItem(id, 1, amount, price);
+ sellDialog->addItem(id, 0, 1, amount, price);
else
- sellDialog->addItem(id, 1, -1, price);
+ sellDialog->addItem(id, 0, 1, -1, price);
}
}
}
@@ -736,7 +742,7 @@ void ShopWindow::processRequest(const std::string &nick, std::string data,
delete mTradeItem;
// +++ need impliment colors?
- mTradeItem = new ShopItem(-1, id, 1, amount, price);
+ mTradeItem = new ShopItem(-1, id, 0, 1, amount, price);
if (mode == BUY)
{
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index c7cd1712d..ba1285366 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -191,6 +191,7 @@ void TradeWindow::setMoney(const int amount)
}
void TradeWindow::addItem(const int id,
+ const int type,
const bool own,
const int quantity,
const uint8_t refine,
@@ -200,11 +201,12 @@ void TradeWindow::addItem(const int id,
const bool favorite) const
{
Inventory *inv = own ? mMyInventory.get() : mPartnerInventory.get();
- inv->addItem(id, quantity, refine, color,
+ inv->addItem(id, type, quantity, refine, color,
identified, damaged, favorite, false, false);
}
void TradeWindow::addItem2(const int id,
+ const int type,
const int *const cards,
const int sz,
const bool own,
@@ -217,7 +219,7 @@ void TradeWindow::addItem2(const int id,
const bool equipment) const
{
Inventory *inv = own ? mMyInventory.get() : mPartnerInventory.get();
- const int slot = inv->addItem(id, quantity, refine, color,
+ const int slot = inv->addItem(id, type, quantity, refine, color,
identified, damaged, favorite, equipment, false);
if (slot >= 0)
inv->setCards(slot, cards, sz);
diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h
index 5c782cf07..9dcfe91c1 100644
--- a/src/gui/windows/tradewindow.h
+++ b/src/gui/windows/tradewindow.h
@@ -68,6 +68,7 @@ class TradeWindow final : public Window,
* Add an item to the trade window.
*/
void addItem(const int id,
+ const int type,
const bool own,
const int quantity,
const uint8_t refine,
@@ -85,6 +86,7 @@ class TradeWindow final : public Window,
* Add an item to the trade window.
*/
void addItem2(const int id,
+ const int type,
const int *const cards,
const int sz,
const bool own,