From f74cf5eb61deccc478d2a4cbc7a352748d96c65e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 10 Feb 2011 04:15:39 +0200 Subject: Add inventory slots bar in top left corner (hidden by default). --- src/gui/ministatus.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/gui/ministatus.cpp') diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 71e81abf8..ab894b3a8 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -87,6 +87,9 @@ MiniStatusWindow::MiniStatusWindow(): mWeightBar = createBar(0, 140, 20, Theme::PROG_WEIGHT, "weight bar", _("weight bar")); + mInvSlotsBar = createBar(0, 45, 20, Theme::PROG_INVY_SLOTS, + "inventory slots bar", _("inventory slots bar")); + mStatusBar = createBar(100, 150, 20, Theme::PROG_EXP, "status bar", _("status bar")); @@ -99,6 +102,9 @@ MiniStatusWindow::MiniStatusWindow(): mTextPopup = new TextPopup(); addMouseListener(this); + Inventory *inv = PlayerInfo::getInventory(); + if (inv) + inv->addInventoyListener(this); updateStatus(); } @@ -109,6 +115,10 @@ MiniStatusWindow::~MiniStatusWindow() delete mStatusPopup; mStatusPopup = 0; + Inventory *inv = PlayerInfo::getInventory(); + if (inv) + inv->removeInventoyListener(this); + std::list ::iterator it, it_end; for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) { @@ -203,7 +213,7 @@ void MiniStatusWindow::event(Channels channel _UNUSED_, else if (id == EXP || id == EXP_NEEDED) StatusWindow::updateXPBar(mXpBar); else if (id == TOTAL_WEIGHT || id == MAX_WEIGHT) - StatusWindow::updateWeightBar(mWeightBar, false); + StatusWindow::updateWeightBar(mWeightBar); } else if (event.getName() == EVENT_UPDATESTAT) { @@ -348,10 +358,12 @@ void MiniStatusWindow::showBar(std::string name, bool isVisible) void MiniStatusWindow::loadBars() { - if (!config.getValue("ministatussaved", false)) + if (!config.getValue("ministatussaved", 0)) { if (mWeightBar) mWeightBar->setVisible(false); + if (mInvSlotsBar) + mInvSlotsBar->setVisible(false); return; } @@ -386,4 +398,13 @@ void MiniStatusWindow::saveBars() config.deleteKey("ministatus" + toString(f)); config.setValue("ministatussaved", true); -} \ No newline at end of file +} + +void MiniStatusWindow::slotsChanged(Inventory* inventory) +{ + if (!inventory) + return; + + if (inventory->getType() == Inventory::INVENTORY) + StatusWindow::updateInvSlotsBar(mInvSlotsBar); +} -- cgit v1.2.3-60-g2f50