From add62901031e1c981d98779536a0ad16ceddf897 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Tue, 25 Jan 2005 22:25:29 +0000 Subject: *** empty log message *** --- src/graphic/graphic.cpp | 3 +-- src/gui/status.cpp | 24 ++++++++++++++++++++++++ src/gui/status.h | 9 ++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp index c5bed789..8cd117b9 100644 --- a/src/graphic/graphic.cpp +++ b/src/graphic/graphic.cpp @@ -235,7 +235,7 @@ Engine::Engine() // Create dialogs statusWindow = new StatusWindow(); - statusWindow->setPosition(screen->w - statusWindow->getWidth() - 10, 10); + statusWindow->setPosition(screen->w - statusWindow->getWidth(), 0); buyDialog = new BuyDialog(); buyDialog->setVisible(false); @@ -262,7 +262,6 @@ Engine::Engine() statsWindow = new StatsWindow(); statsWindow->setVisible(false); - // Give focus to the chat input chatInput->requestFocus(); diff --git a/src/gui/status.cpp b/src/gui/status.cpp index 40b7d8c4..e5482f09 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -40,8 +40,16 @@ StatusWindow::StatusWindow(): 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); hp->setPosition(WIN_BORDER, WIN_BORDER); sp->setPosition(WIN_BORDER, hp->getY() + hp->getHeight() + CONTROLS_SEPARATOR); @@ -150,3 +158,19 @@ void StatusWindow::update() delete[] tempstr; } + +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()); + } +} diff --git a/src/gui/status.h b/src/gui/status.h index 4f16ef23..7406f977 100644 --- a/src/gui/status.h +++ b/src/gui/status.h @@ -24,6 +24,8 @@ #ifndef _TMW_STATS_H #define _TMW_STATS_H +#include + #include "window.h" #include "progressbar.h" @@ -32,7 +34,7 @@ * * \ingroup GUI */ -class StatusWindow : public Window { +class StatusWindow : public Window, public gcn::ActionListener { public: /** * Constructor. @@ -44,6 +46,11 @@ class StatusWindow : public Window { */ ~StatusWindow(); + /** + * Called when receiving actions from widget. + */ + void action(const std::string& eventId); + /** * Updates this dialog with values from PLAYER_INFO *char_info */ -- cgit v1.2.3-60-g2f50