2022-09-14 05:01:10 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
Item {
|
2022-04-30 07:27:56 +00:00
|
|
|
id: root
|
2022-09-14 05:01:10 +00:00
|
|
|
scale: 2
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
Frame {
|
|
|
|
id: join_server
|
|
|
|
anchors.centerIn: parent
|
2022-05-01 10:37:13 +00:00
|
|
|
background: Rectangle {
|
|
|
|
color: "#88888888"
|
|
|
|
radius: 2
|
|
|
|
}
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
Column {
|
|
|
|
spacing: 8
|
2022-12-18 04:52:52 +00:00
|
|
|
ComboBox {
|
2022-04-30 07:27:56 +00:00
|
|
|
id: server_addr
|
2022-12-18 04:52:52 +00:00
|
|
|
model: []
|
|
|
|
editable: true
|
|
|
|
|
|
|
|
onEditTextChanged: {
|
|
|
|
if (model.indexOf(editText) === -1) {
|
|
|
|
passwordEdit.text = "";
|
|
|
|
} else {
|
|
|
|
let data = config.savedPassword[editText];
|
|
|
|
screenNameEdit.text = data.username;
|
|
|
|
passwordEdit.text = data.shorten_password;
|
|
|
|
}
|
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: screenNameEdit
|
|
|
|
text: "player"
|
2022-12-18 04:52:52 +00:00
|
|
|
onTextChanged: {
|
|
|
|
passwordEdit.text = "";
|
|
|
|
let data = config.savedPassword[server_addr.editText];
|
|
|
|
if (data) {
|
|
|
|
if (text === data.username) {
|
|
|
|
passwordEdit.text = data.shorten_password;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
|
|
|
/*TextField {
|
|
|
|
id: avatarEdit
|
|
|
|
text: "liubei"
|
|
|
|
}*/
|
|
|
|
TextField {
|
|
|
|
id: passwordEdit
|
|
|
|
text: ""
|
|
|
|
echoMode: TextInput.Password
|
|
|
|
passwordCharacter: "*"
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: "Join Server"
|
2022-12-18 04:52:52 +00:00
|
|
|
enabled: passwordEdit.text !== ""
|
2022-04-30 07:27:56 +00:00
|
|
|
onClicked: {
|
2022-12-18 04:52:52 +00:00
|
|
|
config.serverAddr = server_addr.editText;
|
2022-04-30 07:27:56 +00:00
|
|
|
config.screenName = screenNameEdit.text;
|
|
|
|
config.password = passwordEdit.text;
|
|
|
|
mainWindow.busy = true;
|
2022-12-18 04:52:52 +00:00
|
|
|
Backend.joinServer(server_addr.editText);
|
2022-01-24 02:23:08 +00:00
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: "Console start"
|
2022-12-18 04:52:52 +00:00
|
|
|
enabled: passwordEdit.text !== ""
|
2022-04-30 07:27:56 +00:00
|
|
|
onClicked: {
|
2022-12-18 04:52:52 +00:00
|
|
|
config.serverAddr = "127.0.0.1";
|
2022-04-30 07:27:56 +00:00
|
|
|
config.screenName = screenNameEdit.text;
|
|
|
|
config.password = passwordEdit.text;
|
|
|
|
mainWindow.busy = true;
|
|
|
|
Backend.startServer(9527);
|
|
|
|
Backend.joinServer("127.0.0.1");
|
|
|
|
}
|
|
|
|
}
|
2022-01-24 02:23:08 +00:00
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
2022-12-18 04:52:52 +00:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
config.loadConf();
|
|
|
|
server_addr.model = Object.keys(config.savedPassword);
|
|
|
|
server_addr.onModelChanged();
|
|
|
|
server_addr.currentIndex = server_addr.model.indexOf(config.lastLoginServer);
|
|
|
|
|
|
|
|
let data = config.savedPassword[config.lastLoginServer];
|
|
|
|
screenNameEdit.text = data.username;
|
|
|
|
passwordEdit.text = data.shorten_password;
|
|
|
|
}
|
2022-01-24 02:23:08 +00:00
|
|
|
}
|