summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/onlineplayer.h2
-rw-r--r--src/gui/windows/buydialog.cpp30
-rw-r--r--src/gui/windows/buydialog.h2
3 files changed, 24 insertions, 10 deletions
diff --git a/src/gui/onlineplayer.h b/src/gui/onlineplayer.h
index 64ab76abd..b38960c56 100644
--- a/src/gui/onlineplayer.h
+++ b/src/gui/onlineplayer.h
@@ -54,7 +54,7 @@ class OnlinePlayer final
const std::string getNick() const noexcept2 A_WARN_UNUSED
{ return mNick; }
- unsigned char getStaus() const noexcept2 A_WARN_UNUSED
+ unsigned char getStatus() const noexcept2 A_WARN_UNUSED
{ return mStatus; }
void setIsGM(const bool b)
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index f30fb92e4..038ddb3ac 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -226,6 +226,7 @@ BuyDialog::BuyDialog() :
mMoney(0),
mAmountItems(0),
mMaxItems(0),
+ mTotalPurchaseWeight(0),
mAdvanced(false)
{
init();
@@ -248,6 +249,7 @@ BuyDialog::BuyDialog(const BeingId npcId,
mMoney(0),
mAmountItems(0),
mMaxItems(0),
+ mTotalPurchaseWeight(0),
mAdvanced(Net::getNetworkType() != ServerType::TMWATHENA)
{
init();
@@ -272,6 +274,7 @@ BuyDialog::BuyDialog(const std::string &nick,
mMoney(0),
mAmountItems(0),
mMaxItems(0),
+ mTotalPurchaseWeight(0),
mAdvanced(false)
{
init();
@@ -296,6 +299,7 @@ BuyDialog::BuyDialog(const Being *const being,
mMoney(0),
mAmountItems(0),
mMaxItems(0),
+ mTotalPurchaseWeight(0),
mAdvanced(true)
{
init();
@@ -338,8 +342,8 @@ void BuyDialog::init()
"%d / %d", mAmountItems, mMaxItems));
mQuantityLabel->setAlignment(Graphics::CENTER);
mMoneyLabel = new Label(this, strprintf(
- // TRANSLATORS: buy dialog label
- _("Price: %s / Total: %s"), "", ""));
+ // TRANSLATORS: buy dialog label, price, remaining money & free weight
+ _("Price: %s, Remaining: %s & %s"), "", "", ""));
mAmountField = new IntTextField(this, 1, 1, 123, Enable_true, 0);
mAmountField->setActionEventId("amount");
@@ -473,6 +477,7 @@ void BuyDialog::reset()
mShopItemList->setSelected(-1);
mSlider->setValue(0);
+ mTotalPurchaseWeight = 0;
setMoney(0);
}
@@ -637,6 +642,8 @@ void BuyDialog::action(const ActionEvent &event)
else if (mNpcId == fromInt(Vending, BeingId))
{
item->increaseUsedQuantity(mAmountItems);
+ const int itemWeight = item->getInfo().getWeight();
+ mTotalPurchaseWeight += mAmountItems * itemWeight;
item->update();
if (mConfirmButton != nullptr)
mConfirmButton->setEnabled(true);
@@ -650,6 +657,8 @@ void BuyDialog::action(const ActionEvent &event)
if (mAdvanced)
{
item->increaseUsedQuantity(mAmountItems);
+ const int itemWeight = item->getInfo().getWeight();
+ mTotalPurchaseWeight += mAmountItems * itemWeight;
item->update();
if (mConfirmButton != nullptr)
mConfirmButton->setEnabled(true);
@@ -745,6 +754,10 @@ void BuyDialog::updateButtonsAndLabels()
{
const int selectedItem = mShopItemList->getSelected();
int price = 0;
+ int freeWeight
+ = PlayerInfo::getAttribute(Attributes::MAX_WEIGHT)
+ - PlayerInfo::getAttribute(Attributes::TOTAL_WEIGHT)
+ - mTotalPurchaseWeight;
if (selectedItem > -1)
{
@@ -765,10 +778,7 @@ void BuyDialog::updateButtonsAndLabels()
const int itemWeight = item->getInfo().getWeight();
if (itemWeight != 0)
{
- const int myFreeWeight
- = PlayerInfo::getAttribute(Attributes::MAX_WEIGHT)
- - PlayerInfo::getAttribute(Attributes::TOTAL_WEIGHT);
- const int canCarry = myFreeWeight / itemWeight;
+ const int canCarry = freeWeight / itemWeight;
mMaxItems = std::min(mMaxItems, canCarry);
}
@@ -786,6 +796,7 @@ void BuyDialog::updateButtonsAndLabels()
if (mAmountItems > mMaxItems)
mAmountItems = mMaxItems;
+ freeWeight -= mAmountItems * itemWeight;
price = mAmountItems * itemPrice;
}
}
@@ -802,10 +813,11 @@ void BuyDialog::updateButtonsAndLabels()
mAmountField->setEnabled(mAmountItems > 0);
mQuantityLabel->setCaption(strprintf("%d / %d", mAmountItems, mMaxItems));
- // TRANSLATORS: buy dialog label
- mMoneyLabel->setCaption(strprintf(_("Price: %s / Total: %s"),
+ // TRANSLATORS: buy dialog label, price, remaining money & free weight
+ mMoneyLabel->setCaption(strprintf(_("Price: %s, Remaining: %s & %s"),
UnitsDb::formatCurrency(mCurrency, price).c_str(),
- UnitsDb::formatCurrency(mCurrency, mMoney - price).c_str()));
+ UnitsDb::formatCurrency(mCurrency, mMoney - price).c_str(),
+ UnitsDb::formatWeight(freeWeight).c_str()));
}
void BuyDialog::setVisible(Visible visible)
diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h
index 4535e1201..969734aec 100644
--- a/src/gui/windows/buydialog.h
+++ b/src/gui/windows/buydialog.h
@@ -202,6 +202,8 @@ class BuyDialog final : public Window,
int mMoney;
int mAmountItems;
int mMaxItems;
+ // combined weight of all items added to shopping list
+ int mTotalPurchaseWeight;
bool mAdvanced;
};