forked from teamnwah/openmw-tes3coop
Show encumbrance preview when trading (Fixes #1793)
This commit is contained in:
parent
f1f38fc786
commit
c775e05d7a
3 changed files with 20 additions and 0 deletions
|
@ -493,6 +493,7 @@ namespace MWGui
|
||||||
|
|
||||||
float capacity = player.getClass().getCapacity(player);
|
float capacity = player.getClass().getCapacity(player);
|
||||||
float encumbrance = player.getClass().getEncumbrance(player);
|
float encumbrance = player.getClass().getEncumbrance(player);
|
||||||
|
mTradeModel->adjustEncumbrance(encumbrance);
|
||||||
mEncumbranceBar->setValue(encumbrance, capacity);
|
mEncumbranceBar->setValue(encumbrance, capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,21 @@ namespace MWGui
|
||||||
unborrowImpl(item, count, mBorrowedFromUs);
|
unborrowImpl(item, count, mBorrowedFromUs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TradeItemModel::adjustEncumbrance(float &encumbrance)
|
||||||
|
{
|
||||||
|
for (std::vector<ItemStack>::iterator it = mBorrowedToUs.begin(); it != mBorrowedToUs.end(); ++it)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr item = it->mBase;
|
||||||
|
encumbrance += item.getClass().getWeight(item) * it->mCount;
|
||||||
|
}
|
||||||
|
for (std::vector<ItemStack>::iterator it = mBorrowedFromUs.begin(); it != mBorrowedFromUs.end(); ++it)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr item = it->mBase;
|
||||||
|
encumbrance -= item.getClass().getWeight(item) * it->mCount;
|
||||||
|
}
|
||||||
|
encumbrance = std::max(0.f, encumbrance);
|
||||||
|
}
|
||||||
|
|
||||||
void TradeItemModel::abort()
|
void TradeItemModel::abort()
|
||||||
{
|
{
|
||||||
mBorrowedFromUs.clear();
|
mBorrowedFromUs.clear();
|
||||||
|
|
|
@ -34,6 +34,10 @@ namespace MWGui
|
||||||
/// Aborts trade
|
/// Aborts trade
|
||||||
void abort();
|
void abort();
|
||||||
|
|
||||||
|
/// 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.
|
||||||
|
void adjustEncumbrance (float& encumbrance);
|
||||||
|
|
||||||
std::vector<ItemStack> getItemsBorrowedToUs();
|
std::vector<ItemStack> getItemsBorrowedToUs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue