feat(ui): importer carries dat FontColor (0x1B) onto text widgets; character colors from dat where present
LayoutImporter.ReadState now reads Properties 0x1B (ColorBaseProperty, ARGB bytes) and stores the normalized Vector4 in ElementInfo.FontColor (nullable). ElementReader.Merge propagates it with the same non-null-derived-wins rule as FontDid and HJustify. DatWidgetFactory.BuildText seeds UiText.DefaultColor from FontColor when present. Diagnosis for LayoutDesc 0x2100002E: ALL 12 header and footer text elements carry NO dat color. Every color is runtime set by CharacterStatController. Comments added at each callsite. No hardcoded colors deleted. Tests added: 3 ElementReader FontColor Merge + 3 DatWidgetFactory DefaultColor. 702 passed, 0 failed. Screenshots: character window, vitals, toolbar all unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
41430420b3
commit
6e0be4bd34
7 changed files with 154 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using System.Numerics;
|
||||
using AcDream.App.UI;
|
||||
using AcDream.App.UI.Layout;
|
||||
namespace AcDream.App.Tests.UI.Layout;
|
||||
|
|
@ -299,4 +300,55 @@ public class DatWidgetFactoryTests
|
|||
t.Centered = false; // controller override
|
||||
Assert.False(t.Centered); // override wins
|
||||
}
|
||||
|
||||
// ── DefaultColor from dat FontColor (importer Fix B) ─────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// When ElementInfo.FontColor is set (dat carried 0x1B ColorBaseProperty),
|
||||
/// DatWidgetFactory.BuildText must copy it onto UiText.DefaultColor.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void BuildText_FontColorPresent_SetsDefaultColor()
|
||||
{
|
||||
var gold = new Vector4(1f, 0.82f, 0.36f, 1f);
|
||||
var info = new ElementInfo { Type = 12, Width = 100, Height = 20, FontColor = gold };
|
||||
var t = Assert.IsType<UiText>(DatWidgetFactory.Create(info, NoTex, null));
|
||||
Assert.Equal(gold, t.DefaultColor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When ElementInfo.FontColor is null (dat carried no 0x1B), DefaultColor must
|
||||
/// stay at white (Vector4.One) — the backward-compatible default.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void BuildText_FontColorAbsent_DefaultColorIsWhite()
|
||||
{
|
||||
var info = new ElementInfo { Type = 12, Width = 100, Height = 20, FontColor = null };
|
||||
var t = Assert.IsType<UiText>(DatWidgetFactory.Create(info, NoTex, null));
|
||||
Assert.Equal(Vector4.One, t.DefaultColor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Backward-compat guarantee: a controller that sets LinesProvider with an
|
||||
/// explicit per-line color AFTER build is unaffected by DefaultColor.
|
||||
/// The controller's per-line color is stored in the Line record, not DefaultColor,
|
||||
/// so DefaultColor changing from dat does not touch existing controller bindings.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void BuildText_ControllerExplicitLineColor_UnaffectedByDefaultColor()
|
||||
{
|
||||
// Dat sets a parchment color.
|
||||
var parchment = new Vector4(0.92f, 0.90f, 0.82f, 1f);
|
||||
var info = new ElementInfo { Type = 12, Width = 100, Height = 20, FontColor = parchment };
|
||||
var t = Assert.IsType<UiText>(DatWidgetFactory.Create(info, NoTex, null));
|
||||
|
||||
// Controller overrides with an explicit gold color in the Line record.
|
||||
var gold = new Vector4(1f, 0.82f, 0.36f, 1f);
|
||||
t.LinesProvider = () => new[] { new UiText.Line("text", gold) };
|
||||
|
||||
// The line's color is gold (controller wins), NOT the dat parchment.
|
||||
Assert.Equal(gold, t.LinesProvider()[0].Color);
|
||||
// DefaultColor still holds the dat parchment (unmodified by the controller binding).
|
||||
Assert.Equal(parchment, t.DefaultColor);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue