acdream/tests/AcDream.App.Tests/UI/Layout/MouseTurningSettingsMacroTests.cs
Erik 9d26ecc623 feat(ui): Campaign OP slice OP3 — Options panel shell, open paths, Gameplay tab
Mounts retail's Options panel (LayoutDesc 0x2100002B resolved through host
0x2100006E slot 0x1000018D, gmPanelUI key 10) via the same catalog-import
pattern CharacterController already validates, registered through
RetailPanelUiController so it shares retail's "one active gmPanelUI child"
mutual exclusion with every other sibling panel for free. F11 and the
toolbar's options button (0x1000019B, already authoring panel id 10) both
now open it; the close button fires the same ToggleOptionsPanel action.

OptionPageModel (OptionPage/BoolOptionRow) ports retail's exact
Apply/Reset/Defaults/visibility semantics from
UIOption_Checkbox/PlayerOptionPage — LED clicks apply live immediately,
Apply commits every row unconditionally + flushes the batched blob, Reset
reverts only Changed rows, Defaults restores without committing, and
tab-switch/window-hide revert uncommitted edits. Wired for all four tabs;
this slice registers real rows on none of them (Gameplay authentically has
none — a pure button list). UiTabPanel gains an ActivePageChanged event so
the page model can hook every tab transition, including the initial
default-tab activation.

The seven Gameplay-tab buttons: Exit Game reuses the existing graceful
window-close path; Exit to Character Selection gets retail's confirmation
dialog and byte-verified mid-air refusal but still behaves as Exit Game
(AD-74 — no pre-world character-select flow exists); Configure Keyboard
and In-Game Help Files are inert this slice (AD-76 for Help — the
plugin retail depends on doesn't exist); Urgent Assistance/Report Abuse
short-circuit to their own byte-verified failure text through the
interface-text seam instead of ShellExecute against a dead URL (AD-75);
Use Mouse Turning Settings runs the pure MouseTurningSettingsMacro port,
persisting five new CameraTurningSettings preferences and sending
PlayerOption.UseMouseTurning — TS-74 records that acdream has no
persistent mouse-turning camera mode for the bit to drive yet.

Full Release suite: 12,918 passed / 4 skipped / 0 failed (baseline
12,871/4/0 — only new tests added).

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

113 lines
4.4 KiB
C#

using AcDream.App.UI.Layout;
using AcDream.Core.Chat;
using AcDream.UI.Abstractions.Panels.Settings;
namespace AcDream.App.Tests.UI.Layout;
/// <summary>
/// Pure logic tests for <see cref="MouseTurningSettingsMacro"/> — the port of
/// <c>gmConfigUI::SetMouseTurningDefaults @0x0049E8F0</c> (research doc
/// <c>2026-08-10-keyboard-config-and-gameplay-tab.md</c> §4.4). No DAT, no
/// runtime — pure input/output over <see cref="CameraTurningSettings"/>.
/// </summary>
public sealed class MouseTurningSettingsMacroTests
{
[Fact]
public void AllSixValuesAtOrdinaryDefaults_ChangesEveryOne()
{
// Retail's ordinary Config-tab defaults (0.45/40.0/0.55/on/off) all
// differ from the macro's targets (0.95/50.0/0.7/off/on) — a fresh
// character clicking this button changes all six.
MouseTurningSettingsMacro.Result result = MouseTurningSettingsMacro.Compute(
CameraTurningSettings.Default,
useMouseTurningCurrent: false);
CameraTurningSettings target = CameraTurningSettings.MouseTurningTarget;
Assert.Equal(target, result.Updated);
Assert.True(result.UseMouseTurningChanged);
Assert.Equal(6, result.ChatLines.Count);
}
[Fact]
public void AllSixValuesAlreadyAtTarget_ChangesNone()
{
MouseTurningSettingsMacro.Result result = MouseTurningSettingsMacro.Compute(
CameraTurningSettings.MouseTurningTarget,
useMouseTurningCurrent: true);
Assert.Equal(CameraTurningSettings.MouseTurningTarget, result.Updated);
Assert.False(result.UseMouseTurningChanged);
Assert.Empty(result.ChatLines);
}
[Fact]
public void OnlyStiffnessDiffers_ChangesOnlyStiffness_WithItsOwnChatLine()
{
CameraTurningSettings current = CameraTurningSettings.MouseTurningTarget with
{
Stiffness = 0.45f,
};
MouseTurningSettingsMacro.Result result =
MouseTurningSettingsMacro.Compute(current, useMouseTurningCurrent: true);
Assert.Equal(0.95f, result.Updated.Stiffness);
Assert.Equal(CameraTurningSettings.MouseTurningTarget.AdjustmentSpeed, result.Updated.AdjustmentSpeed);
Assert.False(result.UseMouseTurningChanged);
Assert.Equal(
[OptionsPanelText.CameraStiffnessChanged(0.45f, 0.95f)],
result.ChatLines);
}
[Fact]
public void OnlyAlignToSlopeDiffers_EmitsTheByteVerifiedLiteralLine()
{
CameraTurningSettings current = CameraTurningSettings.MouseTurningTarget with
{
AlignToSlope = true,
};
MouseTurningSettingsMacro.Result result =
MouseTurningSettingsMacro.Compute(current, useMouseTurningCurrent: true);
Assert.False(result.Updated.AlignToSlope);
Assert.Equal([OptionsPanelText.AlignToSlopeChanged], result.ChatLines);
}
[Fact]
public void OnlyUseMouseTurningDiffers_ReportsChangedWithoutTouchingCameraSettings()
{
MouseTurningSettingsMacro.Result result = MouseTurningSettingsMacro.Compute(
CameraTurningSettings.MouseTurningTarget,
useMouseTurningCurrent: false);
Assert.Equal(CameraTurningSettings.MouseTurningTarget, result.Updated);
Assert.True(result.UseMouseTurningChanged);
Assert.Equal([OptionsPanelText.TurnToFaceCameraChanged], result.ChatLines);
}
[Fact]
public void ChatLines_AreEmittedInRetailOrder()
{
// Retail's own call order: Stiffness, AdjustmentSpeed, Sensitivity,
// AlignToSlope, InvertMouseLookYAxis, UseMouseTurning
// (0x0049E924..0x0049EB57).
MouseTurningSettingsMacro.Result result = MouseTurningSettingsMacro.Compute(
CameraTurningSettings.Default,
useMouseTurningCurrent: false);
CameraTurningSettings d = CameraTurningSettings.Default;
CameraTurningSettings t = CameraTurningSettings.MouseTurningTarget;
Assert.Equal(
new[]
{
OptionsPanelText.CameraStiffnessChanged(d.Stiffness, t.Stiffness),
OptionsPanelText.CameraAdjustmentChanged(d.AdjustmentSpeed, t.AdjustmentSpeed),
OptionsPanelText.MouseSensitivityChanged(d.MouseLookSensitivity, t.MouseLookSensitivity),
OptionsPanelText.AlignToSlopeChanged,
OptionsPanelText.InvertMouseLookAxesChanged,
OptionsPanelText.TurnToFaceCameraChanged,
},
result.ChatLines);
}
}