Lock UI on hook failure

This commit is contained in:
RisaDev
2024-02-04 22:56:31 +03:00
parent 205f60480c
commit 6aa64e43ef
3 changed files with 38 additions and 18 deletions

View File

@@ -16,6 +16,7 @@ public class PluginStateBlock
private readonly PluginConfiguration _configuration;
private readonly GameStateService _gameStateService;
private readonly FantasiaPlusDetectService _fantasiaPlusDetectService;
private readonly HookingService _hookingService;
private static Vector4 normalColor = new Vector4(1, 1, 1, 1);
private static Vector4 warnColor = new Vector4(1, 0.5f, 0, 1);
@@ -25,12 +26,14 @@ public class PluginStateBlock
BoneEditorPanel boneEditorPanel,
PluginConfiguration configuration,
GameStateService gameStateService,
FantasiaPlusDetectService fantasiaPlusDetectService)
FantasiaPlusDetectService fantasiaPlusDetectService,
HookingService hookingService)
{
_boneEditorPanel = boneEditorPanel;
_configuration = configuration;
_gameStateService = gameStateService;
_fantasiaPlusDetectService = fantasiaPlusDetectService;
_hookingService = hookingService;
}
public void Draw(float yPos)
@@ -38,7 +41,12 @@ public class PluginStateBlock
var severity = PluginStateSeverity.Normal;
string? message = null;
if (_fantasiaPlusDetectService.IsFantasiaPlusInstalled)
if(_hookingService.RenderHookFailed || _hookingService.MovementHookFailed)
{
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.";

View File

@@ -28,8 +28,9 @@ public class MainWindow : Window, IDisposable
private readonly PluginStateBlock _pluginStateBlock;
private readonly TemplateEditorManager _templateEditorManager;
private readonly FantasiaPlusDetectService _cPlusDetectService;
private readonly FantasiaPlusDetectService _fantasiaPlusDetectService;
private readonly PluginConfiguration _configuration;
private readonly HookingService _hookingService;
public MainWindow(
DalamudPluginInterface pluginInterface,
@@ -42,7 +43,8 @@ public class MainWindow : Window, IDisposable
PluginStateBlock pluginStateBlock,
TemplateEditorManager templateEditorManager,
PluginConfiguration configuration,
FantasiaPlusDetectService cPlusDetectService
FantasiaPlusDetectService fantasiaPlusDetectService,
HookingService hookingService
) : base($"Customize+ v{Plugin.Version}###CPlusMainWindow")
{
_settingsTab = settingsTab;
@@ -55,8 +57,9 @@ public class MainWindow : Window, IDisposable
_pluginStateBlock = pluginStateBlock;
_templateEditorManager = templateEditorManager;
_cPlusDetectService = cPlusDetectService;
_configuration = configuration;
_fantasiaPlusDetectService = fantasiaPlusDetectService;
_hookingService = hookingService;
pluginInterface.UiBuilder.DisableGposeUiHide = true;
SizeConstraints = new WindowSizeConstraints()
@@ -77,7 +80,7 @@ public class MainWindow : Window, IDisposable
{
var yPos = ImGui.GetCursorPosY();
using (var disabled = ImRaii.Disabled(_cPlusDetectService.IsFantasiaPlusInstalled))
using (var disabled = ImRaii.Disabled(_fantasiaPlusDetectService.IsFantasiaPlusInstalled || _hookingService.RenderHookFailed || _hookingService.MovementHookFailed))
{
LockWindowClosureIfNeeded();
if (ImGui.BeginTabBar("##tabs", ImGuiTabBarFlags.None)) //todo: remember last selected tab