mirror of
https://github.com/hawkeye-stan/msfs-popout-panel-manager.git
synced 2024-11-21 13:20:11 +00:00
Update camera view logic
This commit is contained in:
parent
079e040ce7
commit
324b7a051b
13 changed files with 327 additions and 207 deletions
|
@ -46,6 +46,9 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
|
|||
case StatusMessageType.Failure:
|
||||
run.Foreground = new SolidColorBrush(Colors.IndianRed);
|
||||
break;
|
||||
case StatusMessageType.Executing:
|
||||
run.Foreground = new SolidColorBrush(Colors.Yellow);
|
||||
break;
|
||||
case StatusMessageType.Info:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
|
|||
if (AppSettingData.ApplicationSetting.PopOutSetting.EnablePopOutMessages)
|
||||
{
|
||||
WindowActionManager.ApplyAlwaysOnTop(Handle, PanelType.StatusMessageWindow, true);
|
||||
OnMessageUpdated?.Invoke(this, FormatStatusMessages(e.Messages));
|
||||
OnMessageUpdated?.Invoke(this, FormatStatusMessages(e));
|
||||
|
||||
CenterDialogToGameWindow();
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
_simConnectProvider = null;
|
||||
}
|
||||
|
||||
public void TurnOnTrackIR(bool writeMessage = true)
|
||||
public void TurnOnTrackIR()
|
||||
{
|
||||
if (_simConnectProvider == null)
|
||||
return;
|
||||
|
@ -122,8 +122,8 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
if (!_appSettingData.ApplicationSetting.TrackIRSetting.AutoDisableTrackIR)
|
||||
return;
|
||||
|
||||
StatusMessageWriter.WriteMessage("Turning on TrackIR", StatusMessageType.Info);
|
||||
|
||||
WorkflowStepWithMessage.Execute("Turning on TrackIR", () =>
|
||||
{
|
||||
int count = 0;
|
||||
do
|
||||
{
|
||||
|
@ -133,13 +133,11 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
}
|
||||
while (!_flightSimData.TrackIRStatus && count < 5);
|
||||
|
||||
if (_flightSimData.TrackIRStatus)
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
else
|
||||
StatusMessageWriter.WriteFailureStatusMessage();
|
||||
return _flightSimData.TrackIRStatus;
|
||||
});
|
||||
}
|
||||
|
||||
public void TurnOffTrackIR(bool writeMessage = true)
|
||||
public void TurnOffTrackIR()
|
||||
{
|
||||
if (_simConnectProvider == null)
|
||||
return;
|
||||
|
@ -147,8 +145,8 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
if (!_appSettingData.ApplicationSetting.TrackIRSetting.AutoDisableTrackIR)
|
||||
return;
|
||||
|
||||
StatusMessageWriter.WriteMessage("Turning off TrackIR", StatusMessageType.Info);
|
||||
|
||||
WorkflowStepWithMessage.Execute("Turning off TrackIR", () =>
|
||||
{
|
||||
int count = 0;
|
||||
do
|
||||
{
|
||||
|
@ -158,13 +156,8 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
}
|
||||
while (_flightSimData.TrackIRStatus && count < 5);
|
||||
|
||||
if (!writeMessage)
|
||||
return;
|
||||
|
||||
if (!_flightSimData.TrackIRStatus)
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
else
|
||||
StatusMessageWriter.WriteFailureStatusMessage();
|
||||
return !_flightSimData.TrackIRStatus;
|
||||
});
|
||||
}
|
||||
|
||||
public void TurnOnPower()
|
||||
|
@ -176,8 +169,9 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
return;
|
||||
|
||||
_isTurnedOnPower = true;
|
||||
StatusMessageWriter.WriteMessage("Turning on battery", StatusMessageType.Info);
|
||||
|
||||
WorkflowStepWithMessage.Execute("Turning on battery", () =>
|
||||
{
|
||||
int count = 0;
|
||||
do
|
||||
{
|
||||
|
@ -187,10 +181,8 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
}
|
||||
while (!_flightSimData.ElectricalMasterBatteryStatus && count < 10);
|
||||
|
||||
if (_flightSimData.ElectricalMasterBatteryStatus)
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
else
|
||||
StatusMessageWriter.WriteFailureStatusMessage();
|
||||
return _flightSimData.ElectricalMasterBatteryStatus;
|
||||
});
|
||||
}
|
||||
|
||||
public void TurnOffPower()
|
||||
|
@ -201,8 +193,8 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
if (_profileData.ActiveProfile == null || !_isTurnedOnPower)
|
||||
return;
|
||||
|
||||
StatusMessageWriter.WriteMessage("Turning off battery", StatusMessageType.Info);
|
||||
|
||||
WorkflowStepWithMessage.Execute("Turning off battery", () =>
|
||||
{
|
||||
int count = 0;
|
||||
do
|
||||
{
|
||||
|
@ -212,10 +204,8 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
}
|
||||
while (_flightSimData.ElectricalMasterBatteryStatus && count < 10);
|
||||
|
||||
if (!_flightSimData.ElectricalMasterBatteryStatus)
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
else
|
||||
StatusMessageWriter.WriteFailureStatusMessage();
|
||||
return !_flightSimData.ElectricalMasterBatteryStatus;
|
||||
});
|
||||
|
||||
_isTurnedOnPower = false;
|
||||
}
|
||||
|
@ -230,8 +220,8 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
|
||||
_isTurnedOnAvionics = true;
|
||||
|
||||
StatusMessageWriter.WriteMessage("Turning on avionics", StatusMessageType.Info);
|
||||
|
||||
WorkflowStepWithMessage.Execute("Turning on avionics", () =>
|
||||
{
|
||||
int count = 0;
|
||||
do
|
||||
{
|
||||
|
@ -241,10 +231,8 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
}
|
||||
while (!_flightSimData.AvionicsMasterSwitchStatus && count < 10);
|
||||
|
||||
if (_flightSimData.AvionicsMasterSwitchStatus)
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
else
|
||||
StatusMessageWriter.WriteFailureStatusMessage();
|
||||
return _flightSimData.AvionicsMasterSwitchStatus;
|
||||
});
|
||||
}
|
||||
|
||||
public void TurnOffAvionics()
|
||||
|
@ -255,8 +243,8 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
if (_profileData.ActiveProfile == null || !_isTurnedOnAvionics)
|
||||
return;
|
||||
|
||||
StatusMessageWriter.WriteMessage("Turning off avionics", StatusMessageType.Info);
|
||||
|
||||
WorkflowStepWithMessage.Execute("Turning off avionics", () =>
|
||||
{
|
||||
int count = 0;
|
||||
do
|
||||
{
|
||||
|
@ -266,10 +254,8 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
}
|
||||
while (_flightSimData.AvionicsMasterSwitchStatus && count < 10);
|
||||
|
||||
if (!_flightSimData.AvionicsMasterSwitchStatus)
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
else
|
||||
StatusMessageWriter.WriteFailureStatusMessage();
|
||||
return !_flightSimData.AvionicsMasterSwitchStatus;
|
||||
});
|
||||
|
||||
_isTurnedOnAvionics = false;
|
||||
}
|
||||
|
@ -282,9 +268,10 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
if (!_appSettingData.ApplicationSetting.PopOutSetting.AutoActivePause)
|
||||
return;
|
||||
|
||||
StatusMessageWriter.WriteMessage("Turning on active pause", StatusMessageType.Info);
|
||||
WorkflowStepWithMessage.Execute("Turning on active pause", () =>
|
||||
{
|
||||
_simConnectProvider.TurnOnActivePause();
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
});
|
||||
}
|
||||
|
||||
public void TurnOffActivePause()
|
||||
|
@ -295,10 +282,10 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
if (!_appSettingData.ApplicationSetting.PopOutSetting.AutoActivePause)
|
||||
return;
|
||||
|
||||
StatusMessageWriter.WriteMessage("Turning off active pause", StatusMessageType.Info);
|
||||
WorkflowStepWithMessage.Execute("Turning off active pause", () =>
|
||||
{
|
||||
_simConnectProvider.TurnOffActivePause();
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public void IncreaseSimRate()
|
||||
|
@ -328,6 +315,11 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
_simConnectProvider.SetCockpitCameraZoomLevel(zoomLevel);
|
||||
}
|
||||
|
||||
public void ResetCameraView()
|
||||
{
|
||||
_simConnectProvider.SetCameraRequestAction(1);
|
||||
}
|
||||
|
||||
public void SetHudBarConfig()
|
||||
{
|
||||
if (_simConnectProvider == null)
|
||||
|
|
|
@ -8,6 +8,7 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace MSFSPopoutPanelManager.Orchestration
|
||||
{
|
||||
|
@ -86,7 +87,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
|
||||
StatusMessageWriter.IsEnabled = true;
|
||||
StatusMessageWriter.ClearMessage();
|
||||
StatusMessageWriter.WriteMessageNewLine("Pop out in progress. Please refrain from moving your mouse.", StatusMessageType.Info);
|
||||
StatusMessageWriter.WriteMessageWithNewLine("Pop out in progress. Please refrain from moving your mouse.", StatusMessageType.Info);
|
||||
|
||||
StepPopoutPrep();
|
||||
|
||||
|
@ -141,10 +142,11 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
// Set Windowed Display Mode window's configuration if needed
|
||||
if (_appSettingData.ApplicationSetting.WindowedModeSetting.AutoResizeMsfsGameWindow && WindowActionManager.IsMsfsGameInWindowedMode())
|
||||
{
|
||||
StatusMessageWriter.WriteMessage("Moving and resizing MSFS game window", StatusMessageType.Info);
|
||||
WorkflowStepWithMessage.Execute("Moving and resizing MSFS game window", () =>
|
||||
{
|
||||
WindowActionManager.SetMsfsGameWindowLocation(ActiveProfile.MsfsGameWindowConfig);
|
||||
Thread.Sleep(500);
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
Thread.Sleep(1000);
|
||||
});
|
||||
}
|
||||
|
||||
// Turn on power and avionics if required to pop out panels at least one (fix Cessna 208b grand caravan mod bug where battery is reported as on)
|
||||
|
@ -163,13 +165,28 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
// Setting custom camera angle for auto panning
|
||||
if (AppSetting.PopOutSetting.AutoPanning.IsEnabled)
|
||||
{
|
||||
StatusMessageWriter.WriteMessage("Setting auto panning camera angle", StatusMessageType.Info);
|
||||
StatusMessageWriter.WriteMessageWithNewLine("Setting auto panning camera view", StatusMessageType.Info);
|
||||
|
||||
// Remember current game's zoom level to be recall after pop out
|
||||
_prePopOutCockpitZoomLevel = _flightSimData.CockpitCameraZoom;
|
||||
|
||||
WorkflowStepWithMessage.Execute("Resetting camera view", () =>
|
||||
{
|
||||
ResetCockpitView();
|
||||
Thread.Sleep(2000);
|
||||
}, true);
|
||||
|
||||
WorkflowStepWithMessage.Execute("Loading custom camera view", () =>
|
||||
{
|
||||
LoadCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding);
|
||||
Thread.Sleep(2000);
|
||||
}, true);
|
||||
|
||||
|
||||
WorkflowStepWithMessage.Execute("Setting camera zoom level", () =>
|
||||
{
|
||||
SetCockpitZoomLevel(50);
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
}, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -181,13 +198,16 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
// Save current application location to restore it after pop out
|
||||
var appLocation = WindowActionManager.GetWindowRectangle(WindowProcessManager.GetApplicationProcess().Handle);
|
||||
|
||||
if(ActiveProfile.PanelConfigs.Count > 0)
|
||||
StatusMessageWriter.WriteMessageWithNewLine("Popping out user defined panels", StatusMessageType.Info);
|
||||
|
||||
int index = 0;
|
||||
foreach (var panelConfig in ActiveProfile.PanelConfigs)
|
||||
{
|
||||
if (panelConfig.PanelType == PanelType.CustomPopout)
|
||||
{
|
||||
StatusMessageWriter.WriteMessage($"Popping out panel '{panelConfig.PanelName}'", StatusMessageType.Info);
|
||||
|
||||
WorkflowStepWithMessage.Execute(panelConfig.PanelName, () =>
|
||||
{
|
||||
panelConfig.IsSelectedPanelSource = true;
|
||||
//PanelSourceOrchestrator.ShowPanelSourceNonEdit(panelConfig);
|
||||
//Thread.Sleep(500);
|
||||
|
@ -197,9 +217,10 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
panelConfig.IsSelectedPanelSource = false;
|
||||
|
||||
if (panelConfig.IsPopOutSuccess != null && !(bool)panelConfig.IsPopOutSuccess)
|
||||
StatusMessageWriter.WriteFailureStatusMessage();
|
||||
return false;
|
||||
else
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
return true;
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,20 +246,23 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
FlightSimOrchestrator.TurnOffActivePause();
|
||||
|
||||
// Return to custom camera view if set
|
||||
var task = Task.Run(() => {
|
||||
//SetCockpitZoomLevel(_prePopOutCockpitZoomLevel);
|
||||
ReturnToAfterPopOutCameraView();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void StepAddBuiltInPanels(List<IntPtr> builtInPanelHandles)
|
||||
{
|
||||
if (ActiveProfile.ProfileSetting.IncludeInGamePanels)
|
||||
{
|
||||
var builtInPanels = new List<PanelConfig>();
|
||||
WorkflowStepWithMessage.Execute("Configuring built-in panel", () =>
|
||||
{
|
||||
int count = 0;
|
||||
while (builtInPanelHandles.Count == 0 && count < 5)
|
||||
{
|
||||
builtInPanelHandles = WindowActionManager.GetWindowsByPanelType(new List<PanelType>() { PanelType.BuiltInPopout });
|
||||
}
|
||||
|
||||
StatusMessageWriter.WriteMessage("Configuring built-in panel", StatusMessageType.Info);
|
||||
var builtInPanels = new List<PanelConfig>();
|
||||
|
||||
foreach (var panelHandle in builtInPanelHandles)
|
||||
{
|
||||
|
@ -284,9 +308,10 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
|
||||
if (ActiveProfile.PanelConfigs.Any(p => p.PanelType == PanelType.BuiltInPopout && p.IsPopOutSuccess != null && !(bool)p.IsPopOutSuccess) ||
|
||||
ActiveProfile.PanelConfigs.Count(p => p.PanelType == PanelType.BuiltInPopout) == 0)
|
||||
StatusMessageWriter.WriteFailureStatusMessage();
|
||||
return false;
|
||||
else
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -295,13 +320,11 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
if (!ActiveProfile.ProfileSetting.HudBarConfig.IsEnabled)
|
||||
return;
|
||||
|
||||
StatusMessageWriter.WriteMessage("Opening HUD Bar", StatusMessageType.Info);
|
||||
|
||||
WorkflowStepWithMessage.Execute("Opening HUD Bar", () =>
|
||||
{
|
||||
var panelConfig = ActiveProfile.PanelConfigs.FirstOrDefault(p => p.PanelType == PanelType.HudBarWindow);
|
||||
|
||||
OnHudBarOpened?.Invoke(this, panelConfig);
|
||||
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
});
|
||||
}
|
||||
|
||||
public void SetupRefocusDisplay()
|
||||
|
@ -309,13 +332,21 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
if (!ActiveProfile.ProfileSetting.RefocusOnDisplay.IsEnabled)
|
||||
return;
|
||||
|
||||
foreach (var panelConfig in ActiveProfile.PanelConfigs.Where(p => p.PanelType == PanelType.RefocusDisplay))
|
||||
var panelConfigs = ActiveProfile.PanelConfigs.Where(p => p.PanelType == PanelType.RefocusDisplay);
|
||||
|
||||
if (panelConfigs.Count() == 0)
|
||||
return;
|
||||
|
||||
StatusMessageWriter.WriteMessageWithNewLine("Configurating panels for auto refocus on touch", StatusMessageType.Info);
|
||||
|
||||
foreach (var panelConfig in panelConfigs)
|
||||
{
|
||||
if (panelConfig != null)
|
||||
{
|
||||
StatusMessageWriter.WriteMessage($"Configurating {panelConfig.PanelName} for auto refocus on touch", StatusMessageType.Info);
|
||||
WorkflowStepWithMessage.Execute(panelConfig.PanelName, () =>
|
||||
{
|
||||
panelConfig.PanelHandle = new IntPtr(1);
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -349,9 +380,9 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
PanelConfigurationOrchestrator.StartTouchHook();
|
||||
|
||||
if (CheckForPopOutError())
|
||||
StatusMessageWriter.WriteMessageNewLine("Pop out has been completed with error.", StatusMessageType.Info, 10);
|
||||
StatusMessageWriter.WriteMessageWithNewLine("Pop out has been completed with error.", StatusMessageType.Info);
|
||||
else
|
||||
StatusMessageWriter.WriteMessageNewLine("Pop out has been completed successfully.", StatusMessageType.Info, 10);
|
||||
StatusMessageWriter.WriteMessageWithNewLine("Pop out has been completed successfully.", StatusMessageType.Info);
|
||||
|
||||
Thread.Sleep(1000);
|
||||
OnPopOutCompleted?.Invoke(this, null);
|
||||
|
@ -461,15 +492,41 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
if (!AppSetting.PopOutSetting.AfterPopOutCameraView.IsEnabled)
|
||||
return;
|
||||
|
||||
StatusMessageWriter.WriteMessageWithNewLine("Applying cockpit view after pop out", StatusMessageType.Info);
|
||||
|
||||
switch (AppSetting.PopOutSetting.AfterPopOutCameraView.CameraView)
|
||||
{
|
||||
case AfterPopOutCameraViewType.CockpitCenterView:
|
||||
InputEmulationManager.CenterView();
|
||||
WorkflowStepWithMessage.Execute("Resetting camera view", () =>
|
||||
{
|
||||
ResetCockpitView();
|
||||
Thread.Sleep(1000);
|
||||
}, true);
|
||||
|
||||
WorkflowStepWithMessage.Execute("Setting camera zoom level", () =>
|
||||
{
|
||||
SetCockpitZoomLevel(_prePopOutCockpitZoomLevel);
|
||||
}, true);
|
||||
|
||||
break;
|
||||
case AfterPopOutCameraViewType.CustomCameraView:
|
||||
WorkflowStepWithMessage.Execute("Resetting camera view", () =>
|
||||
{
|
||||
ResetCockpitView();
|
||||
Thread.Sleep(1000);
|
||||
}, true);
|
||||
|
||||
WorkflowStepWithMessage.Execute("Loading custom camera view", () =>
|
||||
{
|
||||
LoadCustomView(AppSetting.PopOutSetting.AfterPopOutCameraView.KeyBinding);
|
||||
Thread.Sleep(1000);
|
||||
}, true);
|
||||
|
||||
WorkflowStepWithMessage.Execute("Setting camera zoom level", () =>
|
||||
{
|
||||
SetCockpitZoomLevel(_prePopOutCockpitZoomLevel);
|
||||
}, true);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -479,13 +536,25 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
return ActiveProfile.PanelConfigs.Count(p => p.IsPopOutSuccess != null && (bool)p.IsPopOutSuccess) != ActiveProfile.PanelConfigs.Count(p => p.IsPopOutSuccess != null);
|
||||
}
|
||||
|
||||
private void ResetCockpitView()
|
||||
{
|
||||
int retry = 10;
|
||||
for (var i = 0; i < retry; i++)
|
||||
{
|
||||
FlightSimOrchestrator.ResetCameraView();
|
||||
Thread.Sleep(1000); // wait for flightsimdata to be updated
|
||||
if (_flightSimData.CameraViewTypeAndIndex1 == 0) // 0 = reset view
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadCustomView(string keybinding)
|
||||
{
|
||||
int retry = 20;
|
||||
for(var i = 0; i < retry; i++)
|
||||
{
|
||||
InputEmulationManager.LoadCustomView(keybinding);
|
||||
Thread.Sleep(750); // wait for flightsimdata to be updated
|
||||
Thread.Sleep(1000); // wait for flightsimdata to be updated
|
||||
if (_flightSimData.CameraViewTypeAndIndex1 == 7) // 7 = custom camera view enum
|
||||
break;
|
||||
}
|
||||
|
@ -497,7 +566,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
for (var i = 0; i < retry; i++)
|
||||
{
|
||||
FlightSimOrchestrator.SetCockpitCameraZoomLevel(zoom);
|
||||
Thread.Sleep(500); // wait for flightsimdata to be updated
|
||||
Thread.Sleep(1000); // wait for flightsimdata to be updated
|
||||
|
||||
if (_flightSimData.CockpitCameraZoom == zoom)
|
||||
break;
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
}
|
||||
|
||||
// Turn off TrackIR if TrackIR is started
|
||||
FlightSimOrchestrator.TurnOffTrackIR(false);
|
||||
FlightSimOrchestrator.TurnOffTrackIR();
|
||||
}
|
||||
|
||||
public async Task EndEditPanelSources()
|
||||
|
@ -88,19 +88,22 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
// Save last auto panning camera angle
|
||||
if (AppSetting.PopOutSetting.AutoPanning.IsEnabled)
|
||||
{
|
||||
InputEmulationManager.SaveCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding);
|
||||
|
||||
// If using windows mode, save MSFS game window configuration
|
||||
if (_appSettingData.ApplicationSetting.WindowedModeSetting.AutoResizeMsfsGameWindow)
|
||||
_profileData.SaveMsfsGameWindowConfig();
|
||||
|
||||
InputEmulationManager.SaveCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding);
|
||||
}
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
Thread.Sleep(500); // wait for custom view save to be completed
|
||||
|
||||
// Recenter game or return to after pop out camera view
|
||||
if (!AppSetting.PopOutSetting.AfterPopOutCameraView.IsEnabled)
|
||||
{
|
||||
InputEmulationManager.CenterView();
|
||||
FlightSimOrchestrator.ResetCameraView();
|
||||
Thread.Sleep(500);
|
||||
SetCockpitZoomLevel(_prePanelConfigurationCockpitZoomLevel);
|
||||
}
|
||||
else
|
||||
|
@ -108,7 +111,8 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
switch (AppSetting.PopOutSetting.AfterPopOutCameraView.CameraView)
|
||||
{
|
||||
case AfterPopOutCameraViewType.CockpitCenterView:
|
||||
InputEmulationManager.CenterView();
|
||||
FlightSimOrchestrator.ResetCameraView();
|
||||
Thread.Sleep(500);
|
||||
SetCockpitZoomLevel(_prePanelConfigurationCockpitZoomLevel);
|
||||
break;
|
||||
case AfterPopOutCameraViewType.CustomCameraView:
|
||||
|
@ -121,7 +125,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
WindowActionManager.BringWindowToForeground(ApplicationHandle);
|
||||
|
||||
// Turn TrackIR back on
|
||||
FlightSimOrchestrator.TurnOnTrackIR(false);
|
||||
FlightSimOrchestrator.TurnOnTrackIR();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -8,20 +8,9 @@ namespace MSFSPopoutPanelManager.Shared
|
|||
public StatusMessageEventArg(List<StatusMessage> messages)
|
||||
{
|
||||
Messages = messages;
|
||||
Duration = -1;
|
||||
}
|
||||
|
||||
public StatusMessageEventArg(List<StatusMessage> messages, int duration)
|
||||
{
|
||||
Messages = messages;
|
||||
Duration = duration;
|
||||
}
|
||||
|
||||
public List<StatusMessage> Messages { get; set; }
|
||||
|
||||
public StatusMessageType StatusMessageType { get; set; }
|
||||
|
||||
public int Duration { get; set; }
|
||||
}
|
||||
|
||||
public class StatusMessage
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
Info,
|
||||
Success,
|
||||
Failure,
|
||||
Executing,
|
||||
Error,
|
||||
Debug
|
||||
}
|
||||
|
|
|
@ -7,44 +7,57 @@ namespace MSFSPopoutPanelManager.Shared
|
|||
{
|
||||
private static List<StatusMessage> _messages = new List<StatusMessage>();
|
||||
|
||||
public static event EventHandler<StatusMessageEventArg> OnStatusMessage;
|
||||
public static event EventHandler<List<StatusMessage>> OnStatusMessage;
|
||||
|
||||
public static void WriteMessage(string message, StatusMessageType statusMessageType, int duration = -1)
|
||||
public static void WriteMessage(string message, StatusMessageType statusMessageType)
|
||||
{
|
||||
_messages.Add(new StatusMessage { Message = message, StatusMessageType = statusMessageType, NewLine = false });
|
||||
_messages.Add(new StatusMessage { Message = message, StatusMessageType = statusMessageType });
|
||||
|
||||
if (IsEnabled)
|
||||
OnStatusMessage?.Invoke(null, new StatusMessageEventArg(_messages, duration));
|
||||
OnStatusMessage?.Invoke(null, _messages);
|
||||
}
|
||||
|
||||
public static void WriteMessageNewLine(string message, StatusMessageType statusMessageType, int duration = -1)
|
||||
public static void WriteMessageWithNewLine(string message, StatusMessageType statusMessageType)
|
||||
{
|
||||
_messages.Add(new StatusMessage { Message = message, StatusMessageType = statusMessageType, NewLine = true });
|
||||
|
||||
if (IsEnabled)
|
||||
OnStatusMessage?.Invoke(null, new StatusMessageEventArg(_messages, duration));
|
||||
OnStatusMessage?.Invoke(null, _messages);
|
||||
}
|
||||
|
||||
public static void WriteOkStatusMessage(int duration = -1)
|
||||
public static void WriteExecutingStatusMessage()
|
||||
{
|
||||
_messages.Add(new StatusMessage { Message = " (Executing)", StatusMessageType = StatusMessageType.Executing, NewLine = false });
|
||||
|
||||
if (IsEnabled)
|
||||
OnStatusMessage?.Invoke(null, _messages);
|
||||
}
|
||||
|
||||
public static void WriteOkStatusMessage()
|
||||
{
|
||||
_messages.Add(new StatusMessage { Message = " (OK)", StatusMessageType = StatusMessageType.Success, NewLine = true });
|
||||
|
||||
if (IsEnabled)
|
||||
OnStatusMessage?.Invoke(null, new StatusMessageEventArg(_messages, duration));
|
||||
OnStatusMessage?.Invoke(null, _messages);
|
||||
}
|
||||
|
||||
public static void WriteFailureStatusMessage(int duration = -1)
|
||||
public static void WriteFailureStatusMessage()
|
||||
{
|
||||
_messages.Add(new StatusMessage { Message = " (FAILED)", StatusMessageType = StatusMessageType.Failure, NewLine = true });
|
||||
|
||||
if (IsEnabled)
|
||||
OnStatusMessage?.Invoke(null, new StatusMessageEventArg(_messages, duration));
|
||||
OnStatusMessage?.Invoke(null, _messages);
|
||||
}
|
||||
|
||||
public static void RemoveLastMessage()
|
||||
{
|
||||
_messages.RemoveAt(_messages.Count - 1);
|
||||
}
|
||||
|
||||
public static void ClearMessage()
|
||||
{
|
||||
_messages.Clear();
|
||||
OnStatusMessage?.Invoke(null, new StatusMessageEventArg(new List<StatusMessage>()));
|
||||
OnStatusMessage?.Invoke(null, new List<StatusMessage>());
|
||||
}
|
||||
|
||||
public static bool IsEnabled { get; set; }
|
||||
|
|
38
Shared/WorkflowStepWithMessage.cs
Normal file
38
Shared/WorkflowStepWithMessage.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
|
||||
namespace MSFSPopoutPanelManager.Shared
|
||||
{
|
||||
public static class WorkflowStepWithMessage
|
||||
{
|
||||
public static void Execute(string message, Func<bool> function, bool isSubTask = false)
|
||||
{
|
||||
if (isSubTask)
|
||||
message = " " + message;
|
||||
|
||||
StatusMessageWriter.WriteMessage(message, StatusMessageType.Info);
|
||||
StatusMessageWriter.WriteExecutingStatusMessage();
|
||||
|
||||
var result = function.Invoke();
|
||||
|
||||
StatusMessageWriter.RemoveLastMessage();
|
||||
if (result)
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
else
|
||||
StatusMessageWriter.WriteFailureStatusMessage();
|
||||
}
|
||||
|
||||
public static void Execute(string message, Action function, bool isSubTask = false)
|
||||
{
|
||||
if (isSubTask)
|
||||
message = " " + message;
|
||||
|
||||
StatusMessageWriter.WriteMessage(message, StatusMessageType.Info);
|
||||
StatusMessageWriter.WriteExecutingStatusMessage();
|
||||
|
||||
function.Invoke();
|
||||
|
||||
StatusMessageWriter.RemoveLastMessage();
|
||||
StatusMessageWriter.WriteOkStatusMessage();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
HUDBAR_DEFINITION,
|
||||
WRITEABLE_TRACKIR_DEFINITION,
|
||||
WRITEABLE_COCKPITCAMERAZOOM_DEFINITION,
|
||||
WRITEABLE_CAMERAREQUESTACTION_DEFINITION,
|
||||
NA
|
||||
}
|
||||
|
||||
|
|
|
@ -236,6 +236,11 @@ namespace MSFSPopoutPanelManager.SimConnectAgent
|
|||
_simConnector.SetDataObject(WriteableVariableName.CockpitCameraZoom, Convert.ToDouble(zoomLevel));
|
||||
}
|
||||
|
||||
public void SetCameraRequestAction(int actionEnum)
|
||||
{
|
||||
_simConnector.SetDataObject(WriteableVariableName.CameraRequestAction, Convert.ToDouble(actionEnum));
|
||||
}
|
||||
|
||||
private void SetTrackIREnable(bool enable)
|
||||
{
|
||||
_simConnector.SetDataObject(WriteableVariableName.TrackIREnable, enable ? Convert.ToDouble(1) : Convert.ToDouble(0));
|
||||
|
|
|
@ -192,6 +192,9 @@ namespace MSFSPopoutPanelManager.SimConnectAgent
|
|||
case WriteableVariableName.CockpitCameraZoom:
|
||||
_simConnect.SetDataOnSimObject(DATA_DEFINITION.WRITEABLE_COCKPITCAMERAZOOM_DEFINITION, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_DATA_SET_FLAG.DEFAULT, dataStruct);
|
||||
break;
|
||||
case WriteableVariableName.CameraRequestAction:
|
||||
_simConnect.SetDataOnSimObject(DATA_DEFINITION.WRITEABLE_CAMERAREQUESTACTION_DEFINITION, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_DATA_SET_FLAG.DEFAULT, dataStruct);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -309,6 +312,7 @@ namespace MSFSPopoutPanelManager.SimConnectAgent
|
|||
|
||||
_simConnect.AddToDataDefinition(DATA_DEFINITION.WRITEABLE_TRACKIR_DEFINITION, "TRACK IR ENABLE", "bool", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
|
||||
_simConnect.AddToDataDefinition(DATA_DEFINITION.WRITEABLE_COCKPITCAMERAZOOM_DEFINITION, "COCKPIT CAMERA ZOOM", "percentage", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
|
||||
_simConnect.AddToDataDefinition(DATA_DEFINITION.WRITEABLE_CAMERAREQUESTACTION_DEFINITION, "CAMERA REQUEST ACTION", "enum", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
|
||||
|
||||
_simConnect.RegisterDataDefineStruct<SimConnectStruct>(DATA_DEFINITION.REQUIRED_DEFINITION);
|
||||
_simConnect.RegisterDataDefineStruct<SimConnectStruct>(DATA_DEFINITION.WRITEABLE_TRACKIR_DEFINITION);
|
||||
|
|
|
@ -94,7 +94,8 @@ namespace MSFSPopoutPanelManager.SimConnectAgent
|
|||
public enum WriteableVariableName
|
||||
{
|
||||
TrackIREnable,
|
||||
CockpitCameraZoom
|
||||
CockpitCameraZoom,
|
||||
CameraRequestAction
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue