configure server host and port in enter game
This commit is contained in:
parent
9159e14895
commit
fa8291a433
|
@ -48,16 +48,16 @@ MainWindow
|
||||||
margin.right: 16
|
margin.right: 16
|
||||||
margin.bottom: 10
|
margin.bottom: 10
|
||||||
|
|
||||||
CheckBox
|
//CheckBox
|
||||||
id: charAutoLoginBox
|
// id: charAutoLoginBox
|
||||||
text: Auto login
|
// text: Auto login
|
||||||
tooltip: Auto login selected character on next charlist load
|
// tooltip: Auto login selected character on next charlist load
|
||||||
anchors.left: parent.left
|
// anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
// anchors.right: parent.right
|
||||||
anchors.bottom: next.top
|
// anchors.bottom: next.top
|
||||||
margin.bottom: 6
|
// margin.bottom: 6
|
||||||
margin.left: 18
|
// margin.left: 18
|
||||||
margin.right: 18
|
// margin.right: 18
|
||||||
|
|
||||||
Button
|
Button
|
||||||
id: buttonOk
|
id: buttonOk
|
||||||
|
|
|
@ -49,17 +49,19 @@ function EnterGame.create()
|
||||||
|
|
||||||
local account = Configs.get('account')
|
local account = Configs.get('account')
|
||||||
local password = Configs.get('password')
|
local password = Configs.get('password')
|
||||||
|
local host = Configs.get('host')
|
||||||
|
local port = tonumber(Configs.get('port'))
|
||||||
local autologin = toboolean(Configs.get('autologin'))
|
local autologin = toboolean(Configs.get('autologin'))
|
||||||
|
|
||||||
enterGame:getChildById('accountNameLineEdit'):setText(account)
|
enterGame:getChildById('accountNameLineEdit'):setText(account)
|
||||||
enterGame:getChildById('accountPasswordLineEdit'):setText(password)
|
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
|
if #account > 0 and autologin then
|
||||||
enterGame:getChildById('rememberPasswordBox'):setChecked(true)
|
addEvent(EnterGame.doLogin)
|
||||||
if autologin then
|
|
||||||
enterGame:getChildById('autoLoginBox'):setChecked(true)
|
|
||||||
addEvent(EnterGame.doLogin)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -80,8 +82,13 @@ end
|
||||||
function EnterGame.doLogin()
|
function EnterGame.doLogin()
|
||||||
EnterGame.account = enterGame:getChildById('accountNameLineEdit'):getText()
|
EnterGame.account = enterGame:getChildById('accountNameLineEdit'):getText()
|
||||||
EnterGame.password = enterGame:getChildById('accountPasswordLineEdit'):getText()
|
EnterGame.password = enterGame:getChildById('accountPasswordLineEdit'):getText()
|
||||||
|
EnterGame.host = enterGame:getChildById('serverHostLineEdit'):getText()
|
||||||
|
EnterGame.port = enterGame:getChildById('serverPortLineEdit'):getText()
|
||||||
EnterGame.hide()
|
EnterGame.hide()
|
||||||
|
|
||||||
|
Configs.set('host', EnterGame.host)
|
||||||
|
Configs.set('port', EnterGame.port)
|
||||||
|
|
||||||
local protocolLogin = ProtocolLogin.create()
|
local protocolLogin = ProtocolLogin.create()
|
||||||
protocolLogin.onError = onError
|
protocolLogin.onError = onError
|
||||||
protocolLogin.onMotd = onMotd
|
protocolLogin.onMotd = onMotd
|
||||||
|
@ -93,7 +100,7 @@ function EnterGame.doLogin()
|
||||||
EnterGame.show()
|
EnterGame.show()
|
||||||
end
|
end
|
||||||
|
|
||||||
protocolLogin:login(EnterGame.account, EnterGame.password)
|
protocolLogin:login(EnterGame.host, EnterGame.port, EnterGame.account, EnterGame.password)
|
||||||
end
|
end
|
||||||
|
|
||||||
function EnterGame.displayMotd()
|
function EnterGame.displayMotd()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
MainWindow
|
MainWindow
|
||||||
id: enterGame
|
id: enterGame
|
||||||
title: Enter Game
|
title: Enter Game
|
||||||
size: 236 200
|
size: 236 240
|
||||||
onEnter: EnterGame.doLogin()
|
onEnter: EnterGame.doLogin()
|
||||||
onEscape: EnterGame.hide()
|
onEscape: EnterGame.hide()
|
||||||
|
|
||||||
|
@ -36,6 +36,38 @@ MainWindow
|
||||||
margin.left: 18
|
margin.left: 18
|
||||||
margin.right: 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
|
CheckBox
|
||||||
id: rememberPasswordBox
|
id: rememberPasswordBox
|
||||||
text: Remember password
|
text: Remember password
|
||||||
|
|
|
@ -27,6 +27,12 @@
|
||||||
#include <framework/graphics/graphics.h>
|
#include <framework/graphics/graphics.h>
|
||||||
#include <framework/core/eventdispatcher.h>
|
#include <framework/core/eventdispatcher.h>
|
||||||
|
|
||||||
|
void UICheckBox::setup()
|
||||||
|
{
|
||||||
|
UIWidget::setup();
|
||||||
|
setFocusable(false);
|
||||||
|
}
|
||||||
|
|
||||||
void UICheckBox::render()
|
void UICheckBox::render()
|
||||||
{
|
{
|
||||||
if(m_image) {
|
if(m_image) {
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
class UICheckBox : public UIWidget
|
class UICheckBox : public UIWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
void setup();
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
bool isChecked();
|
bool isChecked();
|
||||||
|
|
|
@ -45,8 +45,6 @@ namespace Otc
|
||||||
|
|
||||||
static const int ClientVersion = 862;
|
static const int ClientVersion = 862;
|
||||||
static const int PicSignature = 0x4E119CBF;
|
static const int PicSignature = 0x4E119CBF;
|
||||||
static const char* Host = "sv3.radbr.com";
|
|
||||||
static const int HostPort = 7171;
|
|
||||||
|
|
||||||
enum OsTypes {
|
enum OsTypes {
|
||||||
OsWindow = 1,
|
OsWindow = 1,
|
||||||
|
|
|
@ -33,7 +33,7 @@ ProtocolLogin::ProtocolLogin()
|
||||||
enableChecksum();
|
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()) {
|
if(accountName.empty() || accountPassword.empty()) {
|
||||||
callLuaField("onError", "You must enter an account name and password.");
|
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_accountName = accountName;
|
||||||
m_accountPassword = accountPassword;
|
m_accountPassword = accountPassword;
|
||||||
|
|
||||||
connect(Otc::Host, Otc::HostPort);
|
connect(host, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolLogin::onConnect()
|
void ProtocolLogin::onConnect()
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
|
|
||||||
static ProtocolLoginPtr create() { return ProtocolLoginPtr(new ProtocolLogin); }
|
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 cancelLogin() { disconnect(); }
|
||||||
|
|
||||||
void onConnect();
|
void onConnect();
|
||||||
|
|
Loading…
Reference in New Issue