summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2006-01-02 11:34:09 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2006-01-02 11:34:09 +0000
commit25d7576e6b10e5fa5c6981470d0ccd5f005e5650 (patch)
tree7caa7e6d6294efa410547adcfcb43236ac135920 /src/gui
parent6573cf6072c39396d2526edeff41449ea16e7288 (diff)
downloadmana-client-25d7576e6b10e5fa5c6981470d0ccd5f005e5650.tar.gz
mana-client-25d7576e6b10e5fa5c6981470d0ccd5f005e5650.tar.bz2
mana-client-25d7576e6b10e5fa5c6981470d0ccd5f005e5650.tar.xz
mana-client-25d7576e6b10e5fa5c6981470d0ccd5f005e5650.zip
Smoothed also character creation, buttons are now disabled during connection/data phase.
Diffstat (limited to 'src/gui')
-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
5 files changed, 43 insertions, 6 deletions
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;
}
}