summaryrefslogtreecommitdiff
path: root/src/gui/login.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-25 22:50:59 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-25 22:50:59 +0100
commitcc79f0fe21e1a2ef73cbe987d54e848b9a47142d (patch)
treeedd316eb6094f0c02d6d014385865dcd88a2bc56 /src/gui/login.cpp
parentb0df784f1be44a657ca8092069488602270629b7 (diff)
parent99e8a3fd77b63a029fe02dcf771b6af1aad252ed (diff)
downloadmana-client-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.gz
mana-client-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.bz2
mana-client-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.xz
mana-client-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.zip
Merge branch 'eathena/master'
Conflicts: A lot of files.
Diffstat (limited to 'src/gui/login.cpp')
-rw-r--r--src/gui/login.cpp45
1 files changed, 17 insertions, 28 deletions
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index e68a8da1..281a25a2 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -19,10 +19,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <guichan/widgets/label.hpp>
-
#include "button.h"
#include "checkbox.h"
+#include "label.h"
#include "listbox.h"
#include "login.h"
#include "ok_dialog.h"
@@ -48,12 +47,12 @@ static const int FIELD_WIDTH = LOGIN_DIALOG_WIDTH - 70;
LoginDialog::LoginDialog(LoginData *loginData):
Window(_("Login")), mLoginData(loginData)
{
- gcn::Label *userLabel = new gcn::Label(_("Name:"));
- gcn::Label *passLabel = new gcn::Label(_("Password:"));
+ gcn::Label *userLabel = new Label(_("Name:"));
+ gcn::Label *passLabel = new Label(_("Password:"));
#ifdef EATHENA_SUPPORT
- gcn::Label *serverLabel = new gcn::Label(_("Server:"));
- gcn::Label *portLabel = new gcn::Label(_("Port:"));
- gcn::Label *dropdownLabel = new gcn::Label(_("Recent:"));
+ gcn::Label *serverLabel = new Label(_("Server:"));
+ gcn::Label *portLabel = new Label(_("Port:"));
+ gcn::Label *dropdownLabel = new Label(_("Recent:"));
std::vector<std::string> dfltServer;
dfltServer.push_back("server.themanaworld.org");
std::vector<std::string> dfltPort;
@@ -124,14 +123,13 @@ LoginDialog::LoginDialog(LoginData *loginData):
place(3, 6, mOkButton);
reflowLayout(250, 0);
- setLocationRelativeTo(getParent());
+ center();
setVisible(true);
- if (mUserField->getText().empty()) {
+ if (mUserField->getText().empty())
mUserField->requestFocus();
- } else {
+ else
mPassField->requestFocus();
- }
mOkButton->setEnabled(canSubmit());
}
@@ -179,15 +177,13 @@ void LoginDialog::action(const gcn::ActionEvent &event)
#ifdef EATHENA_SUPPORT
// Transfer these fields on to the register dialog
mLoginData->hostname = mServerField->getText();
+
if (isUShort(mPortField->getText()))
- {
mLoginData->port = getUShort(mPortField->getText());
- }
else
- {
mLoginData->port = 6901;
- }
#endif
+
mLoginData->username = mUserField->getText();
mLoginData->password = mPassField->getText();
@@ -223,14 +219,12 @@ bool LoginDialog::isUShort(const std::string &str)
strPtr != strEnd; ++strPtr)
{
if (*strPtr < '0' || *strPtr > '9')
- {
return false;
- }
+
l = l * 10 + (*strPtr - '0'); // *strPtr - '0' will never be negative
+
if (l > 65535)
- {
return false;
- }
}
return true;
}
@@ -306,9 +300,7 @@ void LoginDialog::DropDownList::save(const std::string &server,
++sPtr, ++pPtr)
{
if (*sPtr != server || *pPtr != port)
- {
saveEntry(*sPtr, *pPtr, position);
- }
}
}
@@ -320,27 +312,24 @@ int LoginDialog::DropDownList::getNumberOfElements()
std::string LoginDialog::DropDownList::getElementAt(int i)
{
if (i < 0 || i >= getNumberOfElements())
- {
- return "";
- }
+ return "";
+
return getServerAt(i) + ":" + getPortAt(i);
}
std::string LoginDialog::DropDownList::getServerAt(int i)
{
if (i < 0 || i >= getNumberOfElements())
- {
return "";
- }
+
return mServers.at(i);
}
std::string LoginDialog::DropDownList::getPortAt(int i)
{
if (i < 0 || i >= getNumberOfElements())
- {
return "";
- }
+
return mPorts.at(i);
}
#endif