summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-01-30 02:04:39 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-01-30 02:04:39 +0000
commit093d95683bfcbbff6e0ddd87414e2cd723f17dc9 (patch)
treec6d07ce0bb312c7e4d7e165ee5c1cb348a6e44fa
parent69ccb03b44f324f17d02b9e27e71c34850f71139 (diff)
downloadmana-client-093d95683bfcbbff6e0ddd87414e2cd723f17dc9.tar.gz
mana-client-093d95683bfcbbff6e0ddd87414e2cd723f17dc9.tar.bz2
mana-client-093d95683bfcbbff6e0ddd87414e2cd723f17dc9.tar.xz
mana-client-093d95683bfcbbff6e0ddd87414e2cd723f17dc9.zip
A few cleanups and simplifications.
-rw-r--r--ChangeLog8
-rw-r--r--src/gui/char_select.cpp13
-rw-r--r--src/gui/confirm_dialog.cpp24
-rw-r--r--src/gui/confirm_dialog.h22
-rw-r--r--src/gui/error.cpp4
-rw-r--r--src/gui/error.h5
-rw-r--r--src/gui/ministatus.cpp2
-rw-r--r--src/gui/ok_dialog.cpp27
-rw-r--r--src/gui/ok_dialog.h25
-rw-r--r--src/gui/setup.cpp10
-rw-r--r--src/net/charserverhandler.cpp6
11 files changed, 37 insertions, 109 deletions
diff --git a/ChangeLog b/ChangeLog
index 37089f9d..7f2a81c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-01-39 Björn Steinbrink <B.Steinbrink@gmx.de>
+
+ * src/gui/char_select.cpp, src/gui/confirm_dialog.cpp,
+ src/gui/confirm_dialog.h, src/gui/error.cpp, src/gui/error.h,
+ src/gui/ministatus.cpp, src/gui/ok_dialog.cpp, src/gui/ok_dialog.h,
+ src/gui/setup.cpp, src/net/charserverhandler.cpp: A few cleanups and
+ simplifications.
+
2006-01-26 Björn Steinbrink <B.Steinbrink@gmx.de>
* src/game.cpp, src/game.h, src/main.cpp: Moved some setup code out of
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index b86a01e3..e3f4766e 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -33,7 +33,6 @@
#include "ok_dialog.h"
#include "playerbox.h"
#include "textfield.h"
-#include "windowcontainer.h"
#include "../game.h"
#include "../localplayer.h"
@@ -54,8 +53,8 @@ class CharDeleteConfirm : public ConfirmDialog
};
CharDeleteConfirm::CharDeleteConfirm(CharSelectDialog *m):
- ConfirmDialog(m,
- "Confirm", "Are you sure you want to delete this character?"),
+ ConfirmDialog("Confirm", "Are you sure you want to delete this character?",
+ NULL, m),
master(m)
{
}
@@ -316,15 +315,15 @@ void CharCreateDialog::action(const std::string& eventId)
// Attempt to create the character
createButton->setEnabled(false);
attemptCharCreate();
- windowContainer->scheduleDelete(this);
+ scheduleDelete();
}
else {
- new OkDialog(this, "Error",
- "Your name needs to be at least 4 characters.");
+ new OkDialog("Error",
+ "Your name needs to be at least 4 characters.", NULL, this);
}
}
else if (eventId == "cancel") {
- windowContainer->scheduleDelete(this);
+ scheduleDelete();
}
else if (eventId == "nextcolor") {
playerBox->hairColor++;
diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp
index 59d48318..2babbf23 100644
--- a/src/gui/confirm_dialog.cpp
+++ b/src/gui/confirm_dialog.cpp
@@ -26,28 +26,15 @@
#include <guichan/widgets/label.hpp>
#include "button.h"
-#include "windowcontainer.h"
ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
- gcn::ActionListener *listener):
- Window(title, true)
-{
- init(msg, listener);
-}
-
-ConfirmDialog::ConfirmDialog(Window *parent, const std::string &title,
- const std::string &msg, gcn::ActionListener *listener):
+ gcn::ActionListener *listener, Window *parent):
Window(title, true, parent)
{
- init(msg, listener);
-}
-
-void ConfirmDialog::init(const std::string &msg, gcn::ActionListener *listener)
-{
- textLabel = new gcn::Label(msg);
- yesButton = new Button("Yes");
- noButton = new Button("No");
+ gcn::Label *textLabel = new gcn::Label(msg);
+ gcn::Button *yesButton = new Button("Yes");
+ gcn::Button *noButton = new Button("No");
int w = textLabel->getWidth() + 20;
int inWidth = yesButton->getWidth() + noButton->getWidth() + 5;
@@ -88,7 +75,8 @@ void ConfirmDialog::init(const std::string &msg, gcn::ActionListener *listener)
void ConfirmDialog::action(const std::string &eventId)
{
+ // Can we receive anything else anyway?
if (eventId == "yes" || eventId == "no") {
- windowContainer->scheduleDelete(this);
+ scheduleDelete();
}
}
diff --git a/src/gui/confirm_dialog.h b/src/gui/confirm_dialog.h
index 8f444057..e3638439 100644
--- a/src/gui/confirm_dialog.h
+++ b/src/gui/confirm_dialog.h
@@ -44,32 +44,12 @@ class ConfirmDialog : public Window, public gcn::ActionListener {
* @see Window::Window
*/
ConfirmDialog(const std::string &title, const std::string &msg,
- gcn::ActionListener *listener = NULL);
-
- /**
- * Constructor with parent reference.
- *
- * @see Window::Window
- */
- ConfirmDialog(Window *window, const std::string &title,
- const std::string &msg,
- gcn::ActionListener *listener = NULL);
+ gcn::ActionListener *listener = NULL, Window *parent = NULL);
/**
* Called when receiving actions from the widgets.
*/
void action(const std::string& eventId);
-
- gcn::Button *yesButton;
- gcn::Button *noButton;
-
- private:
- /**
- * Initializes the dialog.
- */
- void init(const std::string &msg, gcn::ActionListener *listener);
-
- gcn::Label *textLabel;
};
#endif
diff --git a/src/gui/error.cpp b/src/gui/error.cpp
index 4a980caa..3d33c665 100644
--- a/src/gui/error.cpp
+++ b/src/gui/error.cpp
@@ -30,10 +30,6 @@ ErrorDialog::ErrorDialog(const std::string &msg):
{
}
-ErrorDialog::~ErrorDialog()
-{
-}
-
void ErrorDialog::action(const std::string& eventId)
{
if (eventId == "ok")
diff --git a/src/gui/error.h b/src/gui/error.h
index feb864f2..20544358 100644
--- a/src/gui/error.h
+++ b/src/gui/error.h
@@ -43,11 +43,6 @@ class ErrorDialog : public OkDialog {
ErrorDialog(const std::string &msg);
/**
- * Destructor
- */
- ~ErrorDialog();
-
- /**
* Called when receiving actions from the widgets.
*/
void action(const std::string& eventId);
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index 515a4014..f83b3724 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -23,11 +23,11 @@
#include "ministatus.h"
+#include <guichan/imagefont.hpp>
#include <guichan/widgets/label.hpp>
#include <sstream>
#include "gui.h"
-#include <guichan/imagefont.hpp>
#include "progressbar.h"
#include "../localplayer.h"
diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp
index aca42972..2e2594d1 100644
--- a/src/gui/ok_dialog.cpp
+++ b/src/gui/ok_dialog.cpp
@@ -26,30 +26,14 @@
#include <guichan/widgets/label.hpp>
#include "button.h"
-#include "windowcontainer.h"
-OkDialog::OkDialog(const std::string &title, const std::string &msg,
- gcn::ActionListener *listener):
- Window(title, true)
-{
- init(msg, listener);
-}
-OkDialog::OkDialog(Window *parent, const std::string &title,
- const std::string &msg, gcn::ActionListener *listener):
+OkDialog::OkDialog(const std::string &title, const std::string &msg,
+ gcn::ActionListener *listener, Window *parent):
Window(title, true, parent)
{
- init(msg, listener);
-}
-
-OkDialog::~OkDialog()
-{
-}
-
-void OkDialog::init(const std::string &msg, gcn::ActionListener *listener)
-{
- textLabel = new gcn::Label(msg);
- okButton = new Button("Ok");
+ gcn::Label *textLabel = new gcn::Label(msg);
+ gcn::Button *okButton = new Button("Ok");
int w = textLabel->getWidth() + 20;
int h = textLabel->getHeight() + 25 + okButton->getHeight();
@@ -78,7 +62,8 @@ void OkDialog::init(const std::string &msg, gcn::ActionListener *listener)
void OkDialog::action(const std::string &eventId)
{
+ // Can we receive anything else anyway?
if (eventId == "ok") {
- windowContainer->scheduleDelete(this);
+ scheduleDelete();
}
}
diff --git a/src/gui/ok_dialog.h b/src/gui/ok_dialog.h
index b5c792b1..4eac77de 100644
--- a/src/gui/ok_dialog.h
+++ b/src/gui/ok_dialog.h
@@ -43,35 +43,12 @@ class OkDialog : public Window, public gcn::ActionListener {
* @see Window::Window
*/
OkDialog(const std::string &title, const std::string &msg,
- gcn::ActionListener *listener = NULL);
-
- /**
- * Constructor with parent reference.
- *
- * @see Window::Window
- */
- OkDialog(Window *window, const std::string &title,
- const std::string &msg,
- gcn::ActionListener *listener = NULL);
-
- /**
- * Destructor.
- */
- ~OkDialog();
+ gcn::ActionListener *listener = NULL, Window *parent = NULL);
/**
* Called when receiving actions from the widgets.
*/
void action(const std::string& eventId);
-
- private:
- /**
- * Initializes the dialog.
- */
- void init(const std::string &msg, gcn::ActionListener *listener);
-
- gcn::Label *textLabel;
- gcn::Button *okButton;
};
#endif
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 34f5b360..cbb9d599 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -314,8 +314,8 @@ void Setup::action(const std::string &eventId)
}
}
} else {
- new OkDialog(this, "Switching to FullScreen",
- "Restart needed for changes to take effect.");
+ new OkDialog("Switching to FullScreen",
+ "Restart needed for changes to take effect.", NULL, this);
}
config.setValue("screen", fullscreen ? 1 : 0);
}
@@ -329,7 +329,7 @@ void Setup::action(const std::string &eventId)
}
catch (const char *err)
{
- new OkDialog(this, "Sound Engine", err);
+ new OkDialog("Sound Engine", err, NULL, this);
logger->log("Warning: %s", err);
}
}
@@ -345,8 +345,8 @@ void Setup::action(const std::string &eventId)
config.setValue("opengl", openGLCheckBox->isMarked() ? 1 : 0);
// OpenGL can currently only be changed by restarting, notify user.
- new OkDialog(this, "Changing OpenGL",
- "Applying change to OpenGL requires restart.");
+ new OkDialog("Changing OpenGL",
+ "Applying change to OpenGL requires restart.", NULL, this);
}
// We sync old and new values at apply time
diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp
index a60e39b0..e7fe3955 100644
--- a/src/net/charserverhandler.cpp
+++ b/src/net/charserverhandler.cpp
@@ -102,7 +102,7 @@ void CharServerHandler::handleMessage(MessageIn *msg)
break;
case 0x006e:
- new OkDialog(NULL, "Error", "Failed to create character");
+ new OkDialog("Error", "Failed to create character");
break;
case 0x006f:
@@ -110,12 +110,12 @@ void CharServerHandler::handleMessage(MessageIn *msg)
mCharInfo->setEntry(0);
mCharInfo->unlock();
n_character--;
- new OkDialog(NULL, "Info", "Player deleted");
+ new OkDialog("Info", "Player deleted");
break;
case 0x0070:
mCharInfo->unlock();
- new OkDialog(NULL, "Error", "Failed to delete character.");
+ new OkDialog("Error", "Failed to delete character.");
break;
case 0x0071: