summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/gui/stats.cpp87
-rw-r--r--src/gui/stats.h44
3 files changed, 132 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 482168c6..052050fc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,6 +24,7 @@ tmw_SOURCES = sound/sound.cpp \
gui/skill.cpp \
gui/slider.cpp \
gui/status.cpp \
+ gui/stats.cpp \
gui/textfield.cpp \
gui/window.cpp \
net/network.cpp \
diff --git a/src/gui/stats.cpp b/src/gui/stats.cpp
new file mode 100644
index 00000000..3a1a206f
--- /dev/null
+++ b/src/gui/stats.cpp
@@ -0,0 +1,87 @@
+#include "stats_window.h"
+
+/*
+ * Constructor
+ */
+StatsWindow::StatsWindow(gcn::Container *parent)
+ : Window(parent, "Stats")
+{
+ stats_str[0] << "Strenght: " << char_info->STR;
+ stats_str[1] << "Agility: " << char_info->AGI;
+ stats_str[2] << "Vitality: " << char_info->VIT;
+ stats_str[3] << "Inteligence: " << char_info->INT;
+ stats_str[4] << "Dexternity: " << char_info->DEX;
+ stats_str[5] << "Luck: " << char_info->LUK;
+
+ /* New labels */
+ for(int i=0; i<5;i++)
+ statsLabel[i] = new gcn::Label(stats_str[i]);
+
+ /* New buttons */
+ for(i=0; i<5;i++)
+ statsButton[i] = new Button("+");
+
+ /* Set position */
+ for(i=0;i<5;i++) {
+ statsLabel[i]->setPosition(10,(i*22)+10);
+ statsButton[i]->setPosition(170,(i*22)+10);
+ }
+
+ /* 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");
+
+ /* Assemble */
+ for(i=0; i<5; i++) {
+ add(statsLabel[i]);
+ add(statsButton[i]);
+ }
+
+ setSize(200,150);
+ setLocationRelativeTo(getParent());
+}
+
+/*
+ * Destructor
+ */
+StatsWindow::~StatsWindow() {
+ for(int i=0; i<5; i++) {
+ delete statsStr[i];
+ delete statsLabel[i];
+ delete statsButton[i];
+ }
+}
+
+/*
+ * Static method for creating singleton objects
+ */
+StatsWindow * StatsWindow::ptr = NULL;
+StatsWindow * StatsWindow::create_statswindow() {
+ if(ptr == NULL)
+ ptr = new StatsWindow(guiTop);
+ else
+ ptr->setVisible(true);
+ return ptr;
+}
+
+/*
+ * Event handling method
+ */
+void StatsWindow::action(const std::string& eventId) {
+ if(eventId == "STR")
+ setVisible(false);
+ if(eventId == "AGI")
+ setVisible(false);
+ if(eventId == "VIT")
+ setVisible(false);
+ if(eventId == "INT")
+ setVisible(false);
+ if(eventId == "DEX")
+ setVisible(false);
+ if(eventId == "LUK")
+ setVisible(false);
+}
diff --git a/src/gui/stats.h b/src/gui/stats.h
new file mode 100644
index 00000000..9f716ef4
--- /dev/null
+++ b/src/gui/stats.h
@@ -0,0 +1,44 @@
+#ifndef _STATS_WINDOW_H
+#define _STATS_WINDOW_H
+
+#include "button.h"
+#include "window.h"
+#include "main.h"
+
+class StatsWindow : public Window, public gcn::ActionListener {
+ public:
+ /*
+ * Create the Stats window
+ */
+ static StatsWindow *create_statswindow();
+
+ /*
+ * Metod called when receiving actions from widget.
+ */
+ void action(const std::string& eventId);
+
+ private:
+ /* Stats values */
+ std::string statsStr[5];
+
+ /* Stats captions */
+ gcn::Label *statsLabel[5];
+
+ /* Stats buttons */
+ Button *statsButton[5];
+
+ /* Stats window ptr */
+ static StatsWindow *ptr;
+
+ /*
+ * Constructor.
+ */
+ StatsWindow(gcn::Container *parent);
+
+ /*
+ * Destructor.
+ */
+ virtual ~StatsWindow();
+};
+
+#endif /* _STATS_Window_H */