1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Store settings

This commit is contained in:
nordsoft 2022-10-23 23:24:33 +04:00
parent 2761c59cf0
commit aac859a030
3 changed files with 23 additions and 2 deletions

View File

@ -380,7 +380,7 @@
"type" : "object",
"default": {},
"additionalProperties" : false,
"required" : [ "repositoryURL", "enableInstalledMods", "extraResolutionsModPath", "autoCheckRepositories", "updateOnStartup", "updateConfigUrl" ],
"required" : [ "repositoryURL", "enableInstalledMods", "extraResolutionsModPath", "autoCheckRepositories", "updateOnStartup", "updateConfigUrl", "lobbyUrl", "lobbyPort", "lobbyUsername" ],
"properties" : {
"repositoryURL" : {
"type" : "array",
@ -410,6 +410,18 @@
"updateConfigUrl" : {
"type" : "string",
"default" : "https://raw.githubusercontent.com/vcmi/vcmi-updates/master/vcmi-updates.json"
},
"lobbyUrl" : {
"type" : "string",
"default" : "127.0.0.1"
},
"lobbyPort" : {
"type" : "number",
"default" : 5002
},
"lobbyUsername" : {
"type" : "string",
"default" : ""
}
}
}

View File

@ -1,6 +1,9 @@
#include "lobby_moc.h"
#include "ui_lobby_moc.h"
#include "../lib/GameConstants.h"
#include "../jsonutils.h"
#include "../../lib/CConfigHandler.h"
//#include "../../lib/VCMIDirs.h"
SocketLobby::SocketLobby(QObject *parent) :
QObject(parent)
@ -253,6 +256,12 @@ void Lobby::on_connectButton_toggled(bool checked)
if(checked)
{
username = ui->userEdit->text();
Settings node = settings.write["launcher"];
node["lobbyUrl"].String() = ui->hostEdit->text().toStdString();
node["lobbyPort"].Integer() = ui->portEdit->text().toInt();
node["lobbyUsername"].String() = username.toStdString();
socketLobby.connectServer(ui->hostEdit->text(), ui->portEdit->text().toInt(), username);
}
else

View File

@ -36,7 +36,7 @@ const QMap<ProtocolConsts, QString> ProtocolStrings
{SESSIONS, "SESSIONS"}, //amount:session_name:joined_players:total_players:is_protected
{JOINED, "JOIN"}, //session_name:username
{KICKED, "KICK"}, //session_name:username
{START, "START"}, //session_name
{START, "START"}, //session_name:uuid
{STATUS, "STATUS"}, //joined_players:player_name:is_ready
{ERROR, "ERROR"},
{CHAT, "MSG"} //username:message