Deleted FantasiaPlusDetectService

This commit is contained in:
RisaDev
2024-04-13 04:29:34 +03:00
parent d4742416b2
commit bba6551085
5 changed files with 12 additions and 103 deletions

View File

@@ -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<SaveService>()
.AddSingleton<FilenameService>()
.AddSingleton<BackupService>()
.AddSingleton<FantasiaPlusDetectService>()
.AddSingleton<FrameworkManager>();
return services;
}
private static ServiceManager AddRestOfServices(this ServiceManager services) //temp
private static ServiceManager AddDataLoaders(this ServiceManager services)
{
services
.AddSingleton<PoseFileBoneLoader>();
return services;
}
private static ServiceManager AddApi(this ServiceManager services)
{
services
.AddSingleton<PoseFileBoneLoader>()
.AddSingleton<CustomizePlusLegacyIpc>()
.AddSingleton<CustomizePlusIpc>();

View File

@@ -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;
/// <summary>
/// Detects is Fantasia+ is installed and shows a message if it is. The check is performed every 15 seconds.
/// </summary>
public class FantasiaPlusDetectService : IDisposable
{
private readonly DalamudPluginInterface _pluginInterface;
private readonly PopupSystem _popupSystem;
private readonly Logger _logger;
private Timer? _checkTimer = null;
/// <summary>
/// Note: if this is set to true then this is locked until the plugin or game is restarted
/// </summary>
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();
}
}
/// <summary>
/// Returns true if Fantasia+ is installed and loaded
/// </summary>
/// <returns></returns>
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();
}
}

View File

@@ -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<RenderDelegate>? _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();

View File

@@ -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;

View File

@@ -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", [