summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-07-21 20:19:25 -0600
committerJared Adams <jaxad0127@gmail.com>2009-07-21 20:21:55 -0600
commit4cc7305cfa08598398123641987cf1fdf2bd7616 (patch)
treecdf406f0c943201e98a9787fbe1a1f760bb0e22f /src/gui
parentce3d5a56de1309298603c9ce3b95659829f870ef (diff)
downloadmana-client-4cc7305cfa08598398123641987cf1fdf2bd7616.tar.gz
mana-client-4cc7305cfa08598398123641987cf1fdf2bd7616.tar.bz2
mana-client-4cc7305cfa08598398123641987cf1fdf2bd7616.tar.xz
mana-client-4cc7305cfa08598398123641987cf1fdf2bd7616.zip
Merge equipment handling and fix some bugs
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/equipmentwindow.cpp63
-rw-r--r--src/gui/equipmentwindow.h47
-rw-r--r--src/gui/outfitwindow.cpp6
3 files changed, 16 insertions, 100 deletions
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 44006971..d6493ca2 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -50,28 +50,22 @@ static const int BOX_HEIGHT = 36;
// Positions of the boxes, 2nd dimension is X and Y respectively.
static const int boxPosition[][2] = {
- { 50, 208 }, // EQUIP_LEGS_SLOT
- { 8, 123 }, // EQUIP_FIGHT1_SLOT
+ { 90, 40 }, // EQUIP_TORSO_SLOT
{ 8, 78 }, // EQUIP_GLOVES_SLOT
- { 129, 168 }, // EQUIP_RING2_SLOT
+ { 70, 0 }, // EQUIP_HEAD_SLOT
+ { 50, 208 }, // EQUIP_LEGS_SLOT
+ { 90, 208 }, // EQUIP_FEET_SLOT
{ 8, 168 }, // EQUIP_RING1_SLOT
+ { 129, 168 }, // EQUIP_RING2_SLOT
+ { 50, 40 }, // EQUIP_NECK_SLOT
+ { 8, 123 }, // EQUIP_FIGHT1_SLOT
{ 129, 123 }, // EQUIP_FIGHT2_SLOT
- { 90, 208 }, // EQUIP_FEET_SLOT
- { 50, 40 }, // EQUIP_CAPE_SLOT
- { 70, 0 }, // EQUIP_HEAD_SLOT
- { 90, 40 }, // EQUIP_TORSO_SLOT
- { 129, 78 } // EQUIP_AMMO_SLOT
+ { 129, 78 } // EQUIP_PROJECTILE_SLOT
};
-#ifdef TMWSERV_SUPPORT
EquipmentWindow::EquipmentWindow(Equipment *equipment):
-#else
-EquipmentWindow::EquipmentWindow():
-#endif
Window(_("Equipment")),
-#ifdef TMWSERV_SUPPORT
mEquipment(equipment),
-#endif
mSelected(-1)
{
mItemPopup = new ItemPopup;
@@ -96,16 +90,11 @@ EquipmentWindow::EquipmentWindow():
add(playerBox);
add(mUnequip);
- for (int i = 0; i < EQUIP_VECTOREND; i++)
+ for (int i = 0; i < Equipment::EQUIP_VECTOREND; i++)
{
mEquipBox[i].posX = boxPosition[i][0] + getPadding();
mEquipBox[i].posY = boxPosition[i][1] + getTitleBarHeight();
}
-
-#ifdef EATHENA_SUPPORT
- mEquipment = player_node->mEquipment.get();
- mInventory = player_node->getInventory();
-#endif
}
EquipmentWindow::~EquipmentWindow()
@@ -122,7 +111,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
Window::drawChildren(graphics);
- for (int i = 0; i < EQUIP_VECTOREND; i++)
+ for (int i = 0; i < Equipment::EQUIP_VECTOREND; i++)
{
if (i == mSelected)
{
@@ -140,13 +129,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
g->drawRectangle(gcn::Rectangle(mEquipBox[i].posX, mEquipBox[i].posY,
BOX_WIDTH, BOX_HEIGHT));
-#ifdef TMWSERV_SUPPORT
Item *item = mEquipment->getEquipment(i);
-#else
- Item *item = (i != EQUIP_AMMO_SLOT) ?
- mInventory->getItem(mEquipment->getEquipment(i)) :
- mInventory->getItem(mEquipment->getArrows());
-#endif
if (item)
{
// Draw Item.
@@ -154,8 +137,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
g->drawImage(image,
mEquipBox[i].posX + 2,
mEquipBox[i].posY + 2);
-#ifdef EATHENA_SUPPORT
- if (i == EQUIP_AMMO_SLOT)
+ if (i == EQUIP_PROJECTILE_SLOT)
{
g->setColor(guiPalette->getColor(Palette::TEXT));
graphics->drawText(toString(item->getQuantity()),
@@ -163,7 +145,6 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
mEquipBox[i].posY - getFont()->getHeight(),
gcn::Graphics::CENTER);
}
-#endif
}
}
}
@@ -172,13 +153,7 @@ void EquipmentWindow::action(const gcn::ActionEvent &event)
{
if (event.getId() == "unequip" && mSelected > -1)
{
-#ifdef TMWSERV_SUPPORT // TODO: merge these!
Item *item = mEquipment->getEquipment(mSelected);
-#else
- Item *item = (mSelected != EQUIP_AMMO_SLOT) ?
- mInventory->getItem(mEquipment->getEquipment(mSelected)) :
- mInventory->getItem(mEquipment->getArrows());
-#endif
Net::getInventoryHandler()->unequipItem(item);
setSelected(-1);
}
@@ -186,20 +161,14 @@ void EquipmentWindow::action(const gcn::ActionEvent &event)
Item *EquipmentWindow::getItem(int x, int y) const
{
- for (int i = 0; i < EQUIP_VECTOREND; i++)
+ for (int i = 0; i < Equipment::EQUIP_VECTOREND; i++)
{
gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY,
BOX_WIDTH, BOX_HEIGHT);
if (tRect.isPointInRect(x, y))
{
-#ifdef TMWSERV_SUPPORT
return mEquipment->getEquipment(i);
-#else
- return (i != EQUIP_AMMO_SLOT) ?
- mInventory->getItem(mEquipment->getEquipment(i)) :
- mInventory->getItem(mEquipment->getArrows());
-#endif
}
}
return NULL;
@@ -215,15 +184,9 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
{
// Checks if any of the presses were in the equip boxes.
- for (int i = 0; i < EQUIP_VECTOREND; i++)
+ for (int i = 0; i < Equipment::EQUIP_VECTOREND; i++)
{
-#ifdef TMWSERV_SUPPORT
Item *item = mEquipment->getEquipment(i);
-#else
- Item *item = (i != EQUIP_AMMO_SLOT) ?
- mInventory->getItem(mEquipment->getEquipment(i)) :
- mInventory->getItem(mEquipment->getArrows());
-#endif
gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY,
BOX_WIDTH, BOX_HEIGHT);
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index 8bc350a4..a7b2c0d1 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -24,11 +24,11 @@
#include "gui/widgets/window.h"
+#include "equipment.h"
#include "guichanfwd.h"
#include <guichan/actionlistener.hpp>
-class Equipment;
class Inventory;
class Item;
class ItemPopup;
@@ -44,11 +44,7 @@ class EquipmentWindow : public Window, public gcn::ActionListener
/**
* Constructor.
*/
-#ifdef TMWSERV_SUPPORT
EquipmentWindow(Equipment *equipment);
-#else
- EquipmentWindow();
-#endif
/**
* Destructor.
@@ -64,40 +60,6 @@ class EquipmentWindow : public Window, public gcn::ActionListener
void mousePressed(gcn::MouseEvent& mouseEvent);
-#ifdef TMWSERV_SUPPORT
- enum EquipmentSlots
- {
- EQUIP_TORSO_SLOT = 0,
- EQUIP_ARMS_SLOT = 1,
- EQUIP_HEAD_SLOT = 2,
- EQUIP_LEGS_SLOT = 3,
- EQUIP_FEET_SLOT = 4,
- EQUIP_RING1_SLOT = 5,
- EQUIP_RING2_SLOT = 6,
- EQUIP_NECKLACE_SLOT = 7,
- EQUIP_FIGHT1_SLOT = 8,
- EQUIP_FIGHT2_SLOT = 9,
- EQUIP_PROJECTILE_SLOT = 10,
- EQUIP_VECTOREND
- };
-#else
- enum EquipmentSlots
- {
- EQUIP_LEGS_SLOT = 0,
- EQUIP_FIGHT1_SLOT,
- EQUIP_GLOVES_SLOT,
- EQUIP_RING2_SLOT,
- EQUIP_RING1_SLOT,
- EQUIP_FIGHT2_SLOT,
- EQUIP_FEET_SLOT,
- EQUIP_CAPE_SLOT,
- EQUIP_HEAD_SLOT,
- EQUIP_TORSO_SLOT,
- EQUIP_AMMO_SLOT,
- EQUIP_VECTOREND
- };
-#endif
-
private:
void mouseExited(gcn::MouseEvent &event);
void mouseMoved(gcn::MouseEvent &event);
@@ -107,9 +69,6 @@ class EquipmentWindow : public Window, public gcn::ActionListener
void setSelected(int index);
Equipment *mEquipment;
-#ifdef EATHENA_SUPPORT
- Inventory *mInventory;
-#endif
/**
* Equipment box.
@@ -120,12 +79,12 @@ class EquipmentWindow : public Window, public gcn::ActionListener
int posY;
};
- EquipBox mEquipBox[EQUIP_VECTOREND]; /**< Equipment Boxes. */
+ EquipBox mEquipBox[Equipment::EQUIP_VECTOREND]; /**< Equipment Boxes. */
ItemPopup *mItemPopup;
gcn::Button *mUnequip;
- int mSelected; /**< Index of selected item. */
+ int mSelected; /**< Index of selected item. */
};
extern EquipmentWindow *equipmentWindow;
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index f43e1440..58bb1348 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -153,14 +153,8 @@ void OutfitWindow::wearOutfit(int outfit)
//non vis is 3,4,7
if (i != 3 && i != 4 && i != 7)
{
-#ifdef TMWSERV_SUPPORT
if (!(item = player_node->mEquipment.get()->getEquipment(i)))
continue;
-#else
- if (!(item = player_node->getInventory()->getItem(
- player_node->mEquipment.get()->getEquipment(i))))
- continue;
-#endif
Net::getInventoryHandler()->unequipItem(item);
}
}