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();