diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-02 21:57:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-02 22:00:37 +0300 |
commit | eca890c92d3b43b8aae5f2c53cab49612f5efd1d (patch) | |
tree | 8acbdfe972044adcfbcc5a6bf7ea28b4bbb54382 /src/gui/windows | |
parent | 520a495c466793c29f3e721634dfe6cc616b8ede (diff) | |
download | plus-eca890c92d3b43b8aae5f2c53cab49612f5efd1d.tar.gz plus-eca890c92d3b43b8aae5f2c53cab49612f5efd1d.tar.bz2 plus-eca890c92d3b43b8aae5f2c53cab49612f5efd1d.tar.xz plus-eca890c92d3b43b8aae5f2c53cab49612f5efd1d.zip |
Add option "use same ip" for each server.
By default all servers using same ip for subservers.
Diffstat (limited to 'src/gui/windows')
-rw-r--r-- | src/gui/windows/editserverdialog.cpp | 13 | ||||
-rw-r--r-- | src/gui/windows/editserverdialog.h | 3 | ||||
-rw-r--r-- | src/gui/windows/serverdialog.cpp | 12 | ||||
-rw-r--r-- | src/gui/windows/worldselectdialog.cpp | 3 |
4 files changed, 26 insertions, 5 deletions
diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp index 6a25a2d77..a3b687113 100644 --- a/src/gui/windows/editserverdialog.cpp +++ b/src/gui/windows/editserverdialog.cpp @@ -31,6 +31,7 @@ #include "gui/windows/serverdialog.h" #include "gui/widgets/button.h" +#include "gui/widgets/checkbox.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" @@ -56,6 +57,9 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, mOkButton(new Button(this, _("OK"), "addServer", this)), // TRANSLATORS: edit server dialog button mCancelButton(new Button(this, _("Cancel"), "cancel", this)), + // TRANSLATORS: edit server dialog label + mPersistentIp(new CheckBox(this, _("Use same ip"), + true, this, "persistentIp")), mTypeListModel(new TypeListModel), mTypeField(new DropDown(this, mTypeListModel, false, true)), mServerDialog(parent), @@ -96,9 +100,10 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, place(1, 4, mDescriptionField, 4).setPadding(3); place(0, 5, onlineListUrlLabel); place(1, 5, mOnlineListUrlField, 4).setPadding(3); - place(0, 6, mConnectButton); - place(4, 6, mOkButton); - place(3, 6, mCancelButton); + place(0, 6, mPersistentIp, 4).setPadding(3); + place(0, 7, mConnectButton); + place(4, 7, mOkButton); + place(3, 7, mCancelButton); // Do this manually instead of calling reflowLayout so we can enforce a // minimum width. @@ -132,6 +137,7 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, mOnlineListUrlField->setText(mServer.onlineListUrl); mServerAddressField->setText(mServer.hostname); mPortField->setText(toString(mServer.port)); + mPersistentIp->setSelected(mServer.persistentIp); switch (mServer.type) { @@ -200,6 +206,7 @@ void EditServerDialog::action(const ActionEvent &event) mServer.hostname = mServerAddressField->getText(); mServer.port = static_cast<int16_t>(atoi( mPortField->getText().c_str())); + mServer.persistentIp = mPersistentIp->isSelected(); if (mTypeField) { diff --git a/src/gui/windows/editserverdialog.h b/src/gui/windows/editserverdialog.h index 98f5e07fd..d6dc7d8b3 100644 --- a/src/gui/windows/editserverdialog.h +++ b/src/gui/windows/editserverdialog.h @@ -23,6 +23,7 @@ #define GUI_WINDOWS_EDITSERVERDIALOG_H class Button; +class CheckBox; class TextField; class DropDown; class ServerDialog; @@ -70,7 +71,7 @@ class EditServerDialog final : public Window, Button *mConnectButton; Button *mOkButton; Button *mCancelButton; - + CheckBox *mPersistentIp; TypeListModel *mTypeListModel; DropDown *mTypeField; diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 9e85f5c89..c9695c2c1 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -328,6 +328,7 @@ void ServerDialog::connectToSelectedServer() mServerInfo->onlineListUrl = server.onlineListUrl; mServerInfo->supportUrl = server.supportUrl; mServerInfo->save = true; + mServerInfo->persistentIp = server.persistentIp; if (chatLogger) chatLogger->setServerName(mServerInfo->hostname); @@ -630,6 +631,12 @@ void ServerDialog::loadServers(const bool addNew) server.supportUrl = reinterpret_cast<const char*>( subNode->xmlChildrenNode->content); } + else if (xmlNameEqual(subNode, "persistentIp")) + { + std::string text = reinterpret_cast<const char*>( + subNode->xmlChildrenNode->content); + server.persistentIp = (text == "1" || text == "true"); + } } server.version.first = font->getWidth(version); @@ -651,6 +658,7 @@ void ServerDialog::loadServers(const bool addNew) mServers[i].onlineListUrl = server.onlineListUrl; mServers[i].supportUrl = server.supportUrl; mServers[i].althostname = server.althostname; + mServers[i].persistentIp = server.persistentIp; mServersListModel->setVersionString(i, version); found = true; break; @@ -675,6 +683,7 @@ void ServerDialog::loadCustomServers() const std::string portKey("MostUsedServerPort" + index); const std::string onlineListUrlKey ("MostUsedServerOnlineList" + index); + const std::string persistentIpKey("persistentIp" + index); ServerInfo server; server.name = config.getValue(nameKey, ""); @@ -682,6 +691,7 @@ void ServerDialog::loadCustomServers() server.onlineListUrl = config.getValue(onlineListUrlKey, ""); server.hostname = config.getValue(hostKey, ""); server.type = ServerInfo::parseType(config.getValue(typeKey, "")); + server.persistentIp = config.getValue(persistentIpKey, 0) ? true : false; const int defaultPort = defaultPortForServerType(server.type); server.port = static_cast<uint16_t>( @@ -739,6 +749,7 @@ void ServerDialog::saveCustomServers(const ServerInfo ¤tServer, const std::string portKey("MostUsedServerPort" + num); const std::string onlineListUrlKey ("MostUsedServerOnlineList" + num); + const std::string persistentIpKey("persistentIp" + num); config.setValue(nameKey, toString(server.name)); config.setValue(descKey, toString(server.description)); @@ -746,6 +757,7 @@ void ServerDialog::saveCustomServers(const ServerInfo ¤tServer, config.setValue(hostKey, toString(server.hostname)); config.setValue(typeKey, serverTypeToString(server.type)); config.setValue(portKey, toString(server.port)); + config.setValue(persistentIpKey, server.persistentIp); ++ savedServerCount; } diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index 5cd0a3b2f..4a70e3750 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -106,7 +106,8 @@ void WorldSelectDialog::action(const ActionEvent &event) { mChangeLoginButton->setEnabled(false); mChooseWorld->setEnabled(false); - Net::getLoginHandler()->chooseServer(mWorldList->getSelected()); + Net::getLoginHandler()->chooseServer(mWorldList->getSelected(), + client->getPersistentIp()); // Check in case netcode moves us forward if (client->getState() == STATE_WORLD_SELECT) |