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

Update camera view logic

This commit is contained in:
hawkeye 2023-08-16 02:42:18 -04:00
parent 5983ff749d
commit 1999a5c84f
6 changed files with 64 additions and 8 deletions

View file

@ -7,8 +7,11 @@ namespace MSFSPopoutPanelManager.DomainModel.Setting
public AutoPopOutSetting()
{
IsEnabled = true;
ReadyToFlyDelay = 3;
}
public bool IsEnabled { get; set; }
public int ReadyToFlyDelay { get; set; }
}
}

View file

@ -218,6 +218,30 @@
</TextBlock>
</StackPanel>
</WrapPanel>
<WrapPanel Margin="0,0,20,20" Orientation="Vertical">
<TextBlock Style="{StaticResource TextBlockHeading}">Ready to Fly Button Delay</TextBlock>
<Line
Stretch="Fill"
Stroke="Gray"
X2="1" />
<StackPanel Orientation="Horizontal">
<localcontrol:NumericUpDown
Width="90"
Height="24"
FontSize="12"
Increment="1"
MaxValue="10"
MinValue="0"
Value="{Binding AppSettingData.ApplicationSetting.AutoPopOutSetting.ReadyToFlyDelay, Mode=TwoWay}" />
<TextBlock
Width="640"
Margin="10,0,0,0"
Style="{StaticResource TextBlockLabel}"
TextWrapping="Wrap">
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.
</TextBlock>
</StackPanel>
</WrapPanel>
</WrapPanel>
<!-- Pop Out Settings -->

View file

@ -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<IntPtr> 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();

View file

@ -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;

View file

@ -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.

View file

@ -2,7 +2,7 @@
<hr/>
## 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.