diff --git a/Deliveroo/Configuration.cs b/Deliveroo/Configuration.cs index 8edef4f..cf42260 100644 --- a/Deliveroo/Configuration.cs +++ b/Deliveroo/Configuration.cs @@ -17,6 +17,7 @@ internal sealed class Configuration : IPluginConfiguration public int ReservedSealCountAtMaxRank { get; set; } public int PauseAtRank { get; set; } public EBehaviorOnOtherWorld BehaviorOnOtherWorld { get; set; } = EBehaviorOnOtherWorld.Warning; + public bool DisableFrameLimiter { get; set; } = true; internal sealed class PurchasePriority { diff --git a/Deliveroo/Deliveroo.csproj b/Deliveroo/Deliveroo.csproj index 94deef7..312047f 100644 --- a/Deliveroo/Deliveroo.csproj +++ b/Deliveroo/Deliveroo.csproj @@ -1,7 +1,7 @@ net8.0-windows - 4.4 + 4.5 12 enable true diff --git a/Deliveroo/DeliverooPlugin.cs b/Deliveroo/DeliverooPlugin.cs index e8dd619..7cb063c 100644 --- a/Deliveroo/DeliverooPlugin.cs +++ b/Deliveroo/DeliverooPlugin.cs @@ -58,7 +58,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin public DeliverooPlugin(DalamudPluginInterface pluginInterface, IChatGui chatGui, IGameGui gameGui, IFramework framework, IClientState clientState, IObjectTable objectTable, ITargetManager targetManager, IDataManager dataManager, ICondition condition, ICommandManager commandManager, IPluginLog pluginLog, - IAddonLifecycle addonLifecycle, ITextureProvider textureProvider) + IAddonLifecycle addonLifecycle, ITextureProvider textureProvider, IGameConfig gameConfig) { ArgumentNullException.ThrowIfNull(dataManager); @@ -67,23 +67,22 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin _gameGui = gameGui; _framework = framework; _clientState = clientState; - ITargetManager targetManager1 = targetManager; _condition = condition; _commandManager = commandManager; _pluginLog = pluginLog; _addonLifecycle = addonLifecycle; + _configuration = (Configuration?)_pluginInterface.GetPluginConfig() ?? new Configuration(); _gameStrings = new GameStrings(dataManager, _pluginLog); - _externalPluginHandler = new ExternalPluginHandler(_pluginInterface, _pluginLog); + _externalPluginHandler = new ExternalPluginHandler(_pluginInterface, gameConfig, _configuration, _pluginLog); _gameFunctions = new GameFunctions(objectTable, _clientState, targetManager, dataManager, _externalPluginHandler, _pluginLog); - _configuration = (Configuration?)_pluginInterface.GetPluginConfig() ?? new Configuration(); _gcRewardsCache = new GcRewardsCache(dataManager); _iconCache = new IconCache(textureProvider); var itemCache = new ItemCache(dataManager); - _exchangeHandler = new ExchangeHandler(this, _gameFunctions, targetManager1, _gameGui, _chatGui, _pluginLog); - _supplyHandler = new SupplyHandler(this, _gameFunctions, targetManager1, _gameGui, _chatGui, itemCache, + _exchangeHandler = new ExchangeHandler(this, _gameFunctions, targetManager, _gameGui, _chatGui, _pluginLog); + _supplyHandler = new SupplyHandler(this, _gameFunctions, targetManager, _gameGui, _chatGui, itemCache, _pluginLog); _configWindow = new ConfigWindow(_pluginInterface, this, _configuration, _gcRewardsCache, _clientState, diff --git a/Deliveroo/External/ExternalPluginHandler.cs b/Deliveroo/External/ExternalPluginHandler.cs index 91977e1..a80d9f8 100644 --- a/Deliveroo/External/ExternalPluginHandler.cs +++ b/Deliveroo/External/ExternalPluginHandler.cs @@ -8,16 +8,22 @@ namespace Deliveroo.External; internal sealed class ExternalPluginHandler : IDisposable { private readonly DalamudPluginInterface _pluginInterface; + private readonly IGameConfig _gameConfig; + private readonly Configuration _configuration; private readonly IPluginLog _pluginLog; private readonly DeliverooIpc _deliverooIpc; private readonly PandoraIpc _pandoraIpc; private readonly AllaganToolsIpc _allaganToolsIpc; private bool? _pandoraState; + private ConfigState? _configState; - public ExternalPluginHandler(DalamudPluginInterface pluginInterface, IPluginLog pluginLog) + public ExternalPluginHandler(DalamudPluginInterface pluginInterface, IGameConfig gameConfig, + Configuration configuration, IPluginLog pluginLog) { _pluginInterface = pluginInterface; + _gameConfig = gameConfig; + _configuration = configuration; _pluginLog = pluginLog; _deliverooIpc = new DeliverooIpc(pluginInterface); _pandoraIpc = new PandoraIpc(pluginInterface, pluginLog); @@ -38,6 +44,7 @@ internal sealed class ExternalPluginHandler : IDisposable _deliverooIpc.StartTurnIn(); SaveYesAlreadyState(); SavePandoraState(); + SaveGameConfig(); Saved = true; } @@ -57,12 +64,19 @@ internal sealed class ExternalPluginHandler : IDisposable _pluginLog.Info($"Previous pandora feature state: {_pandoraState}"); } + private void SaveGameConfig() + { + if (_configuration.DisableFrameLimiter) + _configState = new ConfigState(_gameConfig); + } + public void Restore() { if (Saved) { RestoreYesAlready(); RestorePandora(); + RestoreGameConfig(); } Saved = false; @@ -87,10 +101,35 @@ internal sealed class ExternalPluginHandler : IDisposable _pandoraIpc.Enable(); } + private void RestoreGameConfig() + { + _configState?.Restore(_gameConfig); + _configState = null; + } + public void Dispose() { _deliverooIpc.Dispose(); } public uint GetRetainerItemCount(uint itemId) => _allaganToolsIpc.GetRetainerItemCount(itemId); + + private sealed record ConfigState(uint Fps, uint FpsInactive) + { + private const string ConfigFps = "Fps"; + private const string ConfigFpsInactive = "FPSInActive"; + + public ConfigState(IGameConfig gameConfig) + : this(gameConfig.System.GetUInt(ConfigFps), gameConfig.System.GetUInt(ConfigFpsInactive)) + { + gameConfig.System.Set(ConfigFps, 0); + gameConfig.System.Set(ConfigFpsInactive, 0); + } + + public void Restore(IGameConfig gameConfig) + { + gameConfig.System.Set(ConfigFps, Fps); + gameConfig.System.Set(ConfigFpsInactive, FpsInactive); + } + } } diff --git a/Deliveroo/Windows/ConfigWindow.cs b/Deliveroo/Windows/ConfigWindow.cs index 115a69b..b75501a 100644 --- a/Deliveroo/Windows/ConfigWindow.cs +++ b/Deliveroo/Windows/ConfigWindow.cs @@ -382,6 +382,15 @@ internal sealed class ConfigWindow : LWindow Save(); } + ImGui.Separator(); + + bool disableFrameLimiter = _configuration.DisableFrameLimiter; + if (ImGui.Checkbox("Disable the game's frame limiter when turning in items", ref disableFrameLimiter)) + { + _configuration.DisableFrameLimiter = disableFrameLimiter; + Save(); + } + ImGui.EndTabItem(); } }