summaryrefslogtreecommitdiff
path: root/src/gui/login.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/login.cpp')
-rw-r--r--src/gui/login.cpp41
1 files changed, 16 insertions, 25 deletions
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index cd74e850..3748106b 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -28,8 +28,8 @@
#include "../graphic/graphic.h"
-LoginDialog::LoginDialog():
- Window("Login")
+LoginDialog::LoginDialog(gcn::Container *parent):
+ Window(parent, "Login")
{
userLabel = new gcn::Label("Name:");
passLabel = new gcn::Label("Password:");
@@ -69,21 +69,7 @@ LoginDialog::LoginDialog():
add(keepCheck);
add(okButton);
add(cancelButton);
-}
-
-LoginDialog::~LoginDialog()
-{
- delete userLabel;
- delete passLabel;
- delete userField;
- delete passField;
- delete keepCheck;
- delete okButton;
- delete cancelButton;
-}
-void LoginDialog::init()
-{
setLocationRelativeTo(getParent());
userField->requestFocus();
userField->setCaretPosition(userField->getText().length());
@@ -96,6 +82,17 @@ void LoginDialog::init()
}
}
+LoginDialog::~LoginDialog()
+{
+ delete userLabel;
+ delete passLabel;
+ delete userField;
+ delete passField;
+ delete keepCheck;
+ delete okButton;
+ delete cancelButton;
+}
+
void LoginDialog::action(const std::string& eventId)
{
if (eventId == "ok") {
@@ -124,13 +121,9 @@ void LoginDialog::action(const std::string& eventId)
}
}
-/**
- * Display login dialog
- */
+
void login() {
- LoginDialog *dialog = new LoginDialog();
- guiTop->add(dialog);
- dialog->init();
+ LoginDialog *dialog = new LoginDialog(guiTop);
while (state == LOGIN) {
clear_bitmap(buffer);
@@ -145,9 +138,7 @@ void login() {
delete dialog;
}
-/**
- * Attempt to login to login server
- */
+
void server_login(const std::string& user, const std::string& pass) {
strncpy(username, user.c_str(), LEN_USERNAME);
strncpy(password, pass.c_str(), LEN_PASSWORD);