summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-01-25 01:10:09 +0300
committerAndrei Karas <akaras@inbox.ru>2015-01-25 01:10:09 +0300
commitcc2c18c2b41e5409a0762b538568b41e9147c6e9 (patch)
tree473c763012a3a99fbaa4873e25332b6a71d504d1 /src
parente94119a81652c829c31f52cbc1ae0bce586f1483 (diff)
downloadmv-cc2c18c2b41e5409a0762b538568b41e9147c6e9.tar.gz
mv-cc2c18c2b41e5409a0762b538568b41e9147c6e9.tar.bz2
mv-cc2c18c2b41e5409a0762b538568b41e9147c6e9.tar.xz
mv-cc2c18c2b41e5409a0762b538568b41e9147c6e9.zip
Add weight bar into cart window.
Diffstat (limited to 'src')
-rw-r--r--src/enums/being/attributes.h4
-rw-r--r--src/gui/windows/inventorywindow.cpp32
-rw-r--r--src/net/eathena/inventoryhandler.cpp8
3 files changed, 34 insertions, 10 deletions
diff --git a/src/enums/being/attributes.h b/src/enums/being/attributes.h
index 91b809faf..45ac46d27 100644
--- a/src/enums/being/attributes.h
+++ b/src/enums/being/attributes.h
@@ -61,7 +61,9 @@ namespace Attributes
MDEF,
MATK,
DEF,
- ATK
+ ATK,
+ CART_TOTAL_WEIGHT = 1000,
+ CART_MAX_WEIGHT
};
} // namespace Attributes
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 7ea15ebc9..712ba7981 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -264,12 +264,18 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
// TRANSLATORS: storage button
mInvCloseButton = new Button(this, _("Close"), "close", this);
- mSlotsBarCell = &place(0, 0, mSlotsBar, 6);
+ mWeightBar = new ProgressBar(this, 0.0F, 100, 0, Theme::PROG_WEIGHT,
+ "weightprogressbar.xml", "weightprogressbar_fill.xml");
+ mWeightBar->setColor(getThemeColor(Theme::WEIGHT_BAR),
+ getThemeColor(Theme::WEIGHT_BAR_OUTLINE));
+
+ mSlotsBarCell = &place(3, 0, mSlotsBar, 3);
mSortDropDownCell = &place(6, 0, mSortDropDown, 1);
mFilterCell = &place(0, 1, mFilter, 7).setPadding(3);
mNameFilterCell = &place(6, 1, mNameFilter, 1);
+ place(0, 0, mWeightBar, 3);
place(0, 2, invenScroll, 7, 4);
place(0, 6, mStoreButton);
place(1, 6, mRetrieveButton);
@@ -755,11 +761,17 @@ void InventoryWindow::close()
void InventoryWindow::updateWeight()
{
- if (!isMainInventory() || !mWeightBar)
+ if (!mInventory || !mWeightBar)
+ return;
+ const InventoryType::Type type = mInventory->getType();
+ if (type != InventoryType::INVENTORY && type != InventoryType::CART)
return;
- const int total = PlayerInfo::getAttribute(Attributes::TOTAL_WEIGHT);
- const int max = PlayerInfo::getAttribute(Attributes::MAX_WEIGHT);
+ const bool isInv = type != InventoryType::INVENTORY;
+ const int total = PlayerInfo::getAttribute(isInv
+ ? Attributes::TOTAL_WEIGHT : Attributes::CART_TOTAL_WEIGHT);
+ const int max = PlayerInfo::getAttribute(isInv
+ ? Attributes::MAX_WEIGHT : Attributes::CART_MAX_WEIGHT);
if (max <= 0)
return;
@@ -767,8 +779,9 @@ void InventoryWindow::updateWeight()
// Adjust progress bar
mWeightBar->setProgress(static_cast<float>(total)
/ static_cast<float>(max));
- mWeightBar->setText(strprintf("%s/%s", Units::formatWeight(total).c_str(),
- Units::formatWeight(max).c_str()));
+ mWeightBar->setText(strprintf("%s/%s",
+ Units::formatWeight(total).c_str(),
+ Units::formatWeight(max).c_str()));
}
void InventoryWindow::slotsChanged(Inventory *const inventory)
@@ -905,6 +918,11 @@ void InventoryWindow::attributeChanged(const int id,
const int oldVal A_UNUSED,
const int newVal A_UNUSED)
{
- if (id == Attributes::TOTAL_WEIGHT || id == Attributes::MAX_WEIGHT)
+ if (id == Attributes::TOTAL_WEIGHT
+ || id == Attributes::MAX_WEIGHT
+ || id == Attributes::CART_TOTAL_WEIGHT
+ || id == Attributes::CART_MAX_WEIGHT)
+ {
updateWeight();
+ }
}
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index 316617be1..ff0e8eaaf 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -26,6 +26,8 @@
#include "enums/equipslot.h"
+#include "enums/being/attributes.h"
+
#include "being/localplayer.h"
#include "listeners/arrowslistener.h"
@@ -764,8 +766,10 @@ void InventoryHandler::processCartInfo(Net::MessageIn &msg)
{
msg.readInt16("cart items used");
const int size = msg.readInt16("max cart items");
- msg.readInt32("cart weight");
- msg.readInt32("max cart weight");
+ PlayerInfo::setAttribute(Attributes::CART_TOTAL_WEIGHT,
+ msg.readInt32("cart weight"));
+ PlayerInfo::setAttribute(Attributes::CART_MAX_WEIGHT,
+ msg.readInt32("max cart weight"));
if (mCartItems.empty())
return;