diff --git a/Deliveroo/Configuration.cs b/Deliveroo/Configuration.cs index cf42260..1a680f2 100644 --- a/Deliveroo/Configuration.cs +++ b/Deliveroo/Configuration.cs @@ -18,6 +18,7 @@ internal sealed class Configuration : IPluginConfiguration public int PauseAtRank { get; set; } public EBehaviorOnOtherWorld BehaviorOnOtherWorld { get; set; } = EBehaviorOnOtherWorld.Warning; public bool DisableFrameLimiter { get; set; } = true; + public bool UncapFrameRate { get; set; } internal sealed class PurchasePriority { diff --git a/Deliveroo/Deliveroo.csproj b/Deliveroo/Deliveroo.csproj index 312047f..827b45b 100644 --- a/Deliveroo/Deliveroo.csproj +++ b/Deliveroo/Deliveroo.csproj @@ -1,7 +1,7 @@ net8.0-windows - 4.5 + 4.6 12 enable true diff --git a/Deliveroo/External/ExternalPluginHandler.cs b/Deliveroo/External/ExternalPluginHandler.cs index a80d9f8..a546b8b 100644 --- a/Deliveroo/External/ExternalPluginHandler.cs +++ b/Deliveroo/External/ExternalPluginHandler.cs @@ -16,7 +16,8 @@ internal sealed class ExternalPluginHandler : IDisposable private readonly AllaganToolsIpc _allaganToolsIpc; private bool? _pandoraState; - private ConfigState? _configState; + private SystemConfigState? _limitFrameRateWhenClientInactive; + private SystemConfigState? _uncapFrameRate; public ExternalPluginHandler(DalamudPluginInterface pluginInterface, IGameConfig gameConfig, Configuration configuration, IPluginLog pluginLog) @@ -66,8 +67,14 @@ internal sealed class ExternalPluginHandler : IDisposable private void SaveGameConfig() { - if (_configuration.DisableFrameLimiter) - _configState = new ConfigState(_gameConfig); + if (!_configuration.DisableFrameLimiter) + return; + + _limitFrameRateWhenClientInactive ??= + new SystemConfigState(_gameConfig, SystemConfigState.ConfigFpsInactive, 0); + + if (_configuration.UncapFrameRate) + _uncapFrameRate ??= new SystemConfigState(_gameConfig, SystemConfigState.ConfigFps, 0); } public void Restore() @@ -103,8 +110,11 @@ internal sealed class ExternalPluginHandler : IDisposable private void RestoreGameConfig() { - _configState?.Restore(_gameConfig); - _configState = null; + _uncapFrameRate?.Restore(_gameConfig); + _uncapFrameRate = null; + + _limitFrameRateWhenClientInactive?.Restore(_gameConfig); + _limitFrameRateWhenClientInactive = null; } public void Dispose() @@ -114,22 +124,20 @@ internal sealed class ExternalPluginHandler : IDisposable public uint GetRetainerItemCount(uint itemId) => _allaganToolsIpc.GetRetainerItemCount(itemId); - private sealed record ConfigState(uint Fps, uint FpsInactive) + private sealed record SystemConfigState(string Key, uint OldValue) { - private const string ConfigFps = "Fps"; - private const string ConfigFpsInactive = "FPSInActive"; + public const string ConfigFps = "Fps"; + public const string ConfigFpsInactive = "FPSInActive"; - public ConfigState(IGameConfig gameConfig) - : this(gameConfig.System.GetUInt(ConfigFps), gameConfig.System.GetUInt(ConfigFpsInactive)) + public SystemConfigState(IGameConfig gameConfig, string key, uint newValue) + : this(key, gameConfig.System.GetUInt(key)) { - gameConfig.System.Set(ConfigFps, 0); - gameConfig.System.Set(ConfigFpsInactive, 0); + gameConfig.System.Set(key, newValue); } public void Restore(IGameConfig gameConfig) { - gameConfig.System.Set(ConfigFps, Fps); - gameConfig.System.Set(ConfigFpsInactive, FpsInactive); + gameConfig.System.Set(Key, OldValue); } } } diff --git a/Deliveroo/Windows/ConfigWindow.cs b/Deliveroo/Windows/ConfigWindow.cs index b75501a..a936f9a 100644 --- a/Deliveroo/Windows/ConfigWindow.cs +++ b/Deliveroo/Windows/ConfigWindow.cs @@ -385,12 +385,24 @@ internal sealed class ConfigWindow : LWindow ImGui.Separator(); bool disableFrameLimiter = _configuration.DisableFrameLimiter; - if (ImGui.Checkbox("Disable the game's frame limiter when turning in items", ref disableFrameLimiter)) + if (ImGui.Checkbox("Disable the game setting 'Limit frame rate when client is inactive'", + ref disableFrameLimiter)) { _configuration.DisableFrameLimiter = disableFrameLimiter; Save(); } + ImGui.Indent(); + ImGui.BeginDisabled(!disableFrameLimiter); + bool uncapFrameRate = _configuration.UncapFrameRate; + if (ImGui.Checkbox("Set frame rate to uncapped", ref uncapFrameRate)) + { + _configuration.UncapFrameRate = uncapFrameRate; + Save(); + } + + ImGui.EndDisabled(); + ImGui.Unindent(); ImGui.EndTabItem(); } }