Ref T357, FSX settings component allows to copy terrain probe via context

This commit is contained in:
Klaus Basan
2018-09-17 03:06:12 +02:00
parent 56ec1ed43d
commit 19ec4c3cf1
4 changed files with 63 additions and 13 deletions

View File

@@ -10,10 +10,15 @@
#include "fsxsettingscomponent.h" #include "fsxsettingscomponent.h"
#include "ui_fsxsettingscomponent.h" #include "ui_fsxsettingscomponent.h"
#include "simulatorfsxcommon.h" #include "simulatorfsxcommon.h"
#include "blackgui/overlaymessagesframe.h"
#include "blackgui/guiapplication.h" #include "blackgui/guiapplication.h"
#include "blackcore/context/contextsimulator.h"
using namespace BlackCore; using namespace BlackCore;
using namespace BlackCore::Context;
using namespace BlackGui; using namespace BlackGui;
using namespace BlackMisc;
using namespace BlackMisc::Simulation;
namespace BlackSimPlugin namespace BlackSimPlugin
{ {
@@ -28,6 +33,7 @@ namespace BlackSimPlugin
connect(ui->cb_TraceSimConnectCalls, &QCheckBox::released, this, &CFsxSettingsComponent::onSimConnectTraceChanged); connect(ui->cb_TraceSimConnectCalls, &QCheckBox::released, this, &CFsxSettingsComponent::onSimConnectTraceChanged);
connect(ui->cb_EnableTerrainProbe, &QCheckBox::released, this, &CFsxSettingsComponent::onEnableTerrainProbeChanged); connect(ui->cb_EnableTerrainProbe, &QCheckBox::released, this, &CFsxSettingsComponent::onEnableTerrainProbeChanged);
connect(ui->pb_CopyTerrainProbe, &QPushButton::released, this, &CFsxSettingsComponent::copyTerrainProbe);
const CSimulatorFsxCommon *fsx = this->getFsxSimulator(); const CSimulatorFsxCommon *fsx = this->getFsxSimulator();
if (fsx) if (fsx)
@@ -40,6 +46,12 @@ namespace BlackSimPlugin
CFsxSettingsComponent::~CFsxSettingsComponent() CFsxSettingsComponent::~CFsxSettingsComponent()
{ } { }
CSimulatorInfo CFsxSettingsComponent::getSimulator() const
{
const CSimulatorFsxCommon *fsx = this->getFsxSimulator();
return fsx ? fsx->getSimulatorInfo() : m_simulator;
}
void CFsxSettingsComponent::onSimConnectTraceChanged() void CFsxSettingsComponent::onSimConnectTraceChanged()
{ {
CSimulatorFsxCommon *fsx = this->getFsxSimulator(); CSimulatorFsxCommon *fsx = this->getFsxSimulator();
@@ -54,6 +66,16 @@ namespace BlackSimPlugin
fsx->setUsingFsxTerrainProbe(ui->cb_EnableTerrainProbe->isChecked()); fsx->setUsingFsxTerrainProbe(ui->cb_EnableTerrainProbe->isChecked());
} }
void CFsxSettingsComponent::copyTerrainProbe()
{
if (!sGui || !sGui->getIContextSimulator() || sGui->isShuttingDown()) { return; }
const CSimulatorInfo simulator(this->getSimulator());
const CStatusMessageList msgs = sGui->getIContextSimulator()->copyFsxTerrainProbe(simulator);
CLogMessage::preformatted(msgs);
if (!m_mf) { m_mf = CGuiUtility::nextOverlayMessageFrame(this); }
if (m_mf) { m_mf->showOverlayMessages(msgs); }
}
CSimulatorFsxCommon *CFsxSettingsComponent::getFsxSimulator() const CSimulatorFsxCommon *CFsxSettingsComponent::getFsxSimulator() const
{ {
if (!sGui || !sGui->getISimulator() || sGui->isShuttingDown()) { return nullptr; } if (!sGui || !sGui->getISimulator() || sGui->isShuttingDown()) { return nullptr; }

View File

@@ -17,6 +17,7 @@
#include <QScopedPointer> #include <QScopedPointer>
namespace Ui { class CFsxSettingsComponent; } namespace Ui { class CFsxSettingsComponent; }
namespace BlackGui { class COverlayMessagesFrame; }
namespace BlackSimPlugin namespace BlackSimPlugin
{ {
namespace FsxCommon namespace FsxCommon
@@ -38,6 +39,9 @@ namespace BlackSimPlugin
//! Simulator, P3D/FSX //! Simulator, P3D/FSX
void setSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) { m_simulator = simulator; } void setSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) { m_simulator = simulator; }
//! Represented simulator
BlackMisc::Simulation::CSimulatorInfo getSimulator() const;
private: private:
//! Trace checkbox changed //! Trace checkbox changed
void onSimConnectTraceChanged(); void onSimConnectTraceChanged();
@@ -45,10 +49,14 @@ namespace BlackSimPlugin
//! Terrain probe checkbox changed //! Terrain probe checkbox changed
void onEnableTerrainProbeChanged(); void onEnableTerrainProbeChanged();
//! Copy the terrain probe
void copyTerrainProbe();
//! Access the concrete implementation //! Access the concrete implementation
CSimulatorFsxCommon *getFsxSimulator () const; CSimulatorFsxCommon *getFsxSimulator() const;
BlackMisc::Simulation::CSimulatorInfo m_simulator { "FSX" }; BlackMisc::Simulation::CSimulatorInfo m_simulator { "FSX" };
BlackGui::COverlayMessagesFrame *m_mf = nullptr;
QScopedPointer<Ui::CFsxSettingsComponent> ui; QScopedPointer<Ui::CFsxSettingsComponent> ui;
}; };
} // ns } // ns

View File

@@ -7,13 +7,20 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>180</width> <width>180</width>
<height>64</height> <height>87</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>FSX settings</string> <string>FSX/P3D settings</string>
</property> </property>
<layout class="QGridLayout" name="gl_FsxSettingsComponent" columnstretch="0,1"> <layout class="QGridLayout" name="gl_SettingsComponent" columnstretch="0,1">
<item row="1" column="1">
<widget class="QLabel" name="lbl_TraceTerrainProbe">
<property name="text">
<string>Use the terrain probe</string>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QCheckBox" name="cb_TraceSimConnectCalls"> <widget class="QCheckBox" name="cb_TraceSimConnectCalls">
<property name="text"> <property name="text">
@@ -21,6 +28,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1" alignment="Qt::AlignLeft">
<widget class="QPushButton" name="pb_CopyTerrainProbe">
<property name="text">
<string> copy terrain probe </string>
</property>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="lbl_TraceSimConnectCalls"> <widget class="QLabel" name="lbl_TraceSimConnectCalls">
<property name="text"> <property name="text">
@@ -38,13 +52,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QLabel" name="lbl_TraceTerrainProbe">
<property name="text">
<string>Use the terrain probe</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>

View File

@@ -265,9 +265,22 @@ console=1
</item> </item>
<item row="4" column="0" colspan="2"> <item row="4" column="0" colspan="2">
<layout class="QHBoxLayout" name="hl_SimConnectCfgButtons"> <layout class="QHBoxLayout" name="hl_SimConnectCfgButtons">
<property name="spacing"> <property name="topMargin">
<number>3</number> <number>10</number>
</property> </property>
<item>
<spacer name="hs_SimConnectCfgButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QPushButton" name="pb_OpenSwiftSimConnectCfg"> <widget class="QPushButton" name="pb_OpenSwiftSimConnectCfg">
<property name="sizePolicy"> <property name="sizePolicy">