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:
parent
21b8c7719e
commit
e186fc6e2a
3 changed files with 14 additions and 2 deletions
|
@ -141,6 +141,8 @@ void MPServersModel::restoreMPServerSelection()
|
|||
|
||||
if (it != m_servers.end()) {
|
||||
emit restoreIndex(std::distance(m_servers.begin(), it));
|
||||
} else {
|
||||
emit restoreDefault();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
Q_INVOKABLE int portForIndex(int index) const;
|
||||
signals:
|
||||
void restoreIndex(int index);
|
||||
|
||||
void restoreDefault();
|
||||
private:
|
||||
|
||||
SGSharedPtr<RemoteXMLRequest> m_mpServerRequest;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue