summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-02-03 13:57:34 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-02-03 13:57:34 +0000
commit9dc99e1888de6194c7ce555c33245e6bff586b3d (patch)
tree39b4159d2a56976474da4cc4659e5dd04f1cfa25 /src/gui
parentf8d16a36db8f9d1f22f3a15d2fbee19b7c68ebef (diff)
downloadmana-client-9dc99e1888de6194c7ce555c33245e6bff586b3d.tar.gz
mana-client-9dc99e1888de6194c7ce555c33245e6bff586b3d.tar.bz2
mana-client-9dc99e1888de6194c7ce555c33245e6bff586b3d.tar.xz
mana-client-9dc99e1888de6194c7ce555c33245e6bff586b3d.zip
Made the login dialog work on LoginData only, without playing with the config, it's not its job to do so.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/login.cpp45
-rw-r--r--src/gui/login.h7
2 files changed, 13 insertions, 39 deletions
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index e3828af7..a66273da 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -28,8 +28,6 @@
#include <guichan/widgets/label.hpp>
#include "../main.h"
-#include "../configuration.h"
-#include "../log.h"
#include "../logindata.h"
#include "button.h"
@@ -62,9 +60,9 @@ LoginDialog::LoginDialog(LoginData *loginData):
userLabel = new gcn::Label("Name:");
passLabel = new gcn::Label("Password:");
serverLabel = new gcn::Label("Server:");
- userField = new TextField("player");
- passField = new PasswordField();
- serverField = new TextField();
+ userField = new TextField(mLoginData->username);
+ passField = new PasswordField(mLoginData->password);
+ serverField = new TextField(mLoginData->hostname);
keepCheck = new CheckBox("Keep", false);
okButton = new Button("OK");
cancelButton = new Button("Cancel");
@@ -84,7 +82,7 @@ LoginDialog::LoginDialog(LoginData *loginData):
passField->setWidth(130);
serverField->setWidth(130);
keepCheck->setPosition(4, 77);
- keepCheck->setMarked(config.getValue("remember", 0));
+ keepCheck->setMarked(mLoginData->remember);
cancelButton->setPosition(
200 - cancelButton->getWidth() - 5,
100 - cancelButton->getHeight() - 5);
@@ -121,18 +119,13 @@ LoginDialog::LoginDialog(LoginData *loginData):
add(registerButton);
setLocationRelativeTo(getParent());
- userField->requestFocus();
- userField->setCaretPosition(userField->getText().length());
- if (config.getValue("remember", 0) != 0) {
- if (config.getValue("username", "") != "") {
- userField->setText(config.getValue("username", ""));
- passField->requestFocus();
- }
+ if (!userField->getText().length()) {
+ userField->requestFocus();
+ } else {
+ passField->requestFocus();
}
- serverField->setText(config.getValue("host", ""));
-
wrongDataNoticeListener = new WrongDataNoticeListener();
}
@@ -146,24 +139,8 @@ LoginDialog::action(const std::string& eventId)
{
if (eventId == "ok")
{
- const std::string user = userField->getText();
- logger->log("Network: Username is %s", user.c_str());
-
- // Store config settings
- config.setValue("remember", keepCheck->isMarked());
-
- if (keepCheck->isMarked())
- {
- config.setValue("username", user);
- config.setValue("host", serverField->getText());
- }
- else
- {
- config.setValue("username", "");
- }
-
// Check login
- if (user.length() == 0)
+ if (userField->getText().length() == 0)
{
wrongDataNoticeListener->setTarget(this->passField);
OkDialog *dlg = new OkDialog("Error", "Enter your username first");
@@ -171,10 +148,10 @@ LoginDialog::action(const std::string& eventId)
}
else
{
- mLoginData->hostname = config.getValue("host", "animesites.de");
- mLoginData->port = (short)config.getValue("port", 0);
+ mLoginData->hostname = serverField->getText();
mLoginData->username = userField->getText();
mLoginData->password = passField->getText();
+ mLoginData->remember = keepCheck->isMarked();
okButton->setEnabled(false);
//cancelButton->setEnabled(false);
diff --git a/src/gui/login.h b/src/gui/login.h
index b096d05f..9e6dc6b4 100644
--- a/src/gui/login.h
+++ b/src/gui/login.h
@@ -67,15 +67,12 @@ class LoginDialog : public Window, public gcn::ActionListener {
*/
void action(const std::string& eventId);
- // Made them public to have the possibility to request focus
- // from external functions.
- gcn::TextField *userField;
- gcn::TextField *passField;
-
private:
gcn::Label *userLabel;
gcn::Label *passLabel;
gcn::Label *serverLabel;
+ gcn::TextField *userField;
+ gcn::TextField *passField;
gcn::TextField *serverField;
gcn::CheckBox *keepCheck;
gcn::Button *okButton;