Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions AutoDuty/Helpers/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ namespace AutoDuty.Helpers
using System;
using Dalamud.Interface;
using Dalamud.Interface.Utility.Raii;
using ECommons.DalamudServices;
using ECommons.ImGuiMethods;
using global::AutoDuty.IPC;
using IPC;
using System.Numerics;
using static Dalamud.Interface.Utility.Raii.ImRaii;

internal static class ImGuiHelper
{
Expand Down Expand Up @@ -133,7 +130,7 @@ internal static void DrawIcon(FontAwesomeIcon icon)
ImGui.SameLine();
}

internal static IEndObject RequiresPlugin(ExternalPlugin plugin, string id, string? message = null, bool inline = false, bool write = true)
internal static ImRaii.IEndObject RequiresPlugin(ExternalPlugin plugin, string id, string? message = null, bool inline = false, bool write = true)
{
if (IPCSubscriber_Common.IsReady(plugin.GetExternalPluginData().name))
{
Expand All @@ -151,11 +148,12 @@ internal static IEndObject RequiresPlugin(ExternalPlugin plugin, string id, stri
}
else
{
ImGui.BeginDisabled();
ImRaii.IEndObject disabled = ImRaii.Disabled();

ImGui.AlignTextToFramePadding();
return new EndUnconditionally(() =>
{
ImGui.EndDisabled();
disabled.Dispose();

if (!write)
return;
Expand All @@ -176,7 +174,7 @@ internal static IEndObject RequiresPlugin(ExternalPlugin plugin, string id, stri


//Straight from Dalamud
private struct EndUnconditionally(Action endAction, bool success) : IEndObject
private struct EndUnconditionally(Action endAction, bool success) : ImRaii.IEndObject
{
private Action EndAction { get; } = endAction;

Expand Down