mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-29 20:03:41 +01:00
Fix UIColor handling per theme (#1995)
UIColor sheet has color sets per theme. Updated `UIColorWidget` to reflect that, and added `SeStringDrawParams.ThemeIndex` to let users choose which theme color set to use while drawing SeString from Dalamud.
This commit is contained in:
parent
eb2724f366
commit
694b42a378
8 changed files with 215 additions and 107 deletions
|
|
@ -56,7 +56,7 @@ internal class DataWindow : Window, IDisposable
|
|||
new TaskSchedulerWidget(),
|
||||
new TexWidget(),
|
||||
new ToastWidget(),
|
||||
new UIColorWidget(),
|
||||
new UiColorWidget(),
|
||||
};
|
||||
|
||||
private readonly IOrderedEnumerable<IDataWindowWidget> orderedModules;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ using Dalamud.Interface.Utility;
|
|||
using Dalamud.Storage.Assets;
|
||||
using Dalamud.Utility;
|
||||
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
|
||||
using ImGuiNET;
|
||||
|
||||
using Lumina.Excel.GeneratedSheets2;
|
||||
|
|
@ -28,10 +30,10 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
|
|||
/// </summary>
|
||||
internal unsafe class SeStringRendererTestWidget : IDataWindowWidget
|
||||
{
|
||||
private static readonly string[] ThemeNames = ["Dark", "Light", "Classic FF", "Clear Blue"];
|
||||
private ImVectorWrapper<byte> testStringBuffer;
|
||||
private string testString = string.Empty;
|
||||
private Addon[]? addons;
|
||||
private ReadOnlySeString? uicolor;
|
||||
private ReadOnlySeString? logkind;
|
||||
private SeStringDrawParams style;
|
||||
private bool interactable;
|
||||
|
|
@ -51,7 +53,6 @@ internal unsafe class SeStringRendererTestWidget : IDataWindowWidget
|
|||
{
|
||||
this.style = new() { GetEntity = this.GetEntity };
|
||||
this.addons = null;
|
||||
this.uicolor = null;
|
||||
this.logkind = null;
|
||||
this.testString = string.Empty;
|
||||
this.interactable = this.useEntity = true;
|
||||
|
|
@ -117,6 +118,12 @@ internal unsafe class SeStringRendererTestWidget : IDataWindowWidget
|
|||
if (ImGui.Checkbox("Shadow", ref t))
|
||||
this.style.Shadow = t;
|
||||
|
||||
ImGui.SameLine();
|
||||
var t4 = this.style.ThemeIndex ?? AtkStage.Instance()->AtkUIColorHolder->ActiveColorThemeType;
|
||||
ImGui.PushItemWidth(ImGui.CalcTextSize("WWWWWWWWWWWWWW").X);
|
||||
if (ImGui.Combo("##theme", ref t4, ThemeNames, ThemeNames.Length))
|
||||
this.style.ThemeIndex = t4;
|
||||
|
||||
ImGui.SameLine();
|
||||
t = this.style.LinkUnderlineThickness > 0f;
|
||||
if (ImGui.Checkbox("Link Underline", ref t))
|
||||
|
|
@ -136,50 +143,6 @@ internal unsafe class SeStringRendererTestWidget : IDataWindowWidget
|
|||
if (ImGui.Checkbox("Use Entity Replacements", ref t))
|
||||
this.useEntity = t;
|
||||
|
||||
if (ImGui.CollapsingHeader("UIColor Preview"))
|
||||
{
|
||||
if (this.uicolor is null)
|
||||
{
|
||||
var tt = new SeStringBuilder();
|
||||
foreach (var uc in Service<DataManager>.Get().GetExcelSheet<UIColor>()!)
|
||||
{
|
||||
tt.Append($"#{uc.RowId}: ")
|
||||
.BeginMacro(MacroCode.EdgeColorType).AppendUIntExpression(uc.RowId).EndMacro()
|
||||
.Append("Edge ")
|
||||
.BeginMacro(MacroCode.ColorType).AppendUIntExpression(uc.RowId).EndMacro()
|
||||
.Append("Edge+Color ")
|
||||
.BeginMacro(MacroCode.EdgeColorType).AppendUIntExpression(0).EndMacro()
|
||||
.Append("Color ")
|
||||
.BeginMacro(MacroCode.ColorType).AppendUIntExpression(0).EndMacro();
|
||||
if (uc.RowId >= 500)
|
||||
{
|
||||
if (uc.RowId % 2 == 0)
|
||||
{
|
||||
tt.BeginMacro(MacroCode.EdgeColorType).AppendUIntExpression(uc.RowId).EndMacro()
|
||||
.BeginMacro(MacroCode.ColorType).AppendUIntExpression(uc.RowId + 1).EndMacro()
|
||||
.Append($" => color#{uc.RowId + 1} + edge#{uc.RowId}")
|
||||
.BeginMacro(MacroCode.EdgeColorType).AppendUIntExpression(0).EndMacro()
|
||||
.BeginMacro(MacroCode.ColorType).AppendUIntExpression(0).EndMacro();
|
||||
}
|
||||
else
|
||||
{
|
||||
tt.BeginMacro(MacroCode.EdgeColorType).AppendUIntExpression(uc.RowId).EndMacro()
|
||||
.BeginMacro(MacroCode.ColorType).AppendUIntExpression(uc.RowId - 1).EndMacro()
|
||||
.Append($" => color#{uc.RowId - 1} + edge#{uc.RowId}")
|
||||
.BeginMacro(MacroCode.EdgeColorType).AppendUIntExpression(0).EndMacro()
|
||||
.BeginMacro(MacroCode.ColorType).AppendUIntExpression(0).EndMacro();
|
||||
}
|
||||
}
|
||||
|
||||
tt.BeginMacro(MacroCode.NewLine).EndMacro();
|
||||
}
|
||||
|
||||
this.uicolor = tt.ToReadOnlySeString();
|
||||
}
|
||||
|
||||
ImGuiHelpers.SeStringWrapped(this.uicolor.Value.Data.Span, this.style);
|
||||
}
|
||||
|
||||
if (ImGui.CollapsingHeader("LogKind Preview"))
|
||||
{
|
||||
if (this.logkind is null)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
using System.Numerics;
|
||||
using System.Buffers.Binary;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
using Dalamud.Data;
|
||||
using Dalamud.Interface.ImGuiSeStringRenderer.Internal;
|
||||
using Dalamud.Storage.Assets;
|
||||
|
||||
using ImGuiNET;
|
||||
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
|
||||
|
|
@ -10,13 +15,15 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
|
|||
/// <summary>
|
||||
/// Widget for displaying all UI Colors from Lumina.
|
||||
/// </summary>
|
||||
internal class UIColorWidget : IDataWindowWidget
|
||||
internal class UiColorWidget : IDataWindowWidget
|
||||
{
|
||||
private UIColor[]? colors;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string[]? CommandShortcuts { get; init; } = { "uicolor" };
|
||||
|
||||
public string[]? CommandShortcuts { get; init; } = ["uicolor"];
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string DisplayName { get; init; } = "UIColor";
|
||||
public string DisplayName { get; init; } = "UIColor";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Ready { get; set; }
|
||||
|
|
@ -25,33 +32,124 @@ internal class UIColorWidget : IDataWindowWidget
|
|||
public void Load()
|
||||
{
|
||||
this.Ready = true;
|
||||
this.colors = null;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Draw()
|
||||
public unsafe void Draw()
|
||||
{
|
||||
var colorSheet = Service<DataManager>.Get().GetExcelSheet<UIColor>();
|
||||
if (colorSheet is null) return;
|
||||
this.colors ??= Service<DataManager>.Get().GetExcelSheet<UIColor>()?.ToArray();
|
||||
if (this.colors is null) return;
|
||||
|
||||
foreach (var color in colorSheet)
|
||||
ImGui.TextUnformatted("Color notation is #RRGGBB.");
|
||||
if (!ImGui.BeginTable("UIColor", 5))
|
||||
return;
|
||||
|
||||
ImGui.TableSetupScrollFreeze(0, 1);
|
||||
var basew = ImGui.CalcTextSize("9").X;
|
||||
ImGui.TableSetupColumn("Row ID", ImGuiTableColumnFlags.WidthFixed, basew * 7);
|
||||
ImGui.TableSetupColumn("Dark", ImGuiTableColumnFlags.WidthFixed, basew * 17);
|
||||
ImGui.TableSetupColumn("Light", ImGuiTableColumnFlags.WidthFixed, basew * 17);
|
||||
ImGui.TableSetupColumn("Classic FF", ImGuiTableColumnFlags.WidthFixed, basew * 17);
|
||||
ImGui.TableSetupColumn("Clear Blue", ImGuiTableColumnFlags.WidthFixed, basew * 17);
|
||||
ImGui.TableHeadersRow();
|
||||
|
||||
var clipper = new ImGuiListClipperPtr(ImGuiNative.ImGuiListClipper_ImGuiListClipper());
|
||||
clipper.Begin(this.colors.Length);
|
||||
while (clipper.Step())
|
||||
{
|
||||
this.DrawUiColor(color);
|
||||
for (var i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
||||
{
|
||||
var id = this.colors[i].RowId;
|
||||
ImGui.TableNextRow();
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted($"{id}");
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.PushID($"row{id}_col1");
|
||||
DrawColorColumn(this.colors[i].UIForeground);
|
||||
if (id is >= 500 and < 580)
|
||||
DrawEdgePreview(id, this.colors[i].UIForeground, this.colors[i + 1].UIForeground);
|
||||
ImGui.PopID();
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.PushID($"row{id}_col2");
|
||||
DrawColorColumn(this.colors[i].UIGlow);
|
||||
if (id is >= 500 and < 580)
|
||||
DrawEdgePreview(id, this.colors[i].UIGlow, this.colors[i + 1].UIGlow);
|
||||
ImGui.PopID();
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.PushID($"row{id}_col3");
|
||||
DrawColorColumn(this.colors[i].Unknown2);
|
||||
if (id is >= 500 and < 580)
|
||||
DrawEdgePreview(id, this.colors[i].Unknown2, this.colors[i + 1].Unknown2);
|
||||
ImGui.PopID();
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.PushID($"row{id}_col4");
|
||||
DrawColorColumn(this.colors[i].Unknown3);
|
||||
if (id is >= 500 and < 580)
|
||||
DrawEdgePreview(id, this.colors[i].Unknown3, this.colors[i + 1].Unknown3);
|
||||
ImGui.PopID();
|
||||
}
|
||||
}
|
||||
|
||||
clipper.Destroy();
|
||||
ImGui.EndTable();
|
||||
}
|
||||
|
||||
private void DrawUiColor(UIColor color)
|
||||
|
||||
private static void DrawColorColumn(uint sheetColor)
|
||||
{
|
||||
ImGui.Text($"[{color.RowId:D3}] ");
|
||||
sheetColor = BinaryPrimitives.ReverseEndianness(sheetColor);
|
||||
ImGui.Image(
|
||||
Service<DalamudAssetManager>.Get().White4X4.ImGuiHandle,
|
||||
new(ImGui.GetFrameHeight()),
|
||||
Vector2.Zero,
|
||||
Vector2.One,
|
||||
ImGui.ColorConvertU32ToFloat4(sheetColor | 0xFF000000u));
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(this.ConvertToVector4(color.Unknown2), $"Unknown2 ");
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(this.ConvertToVector4(color.UIForeground), "UIForeground ");
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(this.ConvertToVector4(color.Unknown3), "Unknown3 ");
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(this.ConvertToVector4(color.UIGlow), "UIGlow");
|
||||
ImGui.TextUnformatted($"#{sheetColor & 0xFF:X02}{(sheetColor >> 8) & 0xFF:X02}{(sheetColor >> 16) & 0xFF:X02}");
|
||||
}
|
||||
|
||||
|
||||
private static void DrawEdgePreview(uint id, uint sheetColor, uint sheetColor2)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
if (Service<SeStringRenderer>.Get().Draw(
|
||||
new("+E"u8),
|
||||
new()
|
||||
{
|
||||
Edge = true,
|
||||
Color = BinaryPrimitives.ReverseEndianness(sheetColor) | 0xFF000000u,
|
||||
EdgeColor = BinaryPrimitives.ReverseEndianness(sheetColor2) | 0xFF000000u,
|
||||
},
|
||||
"+E"u8).Clicked)
|
||||
ImGui.SetClipboardText($"<colortype({id})><edgecolortype({id + 1})>+E<edgecolortype(0)><colortype(0)>");
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip($"<colortype({id})><edgecolortype({id + 1})>+E<edgecolortype(0)><colortype(0)>");
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
if (Service<SeStringRenderer>.Get().Draw(
|
||||
new("+F"u8),
|
||||
new()
|
||||
{
|
||||
Edge = true,
|
||||
Color = BinaryPrimitives.ReverseEndianness(sheetColor2) | 0xFF000000u,
|
||||
EdgeColor = BinaryPrimitives.ReverseEndianness(sheetColor) | 0xFF000000u,
|
||||
},
|
||||
"+F"u8).Clicked)
|
||||
ImGui.SetClipboardText($"<colortype({id + 1})><edgecolortype({id})>+E<edgecolortype(0)><colortype(0)>");
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip($"<colortype({id + 1})><edgecolortype({id})>+E<edgecolortype(0)><colortype(0)>");
|
||||
}
|
||||
|
||||
private Vector4 ConvertToVector4(uint color)
|
||||
{
|
||||
var r = (byte)(color >> 24);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue