Apply ImRaii to leftover widgets

This commit is contained in:
Infi 2026-01-05 01:31:50 +01:00
parent 17a054fa1b
commit 31d19b76ee
5 changed files with 85 additions and 88 deletions

View file

@ -8,7 +8,7 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
/// <summary>
/// Widget for displaying Addon Data.
/// </summary>
internal unsafe class AddonWidget : IDataWindowWidget
internal class AddonWidget : IDataWindowWidget
{
private string inputAddonName = string.Empty;
private int inputAddonIndex;

View file

@ -2,6 +2,7 @@
using Dalamud.Bindings.ImGui;
using Dalamud.Game;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Utility;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
@ -15,7 +16,7 @@ internal class AddressesWidget : IDataWindowWidget
private nint sigResult = nint.Zero;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "address" };
public string[]? CommandShortcuts { get; init; } = ["address"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Addresses";
@ -46,22 +47,24 @@ internal class AddressesWidget : IDataWindowWidget
}
}
ImGui.Text($"Result: {this.sigResult.ToInt64():X}");
ImGui.AlignTextToFramePadding();
ImGui.Text($"Result: {this.sigResult:X}");
ImGui.SameLine();
if (ImGui.Button($"C##{this.sigResult.ToInt64():X}"))
ImGui.SetClipboardText(this.sigResult.ToInt64().ToString("X"));
if (ImGui.Button($"C##{this.sigResult:X}"))
ImGui.SetClipboardText($"{this.sigResult:X}");
foreach (var debugScannedValue in BaseAddressResolver.DebugScannedValues)
{
ImGui.Text($"{debugScannedValue.Key}");
foreach (var valueTuple in debugScannedValue.Value)
{
ImGui.Text(
$" {valueTuple.ClassName} - {Util.DescribeAddress(valueTuple.Address)}");
using var indent = ImRaii.PushIndent(10.0f);
ImGui.AlignTextToFramePadding();
ImGui.Text($"{valueTuple.ClassName} - {Util.DescribeAddress(valueTuple.Address)}");
ImGui.SameLine();
if (ImGui.Button($"C##{valueTuple.Address.ToInt64():X}"))
ImGui.SetClipboardText(valueTuple.Address.ToInt64().ToString("X"));
if (ImGui.Button($"C##{valueTuple.Address:X}"))
ImGui.SetClipboardText($"{valueTuple.Address:X}");
}
}
}

View file

@ -1,5 +1,6 @@
using Dalamud.Bindings.ImGui;
using Dalamud.Game.ClientState.Aetherytes;
using Dalamud.Interface.Utility.Raii;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
@ -8,11 +9,13 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
/// </summary>
internal class AetherytesWidget : IDataWindowWidget
{
private const ImGuiTableFlags TableFlags = ImGuiTableFlags.ScrollY | ImGuiTableFlags.RowBg | ImGuiTableFlags.Borders;
/// <inheritdoc/>
public bool Ready { get; set; }
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "aetherytes" };
public string[]? CommandShortcuts { get; init; } = ["aetherytes"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Aetherytes";
@ -26,7 +29,8 @@ internal class AetherytesWidget : IDataWindowWidget
/// <inheritdoc/>
public void Draw()
{
if (!ImGui.BeginTable("##aetheryteTable"u8, 11, ImGuiTableFlags.ScrollY | ImGuiTableFlags.RowBg | ImGuiTableFlags.Borders))
using var table = ImRaii.Table("##aetheryteTable"u8, 11, TableFlags);
if (!table.Success)
return;
ImGui.TableSetupScrollFreeze(0, 1);
@ -84,7 +88,5 @@ internal class AetherytesWidget : IDataWindowWidget
ImGui.TableNextColumn(); // Apartment
ImGui.Text($"{info.IsApartment}");
}
ImGui.EndTable();
}
}

View file

@ -23,16 +23,16 @@ internal unsafe class AtkArrayDataBrowserWidget : IDataWindowWidget
private int selectedExtendArray;
private string searchTerm = string.Empty;
private bool hideUnsetStringArrayEntries = false;
private bool hideUnsetExtendArrayEntries = false;
private bool showTextAddress = false;
private bool showMacroString = false;
private bool hideUnsetStringArrayEntries;
private bool hideUnsetExtendArrayEntries;
private bool showTextAddress;
private bool showMacroString;
/// <inheritdoc/>
public bool Ready { get; set; }
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "atkarray" };
public string[]? CommandShortcuts { get; init; } = ["atkarray"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Atk Array Data";
@ -153,17 +153,14 @@ internal unsafe class AtkArrayDataBrowserWidget : IDataWindowWidget
if (ImGui.IsItemHovered())
{
using var tooltip = ImRaii.Tooltip();
if (tooltip)
var raptureAtkUnitManager = RaptureAtkUnitManager.Instance();
for (var j = 0; j < array->SubscribedAddonsCount; j++)
{
var raptureAtkUnitManager = RaptureAtkUnitManager.Instance();
if (array->SubscribedAddons[j] == 0)
continue;
for (var j = 0; j < array->SubscribedAddonsCount; j++)
{
if (array->SubscribedAddons[j] == 0)
continue;
ImGui.Text(raptureAtkUnitManager->GetAddonById(array->SubscribedAddons[j])->NameString);
}
ImGui.Text(raptureAtkUnitManager->GetAddonById(array->SubscribedAddons[j])->NameString);
}
}
}
@ -242,9 +239,9 @@ internal unsafe class AtkArrayDataBrowserWidget : IDataWindowWidget
var atkArrayDataHolder = RaptureAtkModule.Instance()->AtkArrayDataHolder;
using (var sidebarchild = ImRaii.Child("StringArraySidebar"u8, new Vector2(300, -1), false, ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoSavedSettings))
using (var sidebarChild = ImRaii.Child("StringArraySidebar"u8, new Vector2(300, -1), false, ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoSavedSettings))
{
if (sidebarchild)
if (sidebarChild)
{
ImGui.SetNextItemWidth(-1);
ImGui.InputTextWithHint("##TextSearch"u8, "Search..."u8, ref this.searchTerm, 256, ImGuiInputTextFlags.AutoSelectAll);

View file

@ -15,7 +15,7 @@ internal class BuddyListWidget : IDataWindowWidget
public bool Ready { get; set; }
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "buddy", "buddylist" };
public string[]? CommandShortcuts { get; init; } = ["buddy", "buddylist"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Buddy List";
@ -32,18 +32,65 @@ internal class BuddyListWidget : IDataWindowWidget
var buddyList = Service<BuddyList>.Get();
ImGui.Checkbox("Resolve GameData"u8, ref this.resolveGameData);
var companionBuddy = buddyList.CompanionBuddy;
if (companionBuddy == null)
{
var member = buddyList.CompanionBuddy;
if (member == null)
ImGui.Text("[Companion] null"u8);
}
else
{
ImGui.Text($"[Companion] {companionBuddy.Address:X} - {companionBuddy.EntityId} - {companionBuddy.DataID}");
if (this.resolveGameData)
{
ImGui.Text("[Companion] null"u8);
var gameObject = companionBuddy.GameObject;
if (gameObject == null)
{
ImGui.Text("GameObject was null"u8);
}
else
{
Util.PrintGameObject(gameObject, "-", this.resolveGameData);
}
}
else
}
var petBuddy = buddyList.PetBuddy;
if (petBuddy == null)
{
ImGui.Text("[Pet] null"u8);
}
else
{
ImGui.Text($"[Pet] {petBuddy.Address:X} - {petBuddy.EntityId} - {petBuddy.DataID}");
if (this.resolveGameData)
{
ImGui.Text($"[Companion] {member.Address.ToInt64():X} - {member.EntityId} - {member.DataID}");
var gameObject = petBuddy.GameObject;
if (gameObject == null)
{
ImGui.Text("GameObject was null"u8);
}
else
{
Util.PrintGameObject(gameObject, "-", this.resolveGameData);
}
}
}
var count = buddyList.Length;
if (count == 0)
{
ImGui.Text("[BattleBuddy] None present"u8);
}
else
{
for (var i = 0; i < count; i++)
{
var member = buddyList[i];
ImGui.Text($"[BattleBuddy] [{i}] {member?.Address ?? 0:X} - {member?.EntityId ?? 0} - {member?.DataID ?? 0}");
if (this.resolveGameData)
{
var gameObject = member.GameObject;
var gameObject = member?.GameObject;
if (gameObject == null)
{
ImGui.Text("GameObject was null"u8);
@ -55,57 +102,5 @@ internal class BuddyListWidget : IDataWindowWidget
}
}
}
{
var member = buddyList.PetBuddy;
if (member == null)
{
ImGui.Text("[Pet] null"u8);
}
else
{
ImGui.Text($"[Pet] {member.Address.ToInt64():X} - {member.EntityId} - {member.DataID}");
if (this.resolveGameData)
{
var gameObject = member.GameObject;
if (gameObject == null)
{
ImGui.Text("GameObject was null"u8);
}
else
{
Util.PrintGameObject(gameObject, "-", this.resolveGameData);
}
}
}
}
{
var count = buddyList.Length;
if (count == 0)
{
ImGui.Text("[BattleBuddy] None present"u8);
}
else
{
for (var i = 0; i < count; i++)
{
var member = buddyList[i];
ImGui.Text($"[BattleBuddy] [{i}] {member?.Address.ToInt64():X} - {member?.EntityId} - {member?.DataID}");
if (this.resolveGameData)
{
var gameObject = member?.GameObject;
if (gameObject == null)
{
ImGui.Text("GameObject was null"u8);
}
else
{
Util.PrintGameObject(gameObject, "-", this.resolveGameData);
}
}
}
}
}
}
}