summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-08-18 03:06:53 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-08-18 03:06:53 +0200
commit36239b2d689b862a951a65a9be7376a500f1ace9 (patch)
tree1f8dde16f52a4cbbde1c46af0a063c79e28d30d1
parente86f83ed987461adabcbc02508107366b8c65558 (diff)
downloadmana-36239b2d689b862a951a65a9be7376a500f1ace9.tar.gz
mana-36239b2d689b862a951a65a9be7376a500f1ace9.tar.bz2
mana-36239b2d689b862a951a65a9be7376a500f1ace9.tar.xz
mana-36239b2d689b862a951a65a9be7376a500f1ace9.zip
Improved equip slots description for both protocols.
Now the itempopup is also telling what equip slot is under the mouse pointer.
-rw-r--r--src/gui/equipmentwindow.cpp31
-rw-r--r--src/gui/equipmentwindow.h1
-rw-r--r--src/gui/itempopup.cpp3
-rw-r--r--src/net/tmwa/inventoryhandler.h33
4 files changed, 63 insertions, 5 deletions
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 91ab38e8..212dcd2b 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -192,6 +192,19 @@ Item *EquipmentWindow::getItem(int x, int y) const
return 0;
}
+const std::string EquipmentWindow::getSlotName(int x, int y) const
+{
+ for (int i = 0; i < mBoxesNumber; ++i)
+ {
+ gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY,
+ BOX_WIDTH, BOX_HEIGHT);
+
+ if (tRect.isPointInRect(x, y))
+ return mEquipment->getSlotName(i);
+ }
+ return std::string();
+}
+
void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
{
Window::mousePressed(mouseEvent);
@@ -231,15 +244,23 @@ void EquipmentWindow::mouseMoved(gcn::MouseEvent &event)
const int x = event.getX();
const int y = event.getY();
- Item *item = getItem(x, y);
+ int mouseX, mouseY;
+ SDL_GetMouseState(&mouseX, &mouseY);
// Show ItemTooltip
- if (item)
+ std::string slotName = getSlotName(x, y);
+ if (!slotName.empty())
{
- int mouseX, mouseY;
- SDL_GetMouseState(&mouseX, &mouseY);
+ mItemPopup->setEquipmentText(slotName);
+
+ Item *item = getItem(x, y);
+ if (item)
+ {
+ mItemPopup->setItem(item->getInfo());
+ }
+ else
+ mItemPopup->setNoItem();
- mItemPopup->setItem(item->getInfo());
mItemPopup->position(x + getX(), y + getY());
}
else
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index 0001dd4e..b8e63efc 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -79,6 +79,7 @@ class EquipmentWindow : public Window, public gcn::ActionListener
void mouseMoved(gcn::MouseEvent &event);
Item *getItem(int x, int y) const;
+ const std::string getSlotName(int x, int y) const;
void setSelected(int index);
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index de8378d5..d65764a5 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -145,6 +145,9 @@ void ItemPopup::setNoItem()
mItemName->setForegroundColor(Theme::getThemeColor(Theme::GENERIC));
mItemName->setPosition(getPadding(), getPadding());
+ mItemDesc->setText(std::string());
+ mItemEffect->setText(std::string());
+
setContentSize(mItemName->getWidth() + 2 * getPadding(), 0);
}
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index 15fa1fac..44ddd896 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -36,6 +36,8 @@
#include "resources/iteminfo.h"
+#include "utils/gettext.h"
+
#include <list>
namespace TmwAthena {
@@ -54,6 +56,37 @@ class EquipBackend : public Equipment::Backend
return PlayerInfo::getInventory()->getItem(invyIndex);
}
+ std::string getSlotName(int slotIndex) const
+ {
+ switch (slotIndex)
+ {
+ case EQUIP_TORSO_SLOT:
+ return std::string(_("Torso"));
+ case EQUIP_ARMS_SLOT:
+ return std::string(_("Arms"));
+ case EQUIP_HEAD_SLOT:
+ return std::string(_("Head"));
+ case EQUIP_LEGS_SLOT:
+ return std::string(_("Legs"));
+ case EQUIP_FEET_SLOT:
+ return std::string(_("Feet"));
+ case EQUIP_RING1_SLOT:
+ return std::string(_("Ring 1/2"));
+ case EQUIP_RING2_SLOT:
+ return std::string(_("Ring 2/2"));
+ case EQUIP_NECKLACE_SLOT:
+ return std::string(_("Necklace"));
+ case EQUIP_FIGHT1_SLOT:
+ return std::string(_("Hand 1/2"));
+ case EQUIP_FIGHT2_SLOT:
+ return std::string(_("Hand 2/2"));
+ case EQUIP_PROJECTILE_SLOT:
+ return std::string(_("Ammo"));
+ default:
+ return std::string();
+ }
+ }
+
void clear()
{
for (int i = 0; i < EQUIP_VECTOR_END; i++)