1
0
Fork 0

Launcher: avoid MP start with no server selected.

Default to first server in the list, if there is no valid previous
server to restore.
This commit is contained in:
James Turner 2018-01-28 12:35:12 +00:00
parent 21b8c7719e
commit e186fc6e2a
3 changed files with 14 additions and 2 deletions

View file

@ -141,6 +141,8 @@ void MPServersModel::restoreMPServerSelection()
if (it != m_servers.end()) {
emit restoreIndex(std::distance(m_servers.begin(), it));
} else {
emit restoreDefault();
}
}

View file

@ -33,7 +33,7 @@ public:
Q_INVOKABLE int portForIndex(int index) const;
signals:
void restoreIndex(int index);
void restoreDefault();
private:
SGSharedPtr<RemoteXMLRequest> m_mpServerRequest;

View file

@ -48,6 +48,11 @@ Section {
onRestoreIndex: {
mpServer.selectedIndex = index
}
onRestoreDefault: {
console.info("Selecting default MP server");
mpServer.selectedIndex = 0;
}
}
LineEdit {
@ -74,7 +79,12 @@ Section {
_config.setProperty("/sim/multiplay/txport", port);
} else {
var sel = mpServer.selectedIndex
_config.setProperty("/sim/multiplay/txhost", _mpServers.serverForIndex(sel));
var host = _mpServers.serverForIndex(sel);
if (host == "") {
console.warn("No host name for selected MP server " + sel)
}
_config.setProperty("/sim/multiplay/txhost", host);
var port = _mpServers.portForIndex(sel);
if (port == 0) {
port = defaultMPPort;