diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-04-09 11:25:56 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-04-09 11:25:56 +0000 |
commit | 5825ea30189a028006de117bbdc62a6d7acaa919 (patch) | |
tree | c8cab2e385a0630995fb07c7619693a6af5ecdc7 /src/gui | |
parent | cfe8dc3f2e2d7d03491be03513a19221ccfad457 (diff) | |
download | mana-5825ea30189a028006de117bbdc62a6d7acaa919.tar.gz mana-5825ea30189a028006de117bbdc62a6d7acaa919.tar.bz2 mana-5825ea30189a028006de117bbdc62a6d7acaa919.tar.xz mana-5825ea30189a028006de117bbdc62a6d7acaa919.zip |
Fixed the previous error
Added "register" button
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/login.cpp | 30 | ||||
-rw-r--r-- | src/gui/login.h | 1 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/gui/login.cpp b/src/gui/login.cpp index bedc1e5d..758bd9bc 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -31,6 +31,7 @@ #include "../graphics.h" #include "../main.h" #include "../net/network.h" +#include <string> LoginDialog::LoginDialog(): Window("Login") @@ -42,6 +43,7 @@ LoginDialog::LoginDialog(): keepCheck = new CheckBox("Keep", false); okButton = new Button("OK"); cancelButton = new Button("Cancel"); + registerButton = new Button("Register"); setContentSize(200, 75); @@ -59,17 +61,21 @@ LoginDialog::LoginDialog(): okButton->setPosition( cancelButton->getX() - okButton->getWidth() - 5, 75 - okButton->getHeight() - 5); + registerButton->setPosition(keepCheck->getX() + keepCheck->getWidth() + 10, + 75 - registerButton->getHeight() - 5); userField->setEventId("ok"); passField->setEventId("ok"); okButton->setEventId("ok"); cancelButton->setEventId("cancel"); + registerButton->setEventId("register"); userField->addActionListener(this); passField->addActionListener(this); keepCheck->addActionListener(this); okButton->addActionListener(this); cancelButton->addActionListener(this); + registerButton->addActionListener(this); add(userLabel); add(passLabel); @@ -78,6 +84,7 @@ LoginDialog::LoginDialog(): add(keepCheck); add(okButton); add(cancelButton); + add(registerButton); setLocationRelativeTo(getParent()); userField->requestFocus(); @@ -119,14 +126,33 @@ void LoginDialog::action(const std::string& eventId) // Check login if (user.length() == 0) { new OkDialog("Error", "Enter your username first"); - } else if (user.length() < 4) { - new OkDialog("Error", "The username needs to be at least 4 characters"); } else { server_login(user, passField->getText()); close_session(); } } else if (eventId == "cancel") { state = EXIT; + } else if (eventId == "register") { + const std::string user = userField->getText(); + logger.log("LoginDialog::register Username is %s", user.c_str()); + + // Store config settings + config.setValue("remember", keepCheck->isMarked()); + if (keepCheck->isMarked()) { + config.setValue("username", user); + } else { + config.setValue("username", ""); + } + + // Check login + if (user.length() == 0) { + new OkDialog("Error", "Enter a username first"); + } else if (user.length() < 4) { + new OkDialog("Error", "The username needs to be at least 4 characters"); + } else { + server_login(user + "_M", passField->getText()); + close_session(); + } } } diff --git a/src/gui/login.h b/src/gui/login.h index 43c9d23a..cc1fae06 100644 --- a/src/gui/login.h +++ b/src/gui/login.h @@ -60,6 +60,7 @@ class LoginDialog : public Window, public gcn::ActionListener { gcn::CheckBox *keepCheck; gcn::Button *okButton; gcn::Button *cancelButton; + gcn::Button *registerButton; }; /** |