pull/3174/head
kuyondo 3 years ago
parent 83af0402b8
commit 49da33a129

@ -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…
Cancel
Save