mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-19 06:17:43 +01:00
- Apply ImRaii to UIColorWidget
This commit is contained in:
parent
a1d2e275a7
commit
e44fda1911
1 changed files with 38 additions and 35 deletions
|
|
@ -7,6 +7,8 @@ using Dalamud.Data;
|
||||||
using Dalamud.Interface.ImGuiNotification;
|
using Dalamud.Interface.ImGuiNotification;
|
||||||
using Dalamud.Interface.ImGuiNotification.Internal;
|
using Dalamud.Interface.ImGuiNotification.Internal;
|
||||||
using Dalamud.Interface.ImGuiSeStringRenderer.Internal;
|
using Dalamud.Interface.ImGuiSeStringRenderer.Internal;
|
||||||
|
using Dalamud.Interface.Utility.Raii;
|
||||||
|
|
||||||
using Lumina.Excel.Sheets;
|
using Lumina.Excel.Sheets;
|
||||||
|
|
||||||
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
|
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
|
||||||
|
|
@ -32,7 +34,7 @@ internal class UiColorWidget : IDataWindowWidget
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public unsafe void Draw()
|
public void Draw()
|
||||||
{
|
{
|
||||||
var colors = Service<DataManager>.GetNullable()?.GetExcelSheet<UIColor>()
|
var colors = Service<DataManager>.GetNullable()?.GetExcelSheet<UIColor>()
|
||||||
?? throw new InvalidOperationException("UIColor sheet not loaded.");
|
?? throw new InvalidOperationException("UIColor sheet not loaded.");
|
||||||
|
|
@ -44,7 +46,9 @@ internal class UiColorWidget : IDataWindowWidget
|
||||||
"<edgecolor(0xEEEEFF)><color(0x0000FF)>BB<color(stackcolor)><edgecolor(stackcolor)>.<br>" +
|
"<edgecolor(0xEEEEFF)><color(0x0000FF)>BB<color(stackcolor)><edgecolor(stackcolor)>.<br>" +
|
||||||
"· Click on a color to copy the color code.<br>" +
|
"· Click on a color to copy the color code.<br>" +
|
||||||
"· Hover on a color to preview the text with edge, when the next color has been used together.");
|
"· Hover on a color to preview the text with edge, when the next color has been used together.");
|
||||||
if (!ImGui.BeginTable("UIColor"u8, 7))
|
|
||||||
|
using var table = ImRaii.Table("UIColor"u8, 7);
|
||||||
|
if (!table.Success)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImGui.TableSetupScrollFreeze(0, 1);
|
ImGui.TableSetupScrollFreeze(0, 1);
|
||||||
|
|
@ -93,61 +97,61 @@ internal class UiColorWidget : IDataWindowWidget
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.AlignTextToFramePadding();
|
ImGui.AlignTextToFramePadding();
|
||||||
ImGui.PushID($"row{id}_dark");
|
using (ImRaii.PushId($"row{id}_dark"))
|
||||||
if (this.DrawColorColumn(row.Dark) &&
|
{
|
||||||
adjacentRow.HasValue)
|
if (this.DrawColorColumn(row.Dark) && adjacentRow.HasValue)
|
||||||
DrawEdgePreview(id, row.Dark, adjacentRow.Value.Dark);
|
DrawEdgePreview(id, row.Dark, adjacentRow.Value.Dark);
|
||||||
ImGui.PopID();
|
}
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.AlignTextToFramePadding();
|
ImGui.AlignTextToFramePadding();
|
||||||
ImGui.PushID($"row{id}_light");
|
using (ImRaii.PushId($"row{id}_light"))
|
||||||
if (this.DrawColorColumn(row.Light) &&
|
{
|
||||||
adjacentRow.HasValue)
|
if (this.DrawColorColumn(row.Light) && adjacentRow.HasValue)
|
||||||
DrawEdgePreview(id, row.Light, adjacentRow.Value.Light);
|
DrawEdgePreview(id, row.Light, adjacentRow.Value.Light);
|
||||||
ImGui.PopID();
|
}
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.AlignTextToFramePadding();
|
ImGui.AlignTextToFramePadding();
|
||||||
ImGui.PushID($"row{id}_classic");
|
using (ImRaii.PushId($"row{id}_classic"))
|
||||||
if (this.DrawColorColumn(row.ClassicFF) &&
|
{
|
||||||
adjacentRow.HasValue)
|
if (this.DrawColorColumn(row.ClassicFF) && adjacentRow.HasValue)
|
||||||
DrawEdgePreview(id, row.ClassicFF, adjacentRow.Value.ClassicFF);
|
DrawEdgePreview(id, row.ClassicFF, adjacentRow.Value.ClassicFF);
|
||||||
ImGui.PopID();
|
}
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.AlignTextToFramePadding();
|
ImGui.AlignTextToFramePadding();
|
||||||
ImGui.PushID($"row{id}_blue");
|
using (ImRaii.PushId($"row{id}_blue"))
|
||||||
if (this.DrawColorColumn(row.ClearBlue) &&
|
{
|
||||||
adjacentRow.HasValue)
|
if (this.DrawColorColumn(row.ClearBlue) && adjacentRow.HasValue)
|
||||||
DrawEdgePreview(id, row.ClearBlue, adjacentRow.Value.ClearBlue);
|
DrawEdgePreview(id, row.ClearBlue, adjacentRow.Value.ClearBlue);
|
||||||
ImGui.PopID();
|
}
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.AlignTextToFramePadding();
|
ImGui.AlignTextToFramePadding();
|
||||||
ImGui.PushID($"row{id}_white");
|
using (ImRaii.PushId($"row{id}_white"))
|
||||||
if (this.DrawColorColumn(row.ClearWhite) &&
|
{
|
||||||
adjacentRow.HasValue)
|
if (this.DrawColorColumn(row.ClearWhite) && adjacentRow.HasValue)
|
||||||
DrawEdgePreview(id, row.ClearWhite, adjacentRow.Value.ClearWhite);
|
DrawEdgePreview(id, row.ClearWhite, adjacentRow.Value.ClearWhite);
|
||||||
ImGui.PopID();
|
}
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.AlignTextToFramePadding();
|
ImGui.AlignTextToFramePadding();
|
||||||
ImGui.PushID($"row{id}_green");
|
using (ImRaii.PushId($"row{id}_green"))
|
||||||
if (this.DrawColorColumn(row.ClearGreen) &&
|
{
|
||||||
adjacentRow.HasValue)
|
if (this.DrawColorColumn(row.ClearGreen) && adjacentRow.HasValue)
|
||||||
DrawEdgePreview(id, row.ClearGreen, adjacentRow.Value.ClearGreen);
|
DrawEdgePreview(id, row.ClearGreen, adjacentRow.Value.ClearGreen);
|
||||||
ImGui.PopID();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clipper.Destroy();
|
clipper.Destroy();
|
||||||
ImGui.EndTable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DrawEdgePreview(uint id, uint sheetColor, uint sheetColor2)
|
private static void DrawEdgePreview(uint id, uint sheetColor, uint sheetColor2)
|
||||||
{
|
{
|
||||||
ImGui.BeginTooltip();
|
using var tooltip = ImRaii.Tooltip();
|
||||||
|
|
||||||
Span<byte> buf = stackalloc byte[256];
|
Span<byte> buf = stackalloc byte[256];
|
||||||
var ptr = 0;
|
var ptr = 0;
|
||||||
ptr += Encoding.UTF8.GetBytes("<colortype(", buf[ptr..]);
|
ptr += Encoding.UTF8.GetBytes("<colortype(", buf[ptr..]);
|
||||||
|
|
@ -184,7 +188,6 @@ internal class UiColorWidget : IDataWindowWidget
|
||||||
EdgeColor = BinaryPrimitives.ReverseEndianness(sheetColor) | 0xFF000000u,
|
EdgeColor = BinaryPrimitives.ReverseEndianness(sheetColor) | 0xFF000000u,
|
||||||
WrapWidth = float.PositiveInfinity,
|
WrapWidth = float.PositiveInfinity,
|
||||||
});
|
});
|
||||||
ImGui.EndTooltip();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool DrawColorColumn(uint sheetColor)
|
private bool DrawColorColumn(uint sheetColor)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue