summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMateusz Kaduk <mateusz.kaduk@gmail.com>2004-12-22 08:44:44 +0000
committerMateusz Kaduk <mateusz.kaduk@gmail.com>2004-12-22 08:44:44 +0000
commit008704e45a250522c82cc8ba118945e97e5bf17a (patch)
treee08db90f8363319e5241ef0c5b16820ef3a20c9b /src
parenta4a67125dfce17e8307bba6d283ed13d4bf542e7 (diff)
downloadmana-008704e45a250522c82cc8ba118945e97e5bf17a.tar.gz
mana-008704e45a250522c82cc8ba118945e97e5bf17a.tar.bz2
mana-008704e45a250522c82cc8ba118945e97e5bf17a.tar.xz
mana-008704e45a250522c82cc8ba118945e97e5bf17a.zip
- setup gets only called from game.cpp
- setup class changed
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp3
-rw-r--r--src/graphic/graphic.cpp3
-rw-r--r--src/gui/setup.cpp80
-rw-r--r--src/gui/setup.h21
4 files changed, 48 insertions, 59 deletions
diff --git a/src/game.cpp b/src/game.cpp
index f6da9a5b..0d6e95f9 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -48,7 +48,6 @@ volatile int tick_time;
volatile bool refresh = false, action_time = false;
int current_npc, server_tick;
extern unsigned char screen_mode;
-bool show_setup;
#define MAX_TIME 10000
@@ -239,7 +238,7 @@ void do_input() {
}
if(key[KEY_F11] && action_time==true)
- show_setup = true;
+ create_setup();
// Emotions, Skill dialog
if(key_shifts & KB_ALT_FLAG && action_time == true) {
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index d3d944a6..7ce2e93f 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -24,7 +24,6 @@
#include "graphic.h"
#include "2xsai.h"
#include "../gui/gui.h"
-#include "../gui/setup.h"
#include "../gui/stats.h"
#define TILESET_W 480
@@ -56,8 +55,6 @@ char npc_button[10] = "Close";
gcn::TextField *chatInput;
StatsDialog *statsDialog;
-Setup *setup;
-extern bool show_setup;
void ChatListener::action(const std::string& eventId)
{
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 07ade6d3..8e6e23d6 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -7,69 +7,67 @@
#include "setup.h"
-extern bool show_setup;
-
-/*
- * Setup action listener
- */
-void SetupActionListener::action(const std::string& eventId) {
- if(eventId == "apply") {
- puts("apply");
- show_setup = false;
- } else if (eventId == "cancel") {
- puts("calncel");
- show_setup = false;
- }
-}
-
/*
* Display setup dialog
*/
-Setup::Setup() {
- visible = false;
- setupDialog = new gcn::Container();
+Setup::Setup(gcn::Container *parent)
+ : Window(parent, "Setup")
+{
displayLabel = new gcn::Label("Display");
applyButton = new gcn::Button("Apply");
cancelButton = new gcn::Button("Cancel");
- /* Set dialog elements */
- setupDialog->setDimension(gcn::Rectangle(300,300,200,200));
- displayLabel->setPosition(4,14);
- applyButton->setPosition(30,162);
- cancelButton->setPosition(146,162);
+ /* Set dimension */
+ displayLabel->setDimension(gcn::Rectangle(0,0,128, 16));
+ applyButton->setDimension(gcn::Rectangle(0,0,128, 16));
+ cancelButton->setDimension(gcn::Rectangle(0,0,128, 16));
/* Set events */
applyButton->setEventId("apply");
cancelButton->setEventId("cancel");
+ /* Set position */
+ displayLabel->setPosition(10,10);
+ applyButton->setPosition(10,100);
+ cancelButton->setPosition(100,100);
+
/* Listen for actions */
- SetupActionListener *setupActionListener = new SetupActionListener();
- applyButton->addActionListener(setupActionListener);
- cancelButton->addActionListener(setupActionListener);
+ applyButton->addActionListener(this);
+ cancelButton->addActionListener(this);
/* Assemble dialog */
- setupDialog->add(displayLabel);
- setupDialog->add(applyButton);
- setupDialog->add(cancelButton);
-
- setupDialog->setVisible(visible);
- guiTop->add(setupDialog);
+ add(displayLabel);
+ add(applyButton);
+ add(cancelButton);
+
+ setSize(240,216);
+ setLocationRelativeTo(getParent());
}
Setup::~Setup() {
- delete setupDialog;
delete displayLabel;
delete applyButton;
delete cancelButton;
}
-void Setup::toggleVisible(bool toggle) {
- if (!visible && toggle) {
- visible = true;
- }
- else if (visible && !toggle) {
- visible = false;
- }
+void Setup::action(const std::string& eventId)
+{
+
+ if(eventId == "apply") {
+ puts("apply");
+ }
+ else if(eventId == "cancel") {
+ puts("cancel");
+ }
+}
+
+void create_setup() {
+ Setup *setup;
+ setup = new Setup(guiTop);
+
+ while(!key[KEY_ESC] && !key[KEY_ENTER]) {
+ gui_update(NULL);
+ }
- setupDialog->setVisible(visible);
+ delete setup;
}
diff --git a/src/gui/setup.h b/src/gui/setup.h
index bb211997..d94069a9 100644
--- a/src/gui/setup.h
+++ b/src/gui/setup.h
@@ -13,26 +13,21 @@
#include <winalleg.h>
#endif
-class Setup {
- public:
- Setup();
- ~Setup();
- void toggleVisible(bool toggle);
-
+class Setup : public Window, public gcn::ActionListener {
private:
- bool visible;
/* Dialog parts */
- gcn::Container *setupDialog;
gcn::Label *displayLabel;
gcn::Button *applyButton;
gcn::Button *cancelButton;
-};
-
-/* The action listener for setup dialog */
-class SetupActionListener : public gcn::ActionListener
-{
+
public:
+ Setup(gcn::Container *parent);
+ ~Setup();
+
void action(const std::string& eventId);
+
};
+void create_setup();
+
#endif