summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--src/gui/char_select.cpp29
-rw-r--r--src/gui/char_select.h14
-rw-r--r--src/gui/char_server.cpp2
-rw-r--r--src/gui/login.cpp3
-rw-r--r--src/gui/register.cpp1
6 files changed, 50 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 655cd4b4..2832196b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-01-02 Eugenio Favalli <elvenprogrammer@gmail.com>
+
+ * src/gui/char_select.cpp, src/gui/char_select.h,
+ src/gui/char_server.cpp, src/gui/login.cpp, src/gui/register.cpp:
+ Smoothed also character creation, buttons are now disabled during
+ connection/data phase.
+
2006-01-01 Björn Steinbrink <B.Steinbrink@gmx.de>
* src/gui/login.cpp, src/gui/login.h: Remove tracking of OkDialog, the
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index 734ed766..7ac76854 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -124,6 +124,9 @@ void CharSelectDialog::action(const std::string& eventId)
if (eventId == "ok" && n_character > 0) {
// Start game
attemptCharSelect();
+ newCharButton->setEnabled(false);
+ delCharButton->setEnabled(false);
+ selectButton->setEnabled(false);
mStatus = 1;
}
else if (eventId == "cancel") {
@@ -303,7 +306,7 @@ void CharSelectDialog::logic()
}
CharCreateDialog::CharCreateDialog(Window *parent):
- Window("Create Character", true, parent)
+ Window("Create Character", true, parent), mStatus(0)
{
nameField = new TextField("");
nameLabel = new gcn::Label("Name:");
@@ -369,12 +372,29 @@ CharCreateDialog::CharCreateDialog(Window *parent):
setLocationRelativeTo(getParent());
}
+void CharCreateDialog::logic()
+{
+ if (mStatus == 1)
+ {
+ if (packetReady())
+ {
+ checkCharCreate();
+ }
+ else
+ {
+ flush();
+ }
+ }
+}
+
void CharCreateDialog::action(const std::string& eventId)
{
if (eventId == "create") {
if (getName().length() >= 4) {
// Attempt to create the character
- serverCharCreate();
+ attemptCharCreate();
+ createButton->setEnabled(false);
+ mStatus = 1;
}
else {
new OkDialog(this, "Error",
@@ -406,7 +426,7 @@ std::string CharCreateDialog::getName()
return nameField->getText();
}
-void CharCreateDialog::serverCharCreate()
+void CharCreateDialog::attemptCharCreate()
{
// Send character infos
MessageOut outMsg;
@@ -421,7 +441,10 @@ void CharCreateDialog::serverCharCreate()
outMsg.writeInt8(0);
outMsg.writeInt16(playerBox->hairColor + 1);
outMsg.writeInt16(playerBox->hairStyle + 1);
+}
+void CharCreateDialog::checkCharCreate()
+{
MessageIn msg = get_next_message();
if (msg.getId() == 0x006d)
diff --git a/src/gui/char_select.h b/src/gui/char_select.h
index 3692c1e4..a00ada26 100644
--- a/src/gui/char_select.h
+++ b/src/gui/char_select.h
@@ -108,6 +108,8 @@ class CharCreateDialog : public Window, public gcn::ActionListener
* Constructor.
*/
CharCreateDialog(Window *parent = NULL);
+
+ void logic();
void action(const std::string& eventId);
@@ -126,12 +128,18 @@ class CharCreateDialog : public Window, public gcn::ActionListener
gcn::Button *cancelButton;
PlayerBox *playerBox;
+
+ int mStatus;
/**
- * Communicate character creation to the server and receive new char
- * info.
+ * Communicate character creation to the server.
+ */
+ void attemptCharCreate();
+
+ /**
+ * Receive new char info.
*/
- void serverCharCreate();
+ void checkCharCreate();
};
void charSelectInputHandler(SDL_KeyboardEvent *keyEvent);
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index 52b26b9f..40b229a1 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -102,6 +102,8 @@ ServerSelectDialog::action(const std::string& eventId)
const char *host = iptostring(server_info[index]->address);
short port = server_info[index]->port;
openConnection(host, port);
+ okButton->setEnabled(false);
+ //cancelButton->setEnabled(false);
mStatus = NET_CONNECTING;
}
else if (eventId == "cancel") {
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 722911ca..b24c4629 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -183,6 +183,9 @@ LoginDialog::action(const std::string& eventId)
short port = (short)config.getValue("port", 0);
// Attempt to connect to login server
openConnection(host.c_str(), port);
+ okButton->setEnabled(false);
+ //cancelButton->setEnabled(false);
+ registerButton->setEnabled(false);
mStatus = NET_CONNECTING;
}
}
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index 3e03b59e..71d1a740 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -225,6 +225,7 @@ RegisterDialog::action(const std::string& eventId)
short port = (short)config.getValue("port", 0);
// Attempt to connect to login server
openConnection(host.c_str(), port);
+ registerButton->setEnabled(false);
mStatus = NET_CONNECTING;
}
}