summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-13 02:55:05 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-13 02:55:05 +0000
commit682d6a9e44e583c088ed5970d69ef6bd9db7fd23 (patch)
tree73079cdd7d9b57d104c8db400f09aabc3d833122 /src/gui
parent3657bf87641144b605d49767cf466f04242c29c9 (diff)
downloadmana-682d6a9e44e583c088ed5970d69ef6bd9db7fd23.tar.gz
mana-682d6a9e44e583c088ed5970d69ef6bd9db7fd23.tar.bz2
mana-682d6a9e44e583c088ed5970d69ef6bd9db7fd23.tar.xz
mana-682d6a9e44e583c088ed5970d69ef6bd9db7fd23.zip
Got rid of Allegro ok dialog completely. Now just the yes_no dialog remaining.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/char_select.cpp3
-rw-r--r--src/gui/gui.cpp22
-rw-r--r--src/gui/gui.h3
-rw-r--r--src/gui/login.cpp7
-rw-r--r--src/gui/ok_dialog.cpp14
-rw-r--r--src/gui/ok_dialog.h8
-rw-r--r--src/gui/setup.cpp3
7 files changed, 21 insertions, 39 deletions
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index ebf439b1..30c2d2f3 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -219,7 +219,8 @@ void CharSelectDialog::serverCharSelect()
log("CharSelect", "Server: %s:%d", iptostring(map_address), map_port);
RFIFOSKIP(28);
close_session();
- } else if (RFIFOW(0) == 0x006c) {
+ }
+ else if (RFIFOW(0) == 0x006c) {
switch (RFIFOB(2)) {
case 0:
new OkDialog(this, "Error", "Access denied");
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index dac21c00..2a59370f 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -731,28 +731,6 @@ int tmw_dialog_proc(int msg, DIALOG *d, int c) {
return D_O_K;
}
-void ok(const char *title, const char *message) {
- DIALOG alert_dialog[] = {
- /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
- { tmw_dialog_proc, 0, 0, 0, 60, 0, -1, 0, 0, 0, 0, (void *)title, NULL, NULL },
- { tmw_text_proc, 2, 22, 0, 0, 0, 0, 0, 0, 0, 0, (void *)message, NULL, NULL },
- { tmw_button_proc, 0, 40, 44, 18, 0, -1, 'o', D_EXIT, -1, 0, (char *)"&Ok", NULL, NULL },
- { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
- };
-
- BITMAP *temp = gui_bitmap;
- gui_bitmap = screen;
- show_mouse(screen);
- alert_dialog[0].w = text_length(font, message) + 4;
- alert_dialog[1].w = text_length(font, message);
- alert_dialog[1].h = text_height(font);
- alert_dialog[2].x = text_length(font, message) / 2 - 22;
- position_dialog(alert_dialog, 400 - alert_dialog[0].w / 2, 270);
- do_dialog(alert_dialog, 2);
- show_mouse(NULL);
- gui_bitmap = temp;
-}
-
unsigned int yes_no(const char *title, const char *message) {
unsigned int ret;
DIALOG alert_dialog[] = {
diff --git a/src/gui/gui.h b/src/gui/gui.h
index e3a77f31..504c9ceb 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -187,8 +187,7 @@ int tmw_button_proc(int msg, DIALOG *d, int c);
int tmw_text_proc(int msg, DIALOG *d, int c);
int tmw_dialog_proc(int msg, DIALOG *d, int c);
-// Last two remaining Allegro GUI dialogs
-void ok(const char *title, const char *message);
+// Last remaining Allegro GUI dialog
unsigned int yes_no(const char *title, const char *message);
#endif
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 08276562..b1e8b43e 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -116,9 +116,7 @@ void LoginDialog::action(const std::string& eventId)
// Check login
if (user.length() == 0) {
- ok("Error", "Enter your username first");
- warning("Enter your username first");
- state = LOGIN;
+ new OkDialog("Error", "Enter your username first");
} else {
server_login(user, passField->getText());
close_session();
@@ -157,8 +155,7 @@ void server_login(const std::string& user, const std::string& pass) {
if (ret == SOCKET_ERROR) {
state = LOGIN;
- ok("Error", "Unable to connect to login server");
- warning("Unable to connect to login server");
+ new OkDialog("Error", "Unable to connect to login server");
return;
}
diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp
index 54ddf3e9..9164cfa3 100644
--- a/src/gui/ok_dialog.cpp
+++ b/src/gui/ok_dialog.cpp
@@ -24,20 +24,21 @@
#include "ok_dialog.h"
#include "button.h"
-OkDialog::OkDialog(const std::string &title, const std::string &msg):
+OkDialog::OkDialog(const std::string &title, const std::string &msg,
+ gcn::ActionListener *listener):
Window(title, true)
{
- init(msg);
+ init(msg, listener);
}
OkDialog::OkDialog(Window *parent, const std::string &title,
- const std::string &msg):
+ const std::string &msg, gcn::ActionListener *listener):
Window(title, true, parent)
{
- init(msg);
+ init(msg, listener);
}
-void OkDialog::init(const std::string &msg)
+void OkDialog::init(const std::string &msg, gcn::ActionListener *listener)
{
userLabel = new gcn::Label(msg);
okButton = new Button("OK");
@@ -57,6 +58,9 @@ void OkDialog::init(const std::string &msg)
okButton->setEventId("ok");
okButton->addActionListener(this);
+ if (listener) {
+ okButton->addActionListener(listener);
+ }
add(userLabel);
add(okButton);
diff --git a/src/gui/ok_dialog.h b/src/gui/ok_dialog.h
index 95ae52da..bb1a4e58 100644
--- a/src/gui/ok_dialog.h
+++ b/src/gui/ok_dialog.h
@@ -39,7 +39,8 @@ class OkDialog : public Window, public gcn::ActionListener {
*
* @see Window::Window
*/
- OkDialog(const std::string &title, const std::string &msg);
+ OkDialog(const std::string &title, const std::string &msg,
+ gcn::ActionListener *listener = NULL);
/**
* Constructor with parent reference.
@@ -47,7 +48,8 @@ class OkDialog : public Window, public gcn::ActionListener {
* @see Window::Window
*/
OkDialog(Window *window, const std::string &title,
- const std::string &msg);
+ const std::string &msg,
+ gcn::ActionListener *listener = NULL);
/**
* Destructor.
@@ -63,7 +65,7 @@ class OkDialog : public Window, public gcn::ActionListener {
/**
* Initializes the dialog.
*/
- void init(const std::string &msg);
+ void init(const std::string &msg, gcn::ActionListener *listener);
gcn::Label *userLabel;
gcn::Button *okButton;
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 89f7e0a4..589935be 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -32,6 +32,7 @@
#include "scrollarea.h"
#include "listbox.h"
#include "radiobutton.h"
+#include "ok_dialog.h"
#ifndef WIN32
extern Sound sound;
@@ -158,7 +159,7 @@ void Setup::action(const std::string& eventId)
sound.init(32, 20);
}
catch (const char *err) {
- ok("Sound Engine", err);
+ new OkDialog(this, "Sound Engine", err);
warning(err);
}
} else {