diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-04-26 12:39:39 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-04-26 12:39:39 +0300 |
commit | 5857f579da26ac21802679bce1777cd8337bd584 (patch) | |
tree | 455ab7a62d15f447bc3fec5388913c7886945682 /src | |
parent | 298d8e2ef42eb2c60f1a2c24cf1aeb131dcded09 (diff) | |
download | plus-5857f579da26ac21802679bce1777cd8337bd584.tar.gz plus-5857f579da26ac21802679bce1777cd8337bd584.tar.bz2 plus-5857f579da26ac21802679bce1777cd8337bd584.tar.xz plus-5857f579da26ac21802679bce1777cd8337bd584.zip |
add support for separate online list.
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 6 | ||||
-rw-r--r-- | src/client.h | 4 | ||||
-rw-r--r-- | src/gui/editserverdialog.cpp | 12 | ||||
-rw-r--r-- | src/gui/editserverdialog.h | 1 | ||||
-rw-r--r-- | src/gui/serverdialog.cpp | 13 | ||||
-rw-r--r-- | src/gui/whoisonline.cpp | 2 | ||||
-rw-r--r-- | src/net/serverinfo.h | 4 |
7 files changed, 38 insertions, 4 deletions
diff --git a/src/client.cpp b/src/client.cpp index aac1d8139..e1b92733c 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -270,6 +270,7 @@ Client::Client(const Options &options) : mNpcsDir(), mRootDir(), mServerName(), + mOnlineListUrl(), mCurrentServer(), mGame(nullptr), mCurrentDialog(nullptr), @@ -1069,6 +1070,11 @@ int Client::gameExec() mServerName = mCurrentServer.hostname; initServerConfig(mCurrentServer.hostname); loginData.registerUrl = mCurrentServer.registerUrl; + if (!mCurrentServer.onlineListUrl.empty()) + mOnlineListUrl = mCurrentServer.onlineListUrl; + else + mOnlineListUrl = mServerName; + if (mOptions.username.empty()) { if (loginData.remember) diff --git a/src/client.h b/src/client.h index d495521fc..e5bf5183e 100644 --- a/src/client.h +++ b/src/client.h @@ -284,6 +284,9 @@ public: static std::string getServerName() A_WARN_UNUSED { return instance()->mServerName; } + static std::string getOnlineUrl() A_WARN_UNUSED + { return instance()->mOnlineListUrl; } + static void resize(const int width, const int height, const bool always = false) { instance()->resizeVideo(width, height, always); } @@ -383,6 +386,7 @@ private: std::string mNpcsDir; std::string mRootDir; std::string mServerName; + std::string mOnlineListUrl; ServerInfo mCurrentServer; diff --git a/src/gui/editserverdialog.cpp b/src/gui/editserverdialog.cpp index f6da1d5bc..89ad5e967 100644 --- a/src/gui/editserverdialog.cpp +++ b/src/gui/editserverdialog.cpp @@ -70,6 +70,7 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, mPortField(new TextField(this, std::string())), mNameField(new TextField(this, std::string())), mDescriptionField(new TextField(this, std::string())), + mOnlineListUrlField(new TextField(this, std::string())), mConnectButton(new Button(this, _("Connect"), "connect", this)), mOkButton(new Button(this, _("OK"), "addServer", this)), mCancelButton(new Button(this, _("Cancel"), "cancel", this)), @@ -86,6 +87,7 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, Label *const portLabel = new Label(this, _("Port:")); Label *const typeLabel = new Label(this, _("Server type:")); Label *const descriptionLabel = new Label(this, _("Description:")); + Label *const onlineListUrlLabel = new Label(this, _("Online list url:")); mPortField->setNumeric(true); mPortField->setRange(1, 65535); @@ -104,9 +106,11 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, place(1, 3, mTypeField).setPadding(3); place(0, 4, descriptionLabel); place(1, 4, mDescriptionField, 4).setPadding(3); - place(0, 5, mConnectButton); - place(4, 5, mOkButton); - place(3, 5, mCancelButton); + place(0, 5, onlineListUrlLabel); + place(1, 5, mOnlineListUrlField, 4).setPadding(3); + place(0, 6, mConnectButton); + place(4, 6, mOkButton); + place(3, 6, mCancelButton); // Do this manually instead of calling reflowLayout so we can enforce a // minimum width. @@ -136,6 +140,7 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, mNameField->setText(mServer.name); mDescriptionField->setText(mServer.description); + mOnlineListUrlField->setText(mServer.onlineListUrl); mServerAddressField->setText(mServer.hostname); mPortField->setText(toString(mServer.port)); @@ -213,6 +218,7 @@ void EditServerDialog::action(const gcn::ActionEvent &event) mServer.name = mNameField->getText(); mServer.description = mDescriptionField->getText(); + mServer.onlineListUrl = mOnlineListUrlField->getText(); mServer.hostname = mServerAddressField->getText(); mServer.port = static_cast<int16_t>(atoi( mPortField->getText().c_str())); diff --git a/src/gui/editserverdialog.h b/src/gui/editserverdialog.h index f481fa789..269abb0b1 100644 --- a/src/gui/editserverdialog.h +++ b/src/gui/editserverdialog.h @@ -101,6 +101,7 @@ class EditServerDialog final : public Window, TextField *mPortField; TextField *mNameField; TextField *mDescriptionField; + TextField *mOnlineListUrlField; Button *mConnectButton; Button *mOkButton; Button *mCancelButton; diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 56ce6528a..9e3a46bf4 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -366,6 +366,7 @@ void ServerDialog::connectToSelectedServer() mServerInfo->name = server.name; mServerInfo->description = server.description; mServerInfo->registerUrl = server.registerUrl; + mServerInfo->onlineListUrl = server.onlineListUrl; mServerInfo->save = true; if (chatLogger) @@ -637,6 +638,11 @@ void ServerDialog::loadServers(const bool addNew) server.registerUrl = reinterpret_cast<const char*>( subNode->xmlChildrenNode->content); } + else if (xmlNameEqual(subNode, "onlineListUrl")) + { + server.onlineListUrl = reinterpret_cast<const char*>( + subNode->xmlChildrenNode->content); + } } server.version.first = font->getWidth(version); @@ -655,6 +661,7 @@ void ServerDialog::loadServers(const bool addNew) mServers[i].version = server.version; mServers[i].description = server.description; mServers[i].registerUrl = server.registerUrl; + mServers[i].onlineListUrl = server.onlineListUrl; mServersListModel->setVersionString(i, version); found = true; break; @@ -677,10 +684,13 @@ void ServerDialog::loadCustomServers() const std::string hostKey = "MostUsedServerName" + index; const std::string typeKey = "MostUsedServerType" + index; const std::string portKey = "MostUsedServerPort" + index; + const std::string onlineListUrlKey + = "MostUsedServerOnlineList" + index; ServerInfo server; server.name = config.getValue(nameKey, ""); server.description = config.getValue(descKey, ""); + server.onlineListUrl = config.getValue(onlineListUrlKey, ""); server.hostname = config.getValue(hostKey, ""); server.type = ServerInfo::parseType(config.getValue(typeKey, "")); @@ -738,9 +748,12 @@ void ServerDialog::saveCustomServers(const ServerInfo ¤tServer, const std::string hostKey = "MostUsedServerName" + num; const std::string typeKey = "MostUsedServerType" + num; const std::string portKey = "MostUsedServerPort" + num; + const std::string onlineListUrlKey + = "MostUsedServerOnlineList" + num; config.setValue(nameKey, toString(server.name)); config.setValue(descKey, toString(server.description)); + config.setValue(onlineListUrlKey, toString(server.onlineListUrl)); config.setValue(hostKey, toString(server.hostname)); config.setValue(typeKey, serverTypeToString(server.type)); config.setValue(portKey, toString(server.port)); diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 27db30e77..b38218662 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -493,7 +493,7 @@ int WhoIsOnline::downloadThread(void *ptr) int attempts = 0; WhoIsOnline *wio = reinterpret_cast<WhoIsOnline *>(ptr); CURLcode res; - std::string url(Client::getServerName() + "/online.txt"); + std::string url(Client::getOnlineUrl() + "/online.txt"); while (attempts < 1 && !wio->mDownloadComplete) { diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h index 653d1d1ff..7fa9a0640 100644 --- a/src/net/serverinfo.h +++ b/src/net/serverinfo.h @@ -53,6 +53,7 @@ public: std::string description; std::string registerUrl; + std::string onlineListUrl; VersionString version; bool save; @@ -64,6 +65,7 @@ public: port(6901), description(), registerUrl(), + onlineListUrl(), version(), save(false) { @@ -77,6 +79,7 @@ public: port(info.port), description(info.description), registerUrl(info.registerUrl), + onlineListUrl(info.onlineListUrl), version(), save(info.save) { @@ -97,6 +100,7 @@ public: port = 0; description.clear(); registerUrl.clear(); + onlineListUrl.clear(); version.first = 0; version.second.clear(); save = false; |