diff --git a/docs/architecture/retail-divergence-register.md b/docs/architecture/retail-divergence-register.md index dfc23777..673627da 100644 --- a/docs/architecture/retail-divergence-register.md +++ b/docs/architecture/retail-divergence-register.md @@ -58,7 +58,7 @@ accepted-divergence entries (#96, #49, #50). | IA-17 | Toolbar chrome is toolkit-supplied through the central `RetailWindowFrame` mount (`UiCollapsibleFrame` 8-piece bevel) because LayoutDesc `0x21000016` carries no baked frame. It also supports a toolkit-defined collapse-to-one-row (bottom-edge resize snapping between a row-1-only and a two-row height, row-2 visibility tied to the stop) — retail's real collapse is keystone.dll (no decomp) and the DAT stacks both rows always. | `src/AcDream.App/UI/Layout/RetailWindowFrame.cs`; `src/AcDream.App/UI/UiCollapsibleFrame.cs`; toolbar policy in `GameWindow.cs`; spec: `docs/superpowers/specs/2026-06-20-d2b-toolbar-collapse-design.md` | The central mount now owns wrapper geometry/registration uniformly; border-over-content prevents the row-2 right cap from poking through | The collapse stops remain a toolkit reconstruction rather than a byte-port of Keystone behavior | gmToolbarUI WM chrome (keystone.dll, no PDB); no bevel ids in LayoutDesc 0x21000016 (toolbar dump) | | IA-18 | Effect overlay tile (enum 0x10000005) is a `ReplaceColor` SURFACE SOURCE — pure-white pixels in the composited drag icon are replaced PER-PIXEL with the same (x,y) pixel of the effect tile (the SURFACE overload `SurfaceWindow::ReplaceColor` 0x004415b0), preserving the tile's texture/gradient; the tile itself is NOT blitted as an additional layer. This IS faithful retail behavior. **Anti-regression: do NOT re-implement this as a blit layer NOR as a flat-color replace (it is a per-pixel surface copy).** | `src/AcDream.App/UI/IconComposer.cs` (`ReplaceWhiteFromSurface`) | Faithful port of `IconData::RenderIcons` @407614 → the SURFACE overload `ReplaceColor` 0x004415b0 (`dst[x,y]=src[x,y]` where `dst==white`); confirmed via clean Ghidra decompile + named decomp + visual (the Energy Crystal's blue is a gradient, 2026-06-17). | A blit-layer or flat-color re-implementation would show the wrong effect look (no gradient) — the visual-verification regression that retired the mean-color approximation | `IconData::RenderIcons` acclient_2013_pseudo_c.txt:407524; `ReplaceColor` SURFACE overload 0x004415b0:71656; `docs/research/2026-06-17-stateful-icon-RESOLVED.md` | | IA-19 | Automatic combat acquisition is narrowed to attackable non-player monsters. Retail `AutoTarget` falls back to `SelectNext(SELECTION_TYPE_COMPASS_ITEM)`, whose combat filter can also admit attackable enemy players in compatible PK states. | `src/AcDream.Core/Combat/CombatTargetPolicy.cs`; consumer `src/AcDream.App/Rendering/GameWindow.cs` | Explicit product direction: Auto Target must never select NPCs, players, pets, or other objects; manual player-selection commands remain available | In PK play, Auto Target will not acquire an otherwise valid hostile player as retail would; the player must be selected manually | `ClientCombatSystem::AutoTarget @ 0x0056BC80`; `CPlayerSystem::SelectNext @ 0x0055F9A0`; `ClientCombatSystem::ObjectIsAttackable @ 0x0056A600` | -| IA-20 | The basic combat bar keeps dark-red media `0x0600715E` visible as the middle baseline between Speed and Power. Retail owns that media as field `0x100005EF` and toggles it with trained Recklessness during the scalar-message path. | `src/AcDream.App/UI/UiScrollbar.cs`; binding geometry in `src/AcDream.App/UI/Layout/CombatUiController.cs` | Explicit connected visual direction: the dark middle track must remain present behind the live bright-red charge fill; the exact skill-gated presentation remains tracked by AP-112 | Untrained characters see the dark-red baseline where retail may leave only the gray track; trained/untrained Recklessness presentation is not distinguishable | `gmCombatUI::PostInit @ 0x004CC1A0`; `gmCombatUI::ListenToElementMessage @ 0x004CC430`; LayoutDesc `0x21000073` child `0x100005EF` | +| IA-20 | The basic combat bar keeps dark-red media `0x0600715E` visible as the centered middle baseline and renders bright `0x06001200` from the absolute left edge to the desired-power thumb. Retail skill-gates field `0x100005EF` to trained Recklessness and drives meter child `0x10000050` from live `SetPowerbarLevel` notices independently of the thumb. | `src/AcDream.App/UI/UiScrollbar.cs`; binding geometry in `src/AcDream.App/UI/Layout/CombatUiController.cs` | Explicit connected visual direction: dark must remain centered between Speed/Power and bright must visualize the selected delay from the bar's left edge to the green slider; the exact skill-gated treatment remains tracked by AP-112 | Untrained characters retain the dark baseline and the bar shows desired power rather than retail's transient live charge level | `gmCombatUI::RecvNotice_SetPowerbarLevel @ 0x004CC0E0`; `RecvNotice_DesiredAttackPowerChanged @ 0x004CC110`; `gmCombatUI::ListenToElementMessage @ 0x004CC430`; LayoutDesc `0x21000073` | --- diff --git a/docs/plans/2026-04-11-roadmap.md b/docs/plans/2026-04-11-roadmap.md index b655d677..afe745e8 100644 --- a/docs/plans/2026-04-11-roadmap.md +++ b/docs/plans/2026-04-11-roadmap.md @@ -497,7 +497,7 @@ behavior. Estimated 17–26 days focused work, 3–5 weeks calendar. - **Wave 4.4e implemented — exact missile ammo number (live gate pending).** Pure Core reproduces retail's thrown-weapon-vs-separate-ammo resolution over the ordered player equipment list and its zero-to-one count normalization. Relevant equipment/stack events update authored missile indicator `0x10000194` with the DAT font. Warning-free Release build and 4,754-pass / 5-skip suite are green; AP-101 is retired. - **M2 held-object parenting shipped and live-gated 2026-07-11.** The combat toggle now ports `GetDefaultCombatMode` over ordered equipped contents, so a bow requests Missile instead of the old hardcoded Melee. CreateObject preserves parent/placement/timestamp fields, `0xF749` ParentEvent is handled, and `EquippedChildRenderController` renders the weapon as a separate child composed from the animated hand part + holding frame + child placement frame. Live gate passed: bow selected missile stance, rendered in-hand, followed animation, unequipped cleanly, and melee remained correct. App Release builds with zero warnings; the full 4,765-pass / 5-skip suite is green. AP-111 is retired; research: `docs/research/2026-07-11-combat-default-and-parent-event-pseudocode.md`. - **M2 local attack receive funnel implemented 2026-07-11; live gate pending.** Retail `ExecuteAttack` only sends the request; ACE chooses the concrete melee/missile action and returns it in a non-autonomous mt-0 `UpdateMotion`. The local branch now runs that state through the same constructor-defaulted `MoveToInterpretedState` funnel and 15-bit action-stamp gate as remotes, then applies sticky/long-jump tails. The old local-only direct `Commands[]` replay is deleted. Shared conversion lives in `InboundInterpretedMotionFactory`; research: `docs/research/2026-07-11-local-combat-motion-pseudocode.md`. -- **M2 basic retail combat bar implemented 2026-07-11; corrective live visual gate pending.** Production mounts authored `gmCombatUI` LayoutDesc `0x21000073`, shows it only for Melee/Missile, and routes mouse plus keyboard through one `CombatAttackController`. Corrections include the centered dark-red baseline (accepted IA-20), left-to-right live bright-red charge fill from Speed, exact Speed-left/Power-right justification, silent control-only `AttackDone(ActionCancelled)`, target-frame Keep in View with manual orbit, and persistent corpse motion: the AP-80 velocity-only NPC adaptation can now replace only Ready/Walk/Run, never authoritative Dead/actions. `CombatTargetController` ports the selection-cleared AutoTarget consumer, so a selected creature's authoritative Dead motion clears it and selects the nearest eligible creature when enabled. The 2026-07-12 replacement-corpse correction unifies both multi-frame and static/reactive spawns behind retail's CreateObject lifecycle: apply the wire's Dead state while detached, then `MotionTableManager::HandleEnterWorld` strips Ready→Dead links before the first in-world tick; multiple corpses remaining fallen passed the live user gate that day. Follow-up #205 makes the toolbar read the final canonical selection after a reentrant Auto Target notice and restricts automatic candidates to hostile non-player monsters (intentional PK-edge divergence IA-19); that live gate also passed 2026-07-12. Research: `docs/research/2026-07-11-retail-combat-bar-pseudocode.md`, `docs/research/2026-07-11-combat-target-camera-pseudocode.md`, `docs/research/2026-07-12-death-and-auto-target-pseudocode.md`; AP-24/AP-95 retired, AP-80 narrowed, AP-110 narrowed, AP-112 records the remaining attack-start and exact trained-Recklessness seams. +- **M2 basic retail combat bar implemented 2026-07-11; corrective live visual gate pending.** Production mounts authored `gmCombatUI` LayoutDesc `0x21000073`, shows it only for Melee/Missile, and routes mouse plus keyboard through one `CombatAttackController`. Corrections include the post-reflow centered dark-red baseline plus absolute-left-to-thumb bright desired-power band (accepted IA-20), exact Speed-left/Power-right justification, silent control-only `AttackDone(ActionCancelled)`, target-frame Keep in View with manual orbit, and persistent corpse motion: the AP-80 velocity-only NPC adaptation can now replace only Ready/Walk/Run, never authoritative Dead/actions. `CombatTargetController` ports the selection-cleared AutoTarget consumer, so a selected creature's authoritative Dead motion clears it and selects the nearest eligible creature when enabled. The 2026-07-12 replacement-corpse correction unifies both multi-frame and static/reactive spawns behind retail's CreateObject lifecycle: apply the wire's Dead state while detached, then `MotionTableManager::HandleEnterWorld` strips Ready→Dead links before the first in-world tick; multiple corpses remaining fallen passed the live user gate that day. Follow-up #205 makes the toolbar read the final canonical selection after a reentrant Auto Target notice and restricts automatic candidates to hostile non-player monsters (intentional PK-edge divergence IA-19); that live gate also passed 2026-07-12. Research: `docs/research/2026-07-11-retail-combat-bar-pseudocode.md`, `docs/research/2026-07-11-combat-target-camera-pseudocode.md`, `docs/research/2026-07-12-death-and-auto-target-pseudocode.md`; AP-24/AP-95 retired, AP-80 narrowed, AP-110 narrowed, AP-112 records the remaining attack-start and exact trained-Recklessness seams. - **✓ SHIPPED — Character window** (`LayoutDesc 0x2100002E`, `CharacterStatController`, 2026-06-26, same branch). **Visually user-confirmed 2026-06-26 — Attributes tab reads as retail.** Three tabs, header (name/heritage/PK), large-gold level number (dat font, `largeDatFont` 18px), "Total Experience (XP):" + "XP for next level:" captions, 9-row attribute list (icons + right-aligned values + Health/Stamina/Mana vitals), click-to-select (top/bottom selection bars + footer State-B "{Attr}: {value}" / "Experience To Raise: Infinity!" + affordability-gated raise triangles), centered footer. User noted "still needs some polish for later" — deferred to Issue #158. - **✓ SHIPPED — D.5.4 — Client object/item data model (foundation).** Shipped 2026-06-18 (`b506f53`..`a33e897`, 11 commits). Renamed `ItemRepository`→`ClientObjectTable` / `ItemInstance`→`ClientObject`; broadened the table to hold EVERY server object (retail `weenie_object_table` shape). `CreateObject` is now the canonical merge-upsert (`ClientObjectTable.Ingest`, retail `SetWeenieDesc` semantics) via a new Core.Net `ObjectTableWiring` (off GameWindow); `DeleteObject` evicts; `PlayerDescription` is a membership manifest (`RecordMembership`); live container-membership index (`GetContents`, retail `object_inventory_table`). `_liveEntityInfoByGuid` retired (selection/describe resolve from the one table). Root fix: the old enrich-existing-only `EnrichItem` dropped `CreateObject`s for items with no `PlayerDescription` stub — live-Coldeve 4/6 hotbar slots blank; items are now created, not dropped. **Crux resolved:** retail is TWO tables (`object_table` + `weenie_object_table`), NOT one — acdream's `WorldEntity` (3D system) + `ClientObjectTable` (data/UI) split was already architecturally faithful; the fix was the ingestion path, not a table unification. 2671 tests green. - **Roadmap correction (2026-07-10):** the completion order is now the architecture-first campaign in `docs/superpowers/plans/2026-07-10-retail-ui-fidelity-completion.md`. Retail `gmToolbarUI` is object-only: preserve `ShortCutData.index_`, `objectID_`, and `spellID_`, but do not invent spell glyphs on this bar. `PlayerModule::favorite_spells_[8]` feeds separate spell bars. diff --git a/docs/research/2026-07-11-retail-combat-bar-pseudocode.md b/docs/research/2026-07-11-retail-combat-bar-pseudocode.md index c59791e8..4bd9dde2 100644 --- a/docs/research/2026-07-11-retail-combat-bar-pseudocode.md +++ b/docs/research/2026-07-11-retail-combat-bar-pseudocode.md @@ -185,10 +185,11 @@ The three visual layers remain separate. The gray scrollbar track spans the whole authored control. Retail skill-gates element `0x100005EF` to Recklessness advancement class `Trained` or higher when scalar message `0x0A` is received. Per the connected visual gate, acdream uses that dark-red media as the always- -visible middle baseline (intentional divergence IA-20); the remaining exact -skill-gated treatment stays in AP-112. The meter fill is driven independently -by `RecvNotice_SetPowerbarLevel`, while the green thumb is driven by -`RecvNotice_DesiredAttackPowerChanged`. +visible middle baseline and renders the bright texture as a desired-power band +from the absolute left edge to the green thumb (intentional divergence IA-20); +the remaining exact skill-gated treatment stays in AP-112. Retail instead drives +the meter child independently through `RecvNotice_SetPowerbarLevel`, while the +green thumb is driven by `RecvNotice_DesiredAttackPowerChanged`. The meter authors attribute `0x6F = 1`. `UIElement_Meter` constructor and `DrawChildren @ 0x0046FBD0` make direction 1 the forward horizontal clip, so @@ -202,3 +203,12 @@ behind both captions. Speed's raw property `0x14` value is `2`, which is left justification: `UIElement_Text::CalcJustification @ 0x00467260` centers only value `1`, right-aligns values `3` and `5`, and treats every other value as left. Power uses right justification. + +The combat subtree inherits from an 800-pixel prototype and reflows into its +610-pixel mounted root on the first layout traversal. Therefore the controller +must not snapshot sibling positions during `Bind`: before reflow the bar is +`x=8,w=707` and Power is `x=611`; after retail anchoring they are `x=8,w=507` +and `x=411`. `ScalarRangeProvider` reads the live sibling rectangles during +drawing, producing the centered local interval `x=104,w=299`. Freezing the +pre-reflow width clamps that range to the bar's right edge and visibly shifts +the dark texture toward Power. diff --git a/src/AcDream.App/UI/Layout/CombatUiController.cs b/src/AcDream.App/UI/Layout/CombatUiController.cs index e5ab72aa..2f5fbfa5 100644 --- a/src/AcDream.App/UI/Layout/CombatUiController.cs +++ b/src/AcDream.App/UI/Layout/CombatUiController.cs @@ -93,7 +93,8 @@ public sealed class CombatUiController : IRetainedPanelController _powerControl.SetScalarPosition(_attacks.DesiredPower); _powerControl.ScalarChanged = _attacks.SetDesiredPower; - _powerControl.ScalarFill = () => _attacks.PowerBarLevel; + _powerControl.ScalarFill = () => null; + _powerControl.ScalarFillFollowsThumb = true; BindAttackButton(_high, AttackHeight.High); BindAttackButton(_medium, AttackHeight.Medium); @@ -201,12 +202,14 @@ public sealed class CombatUiController : IRetainedPanelController // the meter between the authored text rectangles leaves the base gray // track behind Speed/Power while the dark/live red textures occupy the // semantic power range between them. - float left = speedLabel.Left + speedLabel.Width - _powerControl.Left; - float right = powerLabel.Left - _powerControl.Left; - _powerControl.ScalarRangeLeft = Math.Clamp(left, 0f, _powerControl.Width); - _powerControl.ScalarRangeWidth = Math.Max( - 0f, Math.Clamp(right, 0f, _powerControl.Width) - - _powerControl.ScalarRangeLeft); + _powerControl.ScalarRangeProvider = () => + { + float left = speedLabel.Left + speedLabel.Width - _powerControl.Left; + float right = powerLabel.Left - _powerControl.Left; + float clampedLeft = Math.Clamp(left, 0f, _powerControl.Width); + return (clampedLeft, Math.Max( + 0f, Math.Clamp(right, 0f, _powerControl.Width) - clampedLeft)); + }; } private static void SetStaticText(UiText? text, string value, bool rightAligned) @@ -233,6 +236,8 @@ public sealed class CombatUiController : IRetainedPanelController _attacks.StateChanged -= OnAttackStateChanged; _powerControl.ScalarChanged = null; _powerControl.ScalarFill = () => null; + _powerControl.ScalarFillFollowsThumb = false; + _powerControl.ScalarRangeProvider = null; _high.OnPressed = null; _high.OnReleased = null; _medium.OnPressed = null; diff --git a/src/AcDream.App/UI/UiScrollbar.cs b/src/AcDream.App/UI/UiScrollbar.cs index 0a082f39..c91e8738 100644 --- a/src/AcDream.App/UI/UiScrollbar.cs +++ b/src/AcDream.App/UI/UiScrollbar.cs @@ -49,6 +49,14 @@ public sealed class UiScrollbar : UiElement public float ScalarRangeLeft { get; set; } public float ScalarRangeWidth { get; set; } = float.PositiveInfinity; /// + /// Optional live range geometry. Imported sibling controls reflow immediately + /// before drawing, so combat derives its centered range from their current + /// rectangles instead of freezing pre-reflow prototype coordinates. + /// + public Func<(float Left, float Width)>? ScalarRangeProvider { get; set; } + /// Draw the scalar fill from the absolute left edge to the thumb center. + public bool ScalarFillFollowsThumb { get; set; } + /// /// Draw the scalar meter from the power end (right) toward the speed end /// (left). This is the authored gmCombatUI power meter direction. /// @@ -141,14 +149,21 @@ public sealed class UiScrollbar : UiElement if (ScalarRangeSprite != 0) DrawTiled(ctx, resolve, ScalarRangeSprite, rangeLeft, 0f, rangeWidth, Height); - if (ScalarFill() is float fill && ScalarFillSprite != 0) + float thumbWidth = ScalarThumbWidth(resolve); + if (ScalarFillSprite != 0 && ScalarFillFollowsThumb) + { + var (fillX, visibleWidth) = ScalarThumbFillRect( + Width, thumbWidth, ScalarPosition); + DrawTiledClipped(ctx, resolve, ScalarFillSprite, + 0f, fillX, visibleWidth, Height); + } + else if (ScalarFill() is float fill && ScalarFillSprite != 0) { var (fillX, visibleWidth) = ScalarFillRect( rangeLeft, rangeWidth, fill, ScalarFillFromRight); DrawTiledClipped(ctx, resolve, ScalarFillSprite, rangeLeft, fillX, visibleWidth, Height); } - float thumbWidth = ScalarThumbWidth(resolve); float travel = MathF.Max(0f, Width - thumbWidth); float x = travel * ScalarPosition; DrawSprite(ctx, resolve, ThumbSprite, x, 0f, thumbWidth, Height); @@ -233,14 +248,27 @@ public sealed class UiScrollbar : UiElement private (float left, float width) ScalarRangeRect() { - float left = Math.Clamp(ScalarRangeLeft, 0f, Width); - float requestedWidth = float.IsPositiveInfinity(ScalarRangeWidth) + (float configuredLeft, float configuredWidth) = ScalarRangeProvider?.Invoke() + ?? (ScalarRangeLeft, ScalarRangeWidth); + float left = Math.Clamp(configuredLeft, 0f, Width); + float requestedWidth = float.IsPositiveInfinity(configuredWidth) ? Width - left - : MathF.Max(0f, ScalarRangeWidth); + : MathF.Max(0f, configuredWidth); float width = Math.Clamp(requestedWidth, 0f, Width - left); return (left, width); } + /// Returns the absolute-left fill ending at the scalar thumb center. + public static (float x, float width) ScalarThumbFillRect( + float totalWidth, float thumbWidth, float position) + { + float safeWidth = MathF.Max(0f, totalWidth); + float safeThumb = Math.Clamp(thumbWidth, 0f, safeWidth); + float travel = safeWidth - safeThumb; + float center = travel * Math.Clamp(position, 0f, 1f) + safeThumb * 0.5f; + return (0f, center); + } + public override bool OnEvent(in UiEvent e) { if (Horizontal && ScalarChanged is not null) diff --git a/tests/AcDream.App.Tests/UI/Layout/CombatLayoutConformanceTests.cs b/tests/AcDream.App.Tests/UI/Layout/CombatLayoutConformanceTests.cs index 4f4d913c..697658be 100644 --- a/tests/AcDream.App.Tests/UI/Layout/CombatLayoutConformanceTests.cs +++ b/tests/AcDream.App.Tests/UI/Layout/CombatLayoutConformanceTests.cs @@ -21,6 +21,7 @@ public sealed class CombatLayoutConformanceTests _ => (0u, 0, 0), datFont: null, stringResolve: _ => "localized"); + ApplyAnchors(layout.Root); var power = Assert.IsType( layout.FindElement(CombatUiController.PowerControlId)); @@ -30,6 +31,15 @@ public sealed class CombatLayoutConformanceTests Assert.Equal(0x0600715Eu, power.ScalarRangeSprite); Assert.False(power.ScalarFillFromRight); + var speed = Assert.IsType( + layout.FindElement(CombatUiController.SpeedLabelId)); + var powerLabel = Assert.IsType( + layout.FindElement(CombatUiController.PowerLabelId)); + Assert.Equal( + (8f, 507f, 12f, 100f, 411f, 100f), + (power.Left, power.Width, speed.Left, speed.Width, + powerLabel.Left, powerLabel.Width)); + var repeat = Assert.IsType( layout.FindElement(CombatUiController.RepeatAttacksId)); Assert.Equal(13f, repeat.FaceWidth); @@ -42,4 +52,13 @@ public sealed class CombatLayoutConformanceTests Assert.Equal("localized", high.Label); Assert.IsType(layout.FindElement(CombatUiController.SpeedLabelId)); } + + private static void ApplyAnchors(UiElement parent) + { + foreach (UiElement child in parent.Children) + { + child.ApplyAnchor(parent.Width, parent.Height); + ApplyAnchors(child); + } + } } diff --git a/tests/AcDream.App.Tests/UI/Layout/CombatUiControllerTests.cs b/tests/AcDream.App.Tests/UI/Layout/CombatUiControllerTests.cs index 311d3bb5..0a68748d 100644 --- a/tests/AcDream.App.Tests/UI/Layout/CombatUiControllerTests.cs +++ b/tests/AcDream.App.Tests/UI/Layout/CombatUiControllerTests.cs @@ -50,9 +50,9 @@ public sealed class CombatUiControllerTests high.OnEvent(new UiEvent(0, high, UiEventType.MouseDown, Data1: 2, Data2: 2)); now = 4.5d; - Assert.Equal(0.5f, power.ScalarFill()!.Value, 3); - Assert.Equal(104f, power.ScalarRangeLeft, 3); - Assert.Equal(299f, power.ScalarRangeWidth, 3); + Assert.True(power.ScalarFillFollowsThumb); + var range = Assert.IsType>(power.ScalarRangeProvider); + Assert.Equal((104f, 299f), range()); high.OnEvent(new UiEvent(0, high, UiEventType.MouseUp, Data1: 2, Data2: 2)); var attack = Assert.Single(sent); @@ -98,9 +98,30 @@ public sealed class CombatUiControllerTests Assert.False(speed.RightAligned); Assert.False(powerLabel.Centered); Assert.True(powerLabel.RightAligned); - Assert.Equal(speed.Left + speed.Width - power.Left, power.ScalarRangeLeft, 3); - Assert.Equal(powerLabel.Left - power.Left - power.ScalarRangeLeft, - power.ScalarRangeWidth, 3); + var range = Assert.IsType>(power.ScalarRangeProvider); + var (left, width) = range(); + Assert.Equal(speed.Left + speed.Width - power.Left, left, 3); + Assert.Equal(powerLabel.Left - power.Left - left, width, 3); + } + + [Fact] + public void ImportedFixture_ReflowUpdatesCenteredDarkRange() + { + ElementInfo info = FixtureLoader.LoadCombatInfos(); + ImportedLayout layout = LayoutImporter.Build(info, NoTex, datFont: null); + var combat = new CombatState(); + using var attacks = CreateAttacks(combat, () => 0d, []); + GameplaySettings gameplay = GameplaySettings.Default; + using var controller = CombatUiController.Bind( + layout, combat, attacks, () => gameplay, value => gameplay = value, + Labels, _ => { })!; + + ApplyAnchors(layout.Root); + + var power = Assert.IsType( + layout.FindElement(CombatUiController.PowerControlId)); + var range = Assert.IsType>(power.ScalarRangeProvider); + Assert.Equal((104f, 299f), range()); } private static readonly CombatUiLabels Labels = new( @@ -181,4 +202,13 @@ public sealed class CombatUiControllerTests }; return (new ImportedLayout(root, byId), basic, advanced, power, high, medium, low); } + + private static void ApplyAnchors(UiElement parent) + { + foreach (UiElement child in parent.Children) + { + child.ApplyAnchor(parent.Width, parent.Height); + ApplyAnchors(child); + } + } } diff --git a/tests/AcDream.App.Tests/UI/UiScrollbarTests.cs b/tests/AcDream.App.Tests/UI/UiScrollbarTests.cs index 47694c77..0efebfcb 100644 --- a/tests/AcDream.App.Tests/UI/UiScrollbarTests.cs +++ b/tests/AcDream.App.Tests/UI/UiScrollbarTests.cs @@ -127,4 +127,17 @@ public class UiScrollbarTests Assert.Equal(expectedX, x, 3); Assert.Equal(expectedWidth, width, 3); } + + [Theory] + [InlineData(0f, 6f)] + [InlineData(0.5f, 253.5f)] + [InlineData(1f, 501f)] + public void ScalarThumbFillRect_StartsAtAbsoluteLeftAndEndsAtThumbCenter( + float position, float expectedWidth) + { + var (x, width) = UiScrollbar.ScalarThumbFillRect( + totalWidth: 507f, thumbWidth: 12f, position); + Assert.Equal(0f, x, 3); + Assert.Equal(expectedWidth, width, 3); + } }