acdream/tests/AcDream.App.Tests/UI/Layout/PowerbarLayoutProbeTests.cs
Erik adf8335675 fix: powerbar mode captions - jump 'Height' + combat 'Power'/'Accuracy'
Retail authors ONE caption element per bar with per-mode state strings,
switched by a PassToChildren state cascade (gmPowerbarUI::
RecvNotice_BeginPowerbar @0x004DA730 sets 0x10000042 Jump / 0x10000043
Melee / 0x10000044 Missile / 0x10000045 DDD; installed-DAT probe
confirmed every string + PassToChildren flag).

- Jump bar (user gate): the floaty powerbar's caption child (0x10000035:
  JumpMode 'Height', authored HJustify=Center over the bar) was dropped
  by UiMeter's child absorption. The stateful-fill meter build now
  absorbs it into per-state labels; TrySetRetailState latches the
  caption and OnDraw shows it when no live Label provider is bound.
  JumpPowerbarController's existing JumpMode flip now surfaces 'Height'
  with zero controller changes. The mount gained the string resolver the
  Build call never passed.
- Combat bar (user gate): label 0x10000052 authors 'MeleeCombat' ->
  'Power' and 'MissileCombat' -> 'Accuracy'; the controller latched the
  MELEE string once at bind. CombatUiLabels now resolves both authored
  strings and OnCombatModeChanged sets the mode's string - switching
  live when swapping melee <-> missile weapons in combat. Also fixed
  the mode-state flip target: the states live on the BASIC PANEL
  (0x1000005C, PassToChildren), not the layout root (Hide/ShowDetail
  only) - the old _root flip was a silent no-op.

New env-gated ACDREAM_PROBE_POWERBAR layout probe (kept, house
pattern). App suite 4,987/3 skips.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-14 08:14:14 +02:00

77 lines
3 KiB
C#

using System.IO;
using AcDream.App.UI.Layout;
using DatReaderWriter;
using DatReaderWriter.Options;
namespace AcDream.App.Tests.UI.Layout;
/// <summary>
/// 2026-08-14 gate probe (the ACDREAM_PROBE_LIVE_MOUNT pattern): dumps the
/// authored per-state strings of the floaty powerbar layout (0x21000072 —
/// gmPowerbarUI's mode states 0x10000042 jump / 0x10000043 melee /
/// 0x10000044 missile / 0x10000045 DDD, RecvNotice_BeginPowerbar
/// @ 0x004DA730) and the combat panel's Power label (0x21000073 element
/// 0x10000052, root states 0x10000003 melee / 0x10000004 missile) from the
/// INSTALLED DAT, so the "Height"/"Power"/"Accuracy" fix binds exactly what
/// retail authors instead of guessing.
/// </summary>
public sealed class PowerbarLayoutProbeTests
{
[Fact]
public void ProbePowerbarAuthoredStrings()
{
if (Environment.GetEnvironmentVariable("ACDREAM_PROBE_POWERBAR") != "1")
return;
var datDir = Environment.GetEnvironmentVariable("ACDREAM_DAT_DIR")
?? Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"Documents",
"Asheron's Call");
using var dats = new DatCollection(datDir, DatAccessType.Read);
var strings = new DatStringResolver(dats);
Dump(dats, strings, JumpPowerbarController.LayoutId, "floaty-powerbar");
Dump(dats, strings, CombatUiController.LayoutId, "combat-panel");
}
private static void Dump(
DatCollection dats,
DatStringResolver strings,
uint layoutId,
string label)
{
ElementInfo? root = LayoutImporter.ImportInfos(dats, layoutId);
if (root is null)
{
Console.WriteLine($"[pbprobe] {label} 0x{layoutId:X8}: import FAILED");
return;
}
Console.WriteLine($"[pbprobe] === {label} 0x{layoutId:X8} ===");
DumpElement(strings, root, 0);
}
private static void DumpElement(DatStringResolver strings, ElementInfo e, int depth)
{
string indent = new(' ', depth * 2);
Console.WriteLine(
$"[pbprobe] {indent}0x{e.Id:X8} type={e.Type} ({e.X},{e.Y} {e.Width}x{e.Height}) "
+ $"defaultState=0x{e.DefaultStateId:X8}('{e.DefaultStateName}') states={e.States.Count} "
+ $"hjustify={e.HJustify} fontColor={(e.FontColor is { } fc ? fc.ToString() : "none")}");
foreach (var (stateId, state) in e.States)
{
string text = "";
if (state.Properties.Values.TryGetValue(0x17u, out var p)
&& p.Kind == UiPropertyKind.StringInfo)
{
text = strings.Resolve(p.StringInfoValue) ?? "<unresolved>";
text = $" text='{text}'";
}
Console.WriteLine(
$"[pbprobe] {indent} state 0x{stateId:X8} '{state.Name}'"
+ $" passToChildren={state.PassToChildren}{text}");
}
foreach (ElementInfo child in e.Children)
DumpElement(strings, child, depth + 1);
}
}