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:
parent
f1f8005820
commit
ed66dfbb4e
8 changed files with 90 additions and 88 deletions
|
@ -19,7 +19,7 @@ namespace MSFSPopoutPanelManager.DomainModel.Profile
|
|||
PanelConfigs = new ObservableCollection<PanelConfig>();
|
||||
ProfileSetting = new ProfileSetting();
|
||||
MsfsGameWindowConfig = new MsfsGameWindowConfig();
|
||||
HomeCockpitModeZoomFactor = 50;
|
||||
PanelSourceCockpitZoomFactor = 50;
|
||||
|
||||
this.PropertyChanged += (sender, e) =>
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ namespace MSFSPopoutPanelManager.DomainModel.Profile
|
|||
|
||||
public MsfsGameWindowConfig MsfsGameWindowConfig { get; set; }
|
||||
|
||||
public int HomeCockpitModeZoomFactor { get; set; }
|
||||
public int PanelSourceCockpitZoomFactor { get; set; }
|
||||
|
||||
public int CompareTo(UserProfile other)
|
||||
{
|
||||
|
|
|
@ -13,7 +13,8 @@ namespace MSFSPopoutPanelManager.MainApp
|
|||
{
|
||||
private PanelCoorOverlayViewModel _viewModel;
|
||||
|
||||
private const int WINDOW_ADJUSTMENT = 15; // half of window height with shadow adjustment
|
||||
private const int WINDOW_ADJUSTMENT = 20; // half of window height with shadow adjustment
|
||||
|
||||
private int _xCoor;
|
||||
private int _yCoor;
|
||||
|
||||
|
@ -23,13 +24,16 @@ namespace MSFSPopoutPanelManager.MainApp
|
|||
|
||||
public IntPtr WindowHandle { get; set; }
|
||||
|
||||
public bool IsAllowedEdit { get; set; }
|
||||
|
||||
public event EventHandler<System.Drawing.Point> WindowLocationChanged;
|
||||
|
||||
public PanelCoorOverlay(Guid id)
|
||||
public PanelCoorOverlay(Guid id, bool isAllowedEdit)
|
||||
{
|
||||
_viewModel = App.AppHost.Services.GetRequiredService<PanelCoorOverlayViewModel>();
|
||||
_viewModel.SetPanelId(id);
|
||||
PanelId = id;
|
||||
IsAllowedEdit = isAllowedEdit;
|
||||
|
||||
InitializeComponent();
|
||||
Loaded += PanelCoorOverlay_Loaded;
|
||||
|
@ -45,6 +49,8 @@ namespace MSFSPopoutPanelManager.MainApp
|
|||
this.Top = 0;
|
||||
|
||||
this.MouseUp += PanelCoorOverlay_MouseUp; // detect location change when user release mouse button when dragging the overlay window
|
||||
|
||||
this.Background = isAllowedEdit ? new SolidColorBrush(Color.FromArgb(1, 240, 240, 255)) : new SolidColorBrush(System.Windows.Media.Colors.Transparent);
|
||||
}
|
||||
|
||||
private void PanelCoorOverlay_Loaded(object sender, RoutedEventArgs e)
|
||||
|
@ -54,6 +60,9 @@ namespace MSFSPopoutPanelManager.MainApp
|
|||
|
||||
private void PanelCoorOverlay_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (!IsAllowedEdit)
|
||||
return;
|
||||
|
||||
if (this.Top is double.NaN || this.Left is double.NaN)
|
||||
return;
|
||||
|
||||
|
@ -74,6 +83,9 @@ namespace MSFSPopoutPanelManager.MainApp
|
|||
|
||||
private void Window_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
|
||||
{
|
||||
if (!IsAllowedEdit)
|
||||
return;
|
||||
|
||||
if (IsEditingPanelLocation && e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
|
||||
this.DragMove();
|
||||
}
|
||||
|
@ -89,6 +101,9 @@ namespace MSFSPopoutPanelManager.MainApp
|
|||
|
||||
private void Canvas_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (!IsAllowedEdit)
|
||||
return;
|
||||
|
||||
if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed && _viewModel.Panel != null)
|
||||
_viewModel.Panel.IsSelectedPanelSource = true;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace MSFSPopoutPanelManager.MainApp.ViewModel
|
||||
{
|
||||
|
@ -16,6 +17,7 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
|
|||
public OrchestratorUIHelper(MainOrchestrator orchestrator) : base(orchestrator)
|
||||
{
|
||||
Orchestrator.PanelSource.OnOverlayShowed += HandleShowOverlay;
|
||||
Orchestrator.PanelSource.OnNonEditOverlayShowed += HandleShowNonEditOverlay;
|
||||
Orchestrator.PanelSource.OnOverlayRemoved += HandleRemoveOverlay;
|
||||
|
||||
Orchestrator.PanelPopOut.OnPopOutStarted += HandleOnPopOutStarted;
|
||||
|
@ -25,33 +27,12 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
|
|||
|
||||
private void HandleShowOverlay(object? sender, PanelConfig panelConfig)
|
||||
{
|
||||
if (panelConfig.PanelType != PanelType.CustomPopout)
|
||||
return;
|
||||
ShowOverlay(panelConfig, false);
|
||||
}
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
PanelCoorOverlay overlay = new PanelCoorOverlay(panelConfig.Id);
|
||||
overlay.IsEditingPanelLocation = true;
|
||||
overlay.WindowStartupLocation = WindowStartupLocation.Manual;
|
||||
overlay.SetWindowCoor(Convert.ToInt32(panelConfig.PanelSource.X), Convert.ToInt32(panelConfig.PanelSource.Y));
|
||||
overlay.ShowInTaskbar = false;
|
||||
|
||||
// Fix MS.Win32.UnsafeNativeMethods.GetWindowText exception
|
||||
try { overlay.Show(); } catch { overlay.Show(); }
|
||||
|
||||
overlay.WindowLocationChanged += (sender, e) =>
|
||||
{
|
||||
if (Orchestrator.ProfileData.ActiveProfile != null)
|
||||
{
|
||||
var panelSource = Orchestrator.ProfileData.ActiveProfile.PanelConfigs.FirstOrDefault(p => p.Id == panelConfig.Id);
|
||||
if (panelSource != null)
|
||||
{
|
||||
panelSource.PanelSource.X = e.X;
|
||||
panelSource.PanelSource.Y = e.Y;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
private void HandleShowNonEditOverlay(object? sender, PanelConfig panelConfig)
|
||||
{
|
||||
ShowOverlay(panelConfig, true);
|
||||
}
|
||||
|
||||
private void HandleRemoveOverlay(object? sender, PanelConfig panelConfig)
|
||||
|
@ -125,5 +106,36 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
|
|||
|
||||
_minimizeForPopOut = false;
|
||||
}
|
||||
|
||||
private void ShowOverlay(PanelConfig panelConfig, bool nonEdit = false)
|
||||
{
|
||||
if (panelConfig.PanelType != PanelType.CustomPopout)
|
||||
return;
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
PanelCoorOverlay overlay = new PanelCoorOverlay(panelConfig.Id, !nonEdit);
|
||||
overlay.IsEditingPanelLocation = true;
|
||||
overlay.WindowStartupLocation = WindowStartupLocation.Manual;
|
||||
overlay.SetWindowCoor(Convert.ToInt32(panelConfig.PanelSource.X), Convert.ToInt32(panelConfig.PanelSource.Y));
|
||||
overlay.ShowInTaskbar = false;
|
||||
|
||||
// Fix MS.Win32.UnsafeNativeMethods.GetWindowText exception
|
||||
try { overlay.Show(); } catch { overlay.Show(); }
|
||||
|
||||
overlay.WindowLocationChanged += (sender, e) =>
|
||||
{
|
||||
if (Orchestrator.ProfileData.ActiveProfile != null)
|
||||
{
|
||||
var panelSource = Orchestrator.ProfileData.ActiveProfile.PanelConfigs.FirstOrDefault(p => p.Id == panelConfig.Id);
|
||||
if (panelSource != null)
|
||||
{
|
||||
panelSource.PanelSource.X = e.X;
|
||||
panelSource.PanelSource.Y = e.Y;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
|
||||
if (_flightSimData.CameraViewTypeAndIndex1 == CAMERA_VIEW_HOME_COCKPIT_MODE)
|
||||
{
|
||||
SetCockpitZoomLevel(_profileData.ActiveProfile.HomeCockpitModeZoomFactor);
|
||||
SetCockpitZoomLevel(_profileData.ActiveProfile.PanelSourceCockpitZoomFactor);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -211,13 +211,13 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
WorkflowStepWithMessage.Execute("Resetting camera view", () =>
|
||||
{
|
||||
ResetCockpitView();
|
||||
Thread.Sleep(2000);
|
||||
Thread.Sleep(1000);
|
||||
}, true);
|
||||
|
||||
WorkflowStepWithMessage.Execute("Loading custom camera view", () =>
|
||||
{
|
||||
LoadCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding);
|
||||
Thread.Sleep(2000);
|
||||
Thread.Sleep(1000);
|
||||
}, true);
|
||||
|
||||
WorkflowStepWithMessage.Execute("Setting camera zoom level", () =>
|
||||
|
@ -247,10 +247,9 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
WorkflowStepWithMessage.Execute(panelConfig.PanelName, () =>
|
||||
{
|
||||
panelConfig.IsSelectedPanelSource = true;
|
||||
//PanelSourceOrchestrator.ShowPanelSourceNonEdit(panelConfig);
|
||||
//Thread.Sleep(500);
|
||||
//PanelSourceOrchestrator.ClosePanelSourceNonEdit(panelConfig);
|
||||
PanelSourceOrchestrator.ShowPanelSourceNonEdit(panelConfig);
|
||||
ExecuteCustomPopout(panelConfig, builtInPanelHandles, index++);
|
||||
PanelSourceOrchestrator.ClosePanelSourceNonEdit(panelConfig);
|
||||
ApplyPanelLocation(panelConfig);
|
||||
panelConfig.IsSelectedPanelSource = false;
|
||||
|
||||
|
@ -423,6 +422,8 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
StatusMessageWriter.WriteMessageWithNewLine("Pop out has been completed with error.", StatusMessageType.Info);
|
||||
else
|
||||
StatusMessageWriter.WriteMessageWithNewLine("Pop out has been completed successfully.", StatusMessageType.Info);
|
||||
|
||||
Thread.Sleep(1000);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -594,11 +595,11 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
|
||||
private void LoadCustomView(string keybinding)
|
||||
{
|
||||
int retry = 20;
|
||||
int retry = 10;
|
||||
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 == CAMERA_VIEW_CUSTOM_CAMERA) // custom camera view enum
|
||||
break;
|
||||
}
|
||||
|
@ -610,7 +611,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
for (var i = 0; i < retry; i++)
|
||||
{
|
||||
FlightSimOrchestrator.SetCockpitCameraZoomLevel(zoom);
|
||||
Thread.Sleep(750); // wait for flightsimdata to be updated
|
||||
Thread.Sleep(1000); // wait for flightsimdata to be updated
|
||||
|
||||
if (_flightSimData.CockpitCameraZoom == zoom)
|
||||
break;
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
private ApplicationSetting AppSetting { get { return _appSettingData == null ? null : _appSettingData.ApplicationSetting; } }
|
||||
|
||||
public event EventHandler<PanelConfig> OnOverlayShowed;
|
||||
public event EventHandler<PanelConfig> OnNonEditOverlayShowed;
|
||||
public event EventHandler<PanelConfig> OnOverlayRemoved;
|
||||
public event EventHandler OnPanelSourceSelectionStarted;
|
||||
public event EventHandler OnPanelSourceSelectionCompleted;
|
||||
|
@ -68,7 +69,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
|
||||
if(_flightSimData.CameraViewTypeAndIndex1 == CAMERA_VIEW_HOME_COCKPIT_MODE)
|
||||
{
|
||||
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_profileData.ActiveProfile.HomeCockpitModeZoomFactor);
|
||||
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_profileData.ActiveProfile.PanelSourceCockpitZoomFactor);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -104,15 +105,15 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
if (_appSettingData.ApplicationSetting.WindowedModeSetting.AutoResizeMsfsGameWindow)
|
||||
_profileData.SaveMsfsGameWindowConfig();
|
||||
|
||||
if (_flightSimData.CameraViewTypeAndIndex1 == CAMERA_VIEW_HOME_COCKPIT_MODE)
|
||||
if(_flightSimData.CameraViewTypeAndIndex1 == CAMERA_VIEW_HOME_COCKPIT_MODE)
|
||||
{
|
||||
_profileData.ActiveProfile.HomeCockpitModeZoomFactor = _flightSimData.CockpitCameraZoom;
|
||||
_profileData.ActiveProfile.PanelSourceCockpitZoomFactor = _flightSimData.CockpitCameraZoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
// !!! Fix MSFS bug that without setting zoom, everything will be off by few pixels
|
||||
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_flightSimData.CockpitCameraZoom);
|
||||
|
||||
// !!! Fix MSFS bug that without setting zoom, everything will be off by few pixels at a time
|
||||
SetCockpitZoomLevel(_flightSimData.CockpitCameraZoom);
|
||||
|
||||
InputEmulationManager.SaveCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding);
|
||||
}
|
||||
}
|
||||
|
@ -121,34 +122,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
{
|
||||
Thread.Sleep(500); // wait for custom view save to be completed
|
||||
|
||||
if (_flightSimData.CameraViewTypeAndIndex1 == CAMERA_VIEW_HOME_COCKPIT_MODE)
|
||||
{
|
||||
FlightSimOrchestrator.ResetCameraView();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Recenter game or return to after pop out camera view
|
||||
if (!AppSetting.PopOutSetting.AfterPopOutCameraView.IsEnabled)
|
||||
{
|
||||
FlightSimOrchestrator.ResetCameraView();
|
||||
SetCockpitZoomLevel(_prePanelConfigurationCockpitZoomLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (AppSetting.PopOutSetting.AfterPopOutCameraView.CameraView)
|
||||
{
|
||||
case AfterPopOutCameraViewType.CockpitCenterView:
|
||||
FlightSimOrchestrator.ResetCameraView();
|
||||
SetCockpitZoomLevel(_prePanelConfigurationCockpitZoomLevel);
|
||||
break;
|
||||
case AfterPopOutCameraViewType.CustomCameraView:
|
||||
LoadCustomView(AppSetting.PopOutSetting.AfterPopOutCameraView.KeyBinding);
|
||||
SetCockpitZoomLevel(_prePanelConfigurationCockpitZoomLevel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FlightSimOrchestrator.ResetCameraView();
|
||||
WindowActionManager.BringWindowToForeground(ApplicationHandle);
|
||||
|
||||
// Turn TrackIR back on
|
||||
|
@ -159,7 +133,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
public void ShowPanelSourceNonEdit(PanelConfig panel)
|
||||
{
|
||||
if (panel.HasPanelSource)
|
||||
OnOverlayShowed?.Invoke(this, panel);
|
||||
OnNonEditOverlayShowed?.Invoke(this, panel);
|
||||
}
|
||||
|
||||
public void ClosePanelSourceNonEdit(PanelConfig panel)
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
## Version 4.0.2
|
||||
********* NOTE: The speed for Pop Out Panel Manager to execute pop outs will be slower than previous version because latest version MSFS had made existing POPM logic to not work reliably. Updated pop out logic requires wider timing threshold which unfortunately resulted in slower pop out speed. *********
|
||||
* IMPORTANT NOTE: The speed for Pop Out Panel Manager to execute pop out is now unfortunately slower than previous version. The latest version of MSFS had made existing POPM logic to fail incosistently. New sets of check logic and redesign workarounds are needed to get POPM to work correctly.
|
||||
|
||||
* Added new logic to detect when flight session is ready to initiate pop out process for auto pop out panel.
|
||||
|
||||
* Updated logic to save and load custom camera view when performing pop out to workaround AAU2 issues. 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.
|
||||
|
||||
* Added workaround for MSFS bug when using cockpit camera zoom setting is set with value other than 50 in MSFS general options. Pop out was failing before because saving and loading custom camera view does not work correctly in MSFS.
|
||||
* Added workaround for MSFS bug when using cockpit camera zoom setting (POV) is set to value other than 50 in MSFS general options. Now, camera POV (zoom, height, horizontal position) can be freely adjusted without affecting how panel source definitions are configured.
|
||||
|
||||
* Added workaround for CJ4 CDU panel not popping out because of MSFS bug.
|
||||
* Added workaround for MSFS bug where CJ4 CDU panel does not pop out.
|
||||
|
||||
* Added new logic to configure panels if using camera options of Home Cockpit Mode. In this mode, since saving and loading of custom camera angle to define pop out panels is not avaible, new logic has been added to get this camera mode to work.
|
||||
|
||||
* Added configurable keyboard shortcut to initiate pop out process (default is Ctrl-Shift-O). This keyboard shortcut can be configured in preference setting. This setting can be disabled to improve computing resource needed to constantly detect keyboard inputs.
|
||||
|
||||
* Added separate logic to configure panels if using camera options of Home Cockpit Mode. Since in this mode, saving and loading of custom camera angle to define pop out panels is not avaible, new updated logic is needed.
|
||||
|
||||
* Fixed issue where full screen mode for pop out panel does not work on certain aircraft configuration.
|
|
@ -7,7 +7,7 @@ namespace MSFSPopoutPanelManager.Shared
|
|||
public static void Execute(string message, Func<bool> function, bool isSubTask = false)
|
||||
{
|
||||
if (isSubTask)
|
||||
message = " " + message;
|
||||
message = " - " + message;
|
||||
|
||||
StatusMessageWriter.WriteMessage(message, StatusMessageType.Info);
|
||||
StatusMessageWriter.WriteExecutingStatusMessage();
|
||||
|
@ -24,7 +24,7 @@ namespace MSFSPopoutPanelManager.Shared
|
|||
public static void Execute(string message, Action function, bool isSubTask = false)
|
||||
{
|
||||
if (isSubTask)
|
||||
message = " " + message;
|
||||
message = " - " + message;
|
||||
|
||||
StatusMessageWriter.WriteMessage(message, StatusMessageType.Info);
|
||||
StatusMessageWriter.WriteExecutingStatusMessage();
|
||||
|
|
12
VERSION.md
12
VERSION.md
|
@ -2,20 +2,20 @@
|
|||
<hr/>
|
||||
|
||||
## Version 4.0.2
|
||||
********* NOTE: The speed for Pop Out Panel Manager to execute pop outs will be slower than previous version because latest version MSFS had made existing POPM logic to not work reliably. Updated pop out logic requires wider timing threshold which unfortunately resulted in slower pop out speed. *********
|
||||
* IMPORTANT NOTE: The speed for Pop Out Panel Manager to execute pop out is now unfortunately slower than previous version. The latest version of MSFS had made existing POPM logic to fail incosistently. New sets of check logic and redesign workarounds are needed to get POPM to work correctly.
|
||||
|
||||
* Added new logic to detect when flight session is ready to initiate pop out process for auto pop out panel.
|
||||
|
||||
* Updated logic to save and load custom camera view when performing pop out to workaround AAU2 issues. 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.
|
||||
|
||||
* Added workaround for MSFS bug when using cockpit camera zoom setting is set with value other than 50 in MSFS general options. Pop out was failing before because saving and loading custom camera view does not work correctly in MSFS.
|
||||
* Added workaround for MSFS bug when using cockpit camera zoom setting (POV) is set to value other than 50 in MSFS general options. Now, camera POV (zoom, height, horizontal position) can be freely adjusted without affecting how panel source definitions are configured.
|
||||
|
||||
* Added workaround for CJ4 CDU panel not popping out because of MSFS bug.
|
||||
* Added workaround for MSFS bug where CJ4 CDU panel does not pop out.
|
||||
|
||||
* Added new logic to configure panels if using camera options of Home Cockpit Mode. In this mode, since saving and loading of custom camera angle to define pop out panels is not avaible, new logic has been added to get this camera mode to work.
|
||||
|
||||
* Added configurable keyboard shortcut to initiate pop out process (default is Ctrl-Shift-O). This keyboard shortcut can be configured in preference setting. This setting can be disabled to improve computing resource needed to constantly detect keyboard inputs.
|
||||
|
||||
* Added separate logic to configure panels if using camera options of Home Cockpit Mode. Since in this mode, saving and loading of custom camera angle to define pop out panels is not avaible, new updated logic is needed.
|
||||
|
||||
* Fixed issue where full screen mode for pop out panel does not work on certain aircraft configuration.
|
||||
|
||||
## Version 4.0.1.2
|
||||
|
|
Loading…
Reference in a new issue