summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game.cpp12
-rw-r--r--src/gui/equipmentwindow.cpp130
-rw-r--r--src/gui/equipmentwindow.h46
3 files changed, 116 insertions, 72 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 92005dba..4da19bf8 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -155,7 +155,17 @@ static void createGuiWindows()
minimap = new Minimap;
chatWindow = new ChatWindow;
tradeWindow = new TradeWindow;
- equipmentWindow = new EquipmentWindow(PlayerInfo::getEquipment());
+ switch (Net::getNetworkType())
+ {
+ case ServerInfo::TMWATHENA:
+ equipmentWindow = new TmwAthena::TaEquipmentWindow(
+ PlayerInfo::getEquipment());
+ break;
+ case ServerInfo::MANASERV:
+ default:
+ equipmentWindow = new EquipmentWindow(PlayerInfo::getEquipment());
+ break;
+ }
statusWindow = new StatusWindow;
inventoryWindow = new InventoryWindow(PlayerInfo::getInventory());
skillDialog = new SkillDialog;
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index d6c029c3..02fc2a96 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -67,9 +67,9 @@ static const int boxPosition[][2] = {
EquipmentWindow::EquipmentWindow(Equipment *equipment):
Window(_("Equipment")),
- mEquipment(equipment),
mEquipBox(0),
- mSelected(-1)
+ mSelected(-1),
+ mEquipment(equipment)
{
mItemPopup = new ItemPopup;
setupWindow->registerWindowForReset(this);
@@ -93,25 +93,10 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment):
add(playerBox);
add(mUnequip);
-
- // Load equipment boxes.
- if (Net::getNetworkType() == ServerInfo::TMWATHENA)
- {
- mEquipBox = new EquipBox[TmwAthena::EQUIP_VECTOR_END];
-
- for (int i = 0; i < TmwAthena::EQUIP_VECTOR_END; i++)
- {
- mEquipBox[i].posX = boxPosition[i][0] + getPadding();
- mEquipBox[i].posY = boxPosition[i][1] + getTitleBarHeight();
- }
- }
}
EquipmentWindow::~EquipmentWindow()
{
- if (Net::getNetworkType() == ServerInfo::TMWATHENA)
- delete[] mEquipBox;
-
delete mItemPopup;
}
@@ -120,50 +105,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
// Draw window graphics
Window::draw(graphics);
- Graphics *g = static_cast<Graphics*>(graphics);
-
Window::drawChildren(graphics);
-
- if (Net::getNetworkType() == ServerInfo::TMWATHENA)
- {
- for (int i = 0; i < TmwAthena::EQUIP_VECTOR_END; i++)
- {
- if (i == mSelected)
- {
- const gcn::Color color = Theme::getThemeColor(Theme::HIGHLIGHT);
-
- // Set color to the highlight color
- g->setColor(gcn::Color(color.r, color.g, color.b, getGuiAlpha()));
- g->fillRectangle(gcn::Rectangle(mEquipBox[i].posX, mEquipBox[i].posY,
- BOX_WIDTH, BOX_HEIGHT));
- }
-
- // Set color black
- g->setColor(gcn::Color(0, 0, 0));
- // Draw box border
- g->drawRectangle(gcn::Rectangle(mEquipBox[i].posX, mEquipBox[i].posY,
- BOX_WIDTH, BOX_HEIGHT));
-
- Item *item = mEquipment->getEquipment(i);
- if (item)
- {
- // Draw Item.
- Image *image = item->getImage();
- image->setAlpha(1.0f); // Ensure the image is drawn with maximum opacity
- g->drawImage(image,
- mEquipBox[i].posX + 2,
- mEquipBox[i].posY + 2);
- if (i == TmwAthena::EQUIP_PROJECTILE_SLOT)
- {
- g->setColor(Theme::getThemeColor(Theme::TEXT));
- graphics->drawText(toString(item->getQuantity()),
- mEquipBox[i].posX + (BOX_WIDTH / 2),
- mEquipBox[i].posY - getFont()->getHeight(),
- gcn::Graphics::CENTER);
- }
- }
- }
- }
}
void EquipmentWindow::action(const gcn::ActionEvent &event)
@@ -262,3 +204,71 @@ void EquipmentWindow::setSelected(int index)
mSelected = index;
mUnequip->setEnabled(mSelected != -1);
}
+
+namespace TmwAthena {
+
+TaEquipmentWindow::TaEquipmentWindow(Equipment *equipment):
+ EquipmentWindow(equipment)
+{
+ // Load equipment boxes.
+ mEquipBox = new EquipBox[TmwAthena::EQUIP_VECTOR_END];
+
+ for (int i = 0; i < TmwAthena::EQUIP_VECTOR_END; i++)
+ {
+ mEquipBox[i].posX = boxPosition[i][0] + getPadding();
+ mEquipBox[i].posY = boxPosition[i][1] + getTitleBarHeight();
+ }
+}
+
+TaEquipmentWindow::~TaEquipmentWindow()
+{
+ delete[] mEquipBox;
+}
+
+void TaEquipmentWindow::draw(gcn::Graphics *graphics)
+{
+ EquipmentWindow::draw(graphics);
+
+ // Draw equipment boxes
+ Graphics *g = static_cast<Graphics*>(graphics);
+
+ for (int i = 0; i < TmwAthena::EQUIP_VECTOR_END; i++)
+ {
+ if (i == mSelected)
+ {
+ const gcn::Color color = Theme::getThemeColor(Theme::HIGHLIGHT);
+
+ // Set color to the highlight color
+ g->setColor(gcn::Color(color.r, color.g, color.b, getGuiAlpha()));
+ g->fillRectangle(gcn::Rectangle(mEquipBox[i].posX, mEquipBox[i].posY,
+ BOX_WIDTH, BOX_HEIGHT));
+ }
+
+ // Set color black
+ g->setColor(gcn::Color(0, 0, 0));
+ // Draw box border
+ g->drawRectangle(gcn::Rectangle(mEquipBox[i].posX, mEquipBox[i].posY,
+ BOX_WIDTH, BOX_HEIGHT));
+
+ Item *item = mEquipment->getEquipment(i);
+ if (item)
+ {
+ // Draw Item.
+ Image *image = item->getImage();
+ image->setAlpha(1.0f); // Ensure the image is drawn with maximum opacity
+ g->drawImage(image,
+ mEquipBox[i].posX + 2,
+ mEquipBox[i].posY + 2);
+ if (i == TmwAthena::EQUIP_PROJECTILE_SLOT)
+ {
+ g->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->drawText(toString(item->getQuantity()),
+ mEquipBox[i].posX + (BOX_WIDTH / 2),
+ mEquipBox[i].posY - getFont()->getHeight(),
+ gcn::Graphics::CENTER);
+ }
+ }
+ }
+}
+
+};
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index a76fa689..a0fa6acb 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -59,16 +59,7 @@ class EquipmentWindow : public Window, public gcn::ActionListener
void mousePressed(gcn::MouseEvent& mouseEvent);
- private:
- void mouseExited(gcn::MouseEvent &event);
- void mouseMoved(gcn::MouseEvent &event);
-
- Item *getItem(int x, int y) const;
-
- void setSelected(int index);
-
- Equipment *mEquipment;
-
+ protected:
/**
* Equipment box.
*/
@@ -80,12 +71,45 @@ class EquipmentWindow : public Window, public gcn::ActionListener
EquipBox *mEquipBox; /**< Equipment Boxes. */
+ int mSelected; /**< Index of selected item. */
+ Equipment *mEquipment;
+
+ private:
+ void mouseExited(gcn::MouseEvent &event);
+ void mouseMoved(gcn::MouseEvent &event);
+
+ Item *getItem(int x, int y) const;
+
+ void setSelected(int index);
+
ItemPopup *mItemPopup;
gcn::Button *mUnequip;
+};
+
+namespace TmwAthena {
+
+class TaEquipmentWindow : public EquipmentWindow
+{
+ public:
+ /**
+ * Constructor.
+ */
+ TaEquipmentWindow(Equipment *equipment);
+
+ /**
+ * Destructor.
+ */
+ ~TaEquipmentWindow();
+
+ /**
+ * Draws the equipment window using TmwAthena routine.
+ */
+ void draw(gcn::Graphics *graphics);
- int mSelected; /**< Index of selected item. */
};
+}; // namespace TmwAthena
+
extern EquipmentWindow *equipmentWindow;
#endif