OpenMW
|
An item model that allows 'borrowing' items from another item model. Used for previewing barter offers. Also filters items that the merchant does not sell. More...
#include <tradeitemmodel.hpp>
Public Member Functions | |
TradeItemModel (ItemModel *sourceModel, const MWWorld::Ptr &merchant) | |
bool | allowedToUseItems () const |
Is the player allowed to use items from this item model? (default true) More... | |
virtual ItemStack | getItem (ModelIndex index) |
Throws for invalid index or out of range index. More... | |
virtual size_t | getItemCount () |
virtual void | update () |
Rebuild the item model, this will invalidate existing model indices. More... | |
void | borrowItemFromUs (ModelIndex itemIndex, size_t count) |
void | borrowItemToUs (ModelIndex itemIndex, ItemModel *source, size_t count) |
void | returnItemBorrowedToUs (ModelIndex itemIndex, size_t count) |
void | returnItemBorrowedFromUs (ModelIndex itemIndex, ItemModel *source, size_t count) |
void | transferItems () |
Permanently transfers items that were borrowed to us from another model to this model. More... | |
void | abort () |
Aborts trade. More... | |
void | adjustEncumbrance (float &encumbrance) |
std::vector< ItemStack > | getItemsBorrowedToUs () |
![]() | |
ProxyItemModel () | |
virtual | ~ProxyItemModel () |
virtual void | onClose () |
virtual bool | onDropItem (const MWWorld::Ptr &item, int count) |
virtual bool | onTakeItem (const MWWorld::Ptr &item, int count) |
virtual MWWorld::Ptr | copyItem (const ItemStack &item, size_t count, bool setNewOwner=false) |
virtual void | removeItem (const ItemStack &item, size_t count) |
virtual ModelIndex | getIndex (ItemStack item) |
Returns an invalid index if the item was not found. More... | |
void | setSourceModel (ItemModel *sourceModel) |
ModelIndex | mapToSource (ModelIndex index) |
ModelIndex | mapFromSource (ModelIndex index) |
![]() | |
ItemModel () | |
virtual | ~ItemModel () |
virtual MWWorld::Ptr | moveItem (const ItemStack &item, size_t count, ItemModel *otherModel) |
Private Member Functions | |
void | borrowImpl (const ItemStack &item, std::vector< ItemStack > &out) |
void | unborrowImpl (const ItemStack &item, size_t count, std::vector< ItemStack > &out) |
Private Attributes | |
std::vector< ItemStack > | mItems |
std::vector< ItemStack > | mBorrowedToUs |
std::vector< ItemStack > | mBorrowedFromUs |
MWWorld::Ptr | mMerchant |
Additional Inherited Members | |
![]() | |
typedef int | ModelIndex |
![]() | |
ItemModel * | mSourceModel |
An item model that allows 'borrowing' items from another item model. Used for previewing barter offers. Also filters items that the merchant does not sell.
MWGui::TradeItemModel::TradeItemModel | ( | ItemModel * | sourceModel, |
const MWWorld::Ptr & | merchant | ||
) |
void MWGui::TradeItemModel::abort | ( | ) |
Aborts trade.
void MWGui::TradeItemModel::adjustEncumbrance | ( | float & | encumbrance | ) |
Adjusts the given encumbrance by adding weight for items that have been lent to us, and removing weight for items we've lent to someone else.
|
virtual |
Is the player allowed to use items from this item model? (default true)
Reimplemented from MWGui::ProxyItemModel.
|
private |
void MWGui::TradeItemModel::borrowItemFromUs | ( | ModelIndex | itemIndex, |
size_t | count | ||
) |
void MWGui::TradeItemModel::borrowItemToUs | ( | ModelIndex | itemIndex, |
ItemModel * | source, | ||
size_t | count | ||
) |
|
virtual |
Throws for invalid index or out of range index.
Implements MWGui::ItemModel.
|
virtual |
The number of items in the model, this specifies the range of indices you can pass to the getItem function (but this range is only valid until the next call to update())
Implements MWGui::ItemModel.
std::vector< ItemStack > MWGui::TradeItemModel::getItemsBorrowedToUs | ( | ) |
void MWGui::TradeItemModel::returnItemBorrowedFromUs | ( | ModelIndex | itemIndex, |
ItemModel * | source, | ||
size_t | count | ||
) |
void MWGui::TradeItemModel::returnItemBorrowedToUs | ( | ModelIndex | itemIndex, |
size_t | count | ||
) |
void MWGui::TradeItemModel::transferItems | ( | ) |
Permanently transfers items that were borrowed to us from another model to this model.
|
private |
|
virtual |
Rebuild the item model, this will invalidate existing model indices.
Implements MWGui::ItemModel.
|
private |
|
private |
|
private |
|
private |