summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--src/game.cpp30
-rw-r--r--src/gui/menuwindow.cpp116
-rw-r--r--src/gui/menuwindow.h74
-rw-r--r--src/gui/ministatus.cpp89
-rw-r--r--src/gui/ministatus.h80
-rw-r--r--src/gui/status.cpp518
-rw-r--r--src/gui/status.h50
8 files changed, 782 insertions, 181 deletions
diff --git a/ChangeLog b/ChangeLog
index 125f9d4b..2f10a23e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-09-17 Yohann Ferreira <bertram@cegetel.net>
+
+ * src/game.cpp, src/gui/ministatus.cpp, src/gui/ministatus.h,
+ src/gui/menuwindow.h, src/gui/menuwindow.cpp, src/gui/status.cpp,
+ src/gui/status.h: Improving General Layout.
+
2005-09-16 Bjørn Lindeijer <bjorn@lindeijer.nl>
* src/resources/image.cpp: Report which error occured when loading of
diff --git a/src/game.cpp b/src/game.cpp
index bbec5eae..62787dff 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -57,8 +57,9 @@
#include "gui/sell.h"
#include "gui/setup.h"
#include "gui/skill.h"
-#include "gui/stats.h"
+#include "gui/menuwindow.h"
#include "gui/status.h"
+#include "gui/ministatus.h"
#include "gui/trade.h"
#include "net/messagein.h"
@@ -87,7 +88,9 @@ OkDialog *deathNotice = NULL;
ConfirmDialog *exitConfirm = NULL;
ChatWindow *chatWindow;
+MenuWindow *menuWindow;
StatusWindow *statusWindow;
+MiniStatusWindow *miniStatusWindow;
BuyDialog *buyDialog;
SellDialog *sellDialog;
BuySellDialog *buySellDialog;
@@ -96,7 +99,6 @@ NpcListDialog *npcListDialog;
NpcTextDialog *npcTextDialog;
SkillDialog *skillDialog;
//NewSkillDialog *newSkillWindow;
-StatsWindow *statsWindow;
Setup* setupWindow;
Minimap *minimap;
EquipmentWindow *equipmentWindow;
@@ -176,7 +178,9 @@ void createGuiWindows()
// Create dialogs
chatWindow = new ChatWindow(
config.getValue("homeDir", "") + std::string("/chatlog.txt"));
+ menuWindow = new MenuWindow();
statusWindow = new StatusWindow();
+ miniStatusWindow = new MiniStatusWindow();
buyDialog = new BuyDialog();
sellDialog = new SellDialog();
buySellDialog = new BuySellDialog();
@@ -185,7 +189,6 @@ void createGuiWindows()
npcListDialog = new NpcListDialog();
skillDialog = new SkillDialog();
//newSkillWindow = new NewSkillDialog();
- statsWindow = new StatsWindow();
setupWindow = new Setup();
minimap = new Minimap();
equipmentWindow = new EquipmentWindow();
@@ -195,17 +198,18 @@ void createGuiWindows()
helpWindow = new HelpWindow();
popupMenu = new PopupMenu();
- // Initialize window posisitons
+ // Initialize window positions
int screenW = graphics->getWidth();
int screenH = graphics->getHeight();
+ statusWindow->setPosition((screenW - statusWindow->getWidth()) / 2,
+ (screenH - statusWindow->getHeight()) / 2);
+ miniStatusWindow->setPosition(0, 0);
+ minimap->setPosition(3, 30);
chatWindow->setPosition(0, screenH - chatWindow->getHeight());
- statusWindow->setPosition(screenW - statusWindow->getWidth() - 5, 5);
+ menuWindow->setPosition(screenW - menuWindow->getWidth(), 0);
inventoryWindow->setPosition(screenW - statusWindow->getWidth() -
inventoryWindow->getWidth() - 10, 5);
- statsWindow->setPosition(
- screenW - 5 - statsWindow->getWidth(),
- statusWindow->getHeight() + 20);
chargeDialog->setPosition(
screenW - 5 - chargeDialog->getWidth(),
screenH - chargeDialog->getHeight() - 15);
@@ -218,7 +222,9 @@ void createGuiWindows()
// Set initial window visibility
chatWindow->setVisible(true);
- statusWindow->setVisible(true);
+ miniStatusWindow->setVisible(true);
+ statusWindow->setVisible(false);
+ menuWindow->setVisible(true);
buyDialog->setVisible(false);
sellDialog->setVisible(false);
buySellDialog->setVisible(false);
@@ -227,7 +233,6 @@ void createGuiWindows()
npcListDialog->setVisible(false);
skillDialog->setVisible(false);
//newSkillWindow->setVisible(false);
- statsWindow->setVisible(false);
setupWindow->setVisible(false);
equipmentWindow->setVisible(false);
chargeDialog->setVisible(false);
@@ -247,6 +252,8 @@ void destroyGuiWindows()
{
delete chatWindow;
delete statusWindow;
+ delete miniStatusWindow;
+ delete menuWindow;
delete buyDialog;
delete sellDialog;
delete buySellDialog;
@@ -254,7 +261,6 @@ void destroyGuiWindows()
delete npcListDialog;
delete npcTextDialog;
delete skillDialog;
- delete statsWindow;
delete setupWindow;
delete minimap;
delete equipmentWindow;
@@ -558,7 +564,7 @@ void do_input()
// Statistics window
case SDLK_s:
- statsWindow->setVisible(!statsWindow->isVisible());
+ statusWindow->setVisible(!statusWindow->isVisible());
used = true;
break;
diff --git a/src/gui/menuwindow.cpp b/src/gui/menuwindow.cpp
new file mode 100644
index 00000000..13d95032
--- /dev/null
+++ b/src/gui/menuwindow.cpp
@@ -0,0 +1,116 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#include "menuwindow.h"
+
+#include <guichan/widgets/label.hpp>
+#include <sstream>
+
+#include "button.h"
+#include "equipmentwindow.h"
+#include "inventorywindow.h"
+#include "status.h"
+#include "skill.h"
+
+extern Window *setupWindow;
+
+
+MenuWindow::MenuWindow():
+ Window("")
+{
+ setResizable(false);
+ setMovable(false);
+ setTitleBarHeight(0);
+
+ // Buttons
+ // ------------
+ statusButton = new Button("Status");
+ statusButton->setEventId("Status");
+ statusButton->addActionListener(this);
+ statusButton->setPosition(0, 3);
+ add(statusButton);
+
+ equipmentButton = new Button("Equipment");
+ equipmentButton->setEventId("Equipment");
+ equipmentButton->addActionListener(this);
+ equipmentButton->setPosition(statusButton->getX() + statusButton->getWidth() + 3, statusButton->getY());
+ add(equipmentButton);
+
+ inventoryButton = new Button("Inventory");
+ inventoryButton->setEventId("Inventory");
+ inventoryButton->addActionListener(this);
+ inventoryButton->setPosition(equipmentButton->getX() + equipmentButton->getWidth() + 3, statusButton->getY());
+ add(inventoryButton);
+
+ skillsButton = new Button("Skills");
+ skillsButton->setEventId("Skills");
+ skillsButton->addActionListener(this);
+ skillsButton->setPosition(inventoryButton->getX() + inventoryButton->getWidth() + 3, statusButton->getY());
+ add(skillsButton);
+
+ setupButton = new Button("Setup");
+ setupButton->setEventId("Setup");
+ setupButton->addActionListener(this);
+ setupButton->setPosition(skillsButton->getX() + skillsButton->getWidth() + 3, statusButton->getY());
+ add(setupButton);
+
+ setContentSize(setupButton->getX() + setupButton->getWidth(), setupButton->getY() + setupButton->getHeight());
+}
+
+MenuWindow::~MenuWindow()
+{
+ delete statusButton;
+ delete equipmentButton;
+ delete skillsButton;
+ delete inventoryButton;
+ delete setupButton;
+}
+
+void MenuWindow::draw(gcn::Graphics *graphics)
+{
+ Window::drawContent(graphics);
+}
+
+void MenuWindow::action(const std::string& eventId)
+{
+ if (eventId == "Status")
+ {
+ statusWindow->setVisible(!statusWindow->isVisible());
+ }
+ if (eventId == "Equipment")
+ {
+ equipmentWindow->setVisible(!equipmentWindow->isVisible());
+ }
+ if (eventId == "Inventory")
+ {
+ inventoryWindow->setVisible(!inventoryWindow->isVisible());
+ }
+ if (eventId == "Skills")
+ {
+ skillDialog->setVisible(!skillDialog->isVisible());
+ }
+ if (eventId == "Setup")
+ {
+ setupWindow->setVisible(!setupWindow->isVisible());
+ }
+}
diff --git a/src/gui/menuwindow.h b/src/gui/menuwindow.h
new file mode 100644
index 00000000..dc035c80
--- /dev/null
+++ b/src/gui/menuwindow.h
@@ -0,0 +1,74 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#ifndef _TMW_MENU_H
+#define _TMW_MENU_H
+
+#include <iosfwd>
+
+#include <guichan/actionlistener.hpp>
+
+#include "window.h"
+
+#include "../guichanfwd.h"
+
+/**
+ * The Button Menu.
+ *
+ * \ingroup Interface
+ */
+class MenuWindow : public Window, public gcn::ActionListener {
+ public:
+ /**
+ * Constructor.
+ */
+ MenuWindow();
+
+ /**
+ * Destructor.
+ */
+ ~MenuWindow();
+
+ /**
+ * Called when receiving actions from widget.
+ */
+ void action(const std::string& eventId);
+
+ /**
+ * Draw this window
+ */
+ void draw(gcn::Graphics *graphics);
+
+ private:
+
+ /**
+ * System Buttons
+ */
+ gcn::Button *statusButton, *equipmentButton;
+ gcn::Button *skillsButton, *inventoryButton, *setupButton;
+};
+
+extern MenuWindow *menuWindow;
+
+#endif
+
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
new file mode 100644
index 00000000..7318ba74
--- /dev/null
+++ b/src/gui/ministatus.cpp
@@ -0,0 +1,89 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#include "ministatus.h"
+
+// #include <guichan/widgets/label.hpp>
+#include <sstream>
+
+#include "progressbar.h"
+
+#include "../playerinfo.h"
+
+MiniStatusWindow::MiniStatusWindow():
+ Window("")
+{
+ setResizable(false);
+ setTitleBarHeight(0);
+ setMovable(false);
+
+ hpBar = new ProgressBar(1.0f,
+ 0, 3, 80, 15,
+ 0, 171, 34);
+
+ mpBar = new ProgressBar(1.0f,
+ hpBar->getX() + hpBar->getWidth() + 3,
+ hpBar->getY(), 80, 15, 26, 102, 230);
+
+ add(hpBar);
+ add(mpBar);
+
+ setContentSize(mpBar->getX() + mpBar->getWidth(),
+ mpBar->getY() + mpBar->getHeight());
+}
+
+MiniStatusWindow::~MiniStatusWindow()
+{
+ delete hpBar;
+ delete mpBar;
+}
+
+void MiniStatusWindow::update()
+{
+ // HP Bar coloration
+ if (player_info->hp < int(player_info->max_hp / 3))
+ {
+ hpBar->setColor(223, 32, 32); // Red
+ }
+ else
+ {
+ if (player_info->hp < int((player_info->max_hp / 3) * 2))
+ {
+ hpBar->setColor(230, 171, 34); // Orange
+ }
+ else
+ {
+ hpBar->setColor(0, 171, 34); // Green
+ }
+ }
+
+ hpBar->setProgress((float)player_info->hp / (float)player_info->max_hp);
+ // mpBar->setProgress((float)player_info->mp / (float)player_info->max_mp);
+}
+
+void MiniStatusWindow::draw(gcn::Graphics *graphics)
+{
+ update();
+
+ Window::drawContent(graphics);
+}
diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h
new file mode 100644
index 00000000..27c51e42
--- /dev/null
+++ b/src/gui/ministatus.h
@@ -0,0 +1,80 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#ifndef _TMW_MINISTATUS_H
+#define _TMW_MINISTATUS_H
+
+#include <iosfwd>
+
+#include <guichan/actionlistener.hpp>
+
+#include "window.h"
+
+#include "../guichanfwd.h"
+
+class ProgressBar;
+
+
+/**
+ * The player mini-status dialog.
+ *
+ * \ingroup Interface
+ */
+class MiniStatusWindow : public Window, public gcn::ActionListener {
+ public:
+ /**
+ * Constructor.
+ */
+ MiniStatusWindow();
+
+ /**
+ * Destructor.
+ */
+ ~MiniStatusWindow();
+
+ /**
+ * Draw this window
+ */
+ void draw(gcn::Graphics *graphics);
+
+ /**
+ * Does Nothing
+ **/
+ void action(const std::string&) {};
+
+ private:
+ /**
+ * Updates this dialog with values from PLAYER_INFO *char_info
+ */
+ void update();
+
+ /**
+ * Mini Status Bars
+ */
+ ProgressBar *hpBar, *mpBar;
+};
+
+extern MiniStatusWindow *miniStatusWindow;
+
+#endif
+
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 7964768b..152e3ff3 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -24,188 +24,384 @@
#include "status.h"
#include <guichan/widgets/label.hpp>
+#include <sstream>
#include "button.h"
-#include "equipmentwindow.h"
-#include "inventorywindow.h"
#include "progressbar.h"
-#include "skill.h"
-#include "stats.h"
#include "../playerinfo.h"
-
-extern Window *setupWindow;
-
-#define WIN_BORDER 5
-#define CONTROLS_SEPARATOR 4
+#include "../net/network.h"
StatusWindow::StatusWindow():
- Window("%s Lvl: % 2i Job: % 2i GP: % 2i")
+ Window(player_info->name)
{
- hp = new gcn::Label("HP");
- sp = new gcn::Label("MP");
- hpValue = new gcn::Label();
- spValue = new gcn::Label();
- expLabel = new gcn::Label("Exp");
- jobExpLabel = new gcn::Label("Job");
-
- statsButton = new Button("Stats");
- statsButton->setEventId("Stats");
- statsButton->addActionListener(this);
-
- skillsButton = new Button("Skills");
- skillsButton->setEventId("Skills");
- skillsButton->addActionListener(this);
-
- inventoryButton = new Button("Inventory");
- inventoryButton->setEventId("Inventory");
- inventoryButton->addActionListener(this);
-
- setupButton = new Button("Setup");
- setupButton->setEventId("Setup");
- setupButton->addActionListener(this);
-
- equipmentButton = new Button("Equip.");
- equipmentButton->setEventId("Equipment");
- equipmentButton->addActionListener(this);
-
- hp->setPosition(WIN_BORDER, WIN_BORDER);
- sp->setPosition(WIN_BORDER,
- hp->getY() + hp->getHeight() + CONTROLS_SEPARATOR);
- healthBar = new ProgressBar(1.0f,
- WIN_BORDER + hp->getWidth() + CONTROLS_SEPARATOR, WIN_BORDER, 80,
+ setResizable(false);
+ setContentSize(335, 255);
+
+ // ----------------------
+ // Status Part
+ // ----------------------
+
+ lvlLabel = new gcn::Label("Level:");
+ gpLabel = new gcn::Label("Money:");
+ hpLabel = new gcn::Label("HP:");
+ hpValueLabel = new gcn::Label("");
+ mpLabel = new gcn::Label("MP:");
+ mpValueLabel = new gcn::Label("");
+ xpLabel = new gcn::Label("Exp:");
+ xpValueLabel = new gcn::Label("");
+ jobXpLabel = new gcn::Label("Job:");
+ jobValueLabel = new gcn::Label("");
+
+ lvlLabel->setPosition(5, 3);
+ gpLabel->setPosition(lvlLabel->getX() + lvlLabel->getWidth() + 40, 3);
+ hpLabel->setPosition(5, lvlLabel->getY() + lvlLabel->getHeight() + 5);
+ hpBar = new ProgressBar(1.0f,
+ hpLabel->getX() + hpLabel->getWidth() + 5, hpLabel->getY(), 80,
15, 0, 171, 34);
- hpValue->setPosition(
- healthBar->getX() + healthBar->getWidth() + 2 * CONTROLS_SEPARATOR,
- WIN_BORDER);
- manaBar = new ProgressBar(1.0f,
- WIN_BORDER + sp->getWidth() + CONTROLS_SEPARATOR,
- hp->getY() + hp->getHeight() + CONTROLS_SEPARATOR, 80, 15, 26, 102,
- 230);
- spValue->setPosition(
- manaBar->getX() + manaBar->getWidth() + 2 * CONTROLS_SEPARATOR,
- hp->getY() + hp->getHeight() + CONTROLS_SEPARATOR);
- xpBar = new ProgressBar(1.0f,
- manaBar->getX(), sp->getY() + sp->getHeight() + CONTROLS_SEPARATOR,
- 70, 15, 143, 192, 211);
- expLabel->setPosition(
- xpBar->getX() + xpBar->getWidth() + CONTROLS_SEPARATOR,
- xpBar->getY());
- jobXpBar = new ProgressBar(1.0f, manaBar->getX(),
- xpBar->getY() + xpBar->getHeight() + CONTROLS_SEPARATOR, 70, 15,
- 220, 135, 203);
- jobExpLabel->setPosition(
- jobXpBar->getX() + jobXpBar->getWidth() + CONTROLS_SEPARATOR,
- jobXpBar->getY());
- statsButton->setPosition(WIN_BORDER,
- jobXpBar->getY() + jobXpBar->getHeight() + 2 * CONTROLS_SEPARATOR);
- skillsButton->setPosition(
- statsButton->getX() + statsButton->getWidth() + CONTROLS_SEPARATOR,
- statsButton->getY());
- inventoryButton->setPosition(
- skillsButton->getX() + skillsButton->getWidth() + CONTROLS_SEPARATOR,
- statsButton->getY());
- setupButton->setPosition(
- inventoryButton->getX() + inventoryButton->getWidth() + CONTROLS_SEPARATOR,
- statsButton->getY());
- equipmentButton->setPosition(
- setupButton->getX() + setupButton->getWidth() + CONTROLS_SEPARATOR,
- statsButton->getY());
-
- setContentSize(
- equipmentButton->getX() + equipmentButton->getWidth() + WIN_BORDER,
- statsButton->getY() + statsButton->getHeight() + WIN_BORDER);
-
- add(hp);
- add(sp);
- add(healthBar);
- add(manaBar);
- add(hpValue);
- add(spValue);
- add(expLabel);
- add(jobExpLabel);
+ hpValueLabel->setPosition(hpBar->getX() + hpBar->getWidth() + 5, hpBar->getY());
+ mpLabel->setPosition(5,hpLabel->getY() + hpLabel->getHeight() + 5);
+ mpBar = new ProgressBar(1.0f, hpBar->getX(),
+ mpLabel->getY(), 80, 15, 26, 102, 230);
+ mpValueLabel->setPosition(hpValueLabel->getX(), mpBar->getY());
+
+ xpLabel->setPosition(175, hpLabel->getY());
+ xpBar = new ProgressBar(1.0f, 205, xpLabel->getY(), 80, 15,
+ 143, 192, 211);
+ xpValueLabel->setPosition(290, xpBar->getY());
+ jobXpLabel->setPosition(175, mpLabel->getY());
+ jobXpBar = new ProgressBar(1.0f, 225, jobXpLabel->getY(), 60, 15,
+ 220, 135, 203);
+ jobValueLabel->setPosition(290, jobXpBar->getY());
+
+ add(lvlLabel);
+ add(gpLabel);
+ add(hpLabel);
+ add(hpValueLabel);
+ add(mpLabel);
+ add(mpValueLabel);
+ add(xpLabel);
+ add(xpValueLabel);
+ add(jobXpLabel);
+ add(jobValueLabel);
+ add(hpBar);
+ add(mpBar);
add(xpBar);
add(jobXpBar);
- add(statsButton);
- add(skillsButton);
- add(inventoryButton);
- add(setupButton);
- add(equipmentButton);
-
- setResizable(true);
+
+ // ----------------------
+ // Stats Part
+ // ----------------------
+
+ // Static Labels
+ statsTitleLabel = new gcn::Label("Stats");
+ statsTotalLabel = new gcn::Label("Total");
+ statsCostLabel = new gcn::Label("Cost");
+
+ // Derived Stats
+ statsAttackLabel = new gcn::Label("Attack:");
+ statsDefenseLabel= new gcn::Label("Defense:");
+ statsMagicAttackLabel = new gcn::Label("M.Attack:");
+ statsMagicDefenseLabel = new gcn::Label("M.Defense:");
+ statsAccuracyLabel = new gcn::Label("% Accuracy:");
+ statsEvadeLabel = new gcn::Label("% Evade:");
+ statsReflexLabel = new gcn::Label("% Reflex:");
+
+ statsAttackPoints = new gcn::Label("");
+ statsDefensePoints = new gcn::Label("");
+ statsMagicAttackPoints = new gcn::Label("");
+ statsMagicDefensePoints = new gcn::Label("");
+ statsAccuracyPoints = new gcn::Label("% Accuracy:");
+ statsEvadePoints = new gcn::Label("% Evade:");
+ statsReflexPoints = new gcn::Label("% Reflex:");
+
+ // New labels
+ for (int i = 0; i < 6; i++) {
+ statsLabel[i] = new gcn::Label();
+ statsDisplayLabel[i] = new gcn::Label();
+ pointsLabel[i] = new gcn::Label("0");
+ }
+ remainingStatsPointsLabel = new gcn::Label();
+
+ // New buttons
+ for (int i = 0; i < 6; i++) {
+ statsButton[i] = new Button("+");
+ }
+
+ // Set button events Id
+ statsButton[0]->setEventId("STR");
+ statsButton[1]->setEventId("AGI");
+ statsButton[2]->setEventId("VIT");
+ statsButton[3]->setEventId("INT");
+ statsButton[4]->setEventId("DEX");
+ statsButton[5]->setEventId("LUK");
+
+ // Set position
+ statsTitleLabel->setPosition(mpLabel->getX(), mpLabel->getY() + 23 );
+ statsTotalLabel->setPosition(110, statsTitleLabel->getY() + 15);
+ statsCostLabel->setPosition(170, statsTotalLabel->getY());
+ for (int i = 0; i < 6; i++)
+ {
+ statsLabel[i]->setPosition(5, statsTotalLabel->getY() + (i * 23) + 15);
+ statsDisplayLabel[i]->setPosition(115, statsTotalLabel->getY() + (i * 23) + 15);
+ statsButton[i]->setPosition(145, statsTotalLabel->getY() + (i * 23) + 10);
+ pointsLabel[i]->setPosition(175, statsTotalLabel->getY() + (i * 23) + 15);
+ }
+ remainingStatsPointsLabel->setPosition(5, pointsLabel[5]->getY() + 25);
+
+ statsAttackLabel->setPosition(220, statsLabel[0]->getY());
+ statsDefenseLabel->setPosition(220, statsLabel[1]->getY());
+ statsMagicAttackLabel->setPosition(220, statsLabel[2]->getY());
+ statsMagicDefenseLabel->setPosition(220, statsLabel[3]->getY());
+ statsAccuracyLabel->setPosition(220, statsLabel[4]->getY());
+ statsEvadeLabel->setPosition(220, statsLabel[5]->getY());
+ statsReflexLabel->setPosition(220, remainingStatsPointsLabel->getY());
+
+ statsAttackPoints->setPosition(310, statsLabel[0]->getY());
+ statsDefensePoints->setPosition(310, statsLabel[1]->getY());
+ statsMagicAttackPoints->setPosition(310, statsLabel[2]->getY());
+ statsMagicDefensePoints->setPosition(310, statsLabel[3]->getY());
+ statsAccuracyPoints->setPosition(310, statsLabel[4]->getY());
+ statsEvadePoints->setPosition(310, statsLabel[5]->getY());
+ statsReflexPoints->setPosition(310, remainingStatsPointsLabel->getY());
+
+ // Assemble
+ add(statsTitleLabel);
+ add(statsTotalLabel);
+ add(statsCostLabel);
+ for(int i = 0; i < 6; i++)
+ {
+ add(statsLabel[i]);
+ add(statsDisplayLabel[i]);
+ add(statsButton[i]);
+ add(pointsLabel[i]);
+ statsButton[i]->addActionListener(this);
+ }
+ add(statsAttackLabel);
+ add(statsDefenseLabel);
+ add(statsMagicAttackLabel);
+ add(statsMagicDefenseLabel);
+ add(statsAccuracyLabel);
+ add(statsEvadeLabel);
+ add(statsReflexLabel);
+
+ add(statsAttackPoints);
+ add(statsDefensePoints);
+ add(statsMagicAttackPoints);
+ add(statsMagicDefensePoints);
+ add(statsAccuracyPoints);
+ add(statsEvadePoints);
+ add(statsReflexPoints);
+
+ add(remainingStatsPointsLabel);
}
StatusWindow::~StatusWindow()
{
- delete hp;
- delete sp;
- delete expLabel;
- delete jobExpLabel;
- delete healthBar;
- delete manaBar;
+ // Status Part
+ delete lvlLabel;
+ delete gpLabel;
+ delete hpLabel;
+ delete hpValueLabel;
+ delete mpLabel;
+ delete mpValueLabel;
+ delete xpLabel;
+ delete xpValueLabel;
+ delete jobXpLabel;
+ delete jobValueLabel;
+ delete hpBar;
+ delete mpBar;
delete xpBar;
delete jobXpBar;
- delete statsButton;
- delete skillsButton;
- delete inventoryButton;
- delete setupButton;
- delete equipmentButton;
+
+ // Stats Part
+ delete statsTitleLabel;
+ delete statsTotalLabel;
+ delete statsCostLabel;
+ for (int i = 0; i < 6; i++) {
+ delete statsLabel[i];
+ delete statsDisplayLabel[i];
+ delete statsButton[i];
+ }
+ delete statsAttackLabel;
+ delete statsDefenseLabel;
+ delete statsMagicAttackLabel;
+ delete statsMagicDefenseLabel;
+ delete statsAccuracyLabel;
+ delete statsEvadeLabel;
+ delete statsReflexLabel;
+
+ delete statsAttackPoints;
+ delete statsDefensePoints;
+ delete statsMagicAttackPoints;
+ delete statsMagicDefensePoints;
+ delete statsAccuracyPoints;
+ delete statsEvadePoints;
+ delete statsReflexPoints;
+
+ delete remainingStatsPointsLabel;
}
void StatusWindow::update()
{
- char *tempstr = new char[64];
+ std::stringstream updateText;
- sprintf(tempstr, "%s Lvl: % 2i Job: % 2i GP: % 2i",
- player_info->name.c_str(), player_info->lv, player_info->job_lv,
- player_info->gp);
- setCaption(tempstr);
+ // Status Part
+ // -----------
+ updateText.str("");
+ updateText << "Level: " << player_info->lv;
+ lvlLabel->setCaption(updateText.str());
+ lvlLabel->adjustSize();
- sprintf(tempstr, "%d/%d", player_info->hp, player_info->max_hp);
- hpValue->setCaption(tempstr);
- hpValue->adjustSize();
+ updateText.str("");
+ updateText << "Money: " << player_info->gp << " GP";
+ gpLabel->setCaption(updateText.str());
+ gpLabel->adjustSize();
- sprintf(tempstr, "%d/%d", player_info->sp, player_info->max_sp);
- spValue->setCaption(tempstr);
- spValue->adjustSize();
+ updateText.str("");
+ updateText << "Job: " << player_info->job_lv;
+ jobXpLabel->setCaption(updateText.str());
+ jobXpLabel->adjustSize();
- sprintf(tempstr, "Exp: %d/%d",
- (int)player_info->xp, (int)player_info->xpForNextLevel);
- expLabel->setCaption(tempstr);
- expLabel->adjustSize();
+ updateText.str("");
+ updateText << player_info->hp << "/" << player_info->max_hp;
+ hpValueLabel->setCaption(updateText.str());
+ hpValueLabel->adjustSize();
- sprintf(tempstr, "Job: %d/%d",
- (int)player_info->job_xp, (int)player_info->jobXpForNextLevel);
- jobExpLabel->setCaption(tempstr);
- jobExpLabel->adjustSize();
+ updateText.str("");
+ updateText << player_info->sp << "/" << player_info->max_sp;
+ mpValueLabel->setCaption(updateText.str());
+ mpValueLabel->adjustSize();
+
+ updateText.str("");
+ updateText << (int)player_info->xp << "/" << (int)player_info->xpForNextLevel;
+ xpValueLabel->setCaption(updateText.str());
+ xpValueLabel->adjustSize();
+
+ updateText.str("");
+ updateText << (int)player_info->job_xp << "/" << (int)player_info->jobXpForNextLevel;
+ jobValueLabel->setCaption(updateText.str());
+ jobValueLabel->adjustSize();
// HP Bar coloration
if (player_info->hp < int(player_info->max_hp / 3))
{
- healthBar->setColor(223, 32, 32); // Red
+ hpBar->setColor(223, 32, 32); // Red
}
else
{
if (player_info->hp < int((player_info->max_hp / 3) * 2))
{
- healthBar->setColor(230, 171, 34); // Orange
+ hpBar->setColor(230, 171, 34); // Orange
}
else
{
- healthBar->setColor(0, 171, 34); // Green
+ hpBar->setColor(0, 171, 34); // Green
}
}
- healthBar->setProgress((float)player_info->hp /
- (float)player_info->max_hp);
+ hpBar->setProgress((float)player_info->hp / (float)player_info->max_hp);
+
+ xpBar->setProgress(
+ (float)player_info->xp / (float)player_info->xpForNextLevel);
+ jobXpBar->setProgress(
+ (float)player_info->job_xp / (float)player_info->jobXpForNextLevel);
+
+ // Stats Part
+ // ----------
+ std::stringstream statsStr[6];
+ std::stringstream figureStr[6];
+ std::stringstream pointsStr[6];
+
+ statsStr[0] << "Strength:";
+ figureStr[0] << (int)player_info->STR;
+ statsStr[1] << "Agility:";
+ figureStr[1] << (int)player_info->AGI;
+ statsStr[2] << "Vitality:";
+ figureStr[2] << (int)player_info->VIT;
+ statsStr[3] << "Intelligence:";
+ figureStr[3] << (int)player_info->INT;
+ statsStr[4] << "Dexterity:";
+ figureStr[4] << (int)player_info->DEX;
+ statsStr[5] << "Luck:";
+ figureStr[5] << (int)player_info->LUK;
+
+ int statusPoints = player_info->statsPointsToAttribute;
+
+ updateText.str("");
+ updateText << "Remaining Status Points: " << statusPoints;
+
+ pointsStr[0] << (int)player_info->STRUp;
+ pointsStr[1] << (int)player_info->AGIUp;
+ pointsStr[2] << (int)player_info->VITUp;
+ pointsStr[3] << (int)player_info->INTUp;
+ pointsStr[4] << (int)player_info->DEXUp;
+ pointsStr[5] << (int)player_info->LUKUp;
+
+ // Enable buttons for which there are enough status points
+ statsButton[0]->setEnabled(player_info->STRUp <= statusPoints);
+ statsButton[1]->setEnabled(player_info->AGIUp <= statusPoints);
+ statsButton[2]->setEnabled(player_info->VITUp <= statusPoints);
+ statsButton[3]->setEnabled(player_info->INTUp <= statusPoints);
+ statsButton[4]->setEnabled(player_info->DEXUp <= statusPoints);
+ statsButton[5]->setEnabled(player_info->LUKUp <= statusPoints);
+
+ // Update labels
+ for (int i = 0; i < 6; i++) {
+ statsLabel[i]->setCaption(statsStr[i].str());
+ statsLabel[i]->adjustSize();
+ statsDisplayLabel[i]->setCaption(figureStr[i].str());
+ statsDisplayLabel[i]->adjustSize();
+ pointsLabel[i]->setCaption(pointsStr[i].str());
+ pointsLabel[i]->adjustSize();
+ }
+ remainingStatsPointsLabel->setCaption(updateText.str());
+ remainingStatsPointsLabel->adjustSize();
+
+ // Derived Stats Points
+
+ // Attack TODO: Count equipped Weapons and items attack bonuses
+ updateText.str("");
+ updateText << (10 + (int)player_info->STR);
+ statsAttackPoints->setCaption(updateText.str());
+ statsAttackPoints->adjustSize();
+
+ // Defense TODO: Count equipped Armors and items defense bonuses
+ updateText.str("");
+ updateText << (int)player_info->VIT;
+ statsDefensePoints->setCaption(updateText.str());
+ statsDefensePoints->adjustSize();
+
+ // Magic Attack TODO: Count equipped items M.Attack bonuses
+ updateText.str("");
+ updateText << (10 + (int)player_info->INT);
+ statsMagicAttackPoints->setCaption(updateText.str());
+ statsMagicAttackPoints->adjustSize();
- xpBar->setProgress((float)player_info->xp /
- (float)player_info->xpForNextLevel);
+ // Magic Defense TODO: Count equipped items M.Defense bonuses
+ updateText.str("");
+ updateText << (int)player_info->AGI;
+ statsMagicDefensePoints->setCaption(updateText.str());
+ statsMagicDefensePoints->adjustSize();
- jobXpBar->setProgress((float)player_info->job_xp /
- (float)player_info->jobXpForNextLevel);
+ // Accuracy %
+ updateText.str("");
+ updateText << (50 + (int)player_info->DEX + (int)player_info->AGI);
+ statsAccuracyPoints->setCaption(updateText.str());
+ statsAccuracyPoints->adjustSize();
+
+ // Evasion %
+ updateText.str("");
+ updateText << (((int)player_info->DEX / 2) + (int)player_info->AGI);
+ statsEvadePoints->setCaption(updateText.str());
+ statsEvadePoints->adjustSize();
+
+ // Reflex %
+ updateText.str("");
+ updateText << ((int)player_info->DEX / 4); // + counter
+ statsReflexPoints->setCaption(updateText.str());
+ statsReflexPoints->adjustSize();
- delete[] tempstr;
}
void StatusWindow::draw(gcn::Graphics *graphics)
@@ -217,24 +413,32 @@ void StatusWindow::draw(gcn::Graphics *graphics)
void StatusWindow::action(const std::string& eventId)
{
- if (eventId == "Stats") {
- // Show / Hide the stats dialog
- statsWindow->setVisible(!statsWindow->isVisible());
- }
- if (eventId == "Skills") {
- // Show / Hide the skills dialog
- skillDialog->setVisible(!skillDialog->isVisible());
- }
- if (eventId == "Inventory") {
- // Show / Hide the inventory dialog
- inventoryWindow->setVisible(!inventoryWindow->isVisible());
- }
- if (eventId == "Setup") {
- // Show / Hide the inventory dialog
- setupWindow->setVisible(!setupWindow->isVisible());
- }
- if (eventId == "Equipment") {
- // Show / Hide the inventory dialog
- equipmentWindow->setVisible(!equipmentWindow->isVisible());
+ // Stats Part
+ if ( eventId.length() == 3 )
+ {
+ writeWord(0, 0x00bb);
+
+ if (eventId == "STR") {
+ writeWord(2, 0x000d);
+ }
+ if (eventId == "AGI") {
+ writeWord(2, 0x000e);
+ }
+ if (eventId == "VIT") {
+ writeWord(2, 0x000f);
+ }
+ if (eventId == "INT") {
+ writeWord(2, 0x0010);
+ }
+ if (eventId == "DEX") {
+ writeWord(2, 0x0011);
+ }
+ if (eventId == "LUK") {
+ writeWord(2, 0x0012);
+ }
+
+ flush();
+ writeByte(4, 1);
+ writeSet(5);
}
}
diff --git a/src/gui/status.h b/src/gui/status.h
index 99fbadf5..3d9165af 100644
--- a/src/gui/status.h
+++ b/src/gui/status.h
@@ -21,8 +21,8 @@
* $Id$
*/
-#ifndef _TMW_STATS_H
-#define _TMW_STATS_H
+#ifndef _TMW_STATUS_H
+#define _TMW_STATUS_H
#include <iosfwd>
@@ -64,20 +64,46 @@ class StatusWindow : public Window, public gcn::ActionListener {
private:
/**
- * Updates this dialog with values from <code>player_info</code>
+ * Updates this dialog with values from PLAYER_INFO *char_info
*/
void update();
- gcn::Label *hp, *sp;
- gcn::Label *hpValue, *spValue;
- gcn::Label *expLabel, *jobExpLabel;
- ProgressBar *healthBar, *manaBar;
+ /**
+ * Status Part
+ */
+ gcn::Label *lvlLabel, *gpLabel, *hpLabel, *hpValueLabel, *mpLabel, *mpValueLabel;
+ gcn::Label *xpLabel, *xpValueLabel, *jobXpLabel, *jobValueLabel;
+ ProgressBar *hpBar, *mpBar;
ProgressBar *xpBar, *jobXpBar;
- gcn::Button *statsButton;
- gcn::Button *skillsButton;
- gcn::Button *inventoryButton;
- gcn::Button *setupButton;
- gcn::Button *equipmentButton;
+
+ /**
+ * Caracteristics Part
+ */
+ gcn::Label *statsTitleLabel, *statsTotalLabel, *statsCostLabel;
+
+ /**
+ * Derived Statistics captions
+ */
+ gcn::Label *statsAttackLabel, *statsDefenseLabel, *statsMagicAttackLabel;
+ gcn::Label *statsMagicDefenseLabel, *statsAccuracyLabel, *statsEvadeLabel;
+ gcn::Label *statsReflexLabel;
+
+ gcn::Label *statsAttackPoints, *statsDefensePoints, *statsMagicAttackPoints;
+ gcn::Label *statsMagicDefensePoints, *statsAccuracyPoints, *statsEvadePoints;
+ gcn::Label *statsReflexPoints;
+
+ /**
+ * Stats captions.
+ */
+ gcn::Label *statsLabel[6];
+ gcn::Label *pointsLabel[6];
+ gcn::Label *statsDisplayLabel[6];
+ gcn::Label *remainingStatsPointsLabel;
+
+ /**
+ * Stats buttons.
+ */
+ gcn::Button *statsButton[6];
};
extern StatusWindow *statusWindow;