mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 08:53:52 +00:00
comiit
This commit is contained in:
parent
83af0402b8
commit
49da33a129
2 changed files with 22 additions and 2 deletions
|
@ -52,6 +52,7 @@ namespace MWGui
|
|||
, mItemToSell(-1)
|
||||
, mCurrentBalance(0)
|
||||
, mCurrentMerchantOffer(0)
|
||||
, mReceiveMoney(false)
|
||||
{
|
||||
getWidget(mFilterAll, "AllButton");
|
||||
getWidget(mFilterWeapon, "WeaponButton");
|
||||
|
@ -405,10 +406,15 @@ namespace MWGui
|
|||
|
||||
void TradeWindow::onBalanceValueChanged(int value)
|
||||
{
|
||||
int previousBalance = mCurrentBalance;
|
||||
|
||||
// Entering a "-" sign inverts the buying/selling state
|
||||
mCurrentBalance = (mCurrentBalance >= 0 ? 1 : -1) * value;
|
||||
updateLabels();
|
||||
|
||||
if (mReceiveMoney && mCurrentBalance == 0)
|
||||
mCurrentBalance = previousBalance;
|
||||
|
||||
if (value != std::abs(value))
|
||||
mTotalBalance->setValue(std::abs(value));
|
||||
}
|
||||
|
@ -434,10 +440,23 @@ namespace MWGui
|
|||
{
|
||||
MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);
|
||||
|
||||
mPlayerGold->setCaptionWithReplacing("#{sYourGold} " + MyGUI::utility::toString(playerGold));
|
||||
|
||||
if (mCurrentBalance < 0)
|
||||
TradeItemModel* playerTradeModel = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel();
|
||||
const std::vector<ItemStack>& playerBorrowed = playerTradeModel->getItemsBorrowedToUs();
|
||||
const std::vector<ItemStack>& merchantBorrowed = mTradeModel->getItemsBorrowedToUs();
|
||||
|
||||
if (playerBorrowed.empty() && merchantBorrowed.empty()) {
|
||||
mCurrentBalance = 0;
|
||||
}
|
||||
else if (playerBorrowed.empty()) {
|
||||
mReceiveMoney = false;
|
||||
}
|
||||
else if (merchantBorrowed.empty()) {
|
||||
mReceiveMoney = true;
|
||||
}
|
||||
|
||||
if (mCurrentBalance < 0 || mReceiveMoney)
|
||||
{
|
||||
mTotalBalanceLabel->setCaptionWithReplacing("#{sTotalCost}");
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ namespace MWGui
|
|||
|
||||
int mCurrentBalance;
|
||||
int mCurrentMerchantOffer;
|
||||
bool mReceiveMoney;
|
||||
|
||||
void sellToNpc(const MWWorld::Ptr& item, int count, bool boughtItem); ///< only used for adjusting the gold balance
|
||||
void buyFromNpc(const MWWorld::Ptr& item, int count, bool soldItem); ///< only used for adjusting the gold balance
|
||||
|
|
Loading…
Reference in a new issue