ManaPlus
|
#include <inventory.h>
Public Member Functions | |
Inventory (const InventoryTypeT type, const int size) | |
virtual | ~Inventory () |
unsigned | getSize () const |
Item * | getItem (const int index) const |
Item * | findItem (const int itemId, const ItemColor color) const |
int | addItem (const int id, const ItemTypeT type, const int quantity, const uint8_t refine, const ItemColor color, const Identified identified, const Damaged damaged, const Favorite favorite, const Equipm equipment, const Equipped equipped) |
virtual void | setItem (const int index, const int id, const ItemTypeT type, const int quantity, const uint8_t refine, const ItemColor color, const Identified identified, const Damaged damaged, const Favorite favorite, const Equipm equipment, const Equipped equipped) |
void | setCards (const int index, const int *const cards, const int size) const |
void | setOptions (const int index, const ItemOptionsList *const options) |
void | setTag (const int index, const int tag) |
void | moveItem (const int index1, const int index2) |
void | removeItem (const int id) |
void | removeItemAt (const int index) |
bool | contains (const Item *const item) const |
int | getFreeSlot () const |
void | clear () |
int | getNumberOfSlotsUsed () const |
int | getLastUsedSlot () const |
void | addInventoyListener (InventoryListener *const listener) |
void | removeInventoyListener (InventoryListener *const listener) |
InventoryTypeT | getType () const |
bool | isMainInventory () const |
const Item * | findItemBySprite (std::string spritePath, const GenderT gender, const BeingTypeId race) const |
std::string | getName () const |
void | resize (const unsigned int newSize) |
int | findIndexByTag (const int tag) const |
Item * | findItemByTag (const int tag) const |
virtual bool | addVirtualItem (const Item *const item, int index, const int amount) |
void | virtualRemove (Item *const item, const int amount) |
void | virtualRestore (const Item *const item, const int amount) |
void | restoreVirtuals () |
Static Public Attributes | |
static const int | NO_SLOT_INDEX = -1 |
Protected Types | |
typedef std::list< InventoryListener * > | InventoryListenerList |
Protected Member Functions | |
void | distributeSlotsChangedEvent () |
Protected Attributes | |
InventoryListenerList | mInventoryListeners |
IntMap | mVirtualRemove |
InventoryTypeT | mType |
unsigned | mSize |
Item ** | mItems |
int | mUsed |
Definition at line 53 of file inventory.h.
|
protected |
Definition at line 208 of file inventory.h.
Inventory::Inventory | ( | const InventoryTypeT | type, |
const int | size | ||
) |
Constructor.
size | the number of items that fit in the inventory |
Definition at line 60 of file inventory.cpp.
|
virtual |
void Inventory::addInventoyListener | ( | InventoryListener *const | listener | ) |
Definition at line 302 of file inventory.cpp.
References anonymous_namespace{itemlinkhandler.cpp}::listener, and mInventoryListeners.
Referenced by InventoryWindow::InventoryWindow(), and MiniStatusWindow::MiniStatusWindow().
int Inventory::addItem | ( | const int | id, |
const ItemTypeT | type, | ||
const int | quantity, | ||
const uint8_t | refine, | ||
const ItemColor | color, | ||
const Identified | identified, | ||
const Damaged | damaged, | ||
const Favorite | favorite, | ||
const Equipm | equipment, | ||
const Equipped | equipped | ||
) |
Adds a new item in a free slot.
Definition at line 115 of file inventory.cpp.
References getFreeSlot(), and setItem().
Referenced by TradeWindow::addItem(), MailEditWindow::addItem(), TradeWindow::addItem2(), ComplexInventory::addVirtualItem(), addVirtualItem(), EAthena::Mail2Recv::processAddItemResult(), EAthena::Mail2Recv::processReadMail(), and EAthena::MailRecv::processReadMail().
|
virtual |
Reimplemented in ComplexInventory.
Definition at line 439 of file inventory.cpp.
References addItem(), CAST_S32, Equipm_false, Equipped_false, Item::getColor(), Item::getDamaged(), Item::getFavorite(), Item::getId(), Item::getIdentified(), Item::getInvIndex(), getItem(), Item::getType(), PlayerInfo::isItemProtected(), mItems, mSize, setItem(), and Item::setTag().
Referenced by NpcDialog::action(), and ItemContainer::mouseReleased().
void Inventory::clear | ( | ) |
Reset all item slots.
Definition at line 238 of file inventory.cpp.
References mSize, and removeItemAt().
Referenced by NpcDialog::action(), PlayerInfo::clearInventory(), EAthena::InventoryRecv::processInventoryEndContinue(), EAthena::InventoryRecv::processInventoryStartContinue(), EAthena::InventoryRecv::processPlayerInventory(), TmwAthena::InventoryRecv::processPlayerInventory(), Ea::InventoryRecv::processPlayerStorageClose(), MailViewWindow::removeItems(), TradeWindow::reset(), and resize().
bool Inventory::contains | ( | const Item *const | item | ) | const |
|
protected |
Definition at line 312 of file inventory.cpp.
References FOR_EACH, and mInventoryListeners.
Referenced by moveItem(), removeItemAt(), ComplexInventory::setItem(), and setItem().
int Inventory::findIndexByTag | ( | const int | tag | ) | const |
Definition at line 412 of file inventory.cpp.
References mItems, mSize, and Item::mTag.
Referenced by EAthena::Mail2Recv::processRemoveItemResult().
Searches for the specified item by it's id.
itemId | The id of the item to be searched. |
color | The color of the item to be searched. |
Definition at line 94 of file inventory.cpp.
References ItemColor_one, ItemColor_zero, Item::mColor, Item::mId, mItems, and mSize.
Referenced by EquipmentWindow::action(), ShopWindow::action(), LocalPlayer::changeEquipmentBeforeAttack(), TradeWindow::checkItem(), ItemShortcutContainer::draw(), VirtShortcutContainer::draw(), OutfitWindow::draw(), DropShortcut::dropFirst(), DropShortcut::dropItem(), ItemShortcut::equipItem(), ShopWindow::giveList(), TradeWindow::initTrade(), ItemShortcutContainer::mouseDragged(), VirtShortcutContainer::mouseDragged(), OutfitWindow::mouseDragged(), ItemShortcutContainer::mouseMoved(), VirtShortcutContainer::mouseMoved(), VirtShortcutContainer::mousePressed(), EquipmentWindow::mouseReleased(), EAthena::BuyingStoreRecv::processBuyingStoreItemsList(), ShopWindow::processRequest(), ItemShortcutContainer::safeDraw(), VirtShortcutContainer::safeDraw(), OutfitWindow::safeDraw(), BuyingStoreSellDialog::sellAction(), MailEditWindow::sendMail(), PopupMenu::showItemPopup(), ShopWindow::showList(), ItemShortcut::unequipItem(), ItemShortcut::useItem(), and OutfitWindow::wearOutfit().
const Item * Inventory::findItemBySprite | ( | std::string | spritePath, |
const GenderT | gender, | ||
const BeingTypeId | race | ||
) | const |
Definition at line 318 of file inventory.cpp.
References extractNameFromSprite(), Item::getInfo(), ItemInfo::getSprite(), mItems, mSize, and removeSpriteIndex().
Referenced by LocalPlayer::imitateOutfit().
Item * Inventory::findItemByTag | ( | const int | tag | ) | const |
Definition at line 424 of file inventory.cpp.
References mItems, mSize, and Item::mTag.
Referenced by EAthena::Mail2Recv::processAddItemResult().
int Inventory::getFreeSlot | ( | ) | const |
Returns id of next free slot or -1 if all occupied.
Definition at line 282 of file inventory.cpp.
References CAST_S32, mItems, and mSize.
Referenced by TradeWindow::action(), and addItem().
Item * Inventory::getItem | ( | const int | index | ) | const |
Returns the item at the specified index.
Definition at line 83 of file inventory.cpp.
References CAST_S32, mItems, EAthena::TradeRecv::mQuantity, and mSize.
Referenced by NpcDialog::action(), ComplexInventory::addVirtualItem(), addVirtualItem(), TradeWindow::changeQuantity(), Ea::EquipBackend::clear(), InventoryWindow::combineItems(), OutfitWindow::copyFromEquiped(), ItemContainer::draw(), Ea::EquipBackend::getEquipment(), Actions::getItemByInvIndex(), ItemContainer::getSelectedItem(), TradeWindow::increaseQuantity(), ItemContainer::mouseMoved(), ItemContainer::mousePressed(), ItemContainer::mouseReleased(), ShopListBox::mouseReleased(), EAthena::InventoryRecv::processBindItem(), EAthena::BuyingStoreRecv::processBuyingStoreDeleteItem(), EAthena::PetRecv::processEggsList(), EAthena::InventoryRecv::processItemMoveFailed(), Ea::InventoryRecv::processItemUseResponse(), Ea::BuySellRecv::processNpcSell(), EAthena::InventoryRecv::processPlayerCartAdd(), EAthena::InventoryRecv::processPlayerCartRemove(), EAthena::InventoryRecv::processPlayerInsertCard(), EAthena::InventoryRecv::processPlayerInventoryAdd(), TmwAthena::InventoryRecv::processPlayerInventoryAdd(), EAthena::InventoryRecv::processPlayerInventoryRemove(), TmwAthena::InventoryRecv::processPlayerInventoryRemove(), EAthena::InventoryRecv::processPlayerInventoryRemove2(), EAthena::InventoryRecv::processPlayerInventoryUse(), TmwAthena::InventoryRecv::processPlayerInventoryUse(), EAthena::InventoryRecv::processPlayerItemRentalExpired(), EAthena::InventoryRecv::processPlayerRefine(), EAthena::InventoryRecv::processPlayerUseCard(), EAthena::Mail2Recv::processRemoveItemResult(), EAthena::VendingRecv::processReport(), EAthena::TradeRecv::processTradeItemAddResponse(), TmwAthena::TradeRecv::processTradeItemAddResponse(), ItemContainer::safeDraw(), MailEditWindow::sendMail(), Ea::EquipBackend::setEquipment(), ShopWindow::sumAmount(), OutfitWindow::unequipNotInOutfit(), and ItemContainer::updateMatrix().
int Inventory::getLastUsedSlot | ( | ) | const |
Returns the index of the last occupied slot or 0 if none occupied.
Definition at line 291 of file inventory.cpp.
Referenced by ItemContainer::logic(), and MailViewWindow::updateAttachButton().
std::string Inventory::getName | ( | ) | const |
Definition at line 351 of file inventory.cpp.
References InventoryType::Cart, InventoryType::Craft, InventoryType::Inventory, InventoryType::MailEdit, InventoryType::MailView, mType, N_, InventoryType::Npc, InventoryType::Storage, InventoryType::Trade, InventoryType::TypeEnd, and InventoryType::Vending.
Referenced by InventoryWindow::InventoryWindow().
|
inline |
Get the number of slots filled with an item
Definition at line 164 of file inventory.h.
References mUsed.
Referenced by MiniStatusWindow::mouseMoved(), InventoryWindow::slotsChanged(), and StatusWindow::updateInvSlotsBar().
|
inline |
Returns the size that this instance is configured for.
Definition at line 76 of file inventory.h.
References mSize.
Referenced by NpcDialog::action(), ItemContainer::adjustHeight(), OutfitWindow::copyFromEquiped(), ItemContainer::draw(), MiniStatusWindow::mouseMoved(), EAthena::InventoryRecv::processPlayerCartAdd(), ItemContainer::safeDraw(), InventoryWindow::slotsChanged(), ShopWindow::sumAmount(), OutfitWindow::unequipNotInOutfit(), StatusWindow::updateInvSlotsBar(), and ItemContainer::updateMatrix().
|
inline |
Definition at line 176 of file inventory.h.
References mType.
Referenced by InventoryWindow::close(), InventoryWindow::InventoryWindow(), InventoryWindow::mouseClicked(), ItemContainer::mousePressed(), ItemContainer::mouseReleased(), InventoryWindow::postInit(), MiniStatusWindow::slotsChanged(), InventoryWindow::storeSortOrder(), InventoryWindow::updateWeight(), and InventoryWindow::widgetResized().
|
inline |
Definition at line 179 of file inventory.h.
References InventoryType::Inventory, and mType.
Referenced by InventoryWindow::InventoryWindow(), InventoryWindow::isMainInventory(), InventoryWindow::mouseClicked(), InventoryWindow::updateButtons(), and InventoryWindow::valueChanged().
void Inventory::moveItem | ( | const int | index1, |
const int | index2 | ||
) |
Definition at line 537 of file inventory.cpp.
References CAST_S32, distributeSlotsChangedEvent(), mItems, mSize, and Item::setInvIndex().
Referenced by ItemContainer::mouseReleased().
void Inventory::removeInventoyListener | ( | InventoryListener *const | listener | ) |
Definition at line 307 of file inventory.cpp.
References anonymous_namespace{itemlinkhandler.cpp}::listener, and mInventoryListeners.
Referenced by InventoryWindow::unsetInventory(), InventoryWindow::~InventoryWindow(), and MiniStatusWindow::~MiniStatusWindow().
void Inventory::removeItem | ( | const int | id | ) |
Remove a item from the inventory.
Definition at line 244 of file inventory.cpp.
References Item::mId, mItems, mSize, and removeItemAt().
void Inventory::removeItemAt | ( | const int | index | ) |
Remove the item at the specified index from the inventory.
Definition at line 254 of file inventory.cpp.
References delete2, distributeSlotsChangedEvent(), mItems, and mUsed.
Referenced by clear(), ItemContainer::mouseReleased(), EAthena::BuyingStoreRecv::processBuyingStoreDeleteItem(), Ea::InventoryRecv::processItemUseResponse(), EAthena::InventoryRecv::processPlayerCartRemove(), EAthena::InventoryRecv::processPlayerInsertCard(), EAthena::InventoryRecv::processPlayerInventoryRemove(), TmwAthena::InventoryRecv::processPlayerInventoryRemove(), EAthena::InventoryRecv::processPlayerInventoryRemove2(), EAthena::InventoryRecv::processPlayerInventoryUse(), TmwAthena::InventoryRecv::processPlayerInventoryUse(), EAthena::InventoryRecv::processPlayerItemRentalExpired(), EAthena::InventoryRecv::processPlayerStorageRemove(), TmwAthena::InventoryRecv::processPlayerStorageRemove(), removeItem(), and setItem().
void Inventory::resize | ( | const unsigned int | newSize | ) |
Definition at line 397 of file inventory.cpp.
References CAST_SIZE, clear(), mItems, and mSize.
Referenced by NpcDialog::itemCraftRequest(), NpcDialog::itemIndexRequest(), NpcDialog::itemRequest(), EAthena::InventoryRecv::processCartInfo(), and EAthena::InventoryRecv::processInventoryExpansionInfo().
void Inventory::restoreVirtuals | ( | ) |
Definition at line 500 of file inventory.cpp.
References CAST_S32, FOR_EACH, mItems, Item::mQuantity, mSize, and mVirtualRemove.
Referenced by NpcDialog::restoreVirtuals().
void Inventory::setCards | ( | const int | index, |
const int *const | cards, | ||
const int | size | ||
) | const |
Definition at line 194 of file inventory.cpp.
References CAST_S32, mItems, mSize, reportAlways, Item::setCards(), and EmoteDB::size().
Referenced by TradeWindow::addItem2(), EAthena::Mail2Recv::processAddItemResult(), EAthena::InventoryRecv::processInventoryEndContinue(), EAthena::InventoryRecv::processPlayerCartAdd(), EAthena::InventoryRecv::processPlayerEquipment(), TmwAthena::InventoryRecv::processPlayerEquipment(), EAthena::InventoryRecv::processPlayerInventory(), TmwAthena::InventoryRecv::processPlayerInventory(), EAthena::InventoryRecv::processPlayerInventoryAdd(), TmwAthena::InventoryRecv::processPlayerInventoryAdd(), EAthena::InventoryRecv::processPlayerStorageAdd(), TmwAthena::InventoryRecv::processPlayerStorageAdd(), EAthena::Mail2Recv::processReadMail(), and EAthena::MailRecv::processReadMail().
|
virtual |
Sets the item at the given position.
Reimplemented in ComplexInventory.
Definition at line 141 of file inventory.cpp.
References CAST_S32, distributeSlotsChangedEvent(), MailMessageType::Item, mItems, mSize, mUsed, removeItemAt(), reportAlways, Item::setDamaged(), Item::setEquipment(), Item::setFavorite(), Item::setId(), Item::setIdentified(), Item::setInvIndex(), Item::setQuantity(), and Item::setRefine().
Referenced by addItem(), addVirtualItem(), ItemContainer::mouseReleased(), EAthena::InventoryRecv::processCartInfo(), EAthena::InventoryRecv::processInventoryEndContinue(), EAthena::InventoryRecv::processPlayerCartAdd(), EAthena::InventoryRecv::processPlayerEquipment(), TmwAthena::InventoryRecv::processPlayerEquipment(), EAthena::InventoryRecv::processPlayerInventory(), TmwAthena::InventoryRecv::processPlayerInventory(), EAthena::InventoryRecv::processPlayerInventoryAdd(), TmwAthena::InventoryRecv::processPlayerInventoryAdd(), EAthena::InventoryRecv::processPlayerStorageAdd(), TmwAthena::InventoryRecv::processPlayerStorageAdd(), and Ea::InventoryRecv::processPlayerStorageStatus().
void Inventory::setOptions | ( | const int | index, |
const ItemOptionsList *const | options | ||
) |
Definition at line 210 of file inventory.cpp.
References CAST_S32, mItems, mSize, reportAlways, and Item::setOptions().
Referenced by TradeWindow::addItem2(), EAthena::Mail2Recv::processAddItemResult(), EAthena::InventoryRecv::processInventoryEndContinue(), EAthena::InventoryRecv::processPlayerCartAdd(), EAthena::InventoryRecv::processPlayerEquipment(), EAthena::InventoryRecv::processPlayerInventoryAdd(), EAthena::InventoryRecv::processPlayerStorageAdd(), and EAthena::Mail2Recv::processReadMail().
void Inventory::setTag | ( | const int | index, |
const int | tag | ||
) |
Definition at line 224 of file inventory.cpp.
References CAST_S32, mItems, mSize, reportAlways, and Item::setTag().
Referenced by EAthena::Mail2Recv::processAddItemResult().
void Inventory::virtualRemove | ( | Item *const | item, |
const int | amount | ||
) |
Definition at line 485 of file inventory.cpp.
References Item::getInvIndex(), Item::mQuantity, and mVirtualRemove.
Referenced by NpcDialog::action(), NpcDialog::addCraftItem(), and ItemContainer::mouseReleased().
void Inventory::virtualRestore | ( | const Item *const | item, |
const int | amount | ||
) |
Definition at line 517 of file inventory.cpp.
References CAST_S32, Item::getTag(), mItems, Item::mQuantity, mSize, and mVirtualRemove.
Referenced by ItemContainer::mouseReleased().
|
protected |
Definition at line 209 of file inventory.h.
Referenced by addInventoyListener(), distributeSlotsChangedEvent(), and removeInventoyListener().
|
protected |
The holder of items
Definition at line 216 of file inventory.h.
Referenced by ComplexInventory::addVirtualItem(), addVirtualItem(), contains(), findIndexByTag(), findItem(), findItemBySprite(), findItemByTag(), getFreeSlot(), getItem(), getLastUsedSlot(), Inventory(), moveItem(), removeItem(), removeItemAt(), resize(), restoreVirtuals(), setCards(), ComplexInventory::setItem(), setItem(), setOptions(), setTag(), virtualRestore(), and ~Inventory().
|
protected |
The max number of inventory items
Definition at line 215 of file inventory.h.
Referenced by ComplexInventory::addVirtualItem(), addVirtualItem(), clear(), contains(), findIndexByTag(), findItem(), findItemBySprite(), findItemByTag(), getFreeSlot(), getItem(), getLastUsedSlot(), getSize(), Inventory(), moveItem(), removeItem(), resize(), restoreVirtuals(), setCards(), ComplexInventory::setItem(), setItem(), setOptions(), setTag(), virtualRestore(), and ~Inventory().
|
protected |
Definition at line 214 of file inventory.h.
Referenced by getName(), getType(), and isMainInventory().
|
protected |
THe number of slots in use
Definition at line 217 of file inventory.h.
Referenced by getNumberOfSlotsUsed(), removeItemAt(), ComplexInventory::setItem(), and setItem().
|
protected |
Definition at line 213 of file inventory.h.
Referenced by restoreVirtuals(), virtualRemove(), and virtualRestore().
|
static |
Slot has no index.
Definition at line 58 of file inventory.h.
Referenced by ItemContainer::getSlotByXY(), ItemContainer::getSlotIndex(), ItemContainer::mousePressed(), and ItemContainer::mouseReleased().