fix(ui,net): Campaign LA gate round 2 — char-select exit confirmation, authored row justify, world name

Finding 1 (Exit button dead): retail's gmCharacterManagementUI Exit
button (element 0x100003A4, offset 7 from the listbox base in
ListenToElementMessage@0x004ed5a0) opens MakeConfirmExitDialog
(0x004ed250), whose exact ID_CharacterManagement_ConfirmExit text
(table 0x23000002) and m_confirmExitDialogContext re-entry guard are
now ported. On confirm (matching RecvNotice_CloseDialog@0x004ed760
case 1's ConfirmationResult check) the client exits through the
EXISTING graceful window-close seam (CharacterSelectionRuntimeBindings
.RequestExit -> d.Window.Close, the same delegate
GameplayInputCommandController's Escape fallback already uses) so
disconnected/exited status events still fire via GameWindow.OnClosing
-> CompleteShutdown. Retail's real post-confirm destination is
QueueUIMode(0x10000009) -> gmEpilogueUI, an epilogue screen this round
does not port — recorded as AD-99. Credits (element 0x100003A3,
QueueUIMode(0x10000005) -> gmCreditsUI) stays visibly ghosted like
Create, same treatment, out of scope this round.

Finding 2 (row names center-aligned, retail is left): the character
row template (LayoutDesc 0x21000004, element 0x100003A5, live-DAT
confirmed HJustify=Left with three stateful Type-3 highlight-art
children and no Type-12 caption child) authors its OWN justify
directly, with no separate text child to lift a label from.
DatWidgetFactory.BuildButton's Left-justify branch required
!ReferenceEquals(labelInfo, info) — true only when a label was LIFTED
from a distinct child — so a button's own direct HJustify=Left was
silently dropped to UiButton's Center default. Widened the branch to
also honor the direct case, preserving the existing lifted-child
LabelOffsetX behavior and leaving genuinely-centered buttons
(CREATE/ENTER/DELETE/RESTORE) untouched.

Finding 3 (World box empty): parsed ACE's GameMessageServerName
(opcode 0xF7E1, ACE.Server/Network/GameMessages/Messages/
GameMessageServerName.cs; retail CM_Login::DispatchUI_WorldInfo
@0x006ad860 -> ClientUISystem::Handle_Login__WorldInfo@0x005641a0 ->
ECM_Login::SendNotice_WorldName@0x00692b10, notice 0x186a2, consumed
by gmCharacterManagementUI::UpdateWorldName@0x004ec120 /
RecvNotice_WorldName@0x004ec360 onto element 0x1000039B) as
src/AcDream.Core.Net/Messages/ServerName.cs, cross-checked against
holtburger's ServerNameData. WorldSession.ServerNameReceived fires
alongside CharacterListReceived (ACE sends both in one
SendConnectResponse batch); RuntimeCharacterSelectionState.
ApplyWorldName is the new J-owner field (ungated by lifecycle, since
either message can arrive first); CharacterManagementUiController
binds it onto the WorldTextElementId UiText. Per the LA1 status
vocabulary, the characterList STATUS event's worldName field is
intentionally NOT added this round (kept bounded to the client-side
fix) — a follow-up if the launcher UI wants it.

Also corrects AD-44, discovered stale while filing AD-99: its opening
claim ("acdream has no retained character-management screen") was
false as of this session — LA7/LA8 shipped the screen in earlier
commits without updating this row.

Tests: exit-confirm open/cancel/confirm/re-entry-guard flow;
DatWidgetFactory own-HJustify-Left/Center regression tests plus the
live-DAT pinned row-justify assertion; ServerName parse round-trip
(byte-exact vs ACE's AceWireWriter fixture, truncation/wrong-opcode
cases); WorldSession dispatch test (roster+world in one wire batch);
RuntimeCharacterSelectionState.ApplyWorldName tests (order-independent
of ApplyRoster, unchanged-value no-op, Reset clears); controller test
binding the World text element to the live snapshot. Extended the
shared RetailDialogFactoryTests.BuildDialogLayout test fixture with a
Confirmation-type branch (Accept/Reject buttons) since this is its
first RetailDialogType.Confirmation consumer.

Suites: full solution Release build green; AcDream.App.Tests 5100/6
skips, AcDream.Core.Net.Tests 965/0, AcDream.Runtime.Tests 1665/0, all
Release, 0 failures; live-DAT probes (ACDREAM_PROBE_LIVE_MOUNT=1)
green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-15 11:50:45 +02:00
parent 308f40a3fb
commit ef96c55489
18 changed files with 724 additions and 13 deletions

View file

@ -13,25 +13,46 @@ internal sealed class CharacterManagementUiController : IDisposable
{
internal const uint RootEnum = 0x10000005u;
internal const uint RootElementId = 0x1000039Au;
internal const uint WorldTextElementId = 0x1000039Bu;
internal const uint ListElementId = 0x1000039Du;
internal const uint CreateElementId = 0x100003A0u;
internal const uint EnterElementId = 0x100003A2u;
internal const uint DeleteElementId = 0x1000039Fu;
internal const uint RestoreElementId = 0x1000039Eu;
/// <summary>
/// gmCharacterManagementUI::ListenToElementMessage@0x004ed5a0's element-id
/// switch is keyed off <c>idElement - 0x1000039d</c> (the listbox base);
/// offset 6 -> QueueUIMode(0x10000005), the mode gmCreditsUI registers
/// (Register@0x0047a69e) — out of scope this round (finding 1 note).
/// </summary>
internal const uint CreditsElementId = 0x100003A3u;
/// <summary>Offset 7 from the listbox base -> MakeConfirmExitDialog@0x004ed250.</summary>
internal const uint ExitElementId = 0x100003A4u;
internal sealed record DialogStrings(
Func<string, string> DeleteConfirmation,
string DeleteResponse,
string PleaseWait,
string EnteringWorld);
string EnteringWorld,
/// <summary>
/// Retail <c>ID_CharacterManagement_ConfirmExit</c> (table
/// <c>0x23000002</c>) — "Are you sure you want to leave?", the text
/// <c>MakeConfirmExitDialog@0x004ed250</c> resolves via
/// <c>StringInfo::SetStringIDandTableEnum(compute_str_hash(
/// "ID_CharacterManagement_ConfirmExit"), 0x10000002)</c>.
/// </summary>
string ConfirmExit);
private readonly UiRoot _host;
private readonly ImportedLayout _layout;
private readonly UiText _worldText;
private readonly UiTemplateListBox _list;
private readonly UiButton _create;
private readonly UiButton _enter;
private readonly UiButton _delete;
private readonly UiButton _restore;
private readonly UiButton _credits;
private readonly UiButton _exit;
private readonly RetailDialogFactory _dialogs;
private readonly CharacterSelectionRuntimeBindings _bindings;
private readonly DialogStrings _strings;
@ -41,10 +62,12 @@ internal sealed class CharacterManagementUiController : IDisposable
private Vector2 _authoredCanvas;
private RuntimeGenerationToken _lastGeneration;
private long _lastRevision = long.MinValue;
private string _lastWorldName = string.Empty;
private uint _deleteDialogContext;
private uint _operationWaitContext;
private uint _enterWaitContext;
private uint _errorDialogContext;
private uint _confirmExitDialogContext;
private bool _active;
private bool _restoreCommandInFlight;
private bool _suppressDialogCallbacks;
@ -53,22 +76,28 @@ internal sealed class CharacterManagementUiController : IDisposable
private CharacterManagementUiController(
UiRoot host,
ImportedLayout layout,
UiText worldText,
UiTemplateListBox list,
UiButton create,
UiButton enter,
UiButton delete,
UiButton restore,
UiButton credits,
UiButton exit,
RetailDialogFactory dialogs,
CharacterSelectionRuntimeBindings bindings,
DialogStrings strings)
{
_host = host;
_layout = layout;
_worldText = worldText;
_list = list;
_create = create;
_enter = enter;
_delete = delete;
_restore = restore;
_credits = credits;
_exit = exit;
_dialogs = dialogs;
_bindings = bindings;
_strings = strings;
@ -101,6 +130,22 @@ internal sealed class CharacterManagementUiController : IDisposable
_enter.OnClick = EnterSelected;
_delete.OnClick = RequestDelete;
_restore.OnClick = RestoreSelected;
// Credits (retail QueueUIMode(0x10000005) -> gmCreditsUI) is out of
// scope this round (finding 1 note) — same "future campaign, visibly
// ghosted, no invented action" treatment as Create above. Filed as
// issue #397.
_credits.Visible = true;
_credits.Enabled = false;
_credits.OnClick = null;
_exit.OnClick = RequestExit;
// World name (retail UpdateWorldName@0x004ec120 /
// RecvNotice_WorldName@0x004ec360 both just push
// Client::GetWorldName() onto this element). LinesProvider reads the
// live field Tick() updates each time Runtime's snapshot changes.
_worldText.LinesProvider =
() => [new UiText.Line(_lastWorldName, _worldText.DefaultColor)];
}
internal UiElement Root => _layout.Root;
@ -109,6 +154,7 @@ internal sealed class CharacterManagementUiController : IDisposable
internal uint OperationWaitContext => _operationWaitContext;
internal uint EnterWaitContext => _enterWaitContext;
internal uint ErrorDialogContext => _errorDialogContext;
internal uint ConfirmExitDialogContext => _confirmExitDialogContext;
internal void ResetSession()
{
@ -171,11 +217,14 @@ internal sealed class CharacterManagementUiController : IDisposable
}
if (layout.Root.DatElementId != RootElementId
|| layout.FindElement(WorldTextElementId) is not UiText worldText
|| layout.FindElement(ListElementId) is not UiTemplateListBox list
|| layout.FindElement(CreateElementId) is not UiButton create
|| layout.FindElement(EnterElementId) is not UiButton enter
|| layout.FindElement(DeleteElementId) is not UiButton delete
|| layout.FindElement(RestoreElementId) is not UiButton restore)
|| layout.FindElement(RestoreElementId) is not UiButton restore
|| layout.FindElement(CreditsElementId) is not UiButton credits
|| layout.FindElement(ExitElementId) is not UiButton exit)
{
Console.WriteLine(
"[UI] character management: the authored root/list/button contract is incomplete.");
@ -188,11 +237,14 @@ internal sealed class CharacterManagementUiController : IDisposable
return new CharacterManagementUiController(
host,
layout,
worldText,
list,
create,
enter,
delete,
restore,
credits,
exit,
dialogs,
bindings,
strings);
@ -204,6 +256,7 @@ internal sealed class CharacterManagementUiController : IDisposable
enter.OnClick = null;
delete.OnClick = null;
restore.OnClick = null;
exit.OnClick = null;
throw;
}
}
@ -249,6 +302,11 @@ internal sealed class CharacterManagementUiController : IDisposable
_host.BringToFront(Root);
}
// World name rides independently of the roster revision gate below —
// ServerName can arrive slightly before or after CharacterList (see
// RuntimeCharacterSelectionState.ApplyWorldName).
_lastWorldName = snapshot.WorldName;
if (_lastGeneration != snapshot.Generation
|| _lastRevision != snapshot.Revision)
{
@ -314,6 +372,7 @@ internal sealed class CharacterManagementUiController : IDisposable
_enter.OnClick = null;
_delete.OnClick = null;
_restore.OnClick = null;
_exit.OnClick = null;
foreach (UiButton row in _rows)
{
row.OnClick = null;
@ -550,6 +609,33 @@ internal sealed class CharacterManagementUiController : IDisposable
InvalidateAndTick();
}
private void RequestExit()
{
if (_disposed)
return;
// MakeConfirmExitDialog @ 0x004ed250's own guard: a second Exit
// click while the confirmation is already open is a no-op.
if (_confirmExitDialogContext != 0u)
return;
_confirmExitDialogContext = _dialogs.MakeConfirmation(
_strings.ConfirmExit,
data =>
{
_confirmExitDialogContext = 0u;
if (_disposed || _suppressDialogCallbacks)
return;
// RecvNotice_CloseDialog @ 0x004ed760 case 1: only a
// confirmed (OK) close proceeds through the SAME graceful
// shutdown path window-close uses; Cancel leaves the screen
// exactly as it was.
if (data.GetBoolean(RetailDialogProperty.ConfirmationResult))
_bindings.RequestExit();
});
}
private void ReconcileDialogs(
IRuntimeCharacterSelectionView view,
RuntimeCharacterSelectionSnapshot snapshot)
@ -689,6 +775,7 @@ internal sealed class CharacterManagementUiController : IDisposable
CloseContext(ref _operationWaitContext, suppressCallback: false);
CloseContext(ref _enterWaitContext, suppressCallback: false);
CloseContext(ref _errorDialogContext, suppressCallback: false);
CloseContext(ref _confirmExitDialogContext, suppressCallback: false);
}
finally
{

View file

@ -881,10 +881,24 @@ public static class DatWidgetFactory
button.LabelAlign = UiButton.LabelAlignment.Left;
button.LabelOffsetX = face.X + face.Width + 4f;
}
else if (!ReferenceEquals(labelInfo, info) && labelInfo.HJustify == HJustify.Left)
else if (labelInfo.HJustify == HJustify.Left)
{
// Campaign LA gate round 2 finding 2: the guard used to require
// labelInfo to be a LIFTED Type-12 text child (!ReferenceEquals),
// so a button authoring its OWN HJustify=Left with no separate
// label child — e.g. gmCharacterManagementUI's character-list row
// template (0x21000004/0x100003A5: HJustify=Left, three stateful
// Type-3 highlight-art children, no Type-12 caption child) — fell
// through with LabelAlign left at UiButton's Center default.
// Live-DAT probe confirmed: rowInfo.HJustify=Left,
// authoredFaces.Length=3 (faceSegments, not a single face), no
// Type-12 child, and the built row's LabelAlign came out Center.
// labelInfo.X is only a valid inner-offset when a distinct child
// was actually lifted; for the direct (labelInfo == info) case,
// leave UiButton's own default 3px LabelOffsetX in place.
button.LabelAlign = UiButton.LabelAlignment.Left;
button.LabelOffsetX = labelInfo.X;
if (!ReferenceEquals(labelInfo, info))
button.LabelOffsetX = labelInfo.X;
}
return button;

View file

@ -376,6 +376,20 @@ public sealed record KeyboardRuntimeBindings(
/// mirror; an absent view means the current adapter has not bound (or has
/// already been released).
/// </summary>
/// <param name="RequestExit">
/// Campaign LA gate round 2 finding 1: retail's Exit button
/// (<c>gmCharacterManagementUI::ListenToElementMessage@0x004ed5a0</c>,
/// element offset 7 from the listbox base — id <c>0x100003A4</c>) opens
/// <c>MakeConfirmExitDialog@0x004ed250</c>; on confirm
/// (<c>RecvNotice_CloseDialog@0x004ed760</c> case 1) retail queues UI mode
/// <c>0x10000009</c> (<c>gmEpilogueUI</c>) rather than exiting immediately —
/// out of scope here. This is a plain host action, not a generation-gated
/// Runtime command: it is the SAME window-close path
/// <c>GameplayWindowCommands</c>/<c>IGameplayWindowCommands.Close</c> already
/// use for the in-world Escape fallback (<c>d.Window.Close</c> at
/// composition), so status events <c>disconnected</c>/<c>exited</c> still
/// fire through <c>GameWindow.OnClosing</c> → <c>CompleteShutdown</c>.
/// </param>
public sealed record CharacterSelectionRuntimeBindings(
Func<IRuntimeCharacterSelectionView?> View,
Func<uint, RuntimeCommandResult> Highlight,
@ -383,7 +397,8 @@ public sealed record CharacterSelectionRuntimeBindings(
Func<RuntimeCommandResult> RequestDelete,
Func<RuntimeCommandResult> ConfirmDelete,
Func<RuntimeCommandResult> Restore,
Func<RuntimeCommandResult> Cancel);
Func<RuntimeCommandResult> Cancel,
Action RequestExit);
public sealed record RetailUiRuntimeBindings(
UiHost Host,
@ -3766,6 +3781,7 @@ public sealed class RetailUiRuntime : IDisposable
string? deleteConfirmationProbe;
string? pleaseWait;
string? enteringWorld;
string? confirmExit;
lock (_bindings.Assets.DatLock)
{
deleteConfirmationProbe = strings.ResolveTemplate(
@ -3787,12 +3803,21 @@ public sealed class RetailUiRuntime : IDisposable
strings,
stringTableId,
"ID_Character_EnteringWorld");
// Finding 1: MakeConfirmExitDialog@0x004ed250 resolves this via
// compute_str_hash("ID_CharacterManagement_ConfirmExit") against
// the same table-enum-0x10000002 -> 0x23000002 the other
// character-management dialogs already use.
confirmExit = ResolveCharacterManagementString(
strings,
stringTableId,
"ID_CharacterManagement_ConfirmExit");
}
if (deleteConfirmationProbe is null
|| deleteResponse is null
|| pleaseWait is null
|| enteringWorld is null)
|| enteringWorld is null
|| confirmExit is null)
{
Console.WriteLine(
"[UI] character management: required retail strings are unavailable.");
@ -3835,7 +3860,8 @@ public sealed class RetailUiRuntime : IDisposable
ComposeDeleteConfirmation,
deleteResponse,
pleaseWait,
enteringWorld));
enteringWorld,
confirmExit));
}
private static string? ResolveCharacterManagementString(