mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 16:20:21 +00:00
comiit
This commit is contained in:
parent
83af0402b8
commit
49da33a129
@ -52,6 +52,7 @@ namespace MWGui
|
|||||||
, mItemToSell(-1)
|
, mItemToSell(-1)
|
||||||
, mCurrentBalance(0)
|
, mCurrentBalance(0)
|
||||||
, mCurrentMerchantOffer(0)
|
, mCurrentMerchantOffer(0)
|
||||||
|
, mReceiveMoney(false)
|
||||||
{
|
{
|
||||||
getWidget(mFilterAll, "AllButton");
|
getWidget(mFilterAll, "AllButton");
|
||||||
getWidget(mFilterWeapon, "WeaponButton");
|
getWidget(mFilterWeapon, "WeaponButton");
|
||||||
@ -405,10 +406,15 @@ namespace MWGui
|
|||||||
|
|
||||||
void TradeWindow::onBalanceValueChanged(int value)
|
void TradeWindow::onBalanceValueChanged(int value)
|
||||||
{
|
{
|
||||||
|
int previousBalance = mCurrentBalance;
|
||||||
|
|
||||||
// Entering a "-" sign inverts the buying/selling state
|
// Entering a "-" sign inverts the buying/selling state
|
||||||
mCurrentBalance = (mCurrentBalance >= 0 ? 1 : -1) * value;
|
mCurrentBalance = (mCurrentBalance >= 0 ? 1 : -1) * value;
|
||||||
updateLabels();
|
updateLabels();
|
||||||
|
|
||||||
|
if (mReceiveMoney && mCurrentBalance == 0)
|
||||||
|
mCurrentBalance = previousBalance;
|
||||||
|
|
||||||
if (value != std::abs(value))
|
if (value != std::abs(value))
|
||||||
mTotalBalance->setValue(std::abs(value));
|
mTotalBalance->setValue(std::abs(value));
|
||||||
}
|
}
|
||||||
@ -434,10 +440,23 @@ namespace MWGui
|
|||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWMechanics::getPlayer();
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||||
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);
|
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);
|
||||||
|
|
||||||
mPlayerGold->setCaptionWithReplacing("#{sYourGold} " + MyGUI::utility::toString(playerGold));
|
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}");
|
mTotalBalanceLabel->setCaptionWithReplacing("#{sTotalCost}");
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,7 @@ namespace MWGui
|
|||||||
|
|
||||||
int mCurrentBalance;
|
int mCurrentBalance;
|
||||||
int mCurrentMerchantOffer;
|
int mCurrentMerchantOffer;
|
||||||
|
bool mReceiveMoney;
|
||||||
|
|
||||||
void sellToNpc(const MWWorld::Ptr& item, int count, bool boughtItem); ///< only used for adjusting the gold balance
|
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
|
void buyFromNpc(const MWWorld::Ptr& item, int count, bool soldItem); ///< only used for adjusting the gold balance
|
||||||
|
Loading…
x
Reference in New Issue
Block a user