diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/popupmenu.cpp | 2 | ||||
-rw-r--r-- | src/gui/serverdialog.cpp | 60 | ||||
-rw-r--r-- | src/gui/serverdialog.h | 24 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 11 |
4 files changed, 80 insertions, 17 deletions
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 21bab81e..76b0500e 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -52,7 +52,7 @@ #include <cassert> -extern std::string tradePartnerName; +std::string tradePartnerName; PopupMenu::PopupMenu(): Popup("PopupMenu"), diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index e92c9bec..1dfbd849 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -29,6 +29,7 @@ #include "gui/sdlinput.h" #include "gui/widgets/button.h" +#include "gui/widgets/dropdown.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/listbox.h" @@ -40,6 +41,7 @@ #include "utils/gettext.h" #include "utils/stringutils.h" #include "utils/xml.h" +#include "widgets/dropdown.h" #include <cstdlib> #include <iostream> @@ -111,6 +113,16 @@ std::string ServersListModel::getElementAt(int elementIndex) return myServer; } +std::string TypeListModel::getElementAt(int elementIndex) +{ + if (elementIndex == 0) + return "eAthena"; + else if (elementIndex == 1) + return "Manaserv"; + else + return "Unknown"; +} + ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): Window(_("Choose Your Server")), @@ -122,6 +134,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): { Label *serverLabel = new Label(_("Server:")); Label *portLabel = new Label(_("Port:")); + Label *typeLabel = new Label(_("Server type:")); mServerNameField = new TextField(mServerInfo->hostname); mPortField = new TextField(toString(mServerInfo->port)); @@ -154,6 +167,9 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): ScrollArea *usedScroll = new ScrollArea(mServersList); usedScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); + mTypeListModel = new TypeListModel(); + mTypeField = new DropDown(mTypeListModel); + mDescription = new Label(std::string()); mQuitButton = new Button(_("Quit"), "quit", this); @@ -174,11 +190,13 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): place(1, 0, mServerNameField, 3).setPadding(3); place(0, 1, portLabel); place(1, 1, mPortField, 3).setPadding(3); - place(0, 2, usedScroll, 4, 5).setPadding(3); - place(0, 7, mDescription, 4); - place(0, 8, mManualEntryButton); - place(2, 8, mQuitButton); - place(3, 8, mConnectButton); + place(0, 2, typeLabel); + place(1, 2, mTypeField, 3).setPadding(3); + place(0, 3, usedScroll, 4, 5).setPadding(3); + place(0, 8, mDescription, 4); + place(0, 9, mManualEntryButton); + place(2, 9, mQuitButton); + place(3, 9, mConnectButton); // Make sure the list has enough height getLayout().setRowHeight(3, 80); @@ -211,6 +229,7 @@ ServerDialog::~ServerDialog() if (mDownload) mDownload->cancel(); delete mServersListModel; + delete mTypeListModel; } void ServerDialog::action(const gcn::ActionEvent &event) @@ -240,7 +259,17 @@ void ServerDialog::action(const gcn::ActionEvent &event) ServerInfo tempServer; currentServer.hostname = mServerNameField->getText(); currentServer.port = (short) atoi(mPortField->getText().c_str()); - currentServer.type = ServerInfo::UNKNOWN; + switch (mTypeField->getSelected()) + { + case 0: + currentServer.type = ServerInfo::EATHENA; + break; + case 1: + currentServer.type = ServerInfo::MANASERV; + break; + default: + currentServer.type = ServerInfo::UNKNOWN; + } // now rewrite the configuration... // id = 0 is always the last selected server @@ -274,6 +303,7 @@ void ServerDialog::action(const gcn::ActionEvent &event) } mServerInfo->hostname = currentServer.hostname; mServerInfo->port = currentServer.port; + mServerInfo->type = currentServer.type; state = STATE_CONNECT_SERVER; } } @@ -313,7 +343,17 @@ void ServerDialog::valueChanged(const gcn::SelectionEvent &event) mDescription->setCaption(myServer.name); mServerNameField->setText(myServer.hostname); mPortField->setText(toString(myServer.port)); - + switch (myServer.type) + { + case ServerInfo::UNKNOWN: + mTypeField->setSelected(2); + break; + case ServerInfo::EATHENA: + mTypeField->setSelected(0); + break; + case ServerInfo::MANASERV: + mTypeField->setSelected(1); + } setFieldsReadOnly(true); } @@ -407,13 +447,7 @@ void ServerDialog::loadServers() { if (xmlStrEqual(server->name, BAD_CAST "server")) { - // check wether the build matches (remove with last instances - // if _SUPPORT ifdefs) std::string type = XML::getProperty(server, "type", "unknown"); - if (compareStrI(type, SERVER_BUILD)) - { - continue; - } currentServer.clear(); currentServer.name = XML::getProperty(server, "name", std::string()); diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h index d82e2613..f0d99b30 100644 --- a/src/gui/serverdialog.h +++ b/src/gui/serverdialog.h @@ -42,6 +42,7 @@ class Label; class ListBox; class ServerDialog; class TextField; +class DropDown; /** * Server and Port List Model @@ -73,6 +74,26 @@ class ServersListModel : public gcn::ListModel }; /** + * Server and Port List Model + */ +class TypeListModel : public gcn::ListModel +{ + public: + TypeListModel() { }; + + /** + * Used to get number of line in the list + */ + int getNumberOfElements() { return 2; } + + /** + * Used to get an element from the list + */ + std::string getElementAt(int elementIndex); +}; + + +/** * The server choice dialog. * * \ingroup Interface @@ -134,6 +155,9 @@ class ServerDialog : public Window, ListBox *mServersList; ServersListModel *mServersListModel; + DropDown *mTypeField; + TypeListModel *mTypeListModel; + const std::string &mDir; enum ServerDialogDownloadStatus diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 2ed7deb9..76bf5a22 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -37,6 +37,8 @@ #include "gui/ministatus.h" #include "gui/popupmenu.h" +#include "net/net.h" + #include "resources/monsterinfo.h" #include "resources/resourcemanager.h" @@ -411,7 +413,8 @@ void Viewport::mouseDragged(gcn::MouseEvent &event) if (mPlayerFollowMouse && !event.isShiftPressed()) { -#ifdef MANASERV_SUPPORT + if (Net::getNetworkType() == ServerInfo::MANASERV) + { if (get_elapsed_time(mLocalWalkTime) >= walkingMouseDelay) { mLocalWalkTime = tick_time; @@ -419,7 +422,9 @@ void Viewport::mouseDragged(gcn::MouseEvent &event) event.getY() + (int) mPixelViewY); player_node->pathSetByMouse(); } -#else + } + else + { if (mLocalWalkTime != player_node->getWalkTime()) { mLocalWalkTime = player_node->getWalkTime(); @@ -427,7 +432,7 @@ void Viewport::mouseDragged(gcn::MouseEvent &event) int destY = event.getY() / 32 + mTileViewY; player_node->setDestination(destX, destY); } -#endif + } } } |