From fa8291a433cfa5bb7d6815007fa5a027d6277f1f Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Wed, 16 Nov 2011 18:07:52 -0200 Subject: [PATCH] configure server host and port in enter game --- modules/entergame/characterlist.otui | 20 ++++++++-------- modules/entergame/entergame.lua | 21 +++++++++++------ modules/entergame/entergame.otui | 34 +++++++++++++++++++++++++++- src/framework/ui/uicheckbox.cpp | 6 +++++ src/framework/ui/uicheckbox.h | 1 + src/otclient/const.h | 2 -- src/otclient/net/protocollogin.cpp | 4 ++-- src/otclient/net/protocollogin.h | 2 +- 8 files changed, 67 insertions(+), 23 deletions(-) diff --git a/modules/entergame/characterlist.otui b/modules/entergame/characterlist.otui index f0e18eaf..0a753305 100644 --- a/modules/entergame/characterlist.otui +++ b/modules/entergame/characterlist.otui @@ -48,16 +48,16 @@ MainWindow margin.right: 16 margin.bottom: 10 - CheckBox - id: charAutoLoginBox - text: Auto login - tooltip: Auto login selected character on next charlist load - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: next.top - margin.bottom: 6 - margin.left: 18 - margin.right: 18 + //CheckBox + // id: charAutoLoginBox + // text: Auto login + // tooltip: Auto login selected character on next charlist load + // anchors.left: parent.left + // anchors.right: parent.right + // anchors.bottom: next.top + // margin.bottom: 6 + // margin.left: 18 + // margin.right: 18 Button id: buttonOk diff --git a/modules/entergame/entergame.lua b/modules/entergame/entergame.lua index ed9b0dfb..35ce11a9 100644 --- a/modules/entergame/entergame.lua +++ b/modules/entergame/entergame.lua @@ -49,17 +49,19 @@ function EnterGame.create() local account = Configs.get('account') local password = Configs.get('password') + local host = Configs.get('host') + local port = tonumber(Configs.get('port')) local autologin = toboolean(Configs.get('autologin')) enterGame:getChildById('accountNameLineEdit'):setText(account) enterGame:getChildById('accountPasswordLineEdit'):setText(password) + enterGame:getChildById('serverHostLineEdit'):setText(host) + enterGame:getChildById('serverPortLineEdit'):setText(port) + enterGame:getChildById('autoLoginBox'):setChecked(autologin) + enterGame:getChildById('rememberPasswordBox'):setChecked(#account > 0) - if #account > 0 then - enterGame:getChildById('rememberPasswordBox'):setChecked(true) - if autologin then - enterGame:getChildById('autoLoginBox'):setChecked(true) - addEvent(EnterGame.doLogin) - end + if #account > 0 and autologin then + addEvent(EnterGame.doLogin) end end @@ -80,8 +82,13 @@ end function EnterGame.doLogin() EnterGame.account = enterGame:getChildById('accountNameLineEdit'):getText() EnterGame.password = enterGame:getChildById('accountPasswordLineEdit'):getText() + EnterGame.host = enterGame:getChildById('serverHostLineEdit'):getText() + EnterGame.port = enterGame:getChildById('serverPortLineEdit'):getText() EnterGame.hide() + Configs.set('host', EnterGame.host) + Configs.set('port', EnterGame.port) + local protocolLogin = ProtocolLogin.create() protocolLogin.onError = onError protocolLogin.onMotd = onMotd @@ -93,7 +100,7 @@ function EnterGame.doLogin() EnterGame.show() end - protocolLogin:login(EnterGame.account, EnterGame.password) + protocolLogin:login(EnterGame.host, EnterGame.port, EnterGame.account, EnterGame.password) end function EnterGame.displayMotd() diff --git a/modules/entergame/entergame.otui b/modules/entergame/entergame.otui index 3b1916c1..304570b3 100644 --- a/modules/entergame/entergame.otui +++ b/modules/entergame/entergame.otui @@ -1,7 +1,7 @@ MainWindow id: enterGame title: Enter Game - size: 236 200 + size: 236 240 onEnter: EnterGame.doLogin() onEscape: EnterGame.hide() @@ -36,6 +36,38 @@ MainWindow margin.left: 18 margin.right: 18 + LargerLabel + id: serverLabel + width: 140 + text: Server + anchors.left: prev.left + anchors.top: prev.bottom + margin.top: 8 + + LineEdit + id: serverHostLineEdit + tooltip: Only protocol 8.62 is supported + anchors.left: serverLabel.left + anchors.right: serverLabel.right + anchors.top: serverLabel.bottom + margin.top: 2 + + LargerLabel + id: portLabel + text: Port + width: 50 + anchors.left: serverLabel.right + anchors.top: serverLabel.top + margin.left: 10 + + LineEdit + id: serverPortLineEdit + text: 7171 + anchors.left: portLabel.left + anchors.right: portLabel.right + anchors.top: portLabel.bottom + margin.top: 2 + CheckBox id: rememberPasswordBox text: Remember password diff --git a/src/framework/ui/uicheckbox.cpp b/src/framework/ui/uicheckbox.cpp index b8758ca9..5661ed56 100644 --- a/src/framework/ui/uicheckbox.cpp +++ b/src/framework/ui/uicheckbox.cpp @@ -27,6 +27,12 @@ #include #include +void UICheckBox::setup() +{ + UIWidget::setup(); + setFocusable(false); +} + void UICheckBox::render() { if(m_image) { diff --git a/src/framework/ui/uicheckbox.h b/src/framework/ui/uicheckbox.h index ace638e9..c074679e 100644 --- a/src/framework/ui/uicheckbox.h +++ b/src/framework/ui/uicheckbox.h @@ -28,6 +28,7 @@ class UICheckBox : public UIWidget { public: + void setup(); void render(); bool isChecked(); diff --git a/src/otclient/const.h b/src/otclient/const.h index 4fb87184..275b979d 100644 --- a/src/otclient/const.h +++ b/src/otclient/const.h @@ -45,8 +45,6 @@ namespace Otc static const int ClientVersion = 862; static const int PicSignature = 0x4E119CBF; - static const char* Host = "sv3.radbr.com"; - static const int HostPort = 7171; enum OsTypes { OsWindow = 1, diff --git a/src/otclient/net/protocollogin.cpp b/src/otclient/net/protocollogin.cpp index ed2a02cb..5ac4313d 100644 --- a/src/otclient/net/protocollogin.cpp +++ b/src/otclient/net/protocollogin.cpp @@ -33,7 +33,7 @@ ProtocolLogin::ProtocolLogin() enableChecksum(); } -void ProtocolLogin::login(const std::string& accountName, const std::string& accountPassword) +void ProtocolLogin::login(const std::string& host, int port, const std::string& accountName, const std::string& accountPassword) { if(accountName.empty() || accountPassword.empty()) { callLuaField("onError", "You must enter an account name and password."); @@ -43,7 +43,7 @@ void ProtocolLogin::login(const std::string& accountName, const std::string& acc m_accountName = accountName; m_accountPassword = accountPassword; - connect(Otc::Host, Otc::HostPort); + connect(host, port); } void ProtocolLogin::onConnect() diff --git a/src/otclient/net/protocollogin.h b/src/otclient/net/protocollogin.h index bdc29b5a..facee6b0 100644 --- a/src/otclient/net/protocollogin.h +++ b/src/otclient/net/protocollogin.h @@ -36,7 +36,7 @@ public: static ProtocolLoginPtr create() { return ProtocolLoginPtr(new ProtocolLogin); } - void login(const std::string& accountName, const std::string& accountPassword); + void login(const std::string& host, int port, const std::string& accountName, const std::string& accountPassword); void cancelLogin() { disconnect(); } void onConnect();