summaryrefslogtreecommitdiff
path: root/src/gui/inventorywindow.cpp
diff options
context:
space:
mode:
authorChuck Miller <shadowmil@gmail.com>2010-07-17 21:01:26 -0400
committerChuck Miller <shadowmil@gmail.com>2010-07-17 21:40:48 -0400
commit6a13899daed872debe2375c71903505e6434a731 (patch)
treefaaf483d80c6e791ec182f6331697f06281b97c7 /src/gui/inventorywindow.cpp
parentb738d67f76336641468e3f77cef472a52a6e5ad3 (diff)
downloadmana-client-6a13899daed872debe2375c71903505e6434a731.tar.gz
mana-client-6a13899daed872debe2375c71903505e6434a731.tar.bz2
mana-client-6a13899daed872debe2375c71903505e6434a731.tar.xz
mana-client-6a13899daed872debe2375c71903505e6434a731.zip
Modify how attributes and stats are handled
Handling moved from LocalPlayer to PlayerInfo class Event system used to update windows Reviewed-by: Jared Adams
Diffstat (limited to 'src/gui/inventorywindow.cpp')
-rw-r--r--src/gui/inventorywindow.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 591ebd2f..91acbb00 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -21,11 +21,12 @@
#include "gui/inventorywindow.h"
+#include "event.h"
#include "inventory.h"
#include "item.h"
-#include "localplayer.h"
#include "units.h"
#include "keyboardconfig.h"
+#include "playerinfo.h"
#include "gui/itemamount.h"
#include "gui/setup.h"
@@ -60,6 +61,8 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
mInventory(inventory),
mSplit(false)
{
+ listen("Attributes");
+
setWindowName(isMainInventory() ? "Inventory" : "Storage");
setupWindow->registerWindowForReset(this);
setResizable(true);
@@ -341,10 +344,26 @@ void InventoryWindow::close()
}
}
+void InventoryWindow::event(const std::string &channel, const Mana::Event &event)
+{
+ if (event.getName() == "UpdateAttribute")
+ {
+ int id = event.getInt("id");
+ if (id == TOTAL_WEIGHT ||
+ id == MAX_WEIGHT)
+ {
+ updateWeight();
+ }
+ }
+}
+
void InventoryWindow::updateWeight()
{
- int total = player_node->getTotalWeight();
- int max = player_node->getMaxWeight();
+ int total = PlayerInfo::getAttribute(TOTAL_WEIGHT);
+ int max = PlayerInfo::getAttribute(MAX_WEIGHT);
+
+ if (max <= 0)
+ return;
// Adjust progress bar
mWeightBar->setProgress((float) total / max);