Issue #37 GUI message when FPS drops below threshold

This commit is contained in:
Mat Sutcliffe
2021-08-10 16:02:58 +01:00
parent a89ca2d59a
commit 68933408db
4 changed files with 41 additions and 0 deletions

View File

@@ -108,6 +108,7 @@ namespace BlackGui
{
connect(sGui->getIContextSimulator(), &IContextSimulator::vitalityLost, this, &CLoginAdvComponent::autoLogoffDetection, Qt::QueuedConnection);
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CLoginAdvComponent::onSimulatorStatusChanged, Qt::QueuedConnection);
connect(sGui->getIContextSimulator(), &IContextSimulator::insufficientFrameRateDetected, this, &CLoginAdvComponent::autoLogoffFrameRate, Qt::QueuedConnection);
}
// inital setup, if data already available
@@ -341,6 +342,22 @@ namespace BlackGui
emit this->requestLoginPage();
}
void CLoginAdvComponent::autoLogoffFrameRate(bool fatal)
{
//! \fixme code duplication with function above
if (!ui->cb_AutoLogoff->isChecked()) { return; }
if (!this->hasValidContexts()) { return; }
if (!sGui->getIContextNetwork()->isConnected()) { return; }
const auto msg = fatal
? CStatusMessage(this, CStatusMessage::SeverityError, u"Sim frame rate too low to maintain constant simulation rate. Disconnecting to avoid disrupting the network.")
: CStatusMessage(this, CStatusMessage::SeverityWarning, u"Sim frame rate too low to maintain constant simulation rate. Reduce graphics quality to avoid disconnection.");
const int delaySecs = 30;
this->showOverlayHTMLMessage(msg, qRound(1000 * delaySecs * 0.8));
emit this->requestLoginPage();
}
bool CLoginAdvComponent::updateOwnAircraftCallsignAndPilotFromGuiValues()
{
if (!this->hasValidContexts()) { return false; }

View File

@@ -127,6 +127,9 @@ namespace BlackGui
//! Auto-logoff detection
void autoLogoffDetection();
//! Logoff due to insufficient simulator frame rate
void autoLogoffFrameRate(bool fatal);
//! Pause/Continue timeout
void toggleTimeout();

View File

@@ -146,6 +146,7 @@ namespace BlackGui
connect(sGui->getIContextSimulator(), &IContextSimulator::ownAircraftModelChanged, this, &CLoginComponent::onSimulatorModelChanged, Qt::QueuedConnection);
connect(sGui->getIContextSimulator(), &IContextSimulator::vitalityLost, this, &CLoginComponent::autoLogoffDetection, Qt::QueuedConnection);
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CLoginComponent::onSimulatorStatusChanged, Qt::QueuedConnection);
connect(sGui->getIContextSimulator(), &IContextSimulator::insufficientFrameRateDetected, this, &CLoginComponent::autoLogoffFrameRate, Qt::QueuedConnection);
}
if (sGui && sGui->getIContextNetwork())
@@ -722,6 +723,23 @@ namespace BlackGui
emit this->requestLoginPage();
}
void CLoginComponent::autoLogoffFrameRate(bool fatal)
{
//! \fixme code duplication with function above
if (!ui->cb_AutoLogoff->isChecked()) { return; }
if (!this->hasValidContexts()) { return; }
if (!sGui->getIContextNetwork()->isConnected()) { return; }
const auto msg = fatal
? CStatusMessage(this, CStatusMessage::SeverityError, u"Sim frame rate too low to maintain constant simulation rate. Disconnecting to avoid disrupting the network.")
: CStatusMessage(this, CStatusMessage::SeverityWarning, u"Sim frame rate too low to maintain constant simulation rate. Reduce graphics quality to avoid disconnection.");
const int delaySecs = 30;
this->showOverlayHTMLMessage(msg, qRound(1000 * delaySecs * 0.8));
if (fatal) { this->setLogoffCountdown(delaySecs); }
emit this->requestLoginPage();
}
void CLoginComponent::lookupOwnAircraftModel()
{
if (!this->hasValidContexts()) { return; }

View File

@@ -182,6 +182,9 @@ namespace BlackGui
//! Auto-logoff detection
void autoLogoffDetection();
//! Logoff due to insufficient simulator frame rate
void autoLogoffFrameRate(bool fatal);
//! Lookup own model
void lookupOwnAircraftModel();