mirror of
https://github.com/hawkeye-stan/msfs-popout-panel-manager.git
synced 2024-11-21 13:20:11 +00:00
Update dynamic lod
This commit is contained in:
parent
c68ec210d1
commit
b9d21d58ee
7 changed files with 44 additions and 26 deletions
|
@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Configuration>Release</Configuration>
|
||||
<Configuration>Local</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
<PublishDir>..\..\..\publish\master</PublishDir>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
|
|
|
@ -283,26 +283,28 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
return;
|
||||
|
||||
// Adjust cloud quality if applicable
|
||||
if (deltaFps < 0 && newTlod < DynamicLodSetting.CloudRecoveryTlod && !_isDecreasedCloudQualityActive)
|
||||
if (DynamicLodSetting.DecreaseCloudQuality && (!DynamicLodSetting.TlodMinOnGround && !(SimData.AltAboveGround <= DynamicLodSetting.AltTlodBase)))
|
||||
{
|
||||
_isDecreasedCloudQualityActive = true;
|
||||
WriteMemory(isVr ? _addressCloudQVr : _addressCloudQ, ReadCloudQualitySimValue(isVr) - 1); // High
|
||||
switch (deltaFps)
|
||||
{
|
||||
case < 0 when newTlod < DynamicLodSetting.CloudRecoveryTlod && !_isDecreasedCloudQualityActive:
|
||||
_isDecreasedCloudQualityActive = true;
|
||||
WriteMemory(isVr ? _addressCloudQVr : _addressCloudQ, ReadCloudQualitySimValue(isVr) - 1);
|
||||
|
||||
_lastLodUpdateTime = _lastLodUpdateTime.AddSeconds(2); // Add extra delay for cloud setting to take effect
|
||||
Debug.WriteLine("New Cloud Quality written - 2.");
|
||||
_lastLodUpdateTime =
|
||||
_lastLodUpdateTime.AddSeconds(2); // Add extra delay for cloud setting to take effect
|
||||
Debug.WriteLine("New Cloud Quality written - 2.");
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
case > 0 when newTlod >= DynamicLodSetting.CloudRecoveryTlod && _isDecreasedCloudQualityActive:
|
||||
_isDecreasedCloudQualityActive = false;
|
||||
WriteMemory(isVr ? _addressCloudQVr : _addressCloudQ, ReadCloudQualitySimValue(isVr) + 1);
|
||||
|
||||
if (deltaFps > 0 && newTlod >= DynamicLodSetting.CloudRecoveryTlod && _isDecreasedCloudQualityActive)
|
||||
{
|
||||
_isDecreasedCloudQualityActive = false;
|
||||
WriteMemory(isVr ? _addressCloudQVr : _addressCloudQ, ReadCloudQualitySimValue(isVr) + 1); // Ultra
|
||||
_lastLodUpdateTime = _lastLodUpdateTime.AddSeconds(2);
|
||||
Debug.WriteLine("New Cloud Quality written - 3.");
|
||||
|
||||
_lastLodUpdateTime = _lastLodUpdateTime.AddSeconds(2);
|
||||
Debug.WriteLine("New Cloud Quality written - 3.");
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.WriteLine($"New TLOD written - {newTlod}.");
|
||||
|
|
|
@ -74,12 +74,19 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
|
||||
_simConnectProvider.OnSimConnectDataDynamicLodRefreshed += (_, e) =>
|
||||
{
|
||||
if (!AppSettingData.ApplicationSetting.DynamicLodSetting.IsEnabled || !FlightSimData.IsFlightStarted || !WindowActionManager.IsMsfsInFocus())
|
||||
if (!AppSettingData.ApplicationSetting.DynamicLodSetting.IsEnabled || !FlightSimData.IsFlightStarted)
|
||||
return;
|
||||
|
||||
var isVr = _dynamicLodOrchestrator.ReadIsVr();
|
||||
|
||||
MapDynamicLodSimConnectData(e, isVr);
|
||||
|
||||
var isPaused = (AppSettingData.ApplicationSetting.DynamicLodSetting.PauseWhenMsfsLoseFocus && !WindowActionManager.IsMsfsInFocus()) ||
|
||||
(AppSettingData.ApplicationSetting.DynamicLodSetting.PauseOutsideCockpitView && FlightSimData.CameraState != CameraState.Cockpit);
|
||||
|
||||
if (isPaused)
|
||||
return;
|
||||
|
||||
FlightSimData.DynamicLodSimData.Fps = FpsCalc.GetAverageFps(_dynamicLodOrchestrator.ReadIsFg(isVr) ? _currentFps * 2 : _currentFps);
|
||||
_dynamicLodOrchestrator.UpdateLod(isVr);
|
||||
};
|
||||
|
||||
|
@ -513,10 +520,6 @@ namespace MSFSPopoutPanelManager.Orchestration
|
|||
var cloudQuality = _dynamicLodOrchestrator.ReadCloudQuality(isVr);
|
||||
if (FlightSimData.DynamicLodSimData.CloudQuality != cloudQuality)
|
||||
FlightSimData.DynamicLodSimData.CloudQuality = cloudQuality;
|
||||
|
||||
if (FlightSimData.IsFlightStarted && FlightSimData.IsInCockpit &&
|
||||
(!AppSettingData.ApplicationSetting.DynamicLodSetting.PauseOutsideCockpitView || (AppSettingData.ApplicationSetting.DynamicLodSetting.PauseOutsideCockpitView && FlightSimData.CameraState == CameraState.Cockpit)))
|
||||
FlightSimData.DynamicLodSimData.Fps = FpsCalc.GetAverageFps(_dynamicLodOrchestrator.ReadIsFg(isVr) ? _currentFps * 2 : _currentFps);
|
||||
}
|
||||
|
||||
private int _currentFps;
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace MSFSPopoutPanelManager.SimConnectAgent
|
|||
{
|
||||
public class FpsCalc
|
||||
{
|
||||
private const int FpsLen = 50;
|
||||
private const int FpsLen = 25;
|
||||
private static readonly float[] FpsStatistic = new float[FpsLen];
|
||||
private static int _fpsIndex = -1;
|
||||
|
||||
|
|
|
@ -86,6 +86,8 @@ namespace MSFSPopoutPanelManager.WindowsAgent
|
|||
if (_isHookMouseDown)
|
||||
return;
|
||||
|
||||
PInvoke.SetForegroundWindow(WindowProcessManager.SimulatorProcess.Handle);
|
||||
|
||||
var rect = WindowActionManager.GetWindowRectangle(WindowProcessManager.SimulatorProcess.Handle);
|
||||
PInvoke.SetCursorPos(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
|
||||
}
|
||||
|
|
|
@ -192,6 +192,8 @@ namespace MSFSPopoutPanelManager.WindowsAgent
|
|||
|
||||
if (currentRefocusIndex == _refocusedTaskIndex)
|
||||
{
|
||||
PInvoke.SetForegroundWindow(WindowProcessManager.SimulatorProcess.Handle);
|
||||
|
||||
var rect = WindowActionManager.GetWindowRectangle(WindowProcessManager.SimulatorProcess.Handle);
|
||||
PInvoke.SetCursorPos(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
|
||||
}
|
||||
|
|
|
@ -298,7 +298,16 @@ namespace MSFSPopoutPanelManager.WindowsAgent
|
|||
public static bool IsMsfsInFocus()
|
||||
{
|
||||
var handle = PInvoke.GetForegroundWindow();
|
||||
return PInvoke.GetWindowText(handle).Substring(0, 26).Equals("Microsoft Flight Simulator", StringComparison.InvariantCultureIgnoreCase);
|
||||
|
||||
var text = PInvoke.GetWindowText(handle);
|
||||
|
||||
if (text == null)
|
||||
return false;
|
||||
|
||||
if (text.Length < 26)
|
||||
return false;
|
||||
|
||||
return text.Substring(0, 26).Equals("Microsoft Flight Simulator", StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue