fix: complete retail parity stability pass
This commit is contained in:
parent
d3df4cb20a
commit
f7aa8e0eb7
131 changed files with 7765 additions and 1190 deletions
|
|
@ -1059,8 +1059,8 @@ public sealed class CharacterCreationLiveDatTests
|
|||
/// GF-13: the BEHAVIOR half — after the real controller mounts through
|
||||
/// <see cref="CharacterCreationUiController.CreateDetached"/> (not a raw
|
||||
/// <see cref="LayoutImporter.Build"/> call), the two authored-invisible
|
||||
/// elements are not <see cref="UiElement.Visible"/>. Exercises
|
||||
/// <c>HideAuthoredInvisibleElements</c>'s real chargen-scoped honor path,
|
||||
/// elements are not <see cref="UiElement.Visible"/>. Exercises the shared
|
||||
/// importer-wide #408 behavior through a real chargen controller mount,
|
||||
/// not just the data plumbing the sibling test above pins.
|
||||
/// </summary>
|
||||
[InstalledDatFact]
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ public sealed class CharacterCreationUiControllerTests
|
|||
/// Center default.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void SkillsPage_InfoBoxPanes_ForceTopVerticalJustify_ToAvoidTitleDescriptionOverlap()
|
||||
public void SkillsPage_InfoBoxPanes_InheritRetailTopDefault_ToAvoidTitleDescriptionOverlap()
|
||||
{
|
||||
using var environment = new EnvironmentHarness();
|
||||
environment.Controller.Open();
|
||||
|
|
|
|||
|
|
@ -168,6 +168,31 @@ public sealed class CharacterManagementUiControllerTests
|
|||
string.Join(" ", worldText.LinesProvider().Select(static line => line.Text)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CreditsButton_QueuesTheCreditsMode_AndPresentationCanBeSuppressedForIt()
|
||||
{
|
||||
int openCalls = 0;
|
||||
using var environment = new EnvironmentHarness(() => openCalls++);
|
||||
CharacterManagementUiController controller = environment.Controller;
|
||||
UiButton credits = environment.Button(
|
||||
CharacterManagementUiController.CreditsElementId);
|
||||
|
||||
Assert.True(credits.Visible);
|
||||
Assert.True(credits.Enabled);
|
||||
Assert.NotNull(credits.OnClick);
|
||||
credits.OnClick!();
|
||||
Assert.Equal(1, openCalls);
|
||||
|
||||
controller.SetPresentationSuppressed(true);
|
||||
Assert.False(controller.Root.Visible);
|
||||
Assert.Null(environment.Host.FixedCanvasSize);
|
||||
|
||||
controller.SetPresentationSuppressed(false);
|
||||
Assert.True(controller.Root.Visible);
|
||||
Assert.Equal(new Vector2(800f, 600f), environment.Host.FixedCanvasSize);
|
||||
Assert.Equal(3, controller.Rows.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RowHeight_UsesAllowedSlotsAndClampsAtOneTenthForLargeRosters()
|
||||
{
|
||||
|
|
@ -882,7 +907,7 @@ public sealed class CharacterManagementUiControllerTests
|
|||
|
||||
private sealed class EnvironmentHarness : IDisposable
|
||||
{
|
||||
public EnvironmentHarness()
|
||||
public EnvironmentHarness(Action? openCredits = null)
|
||||
{
|
||||
Host = new UiRoot { Width = 800f, Height = 600f };
|
||||
Screen = BuildScreen();
|
||||
|
|
@ -901,7 +926,8 @@ public sealed class CharacterManagementUiControllerTests
|
|||
static (_, _) => BuildRow(),
|
||||
Dialogs,
|
||||
Runtime.Bindings,
|
||||
TestStrings()));
|
||||
TestStrings(),
|
||||
openCredits));
|
||||
}
|
||||
|
||||
public UiRoot Host { get; }
|
||||
|
|
|
|||
|
|
@ -1115,7 +1115,7 @@ public sealed class ConfigOptionsPageControllerTests
|
|||
2, // 19 Landscape Texture Detail
|
||||
1, // 20 Environment Texture Detail
|
||||
1, // 21 Texture Filtering
|
||||
8, // 22 Landscape Draw Distance (opaque — AP-198 sub-note)
|
||||
8, // 22 Landscape Draw Distance (retail radius payload)
|
||||
true, // 23 Building Detail Textures
|
||||
false, // 24 Multi-Pass Alpha
|
||||
|
||||
|
|
@ -1418,7 +1418,7 @@ public sealed class ConfigOptionsPageControllerTests
|
|||
(23, RowKind.Menu, true, "Landscape Texture Detail"), // AP-198
|
||||
(24, RowKind.Menu, true, "Environment Texture Detail"), // AP-198
|
||||
(25, RowKind.Menu, true, "Texture Filtering"), // AP-198
|
||||
(26, RowKind.Menu, true, "Landscape Draw Distance"), // AP-198
|
||||
(26, RowKind.Menu, false, "Landscape Draw Distance"), // LIVE — #361
|
||||
(27, RowKind.Toggle, false, "Building Detail Textures"), // LIVE — #226
|
||||
(28, RowKind.Toggle, true, "Multi-Pass Alpha"), // AP-198
|
||||
(31, RowKind.Slider, true, "Mouse Look Sensitivity"), // TS-74
|
||||
|
|
@ -1485,6 +1485,27 @@ public sealed class ConfigOptionsPageControllerTests
|
|||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LandscapeDrawDistance_UsesRetailRadiusPayloads_AndAppliesSelection()
|
||||
{
|
||||
(OptionsPanelController controller, FakeBindings bindings, bool bound) = BindReal();
|
||||
Assert.True(bound);
|
||||
|
||||
var configSlot = UiElement.FindDescendant(controller.TabPanel, ConfigPageSlotId)!;
|
||||
List<UiMenu> menus = CollectMenus(configSlot);
|
||||
UiMenu drawDistance = menus[5];
|
||||
|
||||
Assert.Equal(8, drawDistance.Selected);
|
||||
Assert.Equal(
|
||||
[3, 5, 8, 11, 15, 25],
|
||||
drawDistance.Items.Select(item => Assert.IsType<int>(item.Payload)).ToArray());
|
||||
|
||||
drawDistance.OnSelect!(25);
|
||||
controller.ConfigPage.Apply();
|
||||
|
||||
Assert.Equal(25, bindings.Display.LandscapeDrawDistance);
|
||||
}
|
||||
|
||||
// ── #412-class regression: Config tab content escaping the window frame ──
|
||||
//
|
||||
// 2026-08-16/17 overnight hover/UI round, Batch A bug 2. The user's
|
||||
|
|
|
|||
110
tests/AcDream.App.Tests/UI/Layout/CreditsLiveDatTests.cs
Normal file
110
tests/AcDream.App.Tests/UI/Layout/CreditsLiveDatTests.cs
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
using AcDream.App.UI.Layout;
|
||||
using AcDream.App.UI;
|
||||
using AcDream.Content;
|
||||
using DatReaderWriter;
|
||||
using DatReaderWriter.Options;
|
||||
|
||||
namespace AcDream.App.Tests.UI.Layout;
|
||||
|
||||
/// <summary>
|
||||
/// Installed-retail-DAT oracle for issue #400's <c>gmCreditsUI</c> port.
|
||||
/// Retail creates two independent enum-table-5 roots: the picture strip
|
||||
/// and the scrolling text field.
|
||||
/// </summary>
|
||||
[Trait("Lane", "InstalledDat")]
|
||||
public sealed class CreditsLiveDatTests
|
||||
{
|
||||
[InstalledDatFact]
|
||||
public void Category4_ResolvesAuthoredPictureAndTextRoots()
|
||||
{
|
||||
string datDirectory = Environment.GetEnvironmentVariable("ACDREAM_DAT_DIR")
|
||||
?? Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
|
||||
"Documents",
|
||||
"Asheron's Call");
|
||||
using var dats = new DatCollection(datDirectory, DatAccessType.Read);
|
||||
|
||||
// CreateAndAddRootElement(layoutEnum=0x10000004, rootElementId)
|
||||
// uses the ordinary table-5 layout map, exactly like character
|
||||
// management's (0x10000005, 0x1000039A) pair.
|
||||
uint pictureLayout = RetailDataIdResolver.Resolve(dats, 0x10000004u, 5u);
|
||||
Assert.Equal(0x21000003u, pictureLayout);
|
||||
|
||||
ElementInfo picture = Assert.IsType<ElementInfo>(
|
||||
LayoutImporter.ImportInfos(dats, pictureLayout, 0x10000413u));
|
||||
ElementInfo text = Assert.IsType<ElementInfo>(
|
||||
LayoutImporter.ImportInfos(dats, pictureLayout, 0x10000410u));
|
||||
|
||||
Assert.Equal(CreditsUiController.PictureRootElementId, picture.Id);
|
||||
Assert.Equal(3u, picture.Type);
|
||||
Assert.Equal((0f, 0f, 400f, 600f),
|
||||
(picture.X, picture.Y, picture.Width, picture.Height));
|
||||
Assert.Equal(CreditsUiController.TextRootElementId, text.Id);
|
||||
Assert.Equal(3u, text.Type);
|
||||
Assert.Equal((400f, 0f, 400f, 600f),
|
||||
(text.X, text.Y, text.Width, text.Height));
|
||||
|
||||
Assert.True(TryDataId(text, 0x10000002u, out uint textAreaId));
|
||||
Assert.Equal(CreditsUiController.TextAreaElementId, textAreaId);
|
||||
Assert.True(TryDataId(text, 0x10000003u, out uint stringTableId));
|
||||
Assert.Equal(0x23000008u, stringTableId);
|
||||
Assert.True(text.TryGetEffectiveFloat(0x10000004u, out float seconds));
|
||||
Assert.Equal(20f, seconds);
|
||||
|
||||
ElementInfo textArea = Assert.Single(text.Children);
|
||||
Assert.Equal(CreditsUiController.TextAreaElementId, textArea.Id);
|
||||
Assert.Equal(12u, textArea.Type);
|
||||
Assert.Equal(0x40000000u, textArea.FontDid);
|
||||
Assert.Equal(HJustify.Center, textArea.HJustify);
|
||||
Assert.Equal(VJustify.Center, textArea.VJustify);
|
||||
|
||||
Assert.True(picture.TryGetEffectiveProperty(
|
||||
0x10000005u,
|
||||
out UiPropertyValue pictureArray));
|
||||
Assert.Equal(UiPropertyKind.Array, pictureArray.Kind);
|
||||
Assert.Equal(
|
||||
Enumerable.Range(0, 7).Select(index => 0x06005F14u + (uint)index),
|
||||
pictureArray.ArrayValue.Select(static value => (uint)value.UnsignedValue));
|
||||
|
||||
ImportedLayout builtText = Assert.IsType<ImportedLayout>(
|
||||
LayoutImporter.Import(
|
||||
dats,
|
||||
pictureLayout,
|
||||
CreditsUiController.TextRootElementId,
|
||||
static id => (id, 1, 1),
|
||||
null));
|
||||
Assert.IsType<UiText>(builtText.FindElement(
|
||||
CreditsUiController.TextAreaElementId));
|
||||
|
||||
var strings = new DatStringResolver(dats);
|
||||
int creditsCount = 0;
|
||||
for (int i = 1; i <= 4096; i++)
|
||||
{
|
||||
string? value = strings.Resolve(
|
||||
stringTableId,
|
||||
DatStringResolver.ComputeHash($"ID_Credits{i}"));
|
||||
if (value is null)
|
||||
break;
|
||||
creditsCount++;
|
||||
}
|
||||
Assert.Equal(2345, creditsCount);
|
||||
Assert.NotNull(strings.Resolve(
|
||||
0x23000001u,
|
||||
DatStringResolver.ComputeHash("ID_Wait_PleaseWait")));
|
||||
}
|
||||
|
||||
private static bool TryDataId(
|
||||
ElementInfo info,
|
||||
uint propertyId,
|
||||
out uint value)
|
||||
{
|
||||
if (info.TryGetEffectiveProperty(propertyId, out UiPropertyValue property)
|
||||
&& property.Kind is UiPropertyKind.DataId or UiPropertyKind.Enum)
|
||||
{
|
||||
value = checked((uint)property.UnsignedValue);
|
||||
return true;
|
||||
}
|
||||
value = 0u;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
166
tests/AcDream.App.Tests/UI/Layout/CreditsUiControllerTests.cs
Normal file
166
tests/AcDream.App.Tests/UI/Layout/CreditsUiControllerTests.cs
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
using System.Numerics;
|
||||
using AcDream.App.UI;
|
||||
using AcDream.App.UI.Layout;
|
||||
|
||||
namespace AcDream.App.Tests.UI.Layout;
|
||||
|
||||
public sealed class CreditsUiControllerTests
|
||||
{
|
||||
[Fact]
|
||||
public void Activate_UsesAuthoredCanvas_TextTiming_AndCyclicPictureStrip()
|
||||
{
|
||||
using var environment = new EnvironmentHarness();
|
||||
CreditsUiController controller = environment.Controller;
|
||||
|
||||
controller.Activate();
|
||||
|
||||
Assert.True(controller.IsActive);
|
||||
Assert.Equal(new Vector2(800f, 600f), environment.Host.FixedCanvasSize);
|
||||
Assert.True(controller.PictureRoot.Visible);
|
||||
Assert.True(controller.TextRoot.Visible);
|
||||
Assert.Equal(600f, controller.TextArea.Top);
|
||||
Assert.Equal(48f, controller.TextArea.Height);
|
||||
Assert.Single(controller.Pictures);
|
||||
Assert.Equal(601f, controller.Pictures[0].Top);
|
||||
Assert.Equal(0x06000001u, controller.Pictures[0].BackgroundSprite);
|
||||
Assert.Equal(
|
||||
20d * (600d + 48d) / (600d + 48d / 3d),
|
||||
controller.DurationSeconds,
|
||||
precision: 5);
|
||||
|
||||
environment.Now += controller.DurationSeconds * 0.5d;
|
||||
controller.Tick();
|
||||
|
||||
Assert.Equal(276f, controller.TextArea.Top);
|
||||
Assert.True(controller.Pictures[0].Top < 600f);
|
||||
Assert.Equal(2, controller.Pictures.Count);
|
||||
Assert.Equal(0x06000002u, controller.Pictures[1].BackgroundSprite);
|
||||
Assert.Equal(
|
||||
controller.Pictures[0].Top + controller.Pictures[0].Height + 1f,
|
||||
controller.Pictures[1].Top);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnyKey_ShowsWaitForAFrame_ThenReturnsToCharacterManagement()
|
||||
{
|
||||
using var environment = new EnvironmentHarness();
|
||||
CreditsUiController controller = environment.Controller;
|
||||
controller.Activate();
|
||||
|
||||
environment.Host.OnKeyDown(123);
|
||||
Assert.Equal(1, environment.Dialogs.ActiveCount);
|
||||
|
||||
controller.Tick();
|
||||
Assert.True(controller.IsActive);
|
||||
Assert.Equal(0, environment.ReturnCalls);
|
||||
|
||||
controller.Tick();
|
||||
Assert.False(controller.IsActive);
|
||||
Assert.Equal(1, environment.ReturnCalls);
|
||||
Assert.Equal(0, environment.Dialogs.ActiveCount);
|
||||
Assert.Null(environment.Host.FixedCanvasSize);
|
||||
Assert.False(controller.PictureRoot.Visible);
|
||||
Assert.False(controller.TextRoot.Visible);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NaturalCompletion_UsesTheSameWaitAndReturnPath()
|
||||
{
|
||||
using var environment = new EnvironmentHarness();
|
||||
CreditsUiController controller = environment.Controller;
|
||||
controller.Activate();
|
||||
|
||||
environment.Now += controller.DurationSeconds;
|
||||
controller.Tick();
|
||||
Assert.Equal(1, environment.Dialogs.ActiveCount);
|
||||
|
||||
controller.Tick();
|
||||
Assert.True(controller.IsActive);
|
||||
controller.Tick();
|
||||
|
||||
Assert.False(controller.IsActive);
|
||||
Assert.Equal(1, environment.ReturnCalls);
|
||||
Assert.Equal(0, environment.Dialogs.ActiveCount);
|
||||
}
|
||||
|
||||
private sealed class EnvironmentHarness : IDisposable
|
||||
{
|
||||
public EnvironmentHarness()
|
||||
{
|
||||
Host = new UiRoot { Width = 1280f, Height = 720f };
|
||||
Dialogs = new RetailDialogFactory(
|
||||
Host,
|
||||
RetailDialogFactoryTests.BuildDialogLayout);
|
||||
CreditsUiResources resources = BuildResources();
|
||||
Controller = Assert.IsType<CreditsUiController>(
|
||||
CreditsUiController.CreateDetached(
|
||||
Host,
|
||||
resources,
|
||||
Dialogs,
|
||||
() => Now,
|
||||
ResolveSprite,
|
||||
() => ReturnCalls++));
|
||||
}
|
||||
|
||||
public UiRoot Host { get; }
|
||||
public RetailDialogFactory Dialogs { get; }
|
||||
public CreditsUiController Controller { get; }
|
||||
public double Now { get; set; } = 100d;
|
||||
public int ReturnCalls { get; private set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Controller.Dispose();
|
||||
Dialogs.Dispose();
|
||||
}
|
||||
|
||||
private static (uint tex, int w, int h) ResolveSprite(uint id)
|
||||
=> (id, 400, 300);
|
||||
|
||||
private static CreditsUiResources BuildResources()
|
||||
{
|
||||
ImportedLayout picture = LayoutImporter.Build(
|
||||
new ElementInfo
|
||||
{
|
||||
Id = CreditsUiController.PictureRootElementId,
|
||||
Type = 3u,
|
||||
X = 0f,
|
||||
Y = 0f,
|
||||
Width = 400f,
|
||||
Height = 600f,
|
||||
},
|
||||
ResolveSprite,
|
||||
null);
|
||||
var textRoot = new ElementInfo
|
||||
{
|
||||
Id = CreditsUiController.TextRootElementId,
|
||||
Type = 3u,
|
||||
X = 400f,
|
||||
Y = 0f,
|
||||
Width = 400f,
|
||||
Height = 600f,
|
||||
};
|
||||
textRoot.Children.Add(new ElementInfo
|
||||
{
|
||||
Id = CreditsUiController.TextAreaElementId,
|
||||
Type = 12u,
|
||||
Width = 0f,
|
||||
Height = 0f,
|
||||
HJustify = HJustify.Center,
|
||||
VJustify = VJustify.Center,
|
||||
});
|
||||
ImportedLayout text = LayoutImporter.Build(
|
||||
textRoot,
|
||||
ResolveSprite,
|
||||
null);
|
||||
return new CreditsUiResources(
|
||||
0x21000003u,
|
||||
picture,
|
||||
text,
|
||||
["One\n", "Two\n"],
|
||||
[0x06000001u, 0x06000002u],
|
||||
20f,
|
||||
"Please Wait");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1111,7 +1111,7 @@ public class DatWidgetFactoryTests
|
|||
// ── Justification build-time application (new for importer Fix A) ────────
|
||||
|
||||
/// <summary>
|
||||
/// A Type-12 text element with HJustify=Center (the default) must produce a
|
||||
/// A Type-12 text element with authored HJustify=Center must produce a
|
||||
/// UiText with Centered=true and RightAligned=false at build time.
|
||||
/// This proves BuildText applies the dat's HJustify at construction without a
|
||||
/// controller binding step.
|
||||
|
|
@ -1123,7 +1123,18 @@ public class DatWidgetFactoryTests
|
|||
var t = Assert.IsType<UiText>(DatWidgetFactory.Create(info, NoTex, null));
|
||||
Assert.True(t.Centered);
|
||||
Assert.False(t.RightAligned);
|
||||
Assert.Equal(VJustify.Center, t.VerticalJustify);
|
||||
Assert.Equal(VJustify.Top, t.VerticalJustify);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildText_UnauthoredJustification_UsesRetailNearEdges()
|
||||
{
|
||||
var info = new ElementInfo { Type = 12, Width = 100, Height = 20 };
|
||||
var t = Assert.IsType<UiText>(DatWidgetFactory.Create(info, NoTex, null));
|
||||
|
||||
Assert.False(t.Centered);
|
||||
Assert.False(t.RightAligned);
|
||||
Assert.Equal(VJustify.Top, t.VerticalJustify);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -182,40 +182,40 @@ public class ElementReaderTests
|
|||
// ── HJustify / VJustify — Merge propagation ─────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// When the derived element has a non-Center HJustify, the derived value wins
|
||||
/// (same "non-default wins" rule as FontDid).
|
||||
/// Authored justification is presence-based: raw 3 on the derived element
|
||||
/// overrides raw 1 on its base.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Merge_DerivedHJustifyRight_OverridesBaseCenter()
|
||||
{
|
||||
var base_ = new ElementInfo { HJustify = HJustify.Center };
|
||||
var derived = new ElementInfo { HJustify = HJustify.Right };
|
||||
ElementInfo base_ = WithJustification(0x14u, 1u);
|
||||
ElementInfo derived = WithJustification(0x14u, 3u);
|
||||
var merged = ElementReader.Merge(base_, derived);
|
||||
Assert.Equal(HJustify.Right, merged.HJustify);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the derived element has the default HJustify (Center), the base value
|
||||
/// is inherited — Center from the derived does NOT override a Left base.
|
||||
/// Center is a real authored raw value, not an unset sentinel, and must
|
||||
/// therefore override a Left base.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Merge_DerivedHJustifyCenter_InheritsBaseLeft()
|
||||
public void Merge_DerivedAuthoredHJustifyCenter_OverridesBaseLeft()
|
||||
{
|
||||
var base_ = new ElementInfo { HJustify = HJustify.Left };
|
||||
var derived = new ElementInfo { HJustify = HJustify.Center }; // default — no explicit dat property
|
||||
ElementInfo base_ = WithJustification(0x14u, 2u);
|
||||
ElementInfo derived = WithJustification(0x14u, 1u);
|
||||
var merged = ElementReader.Merge(base_, derived);
|
||||
Assert.Equal(HJustify.Left, merged.HJustify);
|
||||
Assert.Equal(HJustify.Center, merged.HJustify);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// VJustify=Top from the base propagates when the derived element has no explicit
|
||||
/// (Center) vertical justification.
|
||||
/// VJustify=Top from the base propagates when the derived element authors
|
||||
/// no vertical justification.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Merge_BaseVJustifyTop_InheritedWhenDerivedIsCenter()
|
||||
public void Merge_BaseVJustifyTop_InheritedWhenDerivedIsUnauthored()
|
||||
{
|
||||
var base_ = new ElementInfo { VJustify = VJustify.Top };
|
||||
var derived = new ElementInfo { VJustify = VJustify.Center }; // default
|
||||
ElementInfo base_ = WithJustification(0x15u, 4u);
|
||||
var derived = new ElementInfo();
|
||||
var merged = ElementReader.Merge(base_, derived);
|
||||
Assert.Equal(VJustify.Top, merged.VJustify);
|
||||
}
|
||||
|
|
@ -226,8 +226,8 @@ public class ElementReaderTests
|
|||
[Fact]
|
||||
public void Merge_DerivedVJustifyBottom_OverridesBaseCenter()
|
||||
{
|
||||
var base_ = new ElementInfo { VJustify = VJustify.Center };
|
||||
var derived = new ElementInfo { VJustify = VJustify.Bottom };
|
||||
ElementInfo base_ = WithJustification(0x15u, 1u);
|
||||
ElementInfo derived = WithJustification(0x15u, 3u);
|
||||
var merged = ElementReader.Merge(base_, derived);
|
||||
Assert.Equal(VJustify.Bottom, merged.VJustify);
|
||||
}
|
||||
|
|
@ -380,6 +380,54 @@ public class ElementReaderTests
|
|||
return info;
|
||||
}
|
||||
|
||||
private static ElementInfo WithJustification(uint propertyId, uint raw)
|
||||
{
|
||||
ElementInfo info = WithDirectProperty(propertyId, EnumProp(raw));
|
||||
ElementReader.ApplyCanonicalLegacyProjection(info);
|
||||
return info;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Justification_UnauthoredDefaultsMatchRetailConstructors()
|
||||
{
|
||||
var info = new ElementInfo();
|
||||
|
||||
Assert.Equal(HJustify.Left, info.HJustify);
|
||||
Assert.Equal(VJustify.Top, info.VJustify);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0u, HJustify.Left)]
|
||||
[InlineData(1u, HJustify.Center)]
|
||||
[InlineData(2u, HJustify.Left)]
|
||||
[InlineData(3u, HJustify.Right)]
|
||||
[InlineData(4u, HJustify.Left)]
|
||||
[InlineData(5u, HJustify.Right)]
|
||||
public void HorizontalJustification_AllRetailRawValues(
|
||||
uint raw,
|
||||
HJustify expected)
|
||||
{
|
||||
ElementInfo info = WithJustification(0x14u, raw);
|
||||
|
||||
Assert.Equal(expected, info.HJustify);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0u, VJustify.Top)]
|
||||
[InlineData(1u, VJustify.Center)]
|
||||
[InlineData(2u, VJustify.Top)]
|
||||
[InlineData(3u, VJustify.Bottom)]
|
||||
[InlineData(4u, VJustify.Top)]
|
||||
[InlineData(5u, VJustify.Bottom)]
|
||||
public void VerticalJustification_AllRetailRawValues(
|
||||
uint raw,
|
||||
VJustify expected)
|
||||
{
|
||||
ElementInfo info = WithJustification(0x15u, raw);
|
||||
|
||||
Assert.Equal(expected, info.VJustify);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadTabTable_DecodesButtonPageDefaultInAuthoredOrder()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,106 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using AcDream.App.UI;
|
||||
using AcDream.App.UI.Layout;
|
||||
using AcDream.Content;
|
||||
using DatReaderWriter;
|
||||
using DatReaderWriter.DBObjs;
|
||||
using DatReaderWriter.Options;
|
||||
|
||||
namespace AcDream.App.Tests.UI.Layout;
|
||||
|
||||
/// <summary>
|
||||
/// #408 client-wide blast-radius gate for DAT property 0x3B (Invisible).
|
||||
/// Retail applies the property in UIElement::OnSetAttribute for every imported
|
||||
/// element. Enumerate every installed LayoutDesc, then prove every corresponding
|
||||
/// widget which survives importer child-consumption starts hidden.
|
||||
/// </summary>
|
||||
[Trait("Lane", "InstalledDat")]
|
||||
public sealed class LayoutImporterInvisibleSweepTests
|
||||
{
|
||||
private static string DatDirectory =>
|
||||
System.Environment.GetEnvironmentVariable("ACDREAM_DAT_DIR")
|
||||
?? Path.Combine(
|
||||
System.Environment.GetFolderPath(System.Environment.SpecialFolder.UserProfile),
|
||||
"Documents",
|
||||
"Asheron's Call");
|
||||
|
||||
private readonly record struct Finding(uint LayoutId, uint ElementId);
|
||||
|
||||
[InstalledDatFact]
|
||||
public void EveryAuthoredInvisibleWidget_StartsHiddenAcrossAllLayouts()
|
||||
{
|
||||
using var dats = new DatCollection(DatDirectory, DatAccessType.Read);
|
||||
|
||||
var authored = new List<Finding>();
|
||||
var built = new List<Finding>();
|
||||
var incorrectlyVisible = new List<Finding>();
|
||||
|
||||
foreach (uint layoutId in dats.GetAllIdsOfType<LayoutDesc>().OrderBy(static id => id))
|
||||
{
|
||||
ElementInfo? tree = LayoutImporter.ImportInfos(dats, layoutId);
|
||||
if (tree is null) continue;
|
||||
|
||||
CollectAuthored(layoutId, tree, authored);
|
||||
|
||||
ImportedLayout layout = LayoutImporter.Build(
|
||||
tree, _ => (0u, 0, 0), datFont: null, sourceLayoutDid: layoutId);
|
||||
CollectBuilt(layoutId, layout.Root, built, incorrectlyVisible);
|
||||
}
|
||||
|
||||
foreach (IGrouping<uint, Finding> group in authored
|
||||
.GroupBy(static f => f.LayoutId)
|
||||
.OrderBy(static g => g.Key))
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"[INVISIBLE] layout=0x{group.Key:X8} count={group.Count()} ids=["
|
||||
+ string.Join(",", group.Select(static f => $"0x{f.ElementId:X8}"))
|
||||
+ "]");
|
||||
}
|
||||
|
||||
Console.WriteLine(
|
||||
$"[INVISIBLE] authored={authored.Count} layouts="
|
||||
+ $"{authored.Select(static f => f.LayoutId).Distinct().Count()} "
|
||||
+ $"built={built.Count} incorrectlyVisible={incorrectlyVisible.Count}");
|
||||
|
||||
// Keep the global threshold resilient to an installed DAT revision while
|
||||
// pinning landmarks from independent screens in both data and widgets.
|
||||
Assert.True(authored.Count >= 1_000,
|
||||
$"Expected the known client-wide 0x3B population, found {authored.Count}.");
|
||||
Assert.Contains(authored, static f => f.ElementId == 0x10000403u); // chargen GM label
|
||||
Assert.Contains(authored, static f => f.ElementId == 0x10000494u); // chargen envoy label
|
||||
Assert.Contains(authored, static f => f.ElementId == 0x100006A4u); // combat root
|
||||
Assert.Contains(authored, static f => f.ElementId == 0x1000048Cu); // chat new-text indicator
|
||||
|
||||
Assert.Contains(built, static f => f.ElementId == 0x100006A4u);
|
||||
Assert.Contains(built, static f => f.ElementId == 0x1000048Cu);
|
||||
Assert.Empty(incorrectlyVisible);
|
||||
}
|
||||
|
||||
private static void CollectAuthored(uint layoutId, ElementInfo node, List<Finding> findings)
|
||||
{
|
||||
if (node.Invisible)
|
||||
findings.Add(new Finding(layoutId, node.Id));
|
||||
|
||||
foreach (ElementInfo child in node.Children)
|
||||
CollectAuthored(layoutId, child, findings);
|
||||
}
|
||||
|
||||
private static void CollectBuilt(
|
||||
uint layoutId,
|
||||
UiElement node,
|
||||
List<Finding> built,
|
||||
List<Finding> incorrectlyVisible)
|
||||
{
|
||||
if (node.AuthoredInvisible)
|
||||
{
|
||||
var finding = new Finding(layoutId, node.DatElementId);
|
||||
built.Add(finding);
|
||||
if (node.Visible)
|
||||
incorrectlyVisible.Add(finding);
|
||||
}
|
||||
|
||||
foreach (UiElement child in node.Children)
|
||||
CollectBuilt(layoutId, child, built, incorrectlyVisible);
|
||||
}
|
||||
}
|
||||
|
|
@ -363,6 +363,29 @@ public class LayoutImporterTests
|
|||
Assert.Null(found.AuthoredTooltipDelaySeconds);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildWidget_AuthoredInvisible_HidesInitiallyButDoesNotLatchVisibility()
|
||||
{
|
||||
var root = new ElementInfo { Id = 0x1, Type = 3, Width = 100, Height = 40 };
|
||||
var hidden = new ElementInfo
|
||||
{
|
||||
Id = 0x2,
|
||||
Type = 3,
|
||||
Width = 20,
|
||||
Height = 20,
|
||||
Invisible = true,
|
||||
};
|
||||
|
||||
ImportedLayout tree = LayoutImporter.BuildFromInfos(root, [hidden], NoTex, null);
|
||||
UiElement found = tree.FindElement(0x2)!;
|
||||
|
||||
Assert.True(found.AuthoredInvisible);
|
||||
Assert.False(found.Visible);
|
||||
|
||||
found.Visible = true;
|
||||
Assert.True(found.Visible);
|
||||
}
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────
|
||||
|
||||
private static ElementInfo BuildSliceContainer(uint id, uint ReadOrder, uint l, uint t, uint r)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using AcDream.App.UI;
|
||||
using AcDream.App.UI.Layout;
|
||||
using AcDream.Core.Net.Messages;
|
||||
using AcDream.Core.World;
|
||||
using AcDream.Runtime.Gameplay;
|
||||
|
||||
namespace AcDream.App.Tests.UI.Layout;
|
||||
|
||||
|
|
@ -124,7 +126,18 @@ public sealed class MapHousePanelControllerTests
|
|||
/// UiButton hotspots above — a fresh instance per call, matching
|
||||
/// production's real resolver.</summary>
|
||||
private static UiElement? FakeHouseRowTemplate(uint layoutId, uint elementId)
|
||||
=> new UiText { Width = 280f, Height = 28f };
|
||||
=> new UiText
|
||||
{
|
||||
Width = 280f,
|
||||
Height = 28f,
|
||||
DefaultColor = new Vector4(0.1f, 0.1f, 0.1f, 1f),
|
||||
FontColorPalette =
|
||||
[
|
||||
new Vector4(1f, 1f, 1f, 1f),
|
||||
new Vector4(0f, 1f, 0f, 1f),
|
||||
new Vector4(1f, 0f, 0f, 1f),
|
||||
],
|
||||
};
|
||||
|
||||
private static MapHousePanelController.Callbacks MakeCallbacks(
|
||||
List<string>? calls = null,
|
||||
|
|
@ -132,7 +145,8 @@ public sealed class MapHousePanelControllerTests
|
|||
Func<uint>? playerCellId = null,
|
||||
Func<CreateObject.ServerPosition?>? housePosition = null,
|
||||
Func<IReadOnlyList<string>>? houseLines = null,
|
||||
Func<uint, uint, ElementInfo?>? templateInfoResolver = null)
|
||||
Func<uint, uint, ElementInfo?>? templateInfoResolver = null,
|
||||
Func<IReadOnlyList<HousePanelLine>>? housePanelLines = null)
|
||||
{
|
||||
calls ??= new List<string>();
|
||||
return new MapHousePanelController.Callbacks(
|
||||
|
|
@ -147,7 +161,8 @@ public sealed class MapHousePanelControllerTests
|
|||
House: new HousePageController.Bindings(
|
||||
Lines: houseLines ?? (static () => Array.Empty<string>()),
|
||||
OnShown: () => calls.Add("house-shown"),
|
||||
TemplateResolver: FakeHouseRowTemplate));
|
||||
TemplateResolver: FakeHouseRowTemplate,
|
||||
PanelLines: housePanelLines));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -377,4 +392,35 @@ public sealed class MapHousePanelControllerTests
|
|||
"You may buy another house immediately.",
|
||||
Assert.Single(row.LinesProvider()).Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Tick_UsesRetailHousePanelColorAsAuthoredPaletteIndex()
|
||||
{
|
||||
ElementInfo rootInfo = FixtureLoader.LoadMapHouseHostInfos();
|
||||
ImportedLayout layout = FixtureLoader.LoadMapHouseHost();
|
||||
HousePanelLine[] lines =
|
||||
[
|
||||
new("paid", HousePanelTextColor.RentPaid),
|
||||
new("unpaid", HousePanelTextColor.RentNotPaid),
|
||||
];
|
||||
MapHousePanelController? controller = MapHousePanelController.Bind(
|
||||
rootInfo,
|
||||
layout,
|
||||
MakeCallbacks(housePanelLines: () => lines));
|
||||
Assert.NotNull(controller);
|
||||
|
||||
controller!.Tick(0.016);
|
||||
|
||||
var listBox = Assert.IsType<UiTemplateListBox>(
|
||||
UiElement.FindDescendant(controller.Root, HousePageController.TextBoxId));
|
||||
UiScrollablePanel viewport = Assert.IsType<UiScrollablePanel>(
|
||||
listBox.ViewportForTest);
|
||||
Assert.Equal(2, viewport.Children.Count);
|
||||
Assert.Equal(
|
||||
new Vector4(0f, 1f, 0f, 1f),
|
||||
Assert.Single(Assert.IsType<UiText>(viewport.Children[0]).LinesProvider()).Color);
|
||||
Assert.Equal(
|
||||
new Vector4(1f, 0f, 0f, 1f),
|
||||
Assert.Single(Assert.IsType<UiText>(viewport.Children[1]).LinesProvider()).Color);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -313,9 +313,11 @@ public sealed class OptionsPanelLiveMountProbeTests
|
|||
/// LayoutDesc, and <c>Open @0x0046cc30</c> centers the POPUP over the
|
||||
/// button when bool attr 3 is authored. This probe measures all of that
|
||||
/// authored data for the Config option-menu chain (catalog 0x21000043,
|
||||
/// base 0x10000353) with vendor's dropdown (0x1000034F chain — visibly a
|
||||
/// FIXED 6-row + scrollbar popup in retail, user-gated during the vendor
|
||||
/// campaign) as the contrast control.</summary>
|
||||
/// base 0x10000353) and the vendor dropdown's sibling chain
|
||||
/// (0x1000034F). The latter was once treated as a fixed-six-row contrast;
|
||||
/// #386's named-retail trace corrected that reading: it follows the same
|
||||
/// docked size-to-content message route and authors scrollbar property
|
||||
/// 0x79 (hide when disabled).</summary>
|
||||
[Fact]
|
||||
[Trait("Purpose", "Diagnostic")]
|
||||
public void ProbeMenuPopupSizingAndTextStyle()
|
||||
|
|
@ -371,7 +373,7 @@ public sealed class OptionsPanelLiveMountProbeTests
|
|||
Console.WriteLine("[menuprobe3] row template 0x1000035A FAILED to import");
|
||||
}
|
||||
|
||||
Console.WriteLine("[menuprobe3] === CONTROL: vendor chain (fixed 6-row + scrollbar in retail) ===");
|
||||
Console.WriteLine("[menuprobe3] === CONTROL: vendor chain (content-sized; scrollbar 0x79 hides when disabled) ===");
|
||||
DumpDockAndSize(dats, 0x21000043u, 0x1000034Fu, "Vendor popup root");
|
||||
DumpDockAndSize(dats, 0x21000043u, 0x10000350u, "Vendor popup ListBox");
|
||||
ElementInfo? vendorBase = LayoutImporter.ImportInfos(dats, 0x21000043u, 0x1000034Bu);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ public sealed class SpellcastingUiControllerTests
|
|||
ImportedLayout layout = LayoutImporter.Build(
|
||||
FixtureLoader.LoadCombatInfos(), NoTex, datFont: null);
|
||||
RetailCombatLayout.FitFavoriteSlots(layout);
|
||||
// The authored combat root starts Invisible=true. Production's
|
||||
// RetailWindowFrame/CombatUiController show it when combat mode opens
|
||||
// the window; this standalone pointer fixture must model that mount
|
||||
// edge explicitly now that #408 honors the DAT flag client-wide.
|
||||
layout.Root.Visible = true;
|
||||
var spellbook = new Spellbook();
|
||||
spellbook.OnSpellLearned(42u, 1f);
|
||||
spellbook.SetFavorite(0, 0, 42u);
|
||||
|
|
@ -199,6 +204,7 @@ public sealed class SpellcastingUiControllerTests
|
|||
ImportedLayout layout = LayoutImporter.Build(
|
||||
FixtureLoader.LoadCombatInfos(), NoTex, datFont: null);
|
||||
RetailCombatLayout.FitFavoriteSlots(layout);
|
||||
layout.Root.Visible = true;
|
||||
var spellbook = new Spellbook();
|
||||
spellbook.OnSpellLearned(1u, 1f);
|
||||
spellbook.OnSpellLearned(2u, 1f);
|
||||
|
|
@ -468,6 +474,7 @@ public sealed class SpellcastingUiControllerTests
|
|||
ImportedLayout layout = LayoutImporter.Build(
|
||||
FixtureLoader.LoadCombatInfos(), NoTex, datFont: null);
|
||||
RetailCombatLayout.FitFavoriteSlots(layout);
|
||||
layout.Root.Visible = true;
|
||||
var spellbook = new Spellbook();
|
||||
spellbook.OnSpellLearned(1u, 1f);
|
||||
spellbook.OnSpellLearned(2u, 1f);
|
||||
|
|
|
|||
|
|
@ -247,13 +247,12 @@ public class UiDatElementTests
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// The state-0 fallback must NOT honor a base-DirectState Invisible
|
||||
/// (dat 0x3B) — that is the #408 construction-time class, gated
|
||||
/// separately; retail's per-state Invisible honor applies to NAMED
|
||||
/// authored states only.
|
||||
/// #408: retail's unauthored-state fallback commits state 0 and applies
|
||||
/// its properties, including Invisible, through the same OnSetAttribute
|
||||
/// path as a named state.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TrySetRetailState_UnauthoredStateFallback_DoesNotHonorBaseInvisible()
|
||||
public void TrySetRetailState_UnauthoredStateFallback_RestoresBaseInvisible()
|
||||
{
|
||||
var info = new ElementInfo();
|
||||
var baseState = new UiStateInfo { Id = UiStateInfo.DirectStateId };
|
||||
|
|
@ -265,12 +264,12 @@ public class UiDatElementTests
|
|||
info.States[UiStateInfo.DirectStateId] = baseState;
|
||||
info.StateMedia["Normal_rollover"] = (0x06005EB6u, 1);
|
||||
var element = new UiDatElement(info, _ => (0u, 0, 0));
|
||||
Assert.True(element.Visible);
|
||||
element.Visible = true;
|
||||
|
||||
Assert.True(element.TrySetRetailState(UiButtonStateMachine.Normal));
|
||||
|
||||
Assert.Equal("", element.ActiveState);
|
||||
Assert.True(element.Visible);
|
||||
Assert.False(element.Visible);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1005,6 +1005,10 @@ public sealed class VendorUiControllerTests
|
|||
Assert.Equal(6, h.TypeMenu.RowsPerColumn);
|
||||
Assert.Equal(18f, h.TypeMenu.RowHeight);
|
||||
Assert.Equal(100f, h.TypeMenu.ColumnWidth);
|
||||
Assert.True(h.TypeMenu.PopupSizeToContent);
|
||||
Assert.True(h.TypeMenu.PopupScrollbarHideWhenDisabled);
|
||||
Assert.Equal(2 * h.TypeMenu.RowHeight + 2 * 5f, h.TypeMenu.PopupOuterHeight);
|
||||
Assert.Equal(h.TypeMenu.ColumnWidth + 2 * 5f, h.TypeMenu.PopupOuterWidth);
|
||||
|
||||
// Open via the real widget event path.
|
||||
Assert.True(h.TypeMenu.OnEvent(new UiEvent(0, h.TypeMenu, UiEventType.MouseDown, 0, 10, 5)));
|
||||
|
|
@ -1054,7 +1058,7 @@ public sealed class VendorUiControllerTests
|
|||
// where nothing lives; UiMenu treats it as an ordinary button click
|
||||
// and just re-closes the still-open menu instead of picking a row.
|
||||
const int border = 5;
|
||||
float outerH = h.TypeMenu.RowsPerColumn * h.TypeMenu.RowHeight + 2 * border;
|
||||
float outerH = h.TypeMenu.PopupOuterHeight;
|
||||
const int targetRow = 1;
|
||||
float iy = targetRow * h.TypeMenu.RowHeight + h.TypeMenu.RowHeight / 2f;
|
||||
float oldUpwardLy = iy - outerH + border;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue