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

Added turbo mode

This commit is contained in:
hawkeye 2023-09-29 02:15:02 -04:00
parent 13278106cb
commit b29c236bf9
11 changed files with 113 additions and 79 deletions

View file

@ -11,9 +11,9 @@
<PackageProjectUrl>https://github.com/hawkeye-stan/msfs-popout-panel-manager</PackageProjectUrl>
<RootNamespace>MSFSPopoutPanelManager.DomainModel</RootNamespace>
<Platforms>x64</Platforms>
<Version>4.0.2.9</Version>
<AssemblyVersion>4.0.2.9</AssemblyVersion>
<FileVersion>4.0.2.9</FileVersion>
<Version>4.0.3.0</Version>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<FileVersion>4.0.3.0</FileVersion>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<DebugType>Embedded</DebugType>
<Configurations>Debug;Release;Local</Configurations>

View file

@ -12,6 +12,7 @@ namespace MSFSPopoutPanelManager.DomainModel.Setting
StartMinimized = false;
AutoClose = true;
CheckForUpdate = true;
TurboMode = false;
InitializeChildPropertyChangeBinding();
}
@ -26,6 +27,8 @@ namespace MSFSPopoutPanelManager.DomainModel.Setting
public bool CheckForUpdate { get; set; }
public bool TurboMode { get; set; }
[JsonIgnore, IgnorePropertyChanged]
public bool AutoStart
{

View file

@ -14,9 +14,9 @@
<RootNamespace>MSFSPopoutPanelManager.MainApp</RootNamespace>
<ApplicationIcon>logo.ico</ApplicationIcon>
<Platforms>x64</Platforms>
<Version>4.0.2.9</Version>
<AssemblyVersion>4.0.2.9</AssemblyVersion>
<FileVersion>4.0.2.9</FileVersion>
<Version>4.0.3.0</Version>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<FileVersion>4.0.3.0</FileVersion>
<DebugType>embedded</DebugType>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<!-- Publishing options -->

View file

@ -181,6 +181,19 @@
<TextBlock Style="{StaticResource TextBlockLabel}">Automatically close the application when exiting MSFS.</TextBlock>
</WrapPanel>
</WrapPanel>
<WrapPanel Margin="0,0,20,20" Orientation="Vertical">
<TextBlock Style="{StaticResource TextBlockHeading}">Turbo Mode</TextBlock>
<Line
Stretch="Fill"
Stroke="Gray"
X2="1" />
<WrapPanel>
<ToggleButton IsChecked="{Binding AppSettingData.ApplicationSetting.GeneralSetting.TurboMode, Mode=TwoWay}" Style="{StaticResource ToggleButton}" />
<TextBlock Style="{StaticResource TextBlockLabel}">
<Bold>WARNING!</Bold>
This may not work for all PC. Enable turbo mode to pop out panels as fast as possible. If you have a fast PC, this will let Pop Out Panel Manager executes pop out much faster.</TextBlock>
</WrapPanel>
</WrapPanel>
<WrapPanel Margin="0,0,20,20" Orientation="Vertical">
<TextBlock Style="{StaticResource TextBlockHeading}">Check for Update</TextBlock>
<Line
@ -189,7 +202,7 @@
X2="1" />
<WrapPanel>
<ToggleButton IsChecked="{Binding AppSettingData.ApplicationSetting.GeneralSetting.CheckForUpdate, Mode=TwoWay}" Style="{StaticResource ToggleButton}" />
<TextBlock Style="{StaticResource TextBlockLabel}">Enable checking for update of application through Github.</TextBlock>
<TextBlock Style="{StaticResource TextBlockLabel}">Enable check for application update through Github.</TextBlock>
</WrapPanel>
</WrapPanel>
</WrapPanel>

View file

@ -47,7 +47,7 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
run.Foreground = new SolidColorBrush(Colors.IndianRed);
break;
case StatusMessageType.Executing:
run.Foreground = new SolidColorBrush(Colors.Yellow);
run.Foreground = new SolidColorBrush(Colors.NavajoWhite);
break;
case StatusMessageType.Info:
break;

View file

@ -11,9 +11,9 @@
<PackageProjectUrl>https://github.com/hawkeye-stan/msfs-popout-panel-manager</PackageProjectUrl>
<RootNamespace>MSFSPopoutPanelManager.Orchestration</RootNamespace>
<Platforms>x64</Platforms>
<Version>4.0.2.9</Version>
<AssemblyVersion>4.0.2.9</AssemblyVersion>
<FileVersion>4.0.2.9</FileVersion>
<Version>4.0.3.0</Version>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<FileVersion>4.0.3.0</FileVersion>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<DebugType>Embedded</DebugType>
<Configurations>Debug;Release;Local</Configurations>

View file

@ -202,19 +202,19 @@ namespace MSFSPopoutPanelManager.Orchestration
if (_flightSimData.CameraViewTypeAndIndex1 == CAMERA_VIEW_HOME_COCKPIT_MODE)
{
SetCockpitZoomLevel(_profileData.ActiveProfile.PanelSourceCockpitZoomFactor);
SetCockpitZoomLevel(_profileData.ActiveProfile.PanelSourceCockpitZoomFactor, AppSetting.GeneralSetting.TurboMode);
}
else
{
WorkflowStepWithMessage.Execute("Resetting camera view", () =>
{
ResetCockpitView();
ResetCockpitView(AppSetting.GeneralSetting.TurboMode);
}, true);
var success = WorkflowStepWithMessage.Execute("Loading custom camera view", () =>
{
return LoadCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding);
return LoadCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding, AppSetting.GeneralSetting.TurboMode);
}, true);
if (!success)
@ -222,7 +222,7 @@ namespace MSFSPopoutPanelManager.Orchestration
WorkflowStepWithMessage.Execute("Setting camera zoom level", () =>
{
SetCockpitZoomLevel(50);
SetCockpitZoomLevel(50, AppSetting.GeneralSetting.TurboMode);
}, true);
}
}
@ -249,7 +249,22 @@ namespace MSFSPopoutPanelManager.Orchestration
WorkflowStepWithMessage.Execute(panelConfig.PanelName, () =>
{
panelConfig.IsSelectedPanelSource = true;
ExecuteCustomPopout(panelConfig, builtInPanelHandles, index++);
if(AppSetting.GeneralSetting.TurboMode)
{
InputEmulationManager.PrepareToPopOutPanel((int)panelConfig.PanelSource.X, (int)panelConfig.PanelSource.Y, AppSetting.GeneralSetting.TurboMode);
PanelSourceOrchestrator.ShowPanelSourceNonEdit(panelConfig);
ExecuteCustomPopout(panelConfig, builtInPanelHandles, index++);
PanelSourceOrchestrator.ClosePanelSourceNonEdit(panelConfig);
}
else
{
PanelSourceOrchestrator.ShowPanelSourceNonEdit(panelConfig);
InputEmulationManager.PrepareToPopOutPanel((int)panelConfig.PanelSource.X, (int)panelConfig.PanelSource.Y, AppSetting.GeneralSetting.TurboMode);
PanelSourceOrchestrator.ClosePanelSourceNonEdit(panelConfig);
ExecuteCustomPopout(panelConfig, builtInPanelHandles, index++);
}
ApplyPanelLocation(panelConfig);
panelConfig.IsSelectedPanelSource = false;
@ -430,50 +445,43 @@ namespace MSFSPopoutPanelManager.Orchestration
private void ExecuteCustomPopout(PanelConfig panel, List<IntPtr> builtInPanelHandles, int index)
{
if (panel.PanelType == PanelType.CustomPopout)
// There should only be one handle that is not in both builtInPanelHandles vs latestAceAppWindowsWithCaptionHandles
var handle = TryPopOutCustomPanel(panel.PanelSource, builtInPanelHandles, AppSetting.GeneralSetting.TurboMode);
if (handle == IntPtr.Zero)
{
PanelSourceOrchestrator.ShowPanelSourceNonEdit(panel);
InputEmulationManager.PrepareToPopOutPanel((int)panel.PanelSource.X, (int)panel.PanelSource.Y);
PanelSourceOrchestrator.ClosePanelSourceNonEdit(panel);
panel.PanelHandle = IntPtr.Zero;
return;
}
// There should only be one handle that is not in both builtInPanelHandles vs latestAceAppWindowsWithCaptionHandles
var handle = TryPopOutCustomPanel(panel.PanelSource, builtInPanelHandles);
// Unable to pop out panel, the handle was previously popped out's handle
if (_profileData.ActiveProfile.PanelConfigs.Any(p => p.PanelHandle.Equals(handle)) || handle.Equals(WindowProcessManager.SimulatorProcess.Handle) || handle == IntPtr.Zero)
{
panel.PanelHandle = IntPtr.Zero;
return;
}
if (handle == IntPtr.Zero)
{
panel.PanelHandle = IntPtr.Zero;
return;
}
panel.PanelHandle = handle;
WindowActionManager.SetWindowCaption(panel.PanelHandle, $"{panel.PanelName} (Custom)");
// Unable to pop out panel, the handle was previously popped out's handle
if (_profileData.ActiveProfile.PanelConfigs.Any(p => p.PanelHandle.Equals(handle)) || handle.Equals(WindowProcessManager.SimulatorProcess.Handle) || handle == IntPtr.Zero)
{
panel.PanelHandle = IntPtr.Zero;
return;
}
panel.PanelHandle = handle;
WindowActionManager.SetWindowCaption(panel.PanelHandle, $"{panel.PanelName} (Custom)");
// First time popping out
if (panel.Width == 0 && panel.Height == 0)
{
var rect = WindowActionManager.GetWindowRectangle(panel.PanelHandle);
panel.Top = 0 + index * 30;
panel.Left = 0 + index * 30;
panel.Width = rect.Width;
panel.Height = rect.Height;
}
// First time popping out
if (panel.Width == 0 && panel.Height == 0)
{
var rect = WindowActionManager.GetWindowRectangle(panel.PanelHandle);
panel.Top = 0 + index * 30;
panel.Left = 0 + index * 30;
panel.Width = rect.Width;
panel.Height = rect.Height;
}
}
private IntPtr TryPopOutCustomPanel(PanelSource panelSource, List<IntPtr> builtInPanelHandles)
private IntPtr TryPopOutCustomPanel(PanelSource panelSource, List<IntPtr> builtInPanelHandles, bool isTurbo)
{
// Try to pop out 3 times before failure with 1/2 second wait in between
// Try to pop out 5 times before failure with 1/2 second wait in between
int count = 0;
do
{
InputEmulationManager.PopOutPanel((int)panelSource.X, (int)panelSource.Y, AppSetting.PopOutSetting.UseLeftRightControlToPopOut);
InputEmulationManager.PopOutPanel((int)panelSource.X, (int)panelSource.Y, AppSetting.PopOutSetting.UseLeftRightControlToPopOut, isTurbo);
var latestAceAppWindowsWithCaptionHandles = WindowActionManager.GetWindowsByPanelType(new List<PanelType>() { PanelType.BuiltInPopout });
@ -486,7 +494,7 @@ namespace MSFSPopoutPanelManager.Orchestration
Thread.Sleep(500);
count++;
}
while (count < 3);
while (count < 5);
return IntPtr.Zero;
}
@ -548,19 +556,19 @@ namespace MSFSPopoutPanelManager.Orchestration
case AfterPopOutCameraViewType.CockpitCenterView:
WorkflowStepWithMessage.Execute("Resetting camera view", () =>
{
ResetCockpitView();
ResetCockpitView(AppSetting.GeneralSetting.TurboMode);
}, true);
break;
case AfterPopOutCameraViewType.CustomCameraView:
WorkflowStepWithMessage.Execute("Resetting camera view", () =>
{
ResetCockpitView();
ResetCockpitView(AppSetting.GeneralSetting.TurboMode);
}, true);
WorkflowStepWithMessage.Execute("Loading custom camera view", () =>
{
return LoadCustomView(AppSetting.PopOutSetting.AfterPopOutCameraView.KeyBinding);
return LoadCustomView(AppSetting.PopOutSetting.AfterPopOutCameraView.KeyBinding, AppSetting.GeneralSetting.TurboMode);
}, true);
break;
@ -573,25 +581,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()
private void ResetCockpitView(bool isTurboMode)
{
int retry = 10;
for (var i = 0; i < retry; i++)
{
FlightSimOrchestrator.ResetCameraView();
Thread.Sleep(1000); // wait for flightsimdata to be updated
Thread.Sleep(isTurboMode ? 600 : 1000); // wait for flightsimdata to be updated
if (_flightSimData.CameraViewTypeAndIndex1 == 0) // 0 = reset view
break;
}
}
private bool LoadCustomView(string keybinding)
private bool LoadCustomView(string keybinding, bool isTurboMode)
{
int retry = 10;
for(var i = 0; i < retry; i++)
{
InputEmulationManager.LoadCustomView(keybinding);
Thread.Sleep(1000); // wait for flightsimdata to be updated
Thread.Sleep(isTurboMode ? 600 : 1000); // wait for flightsimdata to be updated
if (_flightSimData.CameraViewTypeAndIndex1 == CAMERA_VIEW_CUSTOM_CAMERA) // custom camera view enum
return true;
}
@ -599,13 +607,13 @@ namespace MSFSPopoutPanelManager.Orchestration
return false;
}
private void SetCockpitZoomLevel(int zoom)
private void SetCockpitZoomLevel(int zoom, bool isTurboMode)
{
int retry = 10;
for (var i = 0; i < retry; i++)
{
FlightSimOrchestrator.SetCockpitCameraZoomLevel(zoom);
Thread.Sleep(1000); // wait for flightsimdata to be updated
Thread.Sleep(isTurboMode ? 600 : 1000); // wait for flightsimdata to be updated
if (_flightSimData.CockpitCameraZoom == zoom)
break;

View file

@ -11,9 +11,9 @@
<PackageProjectUrl>https://github.com/hawkeye-stan/msfs-popout-panel-manager</PackageProjectUrl>
<RootNamespace>MSFSPopoutPanelManager.Shared</RootNamespace>
<Platforms>x64</Platforms>
<Version>4.0.2.9</Version>
<AssemblyVersion>4.0.2.9</AssemblyVersion>
<FileVersion>4.0.2.9</FileVersion>
<Version>4.0.3.0</Version>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<FileVersion>4.0.3.0</FileVersion>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<DebugType>Embedded</DebugType>
<Configurations>Debug;Release;Local</Configurations>

View file

@ -11,9 +11,9 @@
<PackageProjectUrl>https://github.com/hawkeye-stan/msfs-popout-panel-manager</PackageProjectUrl>
<RootNamespace>MSFSPopoutPanelManager.SimConnectAgent</RootNamespace>
<Platforms>x64</Platforms>
<Version>4.0.2.9</Version>
<AssemblyVersion>4.0.2.9</AssemblyVersion>
<FileVersion>4.0.2.9</FileVersion>
<Version>4.0.3.0</Version>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<FileVersion>4.0.3.0</FileVersion>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<DebugType>Embedded</DebugType>
<Configurations>Debug;Release;Local</Configurations>

View file

@ -44,35 +44,40 @@ namespace MSFSPopoutPanelManager.WindowsAgent
PInvoke.mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
}
public static void PrepareToPopOutPanel(int x, int y)
public static void PrepareToPopOutPanel(int x, int y, bool isTurboMode)
{
PInvoke.SetForegroundWindow(WindowProcessManager.SimulatorProcess.Handle);
Thread.Sleep(250);
Thread.Sleep(isTurboMode ? 0 : 250);
MoveAppWindowFromLeftClickPoint(x, y);
// Left click outside the cirlce area to focus game window
LeftClick(x + 30, y);
if(!isTurboMode)
LeftClick(x + 30, y); // Left click outside the cirlce area to focus game window
// Force cursor reset and focus
PInvoke.SetCursorPos(x, y);
Thread.Sleep(500);
Thread.Sleep(isTurboMode ? 50 : 500);
}
public static void PopOutPanel(int x, int y, bool useSecondaryKeys)
public static void PopOutPanel(int x, int y, bool useSecondaryKeys, bool isTurbo)
{
if (useSecondaryKeys)
{
InputSimulator.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.LCONTROL);
InputSimulator.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.RCONTROL);
Thread.Sleep(500);
Thread.Sleep(isTurbo ? 0: 500);
PInvoke.mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
Thread.Sleep(200);
PInvoke.mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
Thread.Sleep(200);
Thread.Sleep(isTurbo ? 0 : 200);
PInvoke.mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
Thread.Sleep(200);
PInvoke.mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
InputSimulator.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.RCONTROL);
InputSimulator.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.LCONTROL);
Thread.Sleep(100);
@ -82,14 +87,19 @@ namespace MSFSPopoutPanelManager.WindowsAgent
else
{
InputSimulator.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.RMENU);
Thread.Sleep(500);
Thread.Sleep(isTurbo ? 0 : 500);
PInvoke.mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
Thread.Sleep(200);
PInvoke.mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
Thread.Sleep(200);
Thread.Sleep(isTurbo ? 0 : 200);
PInvoke.mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
Thread.Sleep(200);
PInvoke.mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
InputSimulator.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.RMENU);
Thread.Sleep(100);
InputSimulator.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.RMENU); // resend to make sure Alt key is up

View file

@ -11,9 +11,9 @@
<PackageProjectUrl>https://github.com/hawkeye-stan/msfs-popout-panel-manager</PackageProjectUrl>
<RootNamespace>MSFSPopoutPanelManager.WindowsAgent</RootNamespace>
<Platforms>x64</Platforms>
<Version>4.0.2.9</Version>
<AssemblyVersion>4.0.2.9</AssemblyVersion>
<FileVersion>4.0.2.9</FileVersion>
<Version>4.0.3.0</Version>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<FileVersion>4.0.3.0</FileVersion>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<DebugType>Embedded</DebugType>
<Configurations>Debug;Release;Local</Configurations>