mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-13 03:17:43 +01:00
Implement ImRaii
This commit is contained in:
parent
bf8690fc60
commit
e19f9284e5
17 changed files with 248 additions and 256 deletions
|
|
@ -1,6 +1,8 @@
|
|||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
|
||||
using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
using ImGuiNET;
|
||||
|
|
@ -11,6 +13,7 @@ using static Dalamud.Utility.Util;
|
|||
using static FFXIVClientStructs.FFXIV.Component.GUI.TextureType;
|
||||
using static ImGuiNET.ImGuiTableColumnFlags;
|
||||
using static ImGuiNET.ImGuiTableFlags;
|
||||
using static ImGuiNET.ImGuiTreeNodeFlags;
|
||||
|
||||
namespace Dalamud.Interface.Internal.UiDebug2.Browsing;
|
||||
|
||||
|
|
@ -60,7 +63,9 @@ internal unsafe partial class ImageNodeTree : ResNodeTree
|
|||
return;
|
||||
}
|
||||
|
||||
if (NestedTreePush($"Texture##texture{(nint)this.TexData.Texture->D3D11ShaderResourceView:X}", out _))
|
||||
var tree = ImRaii.TreeNode($"Texture##texture{(nint)this.TexData.Texture->D3D11ShaderResourceView:X}", SpanFullWidth);
|
||||
|
||||
if (tree)
|
||||
{
|
||||
PrintFieldValuePairs(
|
||||
("Texture Type", $"{this.TexData.TexType}"),
|
||||
|
|
@ -93,9 +98,9 @@ internal unsafe partial class ImageNodeTree : ResNodeTree
|
|||
{
|
||||
this.DrawFullTexture();
|
||||
}
|
||||
|
||||
ImGui.TreePop();
|
||||
}
|
||||
|
||||
tree.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -157,7 +162,8 @@ internal unsafe partial class ImageNodeTree : ResNodeTree
|
|||
|
||||
if (ImGui.IsItemClicked())
|
||||
{
|
||||
ImGui.SetClipboardText(ImGui.IsKeyDown(ImGuiKey.ModShift)
|
||||
ImGui.SetClipboardText(
|
||||
ImGui.IsKeyDown(ImGuiKey.ModShift)
|
||||
? $"new Vector4({u}{suffix}, {v}{suffix}, {w}{suffix}, {h}{suffix})"
|
||||
: $"new Vector2({u}{suffix}, {v}{suffix});\nnew Vector2({w}{suffix}, {h}{suffix})");
|
||||
}
|
||||
|
|
@ -185,7 +191,7 @@ internal unsafe partial class ImageNodeTree : ResNodeTree
|
|||
|
||||
private void PrintPartsTable()
|
||||
{
|
||||
ImGui.BeginTable($"partsTable##{(nint)this.TexData.Texture->D3D11ShaderResourceView:X}", 3, Borders | RowBg | Reorderable);
|
||||
var tab = ImRaii.Table($"partsTable##{(nint)this.TexData.Texture->D3D11ShaderResourceView:X}", 3, Borders | RowBg | Reorderable);
|
||||
ImGui.TableSetupColumn("Part ID", WidthFixed);
|
||||
ImGui.TableSetupColumn("Part Texture", WidthFixed);
|
||||
ImGui.TableSetupColumn("Coordinates", WidthFixed);
|
||||
|
|
@ -200,17 +206,8 @@ internal unsafe partial class ImageNodeTree : ResNodeTree
|
|||
{
|
||||
ImGui.TableNextColumn();
|
||||
|
||||
if (i == this.TexData.PartId)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0, 0.85F, 1, 1));
|
||||
}
|
||||
|
||||
ImGui.Text($"#{i.ToString().PadLeft(this.TexData.PartCount.ToString().Length, '0')}");
|
||||
|
||||
if (i == this.TexData.PartId)
|
||||
{
|
||||
ImGui.PopStyleColor(1);
|
||||
}
|
||||
var col = i == this.TexData.PartId ? new Vector4(0, 0.85F, 1, 1) : new(1);
|
||||
ImGui.TextColored(col, $"#{i.ToString().PadLeft(this.TexData.PartCount.ToString().Length, '0')}");
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
|
||||
|
|
@ -245,7 +242,7 @@ internal unsafe partial class ImageNodeTree : ResNodeTree
|
|||
PrintPartCoords(u / tWidth, v / tWidth, (u + width) / tWidth, (v + height) / tHeight, true, true);
|
||||
}
|
||||
|
||||
ImGui.EndTable();
|
||||
tab.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue