ManaPlus
|
#include <shopitems.h>
Public Member Functions | |
ShopItems (const bool mergeDuplicates, const std::string ¤cy) | |
~ShopItems () | |
ShopItem * | addItem (const int id, const ItemTypeT type, const ItemColor color, const int amount, const int price) |
ShopItem * | addItem2 (const int inventoryIndex, const int id, const ItemTypeT type, const ItemColor color, const int amount, const int price) |
ShopItem * | addItemNoDup (const int id, const ItemTypeT type, const ItemColor color, const int amount, const int price) |
int | getNumberOfElements () |
bool | empty () const |
std::string | getElementAt (int i) |
ShopItem * | at (const size_t i) const |
void | erase (const unsigned int i) |
void | del (const unsigned int i) |
void | clear () |
std::vector< ShopItem * > & | items () |
std::vector< ShopItem * > & | allItems () |
void | setMergeDuplicates (const bool b) |
void | updateList () |
Public Member Functions inherited from ListModel | |
ListModel () | |
virtual | ~ListModel () |
Private Member Functions | |
ShopItem * | findItem (const int id, const ItemColor color) const |
bool | findInAllItems (std::vector< ShopItem * >::iterator &it, const ShopItem *const item) |
Private Attributes | |
std::vector< ShopItem * > | mAllShopItems |
std::vector< ShopItem * > | mShopItems |
std::string | mCurrency |
bool | mMergeDuplicates |
This class handles the list of items available in a shop.
The addItem routine can automatically check, if an item already exists and only adds duplicates to the old item, if one is found. The original distribution of the duplicates can be retrieved from the item.
This functionality can be enabled in the constructor.
Definition at line 49 of file shopitems.h.
ShopItems::ShopItems | ( | const bool | mergeDuplicates, |
const std::string & | currency | ||
) |
Constructor.
mergeDuplicates | lets the Shop look for duplicate entries and merges them to one item. |
Definition at line 33 of file shopitems.cpp.
ShopItems::~ShopItems | ( | ) |
Definition at line 43 of file shopitems.cpp.
References clear().
ShopItem * ShopItems::addItem | ( | const int | id, |
const ItemTypeT | type, | ||
const ItemColor | color, | ||
const int | amount, | ||
const int | price | ||
) |
Adds an item to the list.
Definition at line 59 of file shopitems.cpp.
References mAllShopItems, mCurrency, and mShopItems.
Referenced by SellDialog::addItem(), BuyDialog::addItem(), and ShopWindow::loadList().
ShopItem * ShopItems::addItem2 | ( | const int | inventoryIndex, |
const int | id, | ||
const ItemTypeT | type, | ||
const ItemColor | color, | ||
const int | amount, | ||
const int | price | ||
) |
Adds an item to the list (used by sell dialog). Looks for duplicate entries, if mergeDuplicates was turned on.
inventoryIndex | the inventory index of the item |
id | the id of the item |
amount | number of available copies of the item |
price | price of the item |
Definition at line 99 of file shopitems.cpp.
References ShopItem::addDuplicate(), findItem(), mAllShopItems, mCurrency, mMergeDuplicates, and mShopItems.
Referenced by SellDialog::addItem().
ShopItem * ShopItems::addItemNoDup | ( | const int | id, |
const ItemTypeT | type, | ||
const ItemColor | color, | ||
const int | amount, | ||
const int | price | ||
) |
Definition at line 77 of file shopitems.cpp.
References findItem(), mAllShopItems, mCurrency, and mShopItems.
Referenced by ShopWindow::addBuyItem(), and ShopWindow::addSellItem().
|
inline |
Definition at line 139 of file shopitems.h.
References mAllShopItems.
Referenced by BuyDialog::action(), BuyDialog::applyNameFilter(), and NpcSellDialog::sellManyItems().
ShopItem * ShopItems::at | ( | const size_t | i | ) | const |
Returns the item number i in the shop.
Definition at line 129 of file shopitems.cpp.
References mShopItems.
Referenced by BuyDialog::action(), ShopListBox::draw(), ShopListBox::mouseMoved(), ShopListBox::mouseReleased(), BuyingStoreSellDialog::sellAction(), EggSelectionDialog::sellAction(), InsertCardDialog::sellAction(), NpcSellDialog::sellAction(), ShopSellDialog::sellAction(), NpcSellDialog::sellManyItems(), NpcSellDialog::sellOneItem(), SellDialog::updateButtonsAndLabels(), BuyDialog::updateButtonsAndLabels(), and BuyDialog::updateSlider().
void ShopItems::clear | ( | ) |
Clears the list of items in the shop.
Definition at line 174 of file shopitems.cpp.
References delete_all(), mAllShopItems, and mShopItems.
Referenced by ShopWindow::loadList(), SellDialog::reset(), BuyDialog::reset(), and ~ShopItems().
void ShopItems::del | ( | const unsigned int | i | ) |
Removes an element from the shop and destroy it.
i | index to remove |
Definition at line 161 of file shopitems.cpp.
References CAST_U32, findInAllItems(), mAllShopItems, and mShopItems.
Referenced by ShopWindow::action(), and NpcSellDialog::sellOneItem().
|
inline |
Definition at line 102 of file shopitems.h.
References mShopItems.
Referenced by ShopWindow::isShopEmpty().
void ShopItems::erase | ( | const unsigned int | i | ) |
Removes an element from the shop.
i | index to remove |
Definition at line 149 of file shopitems.cpp.
References CAST_U32, findInAllItems(), mAllShopItems, and mShopItems.
|
private |
Searches the current items in the shop for the specified id and returns the item if found, or 0 else.
Definition at line 181 of file shopitems.cpp.
References Item::getColor(), Item::getId(), and mShopItems.
Referenced by addItem2(), and addItemNoDup().
|
virtual |
Returns the name of item number i in the shop.
i | the index to retrieve |
Implements ListModel.
Definition at line 48 of file shopitems.cpp.
References CAST_U32, and mShopItems.
|
inlinevirtual |
Returns the number of items in the shop.
Implements ListModel.
Definition at line 99 of file shopitems.h.
References CAST_S32, and mShopItems.
Referenced by SellDialog::action(), BuyDialog::action(), ShopWindow::action(), ShopListBox::mouseMoved(), ShopListBox::mouseReleased(), and ShopWindow::updateButtonsAndLabels().
|
inline |
Definition at line 136 of file shopitems.h.
References mShopItems.
Referenced by ShopWindow::action(), ShopWindow::announce(), ShopWindow::findShopItem(), ShopWindow::giveList(), ShopWindow::saveList(), and BuyDialog::sort().
|
inline |
Definition at line 142 of file shopitems.h.
References mMergeDuplicates.
Referenced by EggSelectionDialog::initButtons(), InsertCardDialog::initButtons(), and SellDialog::postInit().
void ShopItems::updateList | ( | ) |
Definition at line 198 of file shopitems.cpp.
References FOR_EACH, ShopItem::isVisible(), mAllShopItems, and mShopItems.
Referenced by BuyDialog::applyNameFilter().
|
private |
The list of items in the shop.
Definition at line 161 of file shopitems.h.
Referenced by addItem(), addItem2(), addItemNoDup(), allItems(), clear(), del(), erase(), findInAllItems(), and updateList().
|
private |
Definition at line 165 of file shopitems.h.
Referenced by addItem(), addItem2(), and addItemNoDup().
|
private |
Look for duplicate entries on addition.
Definition at line 168 of file shopitems.h.
Referenced by addItem2(), and setMergeDuplicates().
|
private |
Definition at line 163 of file shopitems.h.
Referenced by addItem(), addItem2(), addItemNoDup(), at(), clear(), del(), empty(), erase(), findItem(), getElementAt(), getNumberOfElements(), items(), and updateList().