summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-02-13 20:04:03 +0200
committerAndrei Karas <akaras@inbox.ru>2011-02-13 20:04:03 +0200
commit932ca64763d5133c4e5d8f6f6d7ed0d582d0456e (patch)
tree68de441cebab14f15514f5798504565529a773ff /src
parent3aba05585b85989b5d0927939812f612c3b0d4d9 (diff)
downloadmanaverse-932ca64763d5133c4e5d8f6f6d7ed0d582d0456e.tar.gz
manaverse-932ca64763d5133c4e5d8f6f6d7ed0d582d0456e.tar.bz2
manaverse-932ca64763d5133c4e5d8f6f6d7ed0d582d0456e.tar.xz
manaverse-932ca64763d5133c4e5d8f6f6d7ed0d582d0456e.zip
Add arrows bar.
Diffstat (limited to 'src')
-rw-r--r--src/gui/equipmentwindow.h3
-rw-r--r--src/gui/ministatus.cpp13
-rw-r--r--src/gui/ministatus.h3
-rw-r--r--src/gui/statuswindow.cpp20
-rw-r--r--src/gui/statuswindow.h1
-rw-r--r--src/net/tmwa/inventoryhandler.cpp11
6 files changed, 49 insertions, 2 deletions
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index d80535ed6..82a6454ba 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -66,6 +66,9 @@ class EquipmentWindow : public Window, public gcn::ActionListener
void mousePressed(gcn::MouseEvent& mouseEvent);
+ Item* getEquipment(int i)
+ { return mEquipment ? mEquipment->getEquipment(i) : 0; }
+
private:
void mouseExited(gcn::MouseEvent &event);
void mouseMoved(gcn::MouseEvent &event);
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index ed124d3b4..214a745ec 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -91,7 +91,10 @@ MiniStatusWindow::MiniStatusWindow():
"inventory slots bar", _("inventory slots bar"));
mMoneyBar = createBar(0, 130, 20, Theme::PROG_INVY_SLOTS,
- "money bar", _("money bar"));
+ "money bar", _("money bar"));
+
+ mArrowsBar = createBar(0, 50, 20, Theme::PROG_INVY_SLOTS,
+ "arrows bar", _("arrows bar"));
mStatusBar = createBar(100, 150, 20, Theme::PROG_EXP,
"status bar", _("status bar"));
@@ -110,6 +113,7 @@ MiniStatusWindow::MiniStatusWindow():
inv->addInventoyListener(this);
StatusWindow::updateMoneyBar(mMoneyBar);
+ StatusWindow::updateArrowsBar(mArrowsBar);
updateStatus();
}
@@ -407,6 +411,8 @@ void MiniStatusWindow::loadBars()
mInvSlotsBar->setVisible(false);
if (mMoneyBar)
mMoneyBar->setVisible(false);
+ if (mArrowsBar)
+ mArrowsBar->setVisible(false);
return;
}
@@ -451,3 +457,8 @@ void MiniStatusWindow::slotsChanged(Inventory* inventory)
if (inventory->getType() == Inventory::INVENTORY)
StatusWindow::updateInvSlotsBar(mInvSlotsBar);
}
+
+void MiniStatusWindow::updateArrows()
+{
+ StatusWindow::updateArrowsBar(mArrowsBar);
+}
diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h
index dad9d6b0f..8477d4dd9 100644
--- a/src/gui/ministatus.h
+++ b/src/gui/ministatus.h
@@ -83,6 +83,8 @@ class MiniStatusWindow : public Popup,
void updateBars();
+ void updateArrows();
+
void slotsChanged(Inventory* inventory);
std::list <ProgressBar*> &getBars()
@@ -109,6 +111,7 @@ class MiniStatusWindow : public Popup,
ProgressBar *mWeightBar;
ProgressBar *mInvSlotsBar;
ProgressBar *mMoneyBar;
+ ProgressBar *mArrowsBar;
ProgressBar *mStatusBar;
TextPopup *mTextPopup;
StatusPopup *mStatusPopup;
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index ffc00db5a..f37b9737a 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -23,12 +23,15 @@
#include "configuration.h"
#include "event.h"
+#include "equipment.h"
#include "inventory.h"
+#include "item.h"
#include "localplayer.h"
#include "playerinfo.h"
#include "units.h"
#include "viewport.h"
+#include "gui/equipmentwindow.h"
#include "gui/setup.h"
#include "gui/theme.h"
@@ -567,8 +570,25 @@ void StatusWindow::updateMoneyBar(ProgressBar *bar)
}
}
+void StatusWindow::updateArrowsBar(ProgressBar *bar)
+{
+ if (!bar || !equipmentWindow)
+ return;
+
+ Item *item = equipmentWindow->getEquipment(
+ Equipment::EQUIP_PROJECTILE_SLOT);
+
+ if (item && item->getQuantity() > 0)
+ bar->setText(toString(item->getQuantity()));
+ else
+ bar->setText("0");
+}
+
void StatusWindow::updateInvSlotsBar(ProgressBar *bar)
{
+ if (!bar)
+ return;
+
Inventory *inv = PlayerInfo::getInventory();
if (!inv)
return;
diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h
index 413ab9313..5f75796f3 100644
--- a/src/gui/statuswindow.h
+++ b/src/gui/statuswindow.h
@@ -69,6 +69,7 @@ class StatusWindow : public Window, public Mana::Listener
static void updateWeightBar(ProgressBar *bar);
static void updateInvSlotsBar(ProgressBar *bar);
static void updateMoneyBar(ProgressBar *bar);
+ static void updateArrowsBar(ProgressBar *bar);
static void updateStatusBar(ProgressBar *bar, bool percent = true);
static void updateProgressBar(ProgressBar *bar, int value, int max,
bool percent);
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index ad5ff4fff..7c6da139e 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -30,6 +30,8 @@
#include "localplayer.h"
#include "log.h"
+#include "gui/ministatus.h"
+
#include "gui/widgets/chattab.h"
#include "net/messagein.h"
@@ -311,6 +313,8 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
item->increaseQuantity(-amount);
if (item->getQuantity() == 0)
inventory->removeItemAt(index);
+ if (miniStatusWindow)
+ miniStatusWindow->updateArrows();
}
}
break;
@@ -483,6 +487,9 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
if (flag)
mEquips.setEquipment(getSlot(equipType), -1);
+ if (miniStatusWindow && equipType & 0x8000)
+ miniStatusWindow->updateArrows();
+
break;
case SMSG_PLAYER_ATTACK_RANGE:
@@ -503,8 +510,10 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
index -= INVENTORY_OFFSET;
- logger->log("Arrows equipped: %i", index);
mEquips.setEquipment(Equipment::EQUIP_PROJECTILE_SLOT, index);
+
+ if (miniStatusWindow)
+ miniStatusWindow->updateArrows();
break;
default: