summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMateusz Kaduk <mateusz.kaduk@gmail.com>2004-12-28 14:49:19 +0000
committerMateusz Kaduk <mateusz.kaduk@gmail.com>2004-12-28 14:49:19 +0000
commit40aba2bd075b3e8c32c03d87696646364c125803 (patch)
tree95b5d0d85b9b7e81d55a217d56a27cc06d112d13 /src
parent42e227d7f1523a5c11fd6fe3babd869f9041cce9 (diff)
downloadmana-40aba2bd075b3e8c32c03d87696646364c125803.tar.gz
mana-40aba2bd075b3e8c32c03d87696646364c125803.tar.bz2
mana-40aba2bd075b3e8c32c03d87696646364c125803.tar.xz
mana-40aba2bd075b3e8c32c03d87696646364c125803.zip
Added update method to stats
Added show/hide feature for stats
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp39
-rw-r--r--src/gui/stats.cpp67
-rw-r--r--src/gui/stats.h6
3 files changed, 77 insertions, 35 deletions
diff --git a/src/game.cpp b/src/game.cpp
index b66b863f..aff40d47 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -50,8 +50,10 @@ volatile int tick_time;
volatile bool refresh = false, action_time = false;
int current_npc, server_tick;
extern unsigned char screen_mode;
-Setup *setup;
-StatsWindow *stats;
+
+Setup *setup = NULL;
+StatsWindow *stats = NULL;
+bool show_stats;
#define MAX_TIME 10000
@@ -168,13 +170,13 @@ void do_exit() {
* Check user input
*/
void do_input() {
- if(walk_status==0) {
- int x = get_x(player_node->coordinates);
- int y = get_y(player_node->coordinates);
-
- if(key[KEY_8_PAD] || key[KEY_UP]) {
- if(get_walk(x, y-1)!=0) {
- walk(x, y-1, NORTH);
+ if(walk_status==0) {
+ int x = get_x(player_node->coordinates);
+ int y = get_y(player_node->coordinates);
+
+ if(key[KEY_8_PAD] || key[KEY_UP]) {
+ if(get_walk(x, y-1)!=0) {
+ walk(x, y-1, NORTH);
walk_status = 1;
src_x = x;
src_y = y;
@@ -285,17 +287,20 @@ void do_input() {
action_time = false;
}
}
-
+
if(key[KEY_S]) {
- //show_skill_dialog = !show_skill_dialog;
- stats = StatsWindow::create_statswindow();
- action_time = false;
+ show_stats = !show_stats;
+ if(stats == NULL)
+ stats = StatsWindow::create_statswindow();
+ else if(show_stats) stats->setVisible(true);
+ else if(!show_stats) stats->setVisible(false);
+ action_time = false;
} else if(key[KEY_I]) {
- inventoryWindow->setVisible(!inventoryWindow->isVisible());
- action_time = false;
+ inventoryWindow->setVisible(!inventoryWindow->isVisible());
+ action_time = false;
} else if(key[KEY_K]) {
- show_skill_list_dialog = !show_skill_dialog;
- action_time = false;
+ show_skill_list_dialog = !show_skill_dialog;
+ action_time = false;
}
}
diff --git a/src/gui/stats.cpp b/src/gui/stats.cpp
index 572d204f..fa927ee7 100644
--- a/src/gui/stats.cpp
+++ b/src/gui/stats.cpp
@@ -22,7 +22,8 @@
*/
#include "stats.h"
-#include <sstream>
+
+extern PLAYER_INFO *char_info;
/**
* Constructor
@@ -47,12 +48,6 @@ StatsWindow::StatsWindow(gcn::Container *parent)
for (i = 0; i < 6; i++)
statsButton[i] = new Button("+");
- /* Set position */
- for (i = 0; i < 6; 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");
@@ -61,6 +56,12 @@ StatsWindow::StatsWindow(gcn::Container *parent)
statsButton[4]->setEventId("DEX");
statsButton[5]->setEventId("LUK");
+ /* Set position */
+ for (i = 0; i < 6; i++) {
+ statsLabel[i]->setPosition(10,(i*22)+10);
+ statsButton[i]->setPosition(170,(i*22)+10);
+ }
+
/* Assemble */
for(i = 0; i < 6; i++) {
add(statsLabel[i]);
@@ -70,6 +71,23 @@ StatsWindow::StatsWindow(gcn::Container *parent)
setSize(200, 150);
setLocationRelativeTo(getParent());
}
+/**
+ * Method updates stats in window
+ */
+void StatsWindow::update(){
+ std::stringstream statsStr[6];
+
+ statsStr[0] << "Strenght: " << char_info->STR;
+ statsStr[1] << "Agility: " << char_info->AGI;
+ statsStr[2] << "Vitality: " << char_info->VIT;
+ statsStr[3] << "Inteligence: " << char_info->INT;
+ statsStr[4] << "Dexternity: " << char_info->DEX;
+ statsStr[5] << "Luck: " << char_info->LUK;
+
+ /* Update labels */
+ for (i = 0; i < 6; i++)
+ statsLabel[i]->setCaption(statsStr[i].str());
+}
/**
* Destructor
@@ -97,17 +115,30 @@ StatsWindow * StatsWindow::create_statswindow() {
* Event handling method
*/
void StatsWindow::action(const std::string& eventId) {
+ //TODO: update char_info
if (eventId == "STR") {
- setVisible(false);
+ puts("STR");
+ update();
+ }
+ if (eventId == "AGI") {
+ puts("AGI");
+ update();
+ }
+ if (eventId == "VIT") {
+ puts("VIT");
+ update();
+ }
+ if (eventId == "INT") {
+ puts("INT");
+ update();
+ }
+ if (eventId == "DEX") {
+ puts("DEX");
+ update();
+ }
+ if (eventId == "LUK") {
+ puts("LUK");
+ update();
}
- 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);
+ puts("default");
}
diff --git a/src/gui/stats.h b/src/gui/stats.h
index 27e83fd0..c58c837f 100644
--- a/src/gui/stats.h
+++ b/src/gui/stats.h
@@ -28,6 +28,7 @@
#include "window.h"
#include "../main.h"
#include <string>
+#include <sstream>
class StatsWindow : public Window, public gcn::ActionListener {
public:
@@ -41,6 +42,11 @@ class StatsWindow : public Window, public gcn::ActionListener {
*/
void action(const std::string& eventId);
+ /**
+ * Metod updates stats in window.
+ */
+ void update();
+
private:
int i;