1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-21 21:30:12 +00:00

Add failure condition for loading custom camera view

This commit is contained in:
hawkeye 2023-09-02 00:10:40 -04:00
parent 6a9e1d3520
commit 6d80416f56
4 changed files with 29 additions and 11 deletions

View file

@ -158,16 +158,20 @@ namespace MSFSPopoutPanelManager.Orchestration
if (!ActiveProfile.HasCustomPanels) if (!ActiveProfile.HasCustomPanels)
return; return;
await StepPreCustomPanelPopOut(); if (!await StepPreCustomPanelPopOut())
{
ActiveProfile.PanelConfigs.Where(p => p.PanelType == PanelType.CustomPopout).ToList().ForEach(p => p.PanelHandle = IntPtr.Zero);
return;
}
await StepCustomPanelPopOut(builtInPanelHandles); await StepCustomPanelPopOut(builtInPanelHandles);
await StepPostCustomPanelPopOut(); await StepPostCustomPanelPopOut();
} }
private async Task StepPreCustomPanelPopOut() private async Task<bool> StepPreCustomPanelPopOut()
{ {
await Task.Run(() => return await Task.Run(() =>
{ {
// Set Windowed Display Mode window's configuration if needed // Set Windowed Display Mode window's configuration if needed
if (_appSettingData.ApplicationSetting.WindowedModeSetting.AutoResizeMsfsGameWindow && WindowActionManager.IsMsfsGameInWindowedMode()) if (_appSettingData.ApplicationSetting.WindowedModeSetting.AutoResizeMsfsGameWindow && WindowActionManager.IsMsfsGameInWindowedMode())
@ -211,17 +215,23 @@ namespace MSFSPopoutPanelManager.Orchestration
ResetCockpitView(); ResetCockpitView();
}, true); }, true);
WorkflowStepWithMessage.Execute("Loading custom camera view", () =>
var success = WorkflowStepWithMessage.Execute("Loading custom camera view", () =>
{ {
LoadCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding); return LoadCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding);
}, true); }, true);
if (!success)
return false;
WorkflowStepWithMessage.Execute("Setting camera zoom level", () => WorkflowStepWithMessage.Execute("Setting camera zoom level", () =>
{ {
SetCockpitZoomLevel(50); SetCockpitZoomLevel(50);
}, true); }, true);
} }
} }
return true;
}); });
} }
@ -556,7 +566,7 @@ namespace MSFSPopoutPanelManager.Orchestration
WorkflowStepWithMessage.Execute("Loading custom camera view", () => WorkflowStepWithMessage.Execute("Loading custom camera view", () =>
{ {
LoadCustomView(AppSetting.PopOutSetting.AfterPopOutCameraView.KeyBinding); return LoadCustomView(AppSetting.PopOutSetting.AfterPopOutCameraView.KeyBinding);
}, true); }, true);
WorkflowStepWithMessage.Execute("Setting camera zoom level", () => WorkflowStepWithMessage.Execute("Setting camera zoom level", () =>
@ -586,7 +596,7 @@ namespace MSFSPopoutPanelManager.Orchestration
} }
} }
private void LoadCustomView(string keybinding) private bool LoadCustomView(string keybinding)
{ {
int retry = 10; int retry = 10;
for(var i = 0; i < retry; i++) for(var i = 0; i < retry; i++)
@ -594,8 +604,10 @@ namespace MSFSPopoutPanelManager.Orchestration
InputEmulationManager.LoadCustomView(keybinding); InputEmulationManager.LoadCustomView(keybinding);
Thread.Sleep(1000); // wait for flightsimdata to be updated Thread.Sleep(1000); // wait for flightsimdata to be updated
if (_flightSimData.CameraViewTypeAndIndex1 == CAMERA_VIEW_CUSTOM_CAMERA) // custom camera view enum if (_flightSimData.CameraViewTypeAndIndex1 == CAMERA_VIEW_CUSTOM_CAMERA) // custom camera view enum
break; return true;
} }
return false;
} }
private void SetCockpitZoomLevel(int zoom) private void SetCockpitZoomLevel(int zoom)

View file

@ -1,5 +1,5 @@
## Version 4.0.2 ## Version 4.0.2
* Added new logic to detect when flight session is ready to initiate pop out process for auto pop out panel. * Added new logic (not based on timing) to detect when flight session is ready to initiate pop out process for auto pop out panel. You can also set Auto Pop Out Panel Delay in preferences to 0 seconds if you have a fast PC.
* Fixed camera logic to save and load custom camera view used by Pop Out Panel Manager. This is to work around camera issue since AAU2. Also, pop out progress messages will now show steps being taken when adjusting camera view. * Fixed camera logic to save and load custom camera view used by Pop Out Panel Manager. This is to work around camera issue since AAU2. Also, pop out progress messages will now show steps being taken when adjusting camera view.

View file

@ -4,7 +4,7 @@ namespace MSFSPopoutPanelManager.Shared
{ {
public static class WorkflowStepWithMessage public static class WorkflowStepWithMessage
{ {
public static void Execute(string message, Func<bool> function, bool isSubTask = false) public static bool Execute(string message, Func<bool> function, bool isSubTask = false)
{ {
if (isSubTask) if (isSubTask)
message = " - " + message; message = " - " + message;
@ -16,9 +16,15 @@ namespace MSFSPopoutPanelManager.Shared
StatusMessageWriter.RemoveLastMessage(); StatusMessageWriter.RemoveLastMessage();
if (result) if (result)
{
StatusMessageWriter.WriteOkStatusMessage(); StatusMessageWriter.WriteOkStatusMessage();
return true;
}
else else
{
StatusMessageWriter.WriteFailureStatusMessage(); StatusMessageWriter.WriteFailureStatusMessage();
return false;
}
} }
public static void Execute(string message, Action function, bool isSubTask = false) public static void Execute(string message, Action function, bool isSubTask = false)

View file

@ -2,7 +2,7 @@
<hr/> <hr/>
## Version 4.0.2 ## Version 4.0.2
* Added new logic to detect when flight session is ready to initiate pop out process for auto pop out panel. * Added new logic (not based on timing) to detect when flight session is ready to initiate pop out process for auto pop out panel. You can also set Auto Pop Out Panel Delay in preferences to 0 seconds if you have a fast PC.
* Fixed camera logic to save and load custom camera view used by Pop Out Panel Manager. This is to work around camera issue since AAU2. Also, pop out progress messages will now show steps being taken when adjusting camera view. * Fixed camera logic to save and load custom camera view used by Pop Out Panel Manager. This is to work around camera issue since AAU2. Also, pop out progress messages will now show steps being taken when adjusting camera view.