From bba65510854398fcd426b75e3bcb22b65fdd3851 Mon Sep 17 00:00:00 2001 From: RisaDev <151885272+RisaDev@users.noreply.github.com> Date: Sat, 13 Apr 2024 04:29:34 +0300 Subject: [PATCH] Deleted FantasiaPlusDetectService --- CustomizePlus/Core/ServiceManagerBuilder.cs | 15 +++- .../Services/FantasiaPlusDetectService.cs | 75 ------------------- CustomizePlus/Core/Services/HookingService.cs | 12 --- .../UI/Windows/Controls/PluginStateBlock.cs | 8 -- .../UI/Windows/MainWindow/MainWindow.cs | 5 +- 5 files changed, 12 insertions(+), 103 deletions(-) delete mode 100644 CustomizePlus/Core/Services/FantasiaPlusDetectService.cs diff --git a/CustomizePlus/Core/ServiceManagerBuilder.cs b/CustomizePlus/Core/ServiceManagerBuilder.cs index 991b38e..ccea5fb 100644 --- a/CustomizePlus/Core/ServiceManagerBuilder.cs +++ b/CustomizePlus/Core/ServiceManagerBuilder.cs @@ -56,7 +56,8 @@ public static class ServiceManagerBuilder .AddProfileServices() .AddGameServices() .AddConfigServices() - .AddRestOfServices(); + .AddDataLoaders() + .AddApi(); DalamudServices.AddServices(services, pi); @@ -139,16 +140,22 @@ public static class ServiceManagerBuilder .AddSingleton() .AddSingleton() .AddSingleton() - .AddSingleton() .AddSingleton(); return services; } - private static ServiceManager AddRestOfServices(this ServiceManager services) //temp + private static ServiceManager AddDataLoaders(this ServiceManager services) + { + services + .AddSingleton(); + + return services; + } + + private static ServiceManager AddApi(this ServiceManager services) { services - .AddSingleton() .AddSingleton() .AddSingleton(); diff --git a/CustomizePlus/Core/Services/FantasiaPlusDetectService.cs b/CustomizePlus/Core/Services/FantasiaPlusDetectService.cs deleted file mode 100644 index 35a242d..0000000 --- a/CustomizePlus/Core/Services/FantasiaPlusDetectService.cs +++ /dev/null @@ -1,75 +0,0 @@ -using CustomizePlus.UI.Windows; -using Dalamud.Plugin; -using OtterGui.Log; -using System; -using System.Linq; -using System.Timers; - -namespace CustomizePlus.Core.Services; - -/// -/// Detects is Fantasia+ is installed and shows a message if it is. The check is performed every 15 seconds. -/// -public class FantasiaPlusDetectService : IDisposable -{ - private readonly DalamudPluginInterface _pluginInterface; - private readonly PopupSystem _popupSystem; - private readonly Logger _logger; - - private Timer? _checkTimer = null; - - /// - /// Note: if this is set to true then this is locked until the plugin or game is restarted - /// - public bool IsFantasiaPlusInstalled { get; private set; } - - public FantasiaPlusDetectService(DalamudPluginInterface pluginInterface, PopupSystem popupSystem, Logger logger) - { - _pluginInterface = pluginInterface; - _popupSystem = popupSystem; - _logger = logger; - - if (CheckFantasiaPlusPresence()) - { - _popupSystem.ShowPopup(PopupSystem.Messages.FantasiaPlusDetected); - _logger.Error("Fantasia+ detected during startup, plugin will be locked"); - } - else - { - _checkTimer = new Timer(15 * 1000); - _checkTimer.Elapsed += CheckTimerOnElapsed; - _checkTimer.Start(); - } - } - - /// - /// Returns true if Fantasia+ is installed and loaded - /// - /// - private bool CheckFantasiaPlusPresence() - { - if (IsFantasiaPlusInstalled) - return true; - - IsFantasiaPlusInstalled = _pluginInterface.InstalledPlugins.Any(pluginInfo => pluginInfo is { InternalName: "FantasiaPlus", IsLoaded: true }); - - return IsFantasiaPlusInstalled; - } - - private void CheckTimerOnElapsed(object? sender, ElapsedEventArgs e) - { - if (CheckFantasiaPlusPresence()) - { - _popupSystem.ShowPopup(PopupSystem.Messages.FantasiaPlusDetected); - _checkTimer!.Stop(); - _checkTimer?.Dispose(); - _logger.Error("Fantasia+ detected by timer, plugin will be locked"); - } - } - - public void Dispose() - { - if (_checkTimer != null) - _checkTimer.Dispose(); - } -} diff --git a/CustomizePlus/Core/Services/HookingService.cs b/CustomizePlus/Core/Services/HookingService.cs index 2246890..7264bde 100644 --- a/CustomizePlus/Core/Services/HookingService.cs +++ b/CustomizePlus/Core/Services/HookingService.cs @@ -22,7 +22,6 @@ public class HookingService : IDisposable private readonly ProfileManager _profileManager; private readonly ArmatureManager _armatureManager; private readonly GameStateService _gameStateService; - private readonly FantasiaPlusDetectService _fantasiaPlusDetectService; private readonly Logger _logger; private Hook? _renderManagerHook; @@ -43,7 +42,6 @@ public class HookingService : IDisposable ProfileManager profileManager, ArmatureManager armatureManager, GameStateService gameStateService, - FantasiaPlusDetectService fantasiaPlusDetectService, Logger logger) { _configuration = configuration; @@ -52,7 +50,6 @@ public class HookingService : IDisposable _profileManager = profileManager; _armatureManager = armatureManager; _gameStateService = gameStateService; - _fantasiaPlusDetectService = fantasiaPlusDetectService; _logger = logger; ReloadHooks(); @@ -111,15 +108,6 @@ public class HookingService : IDisposable throw new Exception(); } - if (_fantasiaPlusDetectService.IsFantasiaPlusInstalled) - { - _logger.Error($"Fantasia+ detected, disabling all hooks"); - _renderManagerHook.Disable(); - _gameObjectMovementHook?.Disable(); - - return _renderManagerHook.Original(a1, a2, a3, a4); - } - try { _armatureManager.OnRender(); diff --git a/CustomizePlus/UI/Windows/Controls/PluginStateBlock.cs b/CustomizePlus/UI/Windows/Controls/PluginStateBlock.cs index fb31279..8fa48de 100644 --- a/CustomizePlus/UI/Windows/Controls/PluginStateBlock.cs +++ b/CustomizePlus/UI/Windows/Controls/PluginStateBlock.cs @@ -17,7 +17,6 @@ public class PluginStateBlock private readonly BoneEditorPanel _boneEditorPanel; private readonly PluginConfiguration _configuration; private readonly GameStateService _gameStateService; - private readonly FantasiaPlusDetectService _fantasiaPlusDetectService; private readonly HookingService _hookingService; private readonly CustomizePlusIpc _ipcService; @@ -25,14 +24,12 @@ public class PluginStateBlock BoneEditorPanel boneEditorPanel, PluginConfiguration configuration, GameStateService gameStateService, - FantasiaPlusDetectService fantasiaPlusDetectService, HookingService hookingService, CustomizePlusIpc ipcService) { _boneEditorPanel = boneEditorPanel; _configuration = configuration; _gameStateService = gameStateService; - _fantasiaPlusDetectService = fantasiaPlusDetectService; _hookingService = hookingService; _ipcService = ipcService; } @@ -47,11 +44,6 @@ public class PluginStateBlock severity = PluginStateSeverity.Error; message = $"Detected failure in game hooks. Customize+ disabled."; } - else if (_fantasiaPlusDetectService.IsFantasiaPlusInstalled) - { - severity = PluginStateSeverity.Error; - message = $"Fantasia+ detected. The plugin is disabled until Fantasia+ is disabled and the game is restarted."; - } else if (!_configuration.PluginEnabled) { severity = PluginStateSeverity.Warning; diff --git a/CustomizePlus/UI/Windows/MainWindow/MainWindow.cs b/CustomizePlus/UI/Windows/MainWindow/MainWindow.cs index 54628ba..ab74f95 100644 --- a/CustomizePlus/UI/Windows/MainWindow/MainWindow.cs +++ b/CustomizePlus/UI/Windows/MainWindow/MainWindow.cs @@ -31,7 +31,6 @@ public class MainWindow : Window, IDisposable private readonly PluginStateBlock _pluginStateBlock; private readonly TemplateEditorManager _templateEditorManager; - private readonly FantasiaPlusDetectService _fantasiaPlusDetectService; private readonly PluginConfiguration _configuration; private readonly HookingService _hookingService; @@ -46,7 +45,6 @@ public class MainWindow : Window, IDisposable PluginStateBlock pluginStateBlock, TemplateEditorManager templateEditorManager, PluginConfiguration configuration, - FantasiaPlusDetectService fantasiaPlusDetectService, HookingService hookingService ) : base($"Customize+ v{Plugin.Version}###CPlusMainWindow") { @@ -61,7 +59,6 @@ public class MainWindow : Window, IDisposable _templateEditorManager = templateEditorManager; _configuration = configuration; - _fantasiaPlusDetectService = fantasiaPlusDetectService; _hookingService = hookingService; pluginInterface.UiBuilder.DisableGposeUiHide = true; @@ -83,7 +80,7 @@ public class MainWindow : Window, IDisposable { var yPos = ImGui.GetCursorPosY(); - using (var disabled = ImRaii.Disabled(_fantasiaPlusDetectService.IsFantasiaPlusInstalled || _hookingService.RenderHookFailed || _hookingService.MovementHookFailed)) + using (var disabled = ImRaii.Disabled(_hookingService.RenderHookFailed || _hookingService.MovementHookFailed)) { LockWindowClosureIfNeeded(); ImGuiEx.EzTabBar("##tabs", [