summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-22 18:59:41 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-22 18:59:41 +0300
commit1cf6cb343c6c8df8a998c617fd6f8d40f5affbea (patch)
treed5e090e99c02a0ce70d00c4dc527d777881cd83c /src/gui
parentf20c99d2bffe798806790e1f1ae838bba494d93c (diff)
downloadmanaplus-1cf6cb343c6c8df8a998c617fd6f8d40f5affbea.tar.gz
manaplus-1cf6cb343c6c8df8a998c617fd6f8d40f5affbea.tar.bz2
manaplus-1cf6cb343c6c8df8a998c617fd6f8d40f5affbea.tar.xz
manaplus-1cf6cb343c6c8df8a998c617fd6f8d40f5affbea.zip
Add support for packet version in servers list xml and in editor.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/windows/editserverdialog.cpp17
-rw-r--r--src/gui/windows/editserverdialog.h4
-rw-r--r--src/gui/windows/serverdialog.cpp10
3 files changed, 25 insertions, 6 deletions
diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp
index 47a0f0335..9fa71b1f4 100644
--- a/src/gui/windows/editserverdialog.cpp
+++ b/src/gui/windows/editserverdialog.cpp
@@ -30,9 +30,9 @@
#include "gui/widgets/checkbox.h"
#include "gui/widgets/createwidget.h"
#include "gui/widgets/dropdown.h"
+#include "gui/widgets/inttextfield.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
-#include "gui/widgets/textfield.h"
#include "utils/gettext.h"
@@ -50,6 +50,7 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent,
mNameField(new TextField(this, std::string())),
mDescriptionField(new TextField(this, std::string())),
mOnlineListUrlField(new TextField(this, std::string())),
+ mPacketVersionField(new IntTextField(this, 0, 0, 20150805)),
// TRANSLATORS: edit server dialog button
mConnectButton(new Button(this, _("Connect"), "connect", this)),
// TRANSLATORS: edit server dialog button
@@ -79,6 +80,8 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent,
Label *const descriptionLabel = new Label(this, _("Description:"));
// TRANSLATORS: edit server dialog label
Label *const onlineListUrlLabel = new Label(this, _("Online list url:"));
+ // TRANSLATORS: edit server dialog label
+ Label *const packetVersionLabel = new Label(this, _("Packet version:"));
mPortField->setNumeric(true);
mPortField->setRange(1, 65535);
@@ -99,10 +102,12 @@ 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, mPersistentIp, 4).setPadding(3);
- place(0, 7, mConnectButton);
- place(4, 7, mOkButton);
- place(3, 7, mCancelButton);
+ place(0, 6, packetVersionLabel);
+ place(1, 6, mPacketVersionField, 4).setPadding(3);
+ place(0, 7, mPersistentIp, 4).setPadding(3);
+ place(0, 8, mConnectButton);
+ place(4, 8, mOkButton);
+ place(3, 8, mCancelButton);
// Do this manually instead of calling reflowLayout so we can enforce a
// minimum width.
@@ -135,6 +140,7 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent,
mDescriptionField->setText(mServer.description);
mOnlineListUrlField->setText(mServer.onlineListUrl);
mServerAddressField->setText(mServer.hostname);
+ mPacketVersionField->setValue(mServer.packetVersion);
mPortField->setText(toString(mServer.port));
mPersistentIp->setSelected(mServer.persistentIp);
@@ -223,6 +229,7 @@ void EditServerDialog::action(const ActionEvent &event)
mServer.description = mDescriptionField->getText();
mServer.onlineListUrl = mOnlineListUrlField->getText();
mServer.hostname = mServerAddressField->getText();
+ mServer.packetVersion = mPacketVersionField->getValue();
mServer.port = CAST_S16(atoi(
mPortField->getText().c_str()));
mServer.persistentIp = mPersistentIp->isSelected();
diff --git a/src/gui/windows/editserverdialog.h b/src/gui/windows/editserverdialog.h
index 596d4a110..5595c3120 100644
--- a/src/gui/windows/editserverdialog.h
+++ b/src/gui/windows/editserverdialog.h
@@ -24,9 +24,10 @@
class Button;
class CheckBox;
-class TextField;
class DropDown;
+class IntTextField;
class ServerDialog;
+class TextField;
class TypeListModel;
#include "gui/widgets/window.h"
@@ -68,6 +69,7 @@ class EditServerDialog final : public Window,
TextField *mNameField A_NONNULLPOINTER;
TextField *mDescriptionField A_NONNULLPOINTER;
TextField *mOnlineListUrlField A_NONNULLPOINTER;
+ IntTextField *mPacketVersionField A_NONNULLPOINTER;
Button *mConnectButton A_NONNULLPOINTER;
Button *mOkButton A_NONNULLPOINTER;
Button *mCancelButton A_NONNULLPOINTER;
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index 179173d2c..f03d28f03 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -236,6 +236,7 @@ void ServerDialog::connectToSelectedServer()
mServerInfo->save = true;
mServerInfo->persistentIp = server.persistentIp;
mServerInfo->updateMirrors = server.updateMirrors;
+ mServerInfo->packetVersion = server.packetVersion;
settings.persistentIp = mServerInfo->persistentIp;
settings.supportUrl = mServerInfo->supportUrl;
@@ -521,6 +522,8 @@ void ServerDialog::loadServers(const bool addNew)
subNode, "althostname", "");
server.port = CAST_U16(
XML::getProperty(subNode, "port", 0));
+ server.packetVersion = XML::getProperty(subNode,
+ "packetVersion", 0);
if (server.port == 0)
{
@@ -584,6 +587,7 @@ void ServerDialog::loadServers(const bool addNew)
mServers[i].althostname = server.althostname;
mServers[i].persistentIp = server.persistentIp;
mServers[i].updateMirrors = server.updateMirrors;
+ mServers[i].packetVersion = server.packetVersion;
mServersListModel->setVersionString(i, version);
found = true;
break;
@@ -609,6 +613,8 @@ void ServerDialog::loadCustomServers()
const std::string onlineListUrlKey
("MostUsedServerOnlineList" + index);
const std::string persistentIpKey("persistentIp" + index);
+ const std::string packetVersionKey
+ ("MostUsedServerPacketVersion" + index);
ServerInfo server;
server.name = config.getValue(nameKey, "");
@@ -618,6 +624,7 @@ void ServerDialog::loadCustomServers()
server.type = ServerInfo::parseType(config.getValue(typeKey, ""));
server.persistentIp = config.getValue(
persistentIpKey, 0) ? true : false;
+ server.packetVersion = config.getValue(packetVersionKey, 0);
const int defaultPort = defaultPortForServerType(server.type);
server.port = CAST_U16(
@@ -676,6 +683,8 @@ void ServerDialog::saveCustomServers(const ServerInfo &currentServer,
const std::string onlineListUrlKey
("MostUsedServerOnlineList" + num);
const std::string persistentIpKey("persistentIp" + num);
+ const std::string packetVersionKey
+ ("MostUsedServerPacketVersion" + num);
config.setValue(nameKey, server.name);
config.setValue(descKey, server.description);
@@ -684,6 +693,7 @@ void ServerDialog::saveCustomServers(const ServerInfo &currentServer,
config.setValue(typeKey, serverTypeToString(server.type));
config.setValue(portKey, toString(server.port));
config.setValue(persistentIpKey, server.persistentIp);
+ config.setValue(packetVersionKey, server.packetVersion);
++ savedServerCount;
}