diff --git a/DomainModel/Setting/AutoPopOutSetting.cs b/DomainModel/Setting/AutoPopOutSetting.cs index 3f26116..3877d89 100644 --- a/DomainModel/Setting/AutoPopOutSetting.cs +++ b/DomainModel/Setting/AutoPopOutSetting.cs @@ -7,8 +7,11 @@ namespace MSFSPopoutPanelManager.DomainModel.Setting public AutoPopOutSetting() { IsEnabled = true; + ReadyToFlyDelay = 3; } public bool IsEnabled { get; set; } + + public int ReadyToFlyDelay { get; set; } } } diff --git a/MainApp/UserControl/PreferenceDrawer.xaml b/MainApp/UserControl/PreferenceDrawer.xaml index a306b64..a067e13 100644 --- a/MainApp/UserControl/PreferenceDrawer.xaml +++ b/MainApp/UserControl/PreferenceDrawer.xaml @@ -218,6 +218,30 @@ + + Ready to Fly Button Delay + + + + + Amount of time in seconds to delay auto pop out panels from starting after ready to fly button has been pressed automatically. Extending this delay helps resolve auto pop out failure because cockpit has not been loaded completely yet on slower PC. + + + diff --git a/Orchestration/PanelPopOutOrchestrator.cs b/Orchestration/PanelPopOutOrchestrator.cs index 6033494..b7f0558 100644 --- a/Orchestration/PanelPopOutOrchestrator.cs +++ b/Orchestration/PanelPopOutOrchestrator.cs @@ -8,12 +8,14 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Windows; -using System.Windows.Input; namespace MSFSPopoutPanelManager.Orchestration { public class PanelPopOutOrchestrator : ObservableObject { + // This will be replaced by a signal from Ready to Fly Skipper into webserver in version 4.0 + private const int READY_TO_FLY_BUTTON_APPEARANCE_DELAY = 2000; + private ProfileData _profileData; private AppSettingData _appSettingData; private FlightSimData _flightSimData; @@ -74,6 +76,8 @@ namespace MSFSPopoutPanelManager.Orchestration return; + await StepReadyToFlyDelay(true); + await CoreSteps(true); }); } @@ -123,6 +127,28 @@ namespace MSFSPopoutPanelManager.Orchestration PanelSourceOrchestrator.CloseAllPanelSource(); } + private async Task StepReadyToFlyDelay(bool isAutoPopOut) + { + if (!isAutoPopOut) + return; + + if (AppSetting.AutoPopOutSetting.ReadyToFlyDelay == 0) + return; + + await Task.Run(() => + { + WorkflowStepWithMessage.Execute("Waiting on ready to fly button delay", () => + { + // Ready to fly button plugin default delay + Thread.Sleep(READY_TO_FLY_BUTTON_APPEARANCE_DELAY); + + // Extra wait for cockpit view to appear and align + Thread.Sleep(AppSetting.AutoPopOutSetting.ReadyToFlyDelay * 1000); + }); + }); + } + + private async Task StepAddCutomPanels(List builtInPanelHandles) { if (!ActiveProfile.HasCustomPanels) @@ -158,9 +184,11 @@ namespace MSFSPopoutPanelManager.Orchestration // Turn off TrackIR if TrackIR is started FlightSimOrchestrator.TurnOffTrackIR(); + Thread.Sleep(500); // Turn on Active Pause FlightSimOrchestrator.TurnOnActivePause(); + Thread.Sleep(500); // Setting custom camera angle for auto panning if (AppSetting.PopOutSetting.AutoPanning.IsEnabled) @@ -182,7 +210,6 @@ namespace MSFSPopoutPanelManager.Orchestration Thread.Sleep(2000); }, true); - WorkflowStepWithMessage.Execute("Setting camera zoom level", () => { SetCockpitZoomLevel(50); @@ -241,9 +268,11 @@ namespace MSFSPopoutPanelManager.Orchestration // Turn TrackIR back on FlightSimOrchestrator.TurnOnTrackIR(); + Thread.Sleep(500); // Turn on Active Pause FlightSimOrchestrator.TurnOffActivePause(); + Thread.Sleep(500); // Return to custom camera view if set ReturnToAfterPopOutCameraView(); diff --git a/Orchestration/PanelSourceOrchestrator.cs b/Orchestration/PanelSourceOrchestrator.cs index b1cba16..130dd02 100644 --- a/Orchestration/PanelSourceOrchestrator.cs +++ b/Orchestration/PanelSourceOrchestrator.cs @@ -88,6 +88,9 @@ namespace MSFSPopoutPanelManager.Orchestration // Save last auto panning camera angle if (AppSetting.PopOutSetting.AutoPanning.IsEnabled) { + // !!! Fix MSFS bug that without setting zoom, everything will be off by few pixels + FlightSimOrchestrator.SetCockpitCameraZoomLevel(_flightSimData.CockpitCameraZoom); + // If using windows mode, save MSFS game window configuration if (_appSettingData.ApplicationSetting.WindowedModeSetting.AutoResizeMsfsGameWindow) _profileData.SaveMsfsGameWindowConfig(); @@ -103,7 +106,6 @@ namespace MSFSPopoutPanelManager.Orchestration if (!AppSetting.PopOutSetting.AfterPopOutCameraView.IsEnabled) { FlightSimOrchestrator.ResetCameraView(); - Thread.Sleep(500); SetCockpitZoomLevel(_prePanelConfigurationCockpitZoomLevel); } else @@ -112,7 +114,6 @@ namespace MSFSPopoutPanelManager.Orchestration { case AfterPopOutCameraViewType.CockpitCenterView: FlightSimOrchestrator.ResetCameraView(); - Thread.Sleep(500); SetCockpitZoomLevel(_prePanelConfigurationCockpitZoomLevel); break; case AfterPopOutCameraViewType.CustomCameraView: @@ -179,7 +180,6 @@ namespace MSFSPopoutPanelManager.Orchestration { // Disable hooks if active InputHookManager.EndMouseHook(); - //InputHookManager.EndKeyboardHook(); _profileData.ActiveProfile.CurrentMoveResizePanelId = Guid.Empty; @@ -206,7 +206,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(750); // wait for flightsimdata to be updated if (_flightSimData.CockpitCameraZoom == zoom) break; diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 970c221..195a8e6 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,5 +1,5 @@ ## Version 4.0.2 -* Added new logic to detect when flight session is ready to initiate pop out process for auto pop out panel. Ready to Fly button delay setting is no longer needed. +* Added new logic to detect when flight session is ready to initiate pop out process for auto pop out panel. * Updated logic to load custom camera view when performing pop out. The new logic is more reliable but unfornately will be a little slower because MSFS AAU2 may have introduced issue in loading and saving camera view. Pop out progress messages will show steps being taken when adjusting camera view. diff --git a/VERSION.md b/VERSION.md index f84e8af..353975f 100644 --- a/VERSION.md +++ b/VERSION.md @@ -2,7 +2,7 @@
## Version 4.0.2 -* Added new logic to detect when flight session is ready to initiate pop out process for auto pop out panel. Ready to Fly button delay setting is no longer needed. +* Added new logic to detect when flight session is ready to initiate pop out process for auto pop out panel. * Updated logic to load custom camera view when performing pop out. The new logic is more reliable but unfornately will be a little slower because MSFS AAU2 may have introduced issue in loading and saving camera view. Pop out progress messages will show steps being taken when adjusting camera view.