summaryrefslogtreecommitdiff
path: root/src/gui/char_select.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-03-22 23:53:13 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-03-22 23:53:13 +0000
commit82c7ecf7a838c43771a676bb9311f9a1fc403f67 (patch)
treeb7bb6316c5b1f9da06f75d7dbb0f13b2c4aaa259 /src/gui/char_select.cpp
parentf6bd7da487f163d8ce6fa6975229715f11e1c3bb (diff)
downloadMana-82c7ecf7a838c43771a676bb9311f9a1fc403f67.tar.gz
Mana-82c7ecf7a838c43771a676bb9311f9a1fc403f67.tar.bz2
Mana-82c7ecf7a838c43771a676bb9311f9a1fc403f67.tar.xz
Mana-82c7ecf7a838c43771a676bb9311f9a1fc403f67.zip
Clarified the error message when character creation fails and made sure the
character creation dialog doesn't close when creation failed.
Diffstat (limited to 'src/gui/char_select.cpp')
-rw-r--r--src/gui/char_select.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index eb9ce31d..845c6d64 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -37,10 +37,14 @@
#include "../localplayer.h"
#include "../main.h"
+#include "../net/charserverhandler.h"
#include "../net/messageout.h"
#include "../utils/tostring.h"
+// Defined in main.cpp, used here for setting the char create dialog
+extern CharServerHandler charServerHandler;
+
/**
* Listener for confirming character deletion.
*/
@@ -144,15 +148,14 @@ void CharSelectDialog::action(const gcn::ActionEvent &event)
{
state = EXIT_STATE;
}
- else if (event.getId() == "new")
+ else if (event.getId() == "new" && n_character <= MAX_SLOT)
{
- if (n_character < MAX_SLOT + 1)
- {
- // Start new character dialog
- mCharInfo->lock();
+ // Start new character dialog
+ mCharInfo->lock();
+ CharCreateDialog *charCreateDialog =
new CharCreateDialog(this, mCharInfo->getPos(), mNetwork, mSex);
- mCharInfo->unlock();
- }
+ charServerHandler.setCharCreateDialog(charCreateDialog);
+ mCharInfo->unlock();
}
else if (event.getId() == "delete")
{
@@ -312,21 +315,25 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network,
setLocationRelativeTo(getParent());
setVisible(true);
+ mNameField->requestFocus();
}
CharCreateDialog::~CharCreateDialog()
{
delete mPlayer;
+
+ // Make sure the char server handler knows that we're gone
+ charServerHandler.setCharCreateDialog(0);
}
-void CharCreateDialog::action(const gcn::ActionEvent &event)
+void
+CharCreateDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "create") {
if (getName().length() >= 4) {
// Attempt to create the character
mCreateButton->setEnabled(false);
attemptCharCreate();
- scheduleDelete();
}
else {
new OkDialog("Error",
@@ -352,12 +359,20 @@ void CharCreateDialog::action(const gcn::ActionEvent &event)
}
}
-std::string CharCreateDialog::getName()
+const std::string&
+CharCreateDialog::getName()
{
return mNameField->getText();
}
-void CharCreateDialog::attemptCharCreate()
+void
+CharCreateDialog::unlock()
+{
+ mCreateButton->setEnabled(true);
+}
+
+void
+CharCreateDialog::attemptCharCreate()
{
// Send character infos
MessageOut outMsg(mNetwork);