feat(ui): Campaign OP slice OP8 — Configure Keyboard
Ports retail's Configure Keyboard screen (gmKeyboardUI, LayoutDesc 0x21000009) — its own separate full-screen window, not a fifth Options- panel tab. Retires OP3's INERT contract for the Gameplay tab's Configure Keyboard button (0x10000204). DAT reader (src/AcDream.Core/Input/RetailActionMap.cs): reads the ActionMap singleton (DID 0x26000000, empirically the only one — not 0x27000000 as GetDBOType's Turbine-internal tag would suggest) and both MasterInputMap defaults (0x14000000 "gmDefaultMap"/0x14000002 "DefaultMap"), union-merged per (InputMapId, ActionId) — proven order- independent since the two maps' one shared context (0x5) has disjoint action-id sets. Empirically resolved three lane-D unknowns against the live DAT: the six ActionClass values (1=Movement, 2=Camera, 3=UI, 4=Combat, 5=Emote, 7=CharacterSettings — 6 is genuinely absent), that the six unnamed InputMaps are 100% non-bindable (render nothing, not an unlabeled group), and that the enum-to-DID pairing for the two master maps is inconsequential to the merge result. Identity table (src/AcDream.UI.Abstractions/Input/RetailActionIdentityTable.cs): maps DAT (InputMapId, ActionId) pairs to acdream's InputAction where a live consumer exists (~140 of 306 user-bindable rows — Movement/Camera/ Combat map almost completely; UI/Quickslot/Chat partially; only 5 of 87 Emotes and none of 48 CharacterSettings hotkeys, since acdream has no general emote player or hotkey-to-option-toggle dispatcher yet). Every entry cross-verified by label match AND a DAT-default-vs- KeyBindings.RetailDefaults() byte comparison (RetailActionIdentityRoundTripTests), which caught a real off-by-one in the Quickslot 13-18 block before it shipped and found three genuine pre-existing RetailDefaults() gaps (walk-mode's Shift-echoed chord, ten CameraAlternateControls arrow-key alternates, and the Quickslot Ctrl+N use-vs-select ambiguity) — none introduced by this slice, all documented rather than silently patched. KeyboardConfigController: six ActionClass list boxes built from the DAT, merged with live KeyBindings for mapped rows (rebind applies immediately through the same InputDispatcher every other input path uses) and a new sibling RetailUnmappedKeyBindings store for rows with no InputAction yet. Left-click a key button opens real InputDispatcher modal capture; right-click erases that slot. N-way conflict detection scans every other row plus the live KeyBindings table for acdream-only actions (Ctrl+M mute, debug F-keys) as the non-user-bindable refusal analogue, using retail's own byte-verified "Could not overwrite " string (table 0x23000004). OK/Cancel/Defaults/Revert reuse the OptionPage/IOptionRow verb model via a new ActionKeyMapOptionRow. Persistence is keybinds.json only (D4 — no .keymap file interchange). Five register rows: AP-202 (.keymap interchange narrowing), AP-203 (store-only rows with no live consumer), AP-204 (silent auto-reassign instead of retail's confirm dialog; OK/Cancel ported as left-click not right-click-release). Small supporting additions: UiButton.OnRightClick (additive, no existing behavior changed), InputDispatcher.Bindings getter (the screen's single live-truth read seam), RetailScanCodeMap (DIK scan code <-> Silk.NET Key, keyboard + the one mouse-device row). 19 new tests (6 ActionMap reader conformance incl. live-DAT row-count/ label pins, 1 DAT-vs-RetailDefaults round-trip, 12 controller behavior tests against the committed keyboard_config_21000009.json fixture) — full solution suite 13,147 passed / 4 skipped / 0 failed (baseline 13,128/4/0, zero regressions). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
ff5776415b
commit
b4edee970f
23 changed files with 35760 additions and 12 deletions
|
|
@ -54,6 +54,10 @@ internal sealed record InteractionRetainedUiDependencies(
|
|||
HostQuiescenceGate HostQuiescence,
|
||||
RetainedUiInputCaptureSlot RetainedInputCapture,
|
||||
InputDispatcher? InputDispatcher,
|
||||
// Campaign OP slice OP8: the portable keybinds.json path
|
||||
// (ApplicationPathSet.KeyBindingsFile) — the Configure Keyboard screen's
|
||||
// Save button writes here, same file GameWindow's startup load reads.
|
||||
string KeyBindingsFilePath,
|
||||
RuntimeSettingsController Settings,
|
||||
GameRuntime Runtime,
|
||||
IRuntimeCombatAttackOperations CombatAttackOperations,
|
||||
|
|
@ -877,7 +881,8 @@ internal sealed class RetailInteractionRetainedUiCompositionFactory
|
|||
action => d.InputDispatcher?.TryInvokeAutomationAction(action) == true,
|
||||
(action, held) =>
|
||||
d.InputDispatcher?.TrySetAutomationActionHeld(action, held) == true,
|
||||
late.Automation));
|
||||
late.Automation),
|
||||
Keyboard: new KeyboardRuntimeBindings(d.InputDispatcher, d.KeyBindingsFilePath));
|
||||
RetailUiRuntime runtime = lease.Mount(
|
||||
() => RetailUiRuntime.CreateUninitialized(bindings));
|
||||
checkpoint(InteractionRetainedUiCompositionPoint.UiRuntimeMounted);
|
||||
|
|
|
|||
|
|
@ -1342,6 +1342,7 @@ public sealed class GameWindow :
|
|||
_hostQuiescence,
|
||||
_retainedInputCapture,
|
||||
hostInputCamera.InputDispatcher,
|
||||
_applicationPaths.KeyBindingsFile,
|
||||
_runtimeSettings,
|
||||
_runtime,
|
||||
_combatAttackOperations,
|
||||
|
|
|
|||
515
src/AcDream.App/UI/Layout/KeyboardConfigController.cs
Normal file
515
src/AcDream.App/UI/Layout/KeyboardConfigController.cs
Normal file
|
|
@ -0,0 +1,515 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AcDream.App.UI;
|
||||
using AcDream.Core.Input;
|
||||
using AcDream.UI.Abstractions.Input;
|
||||
|
||||
namespace AcDream.App.UI.Layout;
|
||||
|
||||
/// <summary>
|
||||
/// Campaign OP slice OP8: retail's Configure Keyboard screen —
|
||||
/// <c>gmKeyboardUI</c> (LayoutDesc <c>0x21000009</c>, root <c>0x1000001F</c>,
|
||||
/// 800×600), its own SEPARATE full-screen window (research doc's structure
|
||||
/// lane §8 / lane D §4.3, NOT a fifth tab of the four-tab Options panel —
|
||||
/// "the retail keyboard screen is NOT one of the four Options tabs"). Mounted
|
||||
/// the same way the Options panel opens (F11/toolbar → <c>ToggleOptionsPanel</c>
|
||||
/// action <c>0x1000001A</c>): the Gameplay tab's Configure Keyboard button
|
||||
/// (<c>0x10000204</c>) and this screen's own OK/Cancel buttons all carry
|
||||
/// authored <c>P0x12 = 0x1000001F</c> — the SAME toggle-window pattern, byte-
|
||||
/// verified against the committed <c>options_gameplay_2100002A.json</c> and
|
||||
/// <c>keyboard_config_21000009.json</c> fixtures — so a single <see cref="Toggle"/>
|
||||
/// callback covers the open path (the Gameplay-tab button) and both close paths
|
||||
/// (OK/Cancel) without porting the generic
|
||||
/// <c>UIElementManager::DoVisibilityToggleAction</c> action-broadcast machinery,
|
||||
/// which nothing else in this codebase needs yet.
|
||||
///
|
||||
/// <para>
|
||||
/// <b>Six ActionClass list boxes.</b> The screen's own Type-8 tab control
|
||||
/// (<c>0x1000049B</c>) hosts six page containers — <c>0x1000049D</c> Movement
|
||||
/// (default tab), <c>0x1000049F</c> Camera, <c>0x100004A1</c> Combat,
|
||||
/// <c>0x100004A3</c> UI, <c>0x10000211</c> CharacterSettings, <c>0x100004A5</c>
|
||||
/// Emote — EACH authoring its OWN identical child subtree: four column headers
|
||||
/// (<c>0x10000021</c>-<c>0x10000024</c>, "Command"/"Mapping 1/2/3") and a
|
||||
/// Type-5 ListBox (<c>0x10000025</c>) + scrollbar (<c>0x10000026</c>). <b>Every
|
||||
/// one of those five ids is REUSED verbatim across all six pages</b> — the
|
||||
/// live-DAT dump (<c>keyboard_config_21000009.json</c>) confirms this is the
|
||||
/// SAME page-scoped-lookup trap the OP campaign has hit before (OP6's caption
|
||||
/// sites): every lookup below is scoped from ITS OWN page's container root via
|
||||
/// <see cref="UiElement.FindDescendant"/>, never a flat/global
|
||||
/// <c>layout.FindElement</c> for these five ids.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// <b>The row template.</b> <c>AddItemFromTemplateList(0)</c> builds the header
|
||||
/// row (<c>0x1000002E</c>, plain text); <c>AddItemFromTemplateList(1)</c> builds
|
||||
/// the action row (<c>0x1000002F</c>, Type <c>0x10000034</c> =
|
||||
/// <c>UIOption_ActionKeyMap</c>). Its 3 authored children (<c>0x10000030</c>/
|
||||
/// <c>31</c>/<c>32</c>, positioned under the "Mapping 1/2/3" columns) are the row's
|
||||
/// key buttons — built automatically by <see cref="LayoutImporter"/>'s normal
|
||||
/// recursive descent (the row itself is not one of OP2's special
|
||||
/// <c>ConsumesDatChildren</c> widgets), so no new <see cref="DatWidgetFactory"/>
|
||||
/// case was needed for Type <c>0x10000034</c>. <b>The shipped 2013 template has
|
||||
/// exactly 3 key-button children and NO separate Clear-button child</b> — a real,
|
||||
/// DAT-verified fact (register row): erasing a single binding is right-click on
|
||||
/// its key button (<c>UIOption_ActionKeyMap::EraseBinding</c>, ported via
|
||||
/// <see cref="UiButton.OnRightClick"/>); there is no authored affordance for
|
||||
/// retail's OWN class-level <c>ClearAllBindings</c> (its <c>m_buttonClear</c>
|
||||
/// field exists in the C++ class but nothing in this layout wires it) — its
|
||||
/// EFFECT (clear every slot on a row) is still reachable one right-click at a
|
||||
/// time. The row's own caption (the action label) is synthesized as a plain
|
||||
/// <see cref="UiText"/> child (composition, not inheritance — <see cref="UiText"/>
|
||||
/// is sealed), exactly the pattern <c>CharacterStatController.BuildHeaderRow</c>
|
||||
/// already uses for a controller-synthesized label beside authored dat children.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// <b>Row identity and binding storage (D4).</b> Every row's identity is the DAT
|
||||
/// pair <c>(InputMapId, ActionId)</c> — retail's own row key. Where
|
||||
/// <see cref="RetailActionIdentityTable"/> resolves that pair to an acdream
|
||||
/// <see cref="InputAction"/> (research: roughly half of the DAT's 306 rows — see
|
||||
/// that table's class doc for the full accounting), the row's bindings ARE
|
||||
/// <see cref="KeyBindings"/>'s bindings for that action: a rebind here takes
|
||||
/// effect immediately for live gameplay dispatch through the SAME
|
||||
/// <see cref="InputDispatcher"/> every other input path uses, and persists to
|
||||
/// <c>keybinds.json</c> exactly like any other rebind (D4 — no separate
|
||||
/// <c>.keymap</c> file format). Where no <see cref="InputAction"/> exists yet
|
||||
/// (mostly Emotes and CharacterSettings — see the identity table's class doc),
|
||||
/// the row is still fully rendered, bindable, conflict-checked, and persisted
|
||||
/// (<see cref="Bindings.CurrentForUnmapped"/>/<see cref="Bindings.SetForUnmapped"/>),
|
||||
/// it just has no live gameplay consumer yet (register row).
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// <b>Conflicts (research doc §5.4).</b> Retail's conflict model is N-way and
|
||||
/// cross-input-map, with a DISTINCT refusal for a chord already bound to a
|
||||
/// non-user-bindable action. This port scans every OTHER row on this screen
|
||||
/// (the full user-bindable universe, since every DAT-sourced row is inherently
|
||||
/// user-bindable — <see cref="RetailActionMapReader"/> already filtered out the
|
||||
/// non-bindable ones) PLUS the live <see cref="KeyBindings"/> table for chords
|
||||
/// bound to an acdream-only action with no <see cref="RetailActionIdentityTable"/>
|
||||
/// row at all (Ctrl+M mute, the debug F-keys, ...) — those are this port's
|
||||
/// "non-user-bindable" analogue (there is no retail row to reassign them from) and
|
||||
/// refuse via <see cref="Bindings.NonBindableRefusalText"/> exactly like retail's
|
||||
/// distinct <c>OpenCantOverwriteBindingDialog</c>. A genuine cross-row conflict
|
||||
/// (register row — narrowed from retail's modal confirm-before-reassign) auto-
|
||||
/// reassigns (erases the losing row's slot, applies the new one) and reports the
|
||||
/// outcome via <see cref="Bindings.NotifyReassigned"/> rather than blocking on a
|
||||
/// confirm dialog this slice does not build.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public sealed class KeyboardConfigController
|
||||
{
|
||||
/// <summary>The screen's own top-level LayoutDesc.</summary>
|
||||
public const uint LayoutId = 0x21000009u;
|
||||
|
||||
/// <summary>The window root — ALSO the retail input-action id
|
||||
/// (<c>0x1000001F</c>, "Show/Hide Keyboard Configuration") that opens/closes
|
||||
/// it, per the Gameplay tab button and this screen's own OK/Cancel buttons
|
||||
/// all authoring <c>P0x12 = 0x1000001F</c>.</summary>
|
||||
public const uint WindowRootElementId = 0x1000001Fu;
|
||||
|
||||
private const uint LoadButtonId = 0x10000027u;
|
||||
private const uint FilenameLabelId = 0x10000028u;
|
||||
private const uint SaveAsButtonId = 0x10000029u;
|
||||
private const uint DefaultsButtonId = 0x1000002Au;
|
||||
private const uint RevertButtonId = 0x1000002Bu;
|
||||
private const uint OkButtonId = 0x1000002Cu;
|
||||
private const uint CancelButtonId = 0x1000002Du;
|
||||
|
||||
// Reused verbatim across all six page containers below — ALWAYS scoped
|
||||
// per-page via UiElement.FindDescendant, never a flat layout.FindElement.
|
||||
private const uint ListBoxElementId = 0x10000025u;
|
||||
private const uint ScrollbarElementId = 0x10000026u;
|
||||
|
||||
private const int HeaderTemplateIndex = 0;
|
||||
private const int RowTemplateIndex = 1;
|
||||
|
||||
// The row template's 3 key-button children, in "Mapping 1/2/3" column order.
|
||||
private static readonly uint[] KeyButtonIds = { 0x10000030u, 0x10000031u, 0x10000032u };
|
||||
|
||||
private static readonly (uint PageContainerId, RetailActionClass Class)[] Pages =
|
||||
{
|
||||
(0x1000049Du, RetailActionClass.Movement),
|
||||
(0x1000049Fu, RetailActionClass.Camera),
|
||||
(0x100004A1u, RetailActionClass.Combat),
|
||||
(0x100004A3u, RetailActionClass.Ui),
|
||||
(0x10000211u, RetailActionClass.CharacterSettings),
|
||||
(0x100004A5u, RetailActionClass.Emote),
|
||||
};
|
||||
|
||||
/// <summary>One rendered row: its DAT identity, the built key-button
|
||||
/// widgets (up to 3, "Mapping 1/2/3" order), and its
|
||||
/// <see cref="ActionKeyMapOptionRow"/> model.</summary>
|
||||
public sealed record RowView(
|
||||
uint InputMapId,
|
||||
uint ActionId,
|
||||
InputAction? MappedAction,
|
||||
string? Label,
|
||||
ActionKeyMapOptionRow Model,
|
||||
IReadOnlyList<UiButton> KeyButtons);
|
||||
|
||||
/// <summary>The live read/write/capture seam this screen writes bindings
|
||||
/// through — mirrors every other Campaign OP page controller's
|
||||
/// <c>Bindings</c> shape (a plain delegate record, no DAT/InputDispatcher
|
||||
/// dependency baked into the controller itself).</summary>
|
||||
public sealed record Bindings(
|
||||
Func<InputAction, IReadOnlyList<KeyChord>> CurrentForAction,
|
||||
Action<InputAction, IReadOnlyList<KeyChord>> SetForAction,
|
||||
Func<(uint InputMapId, uint ActionId), IReadOnlyList<KeyChord>> CurrentForUnmapped,
|
||||
Action<(uint InputMapId, uint ActionId), IReadOnlyList<KeyChord>> SetForUnmapped,
|
||||
Action<Action<KeyChord?>> BeginCapture,
|
||||
Action Save,
|
||||
Action Toggle,
|
||||
Action<string> DisplaySystemMessage,
|
||||
string NonBindableRefusalText,
|
||||
Func<string, string> NotifyReassigned);
|
||||
|
||||
public OptionPage Page { get; } = new();
|
||||
public IReadOnlyList<RowView> Rows => _rows;
|
||||
|
||||
private readonly List<RowView> _rows = new();
|
||||
private Bindings? _bindings;
|
||||
|
||||
private KeyboardConfigController() { }
|
||||
|
||||
/// <summary>
|
||||
/// Builds every header + row across all six pages from
|
||||
/// <paramref name="snapshot"/>, wires each row's key buttons to modal
|
||||
/// capture / right-click erase, and wires the screen's own six buttons
|
||||
/// (Defaults/Revert/OK/Cancel; Load/Save File are INERT — D4, no
|
||||
/// <c>.keymap</c> interchange). Returns null if the layout's window root
|
||||
/// did not import (a missing/malformed LayoutDesc).
|
||||
/// </summary>
|
||||
public static KeyboardConfigController? Bind(
|
||||
ImportedLayout layout,
|
||||
RetailActionMapSnapshot snapshot,
|
||||
Func<uint, uint, UiElement?> templateResolver,
|
||||
Func<uint, uint, string?> resolveString,
|
||||
Bindings bindings)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(layout);
|
||||
ArgumentNullException.ThrowIfNull(snapshot);
|
||||
ArgumentNullException.ThrowIfNull(templateResolver);
|
||||
ArgumentNullException.ThrowIfNull(resolveString);
|
||||
ArgumentNullException.ThrowIfNull(bindings);
|
||||
|
||||
if (layout.FindElement(WindowRootElementId) is null)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"[D.2b] KeyboardConfigController: window root 0x{WindowRootElementId:X8} "
|
||||
+ "not found in the built layout — Configure Keyboard will not open.");
|
||||
return null;
|
||||
}
|
||||
|
||||
var controller = new KeyboardConfigController { _bindings = bindings };
|
||||
|
||||
var byClass = snapshot.Rows
|
||||
.Where(r => r.ActionClass != RetailActionClass.None)
|
||||
.GroupBy(r => r.ActionClass)
|
||||
.ToDictionary(g => g.Key, g => g.ToList());
|
||||
|
||||
foreach ((uint pageContainerId, RetailActionClass cls) in Pages)
|
||||
{
|
||||
UiElement? pageRoot = UiElement.FindDescendant(layout.Root, pageContainerId);
|
||||
if (pageRoot is null)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"[D.2b] KeyboardConfigController: page container 0x{pageContainerId:X8} "
|
||||
+ "not found — that ActionClass tab will have no rows.");
|
||||
continue;
|
||||
}
|
||||
if (UiElement.FindDescendant(pageRoot, ListBoxElementId) is not UiTemplateListBox listBox)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"[D.2b] KeyboardConfigController: ListBox 0x{ListBoxElementId:X8} not found "
|
||||
+ $"(or not a UiTemplateListBox) under page 0x{pageContainerId:X8}.");
|
||||
continue;
|
||||
}
|
||||
listBox.TemplateResolver = templateResolver;
|
||||
if (UiElement.FindDescendant(pageRoot, ScrollbarElementId) is UiScrollbar scrollbar)
|
||||
scrollbar.Model = listBox.Scroll;
|
||||
|
||||
if (!byClass.TryGetValue(cls, out List<RetailActionMapRow>? classRows))
|
||||
continue;
|
||||
|
||||
// Group by InputMapId in first-seen order (retail's own bucket ->
|
||||
// header-per-InputMapId order, research doc §5.2's InitOptions loop).
|
||||
var byInputMap = classRows
|
||||
.GroupBy(r => r.InputMapId)
|
||||
.OrderBy(g => g.Key);
|
||||
|
||||
foreach (var inputMapGroup in byInputMap)
|
||||
{
|
||||
BuildHeaderRow(listBox, inputMapGroup.Key, resolveString);
|
||||
foreach (RetailActionMapRow row in inputMapGroup)
|
||||
controller.BuildActionRow(listBox, row, resolveString, bindings);
|
||||
}
|
||||
}
|
||||
|
||||
WireScreenButtons(layout, controller, bindings);
|
||||
|
||||
return controller;
|
||||
}
|
||||
|
||||
private static void BuildHeaderRow(
|
||||
UiTemplateListBox listBox, uint inputMapId, Func<uint, uint, string?> resolveString)
|
||||
{
|
||||
if (listBox.AddItemFromTemplateList(HeaderTemplateIndex) is not UiText header)
|
||||
{
|
||||
Console.WriteLine(
|
||||
"[D.2b] KeyboardConfigController: header template did not build as UiText "
|
||||
+ $"for InputMap 0x{inputMapId:X8}.");
|
||||
return;
|
||||
}
|
||||
if (!RetailInputMapHeaders.NameByInputMapId.TryGetValue(inputMapId, out string? headerKey))
|
||||
return; // Unnamed InputMap — retail never reaches this (§5.3): no bindable
|
||||
// action of ours falls in one, but stay honest rather than assume.
|
||||
|
||||
string? label = resolveString(
|
||||
RetailInputMapHeaders.StringTableId, DatStringResolver.ComputeHash(headerKey));
|
||||
if (label is null)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"[D.2b] KeyboardConfigController: header string '{headerKey}' did not resolve — "
|
||||
+ "row renders with no text rather than invented English.");
|
||||
return;
|
||||
}
|
||||
header.LinesProvider = () => new[] { new UiText.Line(label, header.DefaultColor) };
|
||||
}
|
||||
|
||||
private void BuildActionRow(
|
||||
UiTemplateListBox listBox,
|
||||
RetailActionMapRow row,
|
||||
Func<uint, uint, string?> resolveString,
|
||||
Bindings bindings)
|
||||
{
|
||||
UiElement? built = listBox.AddItemFromTemplateList(RowTemplateIndex);
|
||||
if (built is null)
|
||||
{
|
||||
Console.WriteLine(
|
||||
"[D.2b] KeyboardConfigController: row template did not build for InputMap "
|
||||
+ $"0x{row.InputMapId:X8} action 0x{row.ActionId:X8}.");
|
||||
return;
|
||||
}
|
||||
|
||||
var keyButtons = new List<UiButton>(KeyButtonIds.Length);
|
||||
foreach (uint id in KeyButtonIds)
|
||||
{
|
||||
if (UiElement.FindDescendant(built, id) is UiButton button)
|
||||
keyButtons.Add(button);
|
||||
}
|
||||
|
||||
string? label = resolveString(RetailInputMapHeaders.StringTableId, row.LabelHash);
|
||||
string? tooltip = resolveString(RetailInputMapHeaders.StringTableId, row.TooltipHash);
|
||||
|
||||
// The row's own caption — synthesized, composed beside the authored key
|
||||
// buttons (UiText is sealed; see class doc). Occupies the "Command" column
|
||||
// (x=0..270, matching the authored column headers).
|
||||
var captionText = new UiText
|
||||
{
|
||||
Left = 0f,
|
||||
Top = 0f,
|
||||
Width = 260f,
|
||||
Height = built.Height,
|
||||
ClickThrough = true,
|
||||
Centered = false,
|
||||
RightAligned = false,
|
||||
Padding = 2f,
|
||||
Anchors = AnchorEdges.Left | AnchorEdges.Top,
|
||||
};
|
||||
if (label is not null)
|
||||
captionText.LinesProvider = () => new[] { new UiText.Line(label, captionText.DefaultColor) };
|
||||
built.AddChild(captionText);
|
||||
|
||||
bool mapped = RetailActionIdentityTable.TryResolve(row.InputMapId, row.ActionId, out InputAction action);
|
||||
InputAction? mappedAction = mapped ? action : null;
|
||||
|
||||
IReadOnlyList<KeyChord> initial = mapped
|
||||
? bindings.CurrentForAction(action)
|
||||
: bindings.CurrentForUnmapped((row.InputMapId, row.ActionId));
|
||||
IReadOnlyList<KeyChord> defaults = DatDefaultsToChords(row.DefaultBindings);
|
||||
|
||||
var model = new ActionKeyMapOptionRow(initial, defaults, apply: value =>
|
||||
{
|
||||
if (mapped)
|
||||
bindings.SetForAction(action, value);
|
||||
else
|
||||
bindings.SetForUnmapped((row.InputMapId, row.ActionId), value);
|
||||
});
|
||||
Page.Register(model);
|
||||
|
||||
var view = new RowView(row.InputMapId, row.ActionId, mappedAction, label, model, keyButtons);
|
||||
_rows.Add(view);
|
||||
|
||||
RefreshRowButtons(view);
|
||||
|
||||
for (int slot = 0; slot < keyButtons.Count; slot++)
|
||||
{
|
||||
int capturedSlot = slot;
|
||||
keyButtons[slot].TooltipText = tooltip;
|
||||
keyButtons[slot].OnClick = () => BeginSlotCapture(view, capturedSlot, bindings);
|
||||
keyButtons[slot].OnRightClick = () => EraseSlot(view, capturedSlot);
|
||||
}
|
||||
}
|
||||
|
||||
private static IReadOnlyList<KeyChord> DatDefaultsToChords(IReadOnlyList<RetailKeyChord> raw)
|
||||
{
|
||||
var result = new List<KeyChord>(raw.Count);
|
||||
foreach (RetailKeyChord chord in raw)
|
||||
{
|
||||
Silk.NET.Input.Key? key = RetailScanCodeMap.ToSilkKey(chord.Scan, chord.Device);
|
||||
if (key is null) continue; // unresolved scan code — omit rather than guess.
|
||||
result.Add(new KeyChord(key.Value, RetailScanCodeMap.ToModifierMask(chord.Modifier), (byte)chord.Device));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void RefreshRowButtons(RowView view)
|
||||
{
|
||||
IReadOnlyList<KeyChord> current = view.Model.Current;
|
||||
for (int i = 0; i < view.KeyButtons.Count; i++)
|
||||
view.KeyButtons[i].Label = i < current.Count ? DescribeChord(current[i]) : null;
|
||||
}
|
||||
|
||||
private static string DescribeChord(KeyChord chord)
|
||||
{
|
||||
string mods = chord.Modifiers == ModifierMask.None ? "" : chord.Modifiers.ToString() + "+";
|
||||
return mods + chord.Key;
|
||||
}
|
||||
|
||||
private void BeginSlotCapture(RowView view, int slot, Bindings bindings)
|
||||
{
|
||||
bindings.BeginCapture(captured =>
|
||||
{
|
||||
if (captured is not { } chord) return; // Escape — retail cancels silently.
|
||||
|
||||
switch (FindConflict(chord, exclude: view))
|
||||
{
|
||||
case ConflictKind.None:
|
||||
break;
|
||||
case ConflictKind.Row:
|
||||
// A real cross-row conflict — auto-reassign (register row: retail
|
||||
// confirms first via OpenOverwriteBindingDialog; this port narrows
|
||||
// to reassign-then-notify rather than a blocking modal).
|
||||
RowView conflictRow = _lastConflictRow!;
|
||||
ReplaceSlotValue(conflictRow, RemoveChord(conflictRow.Model.Current, chord));
|
||||
RefreshRowButtons(conflictRow);
|
||||
bindings.DisplaySystemMessage(bindings.NotifyReassigned(conflictRow.Label ?? "?"));
|
||||
break;
|
||||
case ConflictKind.NonBindable:
|
||||
// Bound to an acdream-only action with no DAT row at all (Ctrl+M
|
||||
// mute, the debug F-keys, ...) — this port's analogue of retail's
|
||||
// distinct "can't overwrite" refusal (OpenCantOverwriteBindingDialog).
|
||||
bindings.DisplaySystemMessage(bindings.NonBindableRefusalText);
|
||||
return;
|
||||
}
|
||||
|
||||
List<KeyChord> updated = new(view.Model.Current);
|
||||
while (updated.Count <= slot) updated.Add(default);
|
||||
updated[slot] = chord;
|
||||
ReplaceSlotValue(view, updated);
|
||||
RefreshRowButtons(view);
|
||||
});
|
||||
}
|
||||
|
||||
private void EraseSlot(RowView view, int slot)
|
||||
{
|
||||
if (slot >= view.Model.Current.Count) return;
|
||||
var updated = new List<KeyChord>(view.Model.Current);
|
||||
updated.RemoveAt(slot);
|
||||
ReplaceSlotValue(view, updated);
|
||||
RefreshRowButtons(view);
|
||||
}
|
||||
|
||||
private static void ReplaceSlotValue(RowView view, IReadOnlyList<KeyChord> value) =>
|
||||
view.Model.SetCurrentValue(value.Where(c => c != default).ToArray());
|
||||
|
||||
private static IReadOnlyList<KeyChord> RemoveChord(IReadOnlyList<KeyChord> from, KeyChord chord) =>
|
||||
from.Where(c => c != chord).ToArray();
|
||||
|
||||
private enum ConflictKind { None, Row, NonBindable }
|
||||
|
||||
// Set by FindConflict just before returning ConflictKind.Row — avoids a
|
||||
// second lookup pass at the call site. Single-threaded (UI thread only).
|
||||
private RowView? _lastConflictRow;
|
||||
|
||||
/// <summary>
|
||||
/// Retail's N-way, cross-input-map conflict scan (research doc §5.4:
|
||||
/// <c>ICIDM::FindConflictingInputMaps</c>/<c>FindConflictingControls</c>),
|
||||
/// scoped to this screen's own universe: every OTHER row's current chord set
|
||||
/// (covers BOTH mapped and unmapped rows — a chord already claimed by an
|
||||
/// unmapped row is just as real a conflict as one claimed by a mapped one),
|
||||
/// then the live <see cref="KeyBindings"/> table for an acdream-only action
|
||||
/// this screen has no row for at all.
|
||||
/// </summary>
|
||||
private ConflictKind FindConflict(KeyChord chord, RowView exclude)
|
||||
{
|
||||
_lastConflictRow = null;
|
||||
foreach (RowView other in _rows)
|
||||
{
|
||||
if (ReferenceEquals(other, exclude)) continue;
|
||||
if (!other.Model.Current.Contains(chord)) continue;
|
||||
_lastConflictRow = other;
|
||||
return ConflictKind.Row;
|
||||
}
|
||||
if (_bindings is null) return ConflictKind.None;
|
||||
foreach (InputAction candidate in Enum.GetValues<InputAction>())
|
||||
{
|
||||
if (RetailActionIdentityTable.Map.Values.Contains(candidate)) continue;
|
||||
if (_bindings.CurrentForAction(candidate).Contains(chord))
|
||||
return ConflictKind.NonBindable;
|
||||
}
|
||||
return ConflictKind.None;
|
||||
}
|
||||
|
||||
private static void WireScreenButtons(
|
||||
ImportedLayout layout, KeyboardConfigController controller, Bindings bindings)
|
||||
{
|
||||
// Load File / Save As — INERT (D4: keybinds.json only, no .keymap
|
||||
// interchange). Authored, clickable, no handler — same shape as OP3's
|
||||
// still-inert buttons.
|
||||
_ = layout.FindElement(LoadButtonId);
|
||||
_ = layout.FindElement(SaveAsButtonId);
|
||||
_ = layout.FindElement(FilenameLabelId);
|
||||
|
||||
if (layout.FindElement(DefaultsButtonId) is UiButton defaultsButton)
|
||||
defaultsButton.OnClick = () =>
|
||||
{
|
||||
foreach (RowView row in controller._rows)
|
||||
row.Model.SetDefaultValue(row.Model.DefaultValue);
|
||||
controller.Page.Defaults();
|
||||
foreach (RowView row in controller._rows)
|
||||
RefreshRowButtons(row);
|
||||
};
|
||||
|
||||
if (layout.FindElement(RevertButtonId) is UiButton revertButton)
|
||||
revertButton.OnClick = () =>
|
||||
{
|
||||
controller.Page.Reset();
|
||||
foreach (RowView row in controller._rows)
|
||||
RefreshRowButtons(row);
|
||||
};
|
||||
|
||||
// OK — right-click release in retail (idMessage 0x19); ported as a plain
|
||||
// left-click here, matching every other Campaign OP button (the asymmetry
|
||||
// is authored-input-only, not a behavior a user would notice — register
|
||||
// row if reviewed otherwise).
|
||||
if (layout.FindElement(OkButtonId) is UiButton okButton)
|
||||
okButton.OnClick = () =>
|
||||
{
|
||||
controller.Page.Apply();
|
||||
bindings.Save();
|
||||
bindings.Toggle();
|
||||
};
|
||||
|
||||
if (layout.FindElement(CancelButtonId) is UiButton cancelButton)
|
||||
cancelButton.OnClick = () =>
|
||||
{
|
||||
controller.Page.Reset();
|
||||
foreach (RowView row in controller._rows)
|
||||
RefreshRowButtons(row);
|
||||
bindings.Toggle();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AcDream.UI.Abstractions.Input;
|
||||
|
||||
namespace AcDream.App.UI.Layout;
|
||||
|
||||
|
|
@ -513,6 +514,79 @@ public sealed class BitfieldOptionRow : IOptionRow
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Campaign OP slice OP8: one Configure Keyboard row's current/saved/default
|
||||
/// triple — up to 3 <see cref="KeyChord"/> slots (<c>UIOption_ActionKeyMap</c>'s
|
||||
/// <c>m_qclCurrent</c>/<c>m_qclSaved</c>/<c>m_qclDefaults</c>, research doc §5.4).
|
||||
/// Unlike <see cref="BoolOptionRow"/>'s single scalar, <see cref="SetCurrentValue"/>
|
||||
/// here replaces the WHOLE slot list at once — the controller computes the new list
|
||||
/// (one slot rebound via capture, or one slot erased) and calls this with the
|
||||
/// result, mirroring retail's per-slot <c>SetBinding</c>/<c>EraseBinding</c> both
|
||||
/// funnelling through the same <c>UIOption::Apply(1)</c> live-write path.
|
||||
/// </summary>
|
||||
public sealed class ActionKeyMapOptionRow : IOptionRow
|
||||
{
|
||||
private readonly Action<IReadOnlyList<KeyChord>>? _apply;
|
||||
private Action? _notifyPageOptionChanged;
|
||||
private IReadOnlyList<KeyChord> _current;
|
||||
private IReadOnlyList<KeyChord> _saved;
|
||||
private IReadOnlyList<KeyChord> _default;
|
||||
|
||||
public ActionKeyMapOptionRow(
|
||||
IReadOnlyList<KeyChord> initial,
|
||||
IReadOnlyList<KeyChord> defaultValue,
|
||||
Action<IReadOnlyList<KeyChord>>? apply = null)
|
||||
{
|
||||
_current = initial;
|
||||
_saved = initial;
|
||||
_default = defaultValue;
|
||||
_apply = apply;
|
||||
}
|
||||
|
||||
/// <summary>The live slot list — what the row's key buttons currently show.</summary>
|
||||
public IReadOnlyList<KeyChord> Current => _current;
|
||||
|
||||
/// <summary>The committed baseline Revert/Cancel reverts to.</summary>
|
||||
public IReadOnlyList<KeyChord> Saved => _saved;
|
||||
|
||||
/// <summary>The DAT master-map default slot list Reset-to-Defaults restores.</summary>
|
||||
public IReadOnlyList<KeyChord> DefaultValue => _default;
|
||||
|
||||
public bool Changed => !_current.SequenceEqual(_saved);
|
||||
|
||||
/// <summary>Reset-to-Defaults reloads the DAT master maps fresh
|
||||
/// (<c>gmKeyboardUI::RestoreDefaultValues</c> — research doc §5.6) before
|
||||
/// restoring each row, so the default slot list itself can change between
|
||||
/// presses (a fresh DAT read), not just at construction time.</summary>
|
||||
public void SetDefaultValue(IReadOnlyList<KeyChord> value) => _default = value;
|
||||
|
||||
/// <summary>The capture/erase entry point — writes <c>m_current</c> and applies
|
||||
/// it live immediately (retail's per-slot <c>SetBinding</c>/<c>EraseBinding</c>,
|
||||
/// both ending in <c>Apply(1)</c>); does not touch <see cref="Saved"/>.</summary>
|
||||
public void SetCurrentValue(IReadOnlyList<KeyChord> value)
|
||||
{
|
||||
_current = value;
|
||||
_apply?.Invoke(value);
|
||||
_notifyPageOptionChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void AttachPageNotify(Action notify) => _notifyPageOptionChanged = notify;
|
||||
|
||||
public void SaveCurrentValue() => _saved = _current;
|
||||
|
||||
public void RestoreSavedValue()
|
||||
{
|
||||
_current = _saved;
|
||||
_apply?.Invoke(_current);
|
||||
}
|
||||
|
||||
public void RestoreDefaultValue()
|
||||
{
|
||||
_current = _default;
|
||||
_apply?.Invoke(_current);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retail <c>OptionPage</c>/<c>PlayerOptionPage</c>: a page's registered-option
|
||||
/// array plus the four verbs (Apply/Reset/Defaults/visibility) with retail's
|
||||
|
|
|
|||
|
|
@ -89,7 +89,11 @@ public sealed class OptionsPanelController : IRetainedPanelController
|
|||
Action ExitGame,
|
||||
Action UseMouseTurningSettings,
|
||||
Action<string> DisplaySystemMessage,
|
||||
Action? AfterApply = null)
|
||||
Action? AfterApply = null,
|
||||
// Campaign OP slice OP8: opens the Configure Keyboard screen — retires
|
||||
// OP3's INERT contract for this button (0x10000204). Null leaves the
|
||||
// button inert (e.g. a test harness with no keyboard screen wired).
|
||||
Action? OpenConfigureKeyboard = null)
|
||||
{
|
||||
/// <summary>Urgent Assistance's own byte-verified retail failure text.</summary>
|
||||
public string UrgentAssistanceMessage { get; init; } =
|
||||
|
|
@ -190,9 +194,9 @@ public sealed class OptionsPanelController : IRetainedPanelController
|
|||
+ "not found in the built layout — its handler was not wired.");
|
||||
|
||||
BindButton(layout, ExitToCharacterSelectionId, callbacks.RequestExitToCharacterSelection);
|
||||
// ConfigureKeyboardId: INERT this slice — authored, clickable, no
|
||||
// handler. OP8 wires the real Configure Keyboard screen; the campaign
|
||||
// cannot close with this button still inert (plan §4 OP3).
|
||||
// ConfigureKeyboardId: Campaign OP slice OP8 wires the real Configure
|
||||
// Keyboard screen — the OP3 INERT contract is retired.
|
||||
BindButton(layout, ConfigureKeyboardId, callbacks.OpenConfigureKeyboard);
|
||||
// InGameHelpFilesId: INERT — retail's own KeyStone::OpenHelp fails
|
||||
// without the missing plugins\ACHelpPlugin.dll (D5, register row).
|
||||
BindButton(layout, UseMouseTurningSettingsId, callbacks.UseMouseTurningSettings);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ using AcDream.Core.Selection;
|
|||
using AcDream.Core.Spells;
|
||||
using AcDream.Runtime.Gameplay;
|
||||
using AcDream.Content;
|
||||
using AcDream.Core.Input;
|
||||
using AcDream.UI.Abstractions;
|
||||
using AcDream.UI.Abstractions.Panels.Chat;
|
||||
using AcDream.UI.Abstractions.Panels.Settings;
|
||||
|
|
@ -283,6 +284,19 @@ public sealed record VendorRuntimeBindings(
|
|||
// own DisplaySystemMessage already uses.
|
||||
Action<string>? DisplaySystemMessage = null);
|
||||
|
||||
/// <summary>
|
||||
/// Campaign OP slice OP8: the Configure Keyboard screen's live read/write seam —
|
||||
/// the ONE live <see cref="InputDispatcher"/> (Bindings for reads,
|
||||
/// SetBindings+BeginCapture for writes/capture) plus the portable
|
||||
/// <c>keybinds.json</c> path (D4 — no <c>.keymap</c> file interchange). Null
|
||||
/// <see cref="Dispatcher"/> (headless/no-window hosts, or before the graphical
|
||||
/// input stack finishes constructing) degrades to "Configure Keyboard has no
|
||||
/// live effect" exactly like every other null-dependency Options-panel seam.
|
||||
/// </summary>
|
||||
public sealed record KeyboardRuntimeBindings(
|
||||
InputDispatcher? Dispatcher,
|
||||
string KeyBindingsFilePath);
|
||||
|
||||
public sealed record RetailUiRuntimeBindings(
|
||||
UiHost Host,
|
||||
RetailUiAssets Assets,
|
||||
|
|
@ -307,7 +321,8 @@ public sealed record RetailUiRuntimeBindings(
|
|||
StackSplitQuantityState StackSplitQuantity,
|
||||
BufferedUiRegistry? Plugins,
|
||||
RetailUiPersistenceBindings? Persistence,
|
||||
RetailUiProbeBindings Probe);
|
||||
RetailUiProbeBindings Probe,
|
||||
KeyboardRuntimeBindings? Keyboard = null);
|
||||
|
||||
/// <summary>
|
||||
/// Composition owner for the production retained gameplay UI. GameWindow supplies
|
||||
|
|
@ -383,6 +398,7 @@ public sealed class RetailUiRuntime : IDisposable
|
|||
MountEffects();
|
||||
MountIndicatorDetailPanels();
|
||||
MountOptionsPanel();
|
||||
MountKeyboardConfig();
|
||||
MountIndicators();
|
||||
MountJumpPowerbar();
|
||||
MountDialogFactory();
|
||||
|
|
@ -2042,7 +2058,8 @@ public sealed class RetailUiRuntime : IDisposable
|
|||
UseMouseTurningSettings: ApplyMouseTurningSettingsMacro,
|
||||
DisplaySystemMessage: _bindings.Options.DisplaySystemMessage,
|
||||
AfterApply: () => _bindings.Options.CommandBus().Publish(
|
||||
new SaveCharacterOptionsRuntimeCmd()));
|
||||
new SaveCharacterOptionsRuntimeCmd()),
|
||||
OpenConfigureKeyboard: () => ToggleWindow(WindowNames.KeyboardConfig));
|
||||
|
||||
Layout.OptionsPanelController? controller =
|
||||
Layout.OptionsPanelController.Bind(layout, callbacks);
|
||||
|
|
@ -2238,6 +2255,161 @@ public sealed class RetailUiRuntime : IDisposable
|
|||
Console.WriteLine("[UI] retail Options panel from LayoutDesc importer (0x2100006E slot 0x1000018D).");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Campaign OP slice OP8: retail's Configure Keyboard screen
|
||||
/// (<c>gmKeyboardUI</c>, LayoutDesc <c>0x21000009</c>) — its own separate
|
||||
/// full-screen window, distinct from the four-tab Options panel's
|
||||
/// <c>gmPanelUI</c> mutual-exclusion group (research doc structure lane
|
||||
/// §8). Skips cleanly (no window, INERT button stays inert) when
|
||||
/// <see cref="RetailUiRuntimeBindings.Keyboard"/> is null — a no-window
|
||||
/// host or an App composition that hasn't wired the input dispatcher yet.
|
||||
/// </summary>
|
||||
private void MountKeyboardConfig()
|
||||
{
|
||||
KeyboardRuntimeBindings? keyboard = _bindings.Keyboard;
|
||||
if (keyboard is null || keyboard.Dispatcher is null)
|
||||
{
|
||||
Console.WriteLine(
|
||||
"[UI] keyboard config: no InputDispatcher wired — Configure Keyboard "
|
||||
+ "screen will not open (button stays inert).");
|
||||
return;
|
||||
}
|
||||
InputDispatcher dispatcher = keyboard.Dispatcher;
|
||||
|
||||
ElementInfo? info;
|
||||
ImportedLayout? layout;
|
||||
RetailActionMapSnapshot? snapshot;
|
||||
DatStringResolver strings;
|
||||
lock (_bindings.Assets.DatLock)
|
||||
{
|
||||
info = LayoutImporter.ImportInfos(_bindings.Assets.Dats, Layout.KeyboardConfigController.LayoutId);
|
||||
layout = info is null
|
||||
? null
|
||||
: LayoutImporter.Build(
|
||||
info,
|
||||
_bindings.Assets.ResolveSprite,
|
||||
_bindings.Assets.DefaultFont,
|
||||
_bindings.Assets.ResolveFont);
|
||||
snapshot = RetailActionMapReader.Read(_bindings.Assets.Dats);
|
||||
strings = new DatStringResolver(_bindings.Assets.Dats);
|
||||
}
|
||||
if (layout is null || snapshot is null)
|
||||
{
|
||||
Console.WriteLine(
|
||||
"[UI] keyboard config: LayoutDesc 0x21000009 or the DAT ActionMap "
|
||||
+ "singleton (0x26000000) not found — Configure Keyboard will not open.");
|
||||
return;
|
||||
}
|
||||
|
||||
string unmappedPath = UnmappedKeyBindingsPath(keyboard.KeyBindingsFilePath);
|
||||
var unmapped = RetailUnmappedKeyBindings.LoadOrEmpty(unmappedPath);
|
||||
|
||||
// ID_KeyMapCantOverwriteReadOnlyKeymap_Label — table 0x23000004, byte-
|
||||
// verified 2026-08-11 (live probe): "Could not overwrite ". Falls back
|
||||
// to silence (no invented English) if the DAT string is ever missing.
|
||||
string? refusalText = strings.Resolve(
|
||||
0x23000004u, DatStringResolver.ComputeHash("ID_KeyMapCantOverwriteReadOnlyKeymap_Label"));
|
||||
|
||||
Layout.KeyboardConfigController? controller = Layout.KeyboardConfigController.Bind(
|
||||
layout,
|
||||
snapshot,
|
||||
templateResolver: (templateLayoutId, templateElementId) =>
|
||||
{
|
||||
lock (_bindings.Assets.DatLock)
|
||||
{
|
||||
ElementInfo? templateInfo = LayoutImporter.ImportInfos(
|
||||
_bindings.Assets.Dats, templateLayoutId, templateElementId);
|
||||
return templateInfo is null
|
||||
? null
|
||||
: LayoutImporter.Build(
|
||||
templateInfo,
|
||||
_bindings.Assets.ResolveSprite,
|
||||
_bindings.Assets.DefaultFont,
|
||||
_bindings.Assets.ResolveFont,
|
||||
strings.Resolve).Root;
|
||||
}
|
||||
},
|
||||
resolveString: (tableId, stringId) => strings.Resolve(tableId, stringId),
|
||||
new Layout.KeyboardConfigController.Bindings(
|
||||
CurrentForAction: action => dispatcher.Bindings.ForAction(action)
|
||||
.Select(b => b.Chord).ToArray(),
|
||||
SetForAction: (action, chords) =>
|
||||
{
|
||||
KeyBindings updated = CloneWithout(dispatcher.Bindings, action);
|
||||
foreach (KeyChord chord in chords)
|
||||
updated.Add(new Binding(chord, action));
|
||||
dispatcher.SetBindings(updated);
|
||||
},
|
||||
CurrentForUnmapped: key => unmapped.Get(key.InputMapId, key.ActionId),
|
||||
SetForUnmapped: (key, chords) => unmapped.Set(key.InputMapId, key.ActionId, chords),
|
||||
BeginCapture: onResult => dispatcher.BeginCapture(
|
||||
chord => onResult(chord == default ? null : chord)),
|
||||
Save: () =>
|
||||
{
|
||||
dispatcher.Bindings.SaveToFile(keyboard.KeyBindingsFilePath);
|
||||
unmapped.SaveToFile(unmappedPath);
|
||||
},
|
||||
Toggle: () => ToggleWindow(WindowNames.KeyboardConfig),
|
||||
DisplaySystemMessage: text =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(text)) _bindings.Options.DisplaySystemMessage(text);
|
||||
},
|
||||
NonBindableRefusalText: refusalText ?? string.Empty,
|
||||
// No retail string exists for "binding reassigned" — retail's
|
||||
// own flow only shows the confirm-before-reassign dialog
|
||||
// (research doc §5.4's OpenOverwriteBindingDialog), never a
|
||||
// post-reassign notice. This port's auto-reassign (register
|
||||
// row) stays silent rather than inventing English for a
|
||||
// message retail never had.
|
||||
NotifyReassigned: _ => string.Empty));
|
||||
|
||||
if (controller is null)
|
||||
{
|
||||
Console.WriteLine("[UI] keyboard config: required window root did not build.");
|
||||
return;
|
||||
}
|
||||
|
||||
KeyboardConfigController = controller;
|
||||
UiElement root = layout.Root;
|
||||
RetailWindowFrame.Mount(
|
||||
Host.Root,
|
||||
root,
|
||||
_bindings.Assets.ResolveSprite,
|
||||
new RetailWindowFrame.Options
|
||||
{
|
||||
WindowName = WindowNames.KeyboardConfig,
|
||||
Chrome = RetailWindowChrome.Imported,
|
||||
Left = Math.Max(0f, (Host.Root.Width - root.Width) * 0.5f),
|
||||
Top = Math.Max(0f, (Host.Root.Height - root.Height) * 0.5f),
|
||||
Visible = false,
|
||||
DatConstraintSource = info,
|
||||
ContentClickThrough = false,
|
||||
});
|
||||
Console.WriteLine("[UI] retail Configure Keyboard screen from gmKeyboardUI LayoutDesc 0x21000009.");
|
||||
}
|
||||
|
||||
private static string UnmappedKeyBindingsPath(string keyBindingsFilePath)
|
||||
{
|
||||
string? dir = System.IO.Path.GetDirectoryName(keyBindingsFilePath);
|
||||
string name = System.IO.Path.GetFileNameWithoutExtension(keyBindingsFilePath);
|
||||
string ext = System.IO.Path.GetExtension(keyBindingsFilePath);
|
||||
string sibling = $"{name}-unmapped{ext}";
|
||||
return string.IsNullOrEmpty(dir) ? sibling : System.IO.Path.Combine(dir, sibling);
|
||||
}
|
||||
|
||||
private static KeyBindings CloneWithout(KeyBindings source, InputAction action)
|
||||
{
|
||||
var result = new KeyBindings();
|
||||
foreach (Binding b in source.All)
|
||||
if (b.Action != action) result.Add(b);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>The mounted Configure Keyboard screen's controller — null until
|
||||
/// <see cref="MountKeyboardConfig"/> runs (or if it degraded — see that
|
||||
/// method's null-dependency guards).</summary>
|
||||
public Layout.KeyboardConfigController? KeyboardConfigController { get; private set; }
|
||||
|
||||
private void MountJumpPowerbar()
|
||||
{
|
||||
ElementInfo? info;
|
||||
|
|
|
|||
|
|
@ -49,6 +49,15 @@ public sealed class UiButton : UiElement, IUiGlobalTimeListener, IUiDatStateful
|
|||
/// <summary>Optional click handler. Wired by the controller (e.g. chat Submit, ToggleMaximize).</summary>
|
||||
public Action? OnClick { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional right-click handler (Campaign OP slice OP8's Configure Keyboard
|
||||
/// screen: right-click a bound key button to erase that one binding —
|
||||
/// <c>UIOption_ActionKeyMap::EraseBinding @0x00487780</c>). Null by default,
|
||||
/// so every pre-existing <see cref="UiButton"/> is unaffected — this only adds
|
||||
/// a new optional event, it does not change any existing click/drag behavior.
|
||||
/// </summary>
|
||||
public Action? OnRightClick { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional pointer transition handlers. These expose retail's distinct
|
||||
/// pressed/released element messages for controls such as the combat-height
|
||||
|
|
@ -518,6 +527,10 @@ public sealed class UiButton : UiElement, IUiGlobalTimeListener, IUiDatStateful
|
|||
OnClick?.Invoke();
|
||||
OnClickAt?.Invoke(e.Data1, e.Data2);
|
||||
return OnClick is not null || OnClickAt is not null;
|
||||
case UiEventType.RightClick:
|
||||
if (!Enabled) return true;
|
||||
OnRightClick?.Invoke();
|
||||
return OnRightClick is not null;
|
||||
case UiEventType.DragEnter:
|
||||
_itemDragAcceptance = e.Payload is ItemDragPayload payload
|
||||
? OnItemDragOver?.Invoke(payload) ?? ItemDragAcceptance.None
|
||||
|
|
|
|||
|
|
@ -28,4 +28,5 @@ public static class WindowNames
|
|||
public const string Examination = "examination";
|
||||
public const string Vendor = "vendor";
|
||||
public const string Options = "options";
|
||||
public const string KeyboardConfig = "keyboard-config";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue