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.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
|
||||
|
|
|
@ -49,19 +49,21 @@ 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)
|
||||
if #account > 0 and autologin then
|
||||
addEvent(EnterGame.doLogin)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function EnterGame.destroy()
|
||||
enterGame:destroy()
|
||||
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -27,6 +27,12 @@
|
|||
#include <framework/graphics/graphics.h>
|
||||
#include <framework/core/eventdispatcher.h>
|
||||
|
||||
void UICheckBox::setup()
|
||||
{
|
||||
UIWidget::setup();
|
||||
setFocusable(false);
|
||||
}
|
||||
|
||||
void UICheckBox::render()
|
||||
{
|
||||
if(m_image) {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
class UICheckBox : public UIWidget
|
||||
{
|
||||
public:
|
||||
void setup();
|
||||
void render();
|
||||
|
||||
bool isChecked();
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue