Lands the codex-worktree D.2b stream plus the extraction the 2026-07-02 UI architecture review mandated before commit: - ItemInteractionController: single owner of double-click use/equip/ container-open, targeted-use mode (health kits), drag-out drop; toolbar shortcut drags don't drop the real item. ItemEquipRules for multi-slot (coat) coverage via equip masks. - Cursor phase: CursorFeedbackController (semantic priority chain: drag > resize > window-move > target-mode > text) + RetailCursorCatalog (enums 0x27/0x28/0x29, hotspot 14,14; ClientUISystem::UpdateCursorState 0x00564630) resolved through the portal EnumIDMap chain by RetailCursorResolver; RetailCursorManager applies dat cursor art to the OS cursor. Register row AP-72 covers the OS standard-cursor fallback. - Character window goes live: CharacterSheetProvider owns sheet assembly, XP-curve/raise-cost math and the raise flow — extracted out of GameWindow per Code Structure Rule 1 instead of committing the ~430-line feature body there. Optimistic XP/credit debits go through eventful store APIs (new ClientObjectTable.UpdateInt64Property + LocalPlayerState.DebitIntProperty/DebitInt64Property) instead of raw property-dictionary writes; register row AP-73 covers the still-missing raise ledger (#163). - RetailWindowFrame: the shared nine-slice window mount recipe; the character window uses it, remaining windows migrate via #164. - Status-bar buttons toggle inventory/character windows; retail row-major backpack ordering; WorldSession.SendUseWithTarget + raise/train sends. GameWindow shrinks 14,214 -> 13,877 lines despite the new features; the sheet/raise logic is unit-tested in CharacterSheetProviderTests instead of trapped in the god object. Build green; full suite 3,286 tests pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
109 lines
3.6 KiB
C#
109 lines
3.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using AcDream.App.Studio;
|
|
using AcDream.App.UI;
|
|
using AcDream.App.UI.Layout;
|
|
using DatReaderWriter;
|
|
using DatReaderWriter.Options;
|
|
using Xunit;
|
|
|
|
namespace AcDream.App.Tests.UI.Layout;
|
|
|
|
public sealed class CharacterLayoutImportProbe
|
|
{
|
|
private const uint CharacterLayout = 0x2100002Eu;
|
|
|
|
private static string? DatDir()
|
|
{
|
|
var d = Environment.GetEnvironmentVariable("ACDREAM_DAT_DIR")
|
|
?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
|
|
"Documents", "Asheron's Call");
|
|
return Directory.Exists(d) ? d : null;
|
|
}
|
|
|
|
[Fact]
|
|
public void Selected_attribute_shows_raise_buttons_on_visible_footer_state()
|
|
{
|
|
var datDir = DatDir();
|
|
if (datDir is null) return;
|
|
|
|
using var dats = new DatCollection(datDir, DatAccessType.Read);
|
|
var layout = LayoutImporter.Import(dats, CharacterLayout, _ => (1u, 30, 26), null);
|
|
Assert.NotNull(layout);
|
|
|
|
CharacterStatController.Bind(layout!, SampleData.SampleCharacter, spriteResolve: _ => (1u, 30, 26));
|
|
|
|
var rows = new List<UiClickablePanel>();
|
|
CollectRows(layout!.Root, rows);
|
|
Assert.True(rows.Count >= 9, $"expected at least 9 attribute rows, found {rows.Count}");
|
|
|
|
rows[4].OnClick!();
|
|
|
|
var buttons = new List<UiButton>();
|
|
CollectButtons(layout.Root, buttons);
|
|
|
|
Assert.Contains(buttons, b =>
|
|
b.ElementId == CharacterStatController.RaiseOneId
|
|
&& b.ActiveState == "Normal"
|
|
&& IsEffectivelyVisible(b));
|
|
Assert.Contains(buttons, b =>
|
|
b.ElementId == CharacterStatController.RaiseTenId
|
|
&& b.ActiveState == "Normal"
|
|
&& IsEffectivelyVisible(b));
|
|
}
|
|
|
|
[Fact]
|
|
public void Close_button_resolves_and_invokes_controller_close_callback()
|
|
{
|
|
var datDir = DatDir();
|
|
if (datDir is null) return;
|
|
|
|
using var dats = new DatCollection(datDir, DatAccessType.Read);
|
|
var layout = LayoutImporter.Import(dats, CharacterLayout, _ => (1u, 30, 26), null);
|
|
Assert.NotNull(layout);
|
|
|
|
var close = layout!.FindElement(WindowChromeController.CharacterCloseButtonId);
|
|
Assert.NotNull(close);
|
|
Assert.True(close is UiButton or UiDatElement,
|
|
$"character close button resolved to {close?.GetType().Name ?? "null"}");
|
|
|
|
int closes = 0;
|
|
CharacterStatController.Bind(layout, SampleData.SampleCharacter, onClose: () => closes++);
|
|
close!.OnEvent(new UiEvent(0u, close, UiEventType.Click));
|
|
|
|
Assert.Equal(1, closes);
|
|
}
|
|
|
|
private static void CollectRows(UiElement node, List<UiClickablePanel> result)
|
|
{
|
|
if (node is UiClickablePanel row && row.Height is >= 20f and <= 22f && row.OnClick is not null)
|
|
result.Add(row);
|
|
foreach (var child in node.Children)
|
|
CollectRows(child, result);
|
|
}
|
|
|
|
private static void CollectButtons(UiElement node, List<UiButton> result)
|
|
{
|
|
if (node is UiButton button
|
|
&& (button.ElementId == CharacterStatController.RaiseOneId
|
|
|| button.ElementId == CharacterStatController.RaiseTenId))
|
|
{
|
|
result.Add(button);
|
|
}
|
|
|
|
foreach (var child in node.Children)
|
|
CollectButtons(child, result);
|
|
}
|
|
|
|
private static bool IsEffectivelyVisible(UiElement element)
|
|
{
|
|
for (UiElement? e = element; e is not null; e = e.Parent)
|
|
{
|
|
if (!e.Visible) return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
}
|