Both OP4 reviews converged on one headline bug (Character-tab rows never re-read live server truth after their pre-login constructor-word seed) plus overlapping MUST-FIXes. All ten converged/consolidated findings land here: MUST-FIX: - BoolOptionRow.SaveCurrentValue now re-reads its live binding (retail's GetValue()-into-SaveCurrentValue) on every OnShown — panel open, tab switch in, initial activation — instead of trusting the pre-login constructor word it was built with. Reset/tab-switch can now only restore values that were actually live at the last show. LockUI's host.Root.UiLocked one-shot mount seed now also converges on every PlayerDescription via the existing OnCharacterOptionsChanged hook. - Apply/Reset are wired to OptionPage.OnOptionChanged in production (Ghosted when nothing changed, Normal when dirty, run once at bind so both start disabled per retail's PostInit); Defaults stays ungated. - The Combat panel's three LEDs (Repeat Attacks/Auto Target/Keep in View) now read/write the same RuntimeCharacterOptionsState seam the Character tab uses instead of a disconnected client-local GameplaySettings copy — closes the "two writable copies" divergence. The three now-orphaned GameplaySettings fields and RuntimeSettingsController's mirror properties/SetCombatGameplay are deleted outright; the headless host's hardcoded AutoRepeatAttack/AutoTarget now read the live option bit. - RuntimeSettingsController.SetUiLocked's convergence guard now compares against the last value actually applied to the runtime target instead of the persisted GameplaySettings.LockUI snapshot, which could already match a server-derived request without ever having been pushed. SHOULD-FIX: - DisplayTimeStamps now prefixes every chat producer (ChatLog.Append is the one seam all of them funnel through), not just AddText's own callers — heard speech, emotes, Turbine channels, and combat text were previously missed. The prefix format escapes its colons and forces InvariantCulture instead of the culture-dependent TimeSeparator placeholder. - sky.frag now honors uFogParams.w (fog mode) like the mesh/terrain shaders, so Disable Distance Fog stops the sky dome's horizon band from blending toward fog color too. - Corrected the "byte-verified" overclaim on the timestamp format string doc comment (BN-sourced, wire doc U6) and the AP-194 anchor-column class-name typo; the RunAsDefaultMovement doc comments now cite retail's actual acclient.h enumerator name. - Added: DispatcherMovementInputSource's option x modifier truth table (incl. || AutoRunActive with the option off), the per-page Apply/Reset enable-gate tests, a real checkbox.OnClick/ToggleBehavior-driven click test, and hash-pins for the six header string keys. - Gate script step 8 corrected for the logout-flush false-failure (closing the panel before relogging is load-bearing); a new step documents the enable-gate sequence and the Combat-panel/Character-tab cross-check. Register: AP-196 (the Group-C default-source change + GameplaySettings retirement) and AP-197 (the ignored per-character timestamp format override) filed in this commit. Full Release suite: 13,044 passed / 4 skipped / 0 failed (was 13,008/4/0; net +36 tests from new coverage and legitimate assertion updates from the GameplaySettings retirement). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
238 lines
8.4 KiB
C#
238 lines
8.4 KiB
C#
using AcDream.App.Input;
|
||
using AcDream.UI.Abstractions.Input;
|
||
using Silk.NET.Input;
|
||
|
||
namespace AcDream.App.Tests.Input;
|
||
|
||
public sealed class DispatcherMovementInputSourceTests
|
||
{
|
||
[Fact]
|
||
public void UnboundSourceCapturesNeutralInput()
|
||
{
|
||
var source = CreateSource();
|
||
|
||
Assert.Equal(default, source.Capture());
|
||
}
|
||
|
||
[Fact]
|
||
public void CapturesDispatcherHeldStateAndRetailWalkModifier()
|
||
{
|
||
var (dispatcher, _, _) = CreateDispatcher();
|
||
var source = CreateSource();
|
||
source.Bind(dispatcher);
|
||
|
||
Assert.True(dispatcher.TrySetAutomationActionHeld(
|
||
InputAction.MovementForward,
|
||
held: true));
|
||
Assert.True(dispatcher.TrySetAutomationActionHeld(
|
||
InputAction.MovementWalkMode,
|
||
held: true));
|
||
|
||
MovementInput captured = source.Capture();
|
||
|
||
Assert.True(captured.Forward);
|
||
Assert.False(captured.Run);
|
||
}
|
||
|
||
[Fact]
|
||
public void RetainedKeyboardCaptureSilencesHeldKeysButDoesNotCancelAutorun()
|
||
{
|
||
var (dispatcher, _, mouse) = CreateDispatcher();
|
||
var source = CreateSource();
|
||
source.Bind(dispatcher);
|
||
dispatcher.TrySetAutomationActionHeld(InputAction.MovementForward, held: true);
|
||
Assert.True(source.HandlePressedAction(InputAction.MovementRunLock));
|
||
|
||
mouse.WantCaptureKeyboard = true;
|
||
MovementInput captured = source.Capture();
|
||
|
||
Assert.True(captured.Forward);
|
||
Assert.True(source.AutoRunActive);
|
||
|
||
source.HandlePressedAction(InputAction.MovementRunLock);
|
||
captured = source.Capture();
|
||
Assert.False(captured.Forward);
|
||
}
|
||
|
||
[Fact]
|
||
public void DevToolsKeyboardCapturePausesAutorunWithoutClearingItsLatch()
|
||
{
|
||
var capture = new FakeCapture();
|
||
var (dispatcher, _, _) = CreateDispatcher();
|
||
var source = CreateSource(capture);
|
||
source.Bind(dispatcher);
|
||
source.HandlePressedAction(InputAction.MovementRunLock);
|
||
|
||
capture.DevToolsWantCaptureKeyboard = true;
|
||
Assert.Equal(default, source.Capture());
|
||
Assert.True(source.AutoRunActive);
|
||
|
||
capture.DevToolsWantCaptureKeyboard = false;
|
||
Assert.True(source.Capture().Forward);
|
||
}
|
||
|
||
[Theory]
|
||
[InlineData(InputAction.MovementBackup)]
|
||
[InlineData(InputAction.MovementStop)]
|
||
[InlineData(InputAction.MovementStrafeLeft)]
|
||
[InlineData(InputAction.MovementStrafeRight)]
|
||
public void RetailCancelActionsClearAutorun(InputAction action)
|
||
{
|
||
var source = CreateSource();
|
||
source.HandlePressedAction(InputAction.MovementRunLock);
|
||
|
||
Assert.False(source.HandlePressedAction(action));
|
||
|
||
Assert.False(source.AutoRunActive);
|
||
}
|
||
|
||
[Fact]
|
||
public void ForwardCancelsAutorun_AndResetClearsIt()
|
||
{
|
||
// Movement parity audit 2026-07-30 — retail
|
||
// CommandInterpreter::HandleNewForwardMovement (0x006b3d60) is
|
||
// literally `SetAutoRun(0, 1)`: EVERY fresh forward press disables
|
||
// autorun and hands control back to the key. The previous pin
|
||
// ("ForwardDoesNotCancelAutorun") codified the divergence.
|
||
var source = CreateSource();
|
||
source.HandlePressedAction(InputAction.MovementRunLock);
|
||
Assert.True(source.AutoRunActive);
|
||
|
||
source.HandlePressedAction(InputAction.MovementForward);
|
||
Assert.False(source.AutoRunActive);
|
||
|
||
source.HandlePressedAction(InputAction.MovementRunLock);
|
||
Assert.True(source.AutoRunActive);
|
||
source.ResetSession();
|
||
Assert.False(source.AutoRunActive);
|
||
}
|
||
|
||
// ── S6 (OP4 review-fix round blast, 2026-08-11): the option × modifier
|
||
// truth table for Run — previously pinned only at option-unbound
|
||
// (⇒ true) + walk-held. ──────────────────────────────────────────
|
||
|
||
[Theory]
|
||
[InlineData(true, false, true)] // run-by-default, no walk modifier -> runs
|
||
[InlineData(true, true, false)] // run-by-default, walk modifier held -> walks
|
||
[InlineData(false, false, false)] // walk-by-default, no modifier -> walks
|
||
[InlineData(false, true, true)] // walk-by-default, modifier held -> runs
|
||
public void Capture_RunReflectsOptionXorWalkModifier(
|
||
bool runAsDefault, bool walkModifierHeld, bool expectedRun)
|
||
{
|
||
var (dispatcher, _, _) = CreateDispatcher();
|
||
var movement = new RuntimeLocalPlayerMovementState
|
||
{
|
||
RunAsDefaultMovementSource = () => runAsDefault,
|
||
};
|
||
var source = new DispatcherMovementInputSource(movement);
|
||
source.Bind(dispatcher);
|
||
dispatcher.TrySetAutomationActionHeld(InputAction.MovementForward, held: true);
|
||
if (walkModifierHeld)
|
||
dispatcher.TrySetAutomationActionHeld(InputAction.MovementWalkMode, held: true);
|
||
|
||
MovementInput captured = source.Capture();
|
||
|
||
Assert.Equal(expectedRun, captured.Run);
|
||
}
|
||
|
||
[Fact]
|
||
public void Capture_AutoRunActive_ForcesRun_EvenWhenOptionIsOff()
|
||
{
|
||
// The `|| AutoRunActive` clause predates OP4 but was unobservable
|
||
// while the default was hardcoded true. Pinned as a
|
||
// CURRENT-BEHAVIOR test (not a retail-correctness claim — see
|
||
// mechanism review N6, which flags this as a possibly-divergent
|
||
// "|| AutoRunActive" that retail's SetAutoRun does not force) so a
|
||
// future change to this clause is deliberate, not accidental.
|
||
var (dispatcher, _, _) = CreateDispatcher();
|
||
var movement = new RuntimeLocalPlayerMovementState
|
||
{
|
||
RunAsDefaultMovementSource = () => false,
|
||
};
|
||
var source = new DispatcherMovementInputSource(movement);
|
||
source.Bind(dispatcher);
|
||
source.HandlePressedAction(InputAction.MovementRunLock); // arm autorun
|
||
Assert.True(source.AutoRunActive);
|
||
|
||
MovementInput captured = source.Capture();
|
||
|
||
Assert.True(captured.Run);
|
||
}
|
||
|
||
[Fact]
|
||
public void BindingIsIdempotentOnlyForTheSameDispatcher()
|
||
{
|
||
var source = CreateSource();
|
||
var (first, _, _) = CreateDispatcher();
|
||
var (second, _, _) = CreateDispatcher();
|
||
|
||
source.Bind(first);
|
||
source.Bind(first);
|
||
|
||
Assert.Throws<InvalidOperationException>(() => source.Bind(second));
|
||
}
|
||
|
||
[Fact]
|
||
public void UnbindRequiresExactDispatcherAndRestoresNeutralCapture()
|
||
{
|
||
var source = CreateSource();
|
||
var (first, _, _) = CreateDispatcher();
|
||
var (other, _, _) = CreateDispatcher();
|
||
source.Bind(first);
|
||
first.TrySetAutomationActionHeld(InputAction.MovementForward, held: true);
|
||
|
||
source.Unbind(other);
|
||
Assert.True(source.Capture().Forward);
|
||
source.Unbind(first);
|
||
|
||
Assert.False(source.IsAvailable);
|
||
Assert.Equal(default, source.Capture());
|
||
}
|
||
|
||
private static (InputDispatcher Dispatcher, FakeKeyboard Keyboard, FakeMouse Mouse)
|
||
CreateDispatcher()
|
||
{
|
||
var keyboard = new FakeKeyboard();
|
||
var mouse = new FakeMouse();
|
||
var dispatcher = InputDispatcher.CreateDetached(
|
||
keyboard,
|
||
mouse,
|
||
new KeyBindings());
|
||
dispatcher.Attach();
|
||
return (dispatcher, keyboard, mouse);
|
||
}
|
||
|
||
private static DispatcherMovementInputSource CreateSource(
|
||
IInputCaptureSource? capture = null) =>
|
||
new(new RuntimeLocalPlayerMovementState(), capture);
|
||
|
||
private sealed class FakeKeyboard : IKeyboardSource
|
||
{
|
||
#pragma warning disable CS0067
|
||
public event Action<Key, ModifierMask>? KeyDown;
|
||
public event Action<Key, ModifierMask>? KeyUp;
|
||
#pragma warning restore CS0067
|
||
public bool IsHeld(Key key) => false;
|
||
public ModifierMask CurrentModifiers => ModifierMask.None;
|
||
}
|
||
|
||
private sealed class FakeMouse : IMouseSource
|
||
{
|
||
#pragma warning disable CS0067
|
||
public event Action<MouseButton, ModifierMask>? MouseDown;
|
||
public event Action<MouseButton, ModifierMask>? MouseUp;
|
||
public event Action<float, float>? MouseMove;
|
||
public event Action<float>? Scroll;
|
||
#pragma warning restore CS0067
|
||
public bool WantCaptureKeyboard { get; set; }
|
||
public bool WantCaptureMouse { get; set; }
|
||
public bool IsHeld(MouseButton button) => false;
|
||
}
|
||
|
||
private sealed class FakeCapture : IInputCaptureSource
|
||
{
|
||
public bool WantCaptureMouse { get; set; }
|
||
public bool WantCaptureKeyboard { get; set; }
|
||
public bool DevToolsWantCaptureKeyboard { get; set; }
|
||
}
|
||
}
|