diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-02-04 16:54:35 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-02-04 16:54:35 +0000 |
commit | 2d12043f225263004b91e256e4b0d14c4842236e (patch) | |
tree | 6dda6785e9d8853badaaa7b22f87d5ac159626e5 /src/gui/char_server.cpp | |
parent | 9dc99e1888de6194c7ce555c33245e6bff586b3d (diff) | |
download | mana-2d12043f225263004b91e256e4b0d14c4842236e.tar.gz mana-2d12043f225263004b91e256e4b0d14c4842236e.tar.bz2 mana-2d12043f225263004b91e256e4b0d14c4842236e.tar.xz mana-2d12043f225263004b91e256e4b0d14c4842236e.zip |
Unify the various login dialogs to use LoginData.
Diffstat (limited to 'src/gui/char_server.cpp')
-rw-r--r-- | src/gui/char_server.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp index c66d4436..876bcd0e 100644 --- a/src/gui/char_server.cpp +++ b/src/gui/char_server.cpp @@ -29,13 +29,27 @@ #include "listbox.h" #include "scrollarea.h" +#include "../logindata.h" #include "../main.h" #include "../serverinfo.h" +#include "../net/network.h" // TODO this is just for iptostring, move that? + extern SERVER_INFO **server_info; -ServerSelectDialog::ServerSelectDialog(): - Window("Select Server") +/** + * The list model for the server list. + */ +class ServerListModel : public gcn::ListModel { + public: + virtual ~ServerListModel() {}; + + int getNumberOfElements(); + std::string getElementAt(int i); +}; + +ServerSelectDialog::ServerSelectDialog(LoginData *loginData): + Window("Select Server"), mLoginData(loginData) { serverListModel = new ServerListModel(); serverList = new ListBox(serverListModel); @@ -91,6 +105,9 @@ ServerSelectDialog::action(const std::string& eventId) { if (eventId == "ok") { okButton->setEnabled(false); + const SERVER_INFO *si = server_info[serverList->getSelected()]; + mLoginData->hostname = iptostring(si->address); + mLoginData->port = si->port; state = CHAR_CONNECT_STATE; } else if (eventId == "cancel") { @@ -98,11 +115,6 @@ ServerSelectDialog::action(const std::string& eventId) } } -SERVER_INFO* ServerSelectDialog::getServerInfo() -{ - return server_info[serverList->getSelected()]; -} - int ServerListModel::getNumberOfElements() { |