as discussed in slack: added default swift testserver (FSD servers) if no settings can be loaded

This commit is contained in:
Klaus Basan
2015-07-11 01:36:06 +02:00
committed by Mathew Sutcliffe
parent d8e0ff83e6
commit 6a1f5e8347
5 changed files with 26 additions and 9 deletions

View File

@@ -16,6 +16,7 @@
#include "blackcore/context_simulator.h"
#include "blackcore/network.h"
#include "blackcore/simulator.h"
#include "blackcore/global_network_settings.h"
#include "blackmisc/logmessage.h"
#include "blackmisc/aviation/aircrafticaodata.h"
#include "../uppercasevalidator.h"
@@ -142,6 +143,12 @@ namespace BlackGui
ps_validateVatsimValues();
ps_onVatsimDataFileLoaded();
CServerList otherServers = this->m_trafficNetworkServers.get();
// add a testserver when no servers can be loaded
if (otherServers.isEmpty() && CProject::isDebugBuild())
{
otherServers.push_back(CGlobalNetworkSettings::instance().swiftFSDTestServer());
}
this->ui->cbp_OtherServers->setServers(otherServers);
}

View File

@@ -11,7 +11,9 @@
#include "ui_settingsnetworkserverscomponent.h"
#include "blackcore/context_network.h"
#include "blackcore/context_settings.h"
#include "blackcore/global_network_settings.h"
#include "blackmisc/logmessage.h"
#include "blackmisc/project.h"
#include "blackmisc/settingsblackmiscclasses.h"
using namespace BlackCore;
@@ -44,8 +46,15 @@ namespace BlackGui
void CSettingsNetworkServersComponent::reloadSettings()
{
// update servers
this->ui->tvp_SettingsTnServers->updateContainer(m_trafficNetworkServers.get());
CServerList serverList(m_trafficNetworkServers.get());
// add swift test server in case we have no servers
// this is debug/bootstrap feature we can continue to test when something goes wrong
if (serverList.isEmpty() && CProject::isDebugBuild())
{
serverList.push_back(CGlobalNetworkSettings::instance().swiftFSDTestServer());
}
this->ui->tvp_SettingsTnServers->updateContainer(serverList);
}
void CSettingsNetworkServersComponent::ps_networkServerSelected(QModelIndex index)
@@ -66,7 +75,7 @@ namespace BlackGui
return;
}
CServerList serverList = m_trafficNetworkServers.get();
CServerList serverList(m_trafficNetworkServers.get());
QObject *sender = QObject::sender();
if (sender == this->ui->pb_SettingsTnServersRemoveServer)
{

View File

@@ -51,7 +51,6 @@ namespace BlackGui
private:
QScopedPointer<Ui::CSettingsNetworkServersComponent> ui;
BlackCore::CSetting<BlackCore::Settings::Network::TrafficServers> m_trafficNetworkServers { this };
};
} // ns

View File

@@ -37,7 +37,7 @@ namespace BlackMisc
};
//! Default constructor.
CServer() : m_port(-1), m_isAcceptingConnections(true) {}
CServer() {}
//! Constructor.
CServer(const QString &name, const QString &description, const QString &address, int port, const CUser &user, bool isAcceptingConnections = true)
@@ -73,10 +73,10 @@ namespace BlackMisc
//! Set port
void setPort(int port) { m_port = port; }
//! Server is accepting connections
//! Server is accepting connections (allows to disable server temporarily)
bool isAcceptingConnections() const { return m_isAcceptingConnections; }
//! Set whether server is accepting connections
//! Set whether server is accepting connections (allows to disable server temporarily)
void setIsAcceptingConnections(bool value) { m_isAcceptingConnections = value; }
//! Is valid for login?
@@ -99,9 +99,9 @@ namespace BlackMisc
QString m_name;
QString m_description;
QString m_address;
int m_port;
int m_port = -1;
CUser m_user;
bool m_isAcceptingConnections;
bool m_isAcceptingConnections = true; //!< temp. disable server
};
} // namespace
} // namespace

View File

@@ -86,6 +86,7 @@ namespace BlackMisc
if (isCompiledWithBlackSound()) sl << "BlackSound";
if (isCompiledWithBlackInput()) sl << "BlackInput";
if (isCompiledWithGui()) sl << "BlackGui";
if (isCompiledWithFs9Support()) sl << "FS9";
if (isCompiledWithFsxSupport()) sl << "FSX";
if (isCompiledWithXPlaneSupport()) sl << "XPlane";
info = sl.join(", ");
@@ -102,6 +103,7 @@ namespace BlackMisc
static QStringList sl;
if (isCompiledWithFsxSupport()) sl << "FSX";
if (isCompiledWithXPlaneSupport()) sl << "XPlane";
if (isCompiledWithFs9Support()) sl << "FS9";
sims = sl.join(", ");
if (sims.isEmpty()) sims = "<none>";
}