feat(ui): port retail radar and compass
This commit is contained in:
parent
c4af181b92
commit
3cbe4b00a1
43 changed files with 2882 additions and 262 deletions
|
|
@ -760,6 +760,11 @@ public sealed class GameWindow : IDisposable
|
|||
private AcDream.App.UI.ItemInteractionController? _itemInteractionController;
|
||||
// Phase D.5.3a — selected-object strip controller (name, overlay state, health meter).
|
||||
private AcDream.App.UI.Layout.SelectedObjectController? _selectedObjectController;
|
||||
// Phase D.6 — retail gmRadarUI (LayoutDesc 0x21000074). Behavior lives in
|
||||
// Core + the retained controller; GameWindow supplies live state only.
|
||||
private AcDream.App.UI.Layout.RadarController? _radarController;
|
||||
private AcDream.App.UI.Layout.RadarSnapshotProvider? _radarSnapshotProvider;
|
||||
private AcDream.App.UI.UiRadar? _radarRoot;
|
||||
// Phase D.2b-B — inventory controller (backpack grid + pack-selector + burden meter).
|
||||
private AcDream.App.UI.Layout.InventoryController? _inventoryController;
|
||||
// Phase D.2b Sub-phase C — paperdoll equip-slot controller (wield drag handler).
|
||||
|
|
@ -1738,6 +1743,11 @@ public sealed class GameWindow : IDisposable
|
|||
try
|
||||
{
|
||||
settingsStore.SaveGameplay(gameplay);
|
||||
// Runtime consumers (including retained gmRadarUI) read
|
||||
// the live persisted snapshot, not SettingsVM's draft.
|
||||
_persistedGameplay = gameplay;
|
||||
if (_uiHost is not null)
|
||||
_uiHost.Root.UiLocked = gameplay.LockUI;
|
||||
Console.WriteLine(
|
||||
"settings: gameplay saved to "
|
||||
+ AcDream.UI.Abstractions.Panels.Settings.SettingsStore.DefaultPath());
|
||||
|
|
@ -1998,6 +2008,7 @@ public sealed class GameWindow : IDisposable
|
|||
{
|
||||
_vitalsVm ??= new AcDream.UI.Abstractions.Panels.Vitals.VitalsVM(Combat, LocalPlayer);
|
||||
_uiHost = new AcDream.App.UI.UiHost(_gl, shadersDir, _debugFont);
|
||||
_uiHost.Root.UiLocked = _persistedGameplay.LockUI;
|
||||
_itemInteractionController = new AcDream.App.UI.ItemInteractionController(
|
||||
Objects,
|
||||
playerGuid: () => _playerServerGuid,
|
||||
|
|
@ -2025,6 +2036,7 @@ public sealed class GameWindow : IDisposable
|
|||
sendRaiseSkill: (statId, cost) => _liveSession?.SendRaiseSkill(statId, cost),
|
||||
sendTrainSkill: (statId, credits) => _liveSession?.SendTrainSkill(statId, credits));
|
||||
_uiHost.Root.DragReleasedOutsideUi += OnUiDragReleasedOutside;
|
||||
_uiHost.Root.WindowMoved += OnRetailWindowMoved;
|
||||
|
||||
// Feed Silk input to the UiRoot tree so windows drag / close / select.
|
||||
// UiRoot consumes UI events; the game InputDispatcher (subscribed to the
|
||||
|
|
@ -2110,6 +2122,52 @@ public sealed class GameWindow : IDisposable
|
|||
Console.WriteLine("[D.2b] vitals: LayoutDesc 0x2100006C not found — vitals unavailable.");
|
||||
}
|
||||
|
||||
// Phase D.6 — retail gmRadarUI. The importer owns the exact static
|
||||
// LayoutDesc 0x21000074 shell; RadarController owns retained behavior;
|
||||
// RadarSnapshotProvider is the thin live-world adapter.
|
||||
AcDream.App.UI.Layout.ImportedLayout? radarLayout;
|
||||
lock (_datLock)
|
||||
radarLayout = AcDream.App.UI.Layout.LayoutImporter.Import(
|
||||
_dats!, AcDream.App.UI.Layout.RadarController.LayoutId,
|
||||
ResolveChrome, vitalsDatFont, ResolveDatFont);
|
||||
if (radarLayout is not null && radarLayout.Root is AcDream.App.UI.UiRadar radarRoot)
|
||||
{
|
||||
_radarRoot = radarRoot;
|
||||
_radarSnapshotProvider = new AcDream.App.UI.Layout.RadarSnapshotProvider(
|
||||
Objects,
|
||||
_entitiesByServerGuid,
|
||||
_lastSpawnByGuid,
|
||||
playerGuid: () => _playerServerGuid,
|
||||
playerYawRadians: () => _playerController?.Yaw ?? 0f,
|
||||
playerCellId: () => _playerController?.CellId ?? 0u,
|
||||
selectedGuid: () => _selectedGuid,
|
||||
coordinatesOnRadar: () => _persistedGameplay.CoordinatesOnRadar,
|
||||
uiLocked: () => _persistedGameplay.LockUI);
|
||||
_radarController = AcDream.App.UI.Layout.RadarController.Bind(
|
||||
radarLayout,
|
||||
snapshotProvider: _radarSnapshotProvider.BuildSnapshot,
|
||||
selectObject: guid => SelectedGuid = guid,
|
||||
setUiLocked: SetRetailUiLocked,
|
||||
datFont: vitalsDatFont);
|
||||
|
||||
radarRoot.Left = System.Math.Max(0f, _window!.Size.X - radarRoot.Width - 10f);
|
||||
radarRoot.Top = 10f;
|
||||
radarRoot.ClickThrough = false;
|
||||
// User-positioned top-level window: Anchors.None prevents the
|
||||
// per-frame anchor pass from undoing drag-handle movement.
|
||||
radarRoot.Anchors = AcDream.App.UI.AnchorEdges.None;
|
||||
radarRoot.Resizable = false;
|
||||
radarRoot.ConstrainDragToParent = true;
|
||||
_uiHost.Root.AddChild(radarRoot);
|
||||
_uiHost.RegisterWindow(AcDream.App.UI.WindowNames.Radar, radarRoot);
|
||||
ApplySavedRadarPosition();
|
||||
Console.WriteLine("[D.6] retail radar/compass from LayoutDesc 0x21000074.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("[D.6] radar: LayoutDesc 0x21000074 not found or root class mismatch.");
|
||||
}
|
||||
|
||||
// Retail chat window — data-driven from LayoutDesc 0x21000006 (gmMainChatUI),
|
||||
// the same importer path as vitals. ChatWindowController binds the transcript,
|
||||
// input, scrollbar and channel menu and routes through ChatVM + ChatCommandRouter.
|
||||
|
|
@ -2866,6 +2924,7 @@ public sealed class GameWindow : IDisposable
|
|||
_liveSession.EnterWorld(user, characterIndex: 0);
|
||||
|
||||
_activeToonKey = chosen.Name;
|
||||
ApplySavedRadarPosition();
|
||||
if (_settingsStore is not null && _settingsVm is not null)
|
||||
{
|
||||
var toonBag = _settingsStore.LoadCharacter(_activeToonKey);
|
||||
|
|
@ -11776,6 +11835,62 @@ public sealed class GameWindow : IDisposable
|
|||
_toolbarController.SetCharacterOpen(_uiHost.IsWindowVisible(AcDream.App.UI.WindowNames.Character));
|
||||
}
|
||||
|
||||
private void SetRetailUiLocked(bool locked)
|
||||
{
|
||||
if (_persistedGameplay.LockUI == locked)
|
||||
return;
|
||||
|
||||
_persistedGameplay = _persistedGameplay with { LockUI = locked };
|
||||
if (_uiHost is not null)
|
||||
_uiHost.Root.UiLocked = locked;
|
||||
if (_settingsVm is not null)
|
||||
_settingsVm.SetGameplay(_settingsVm.GameplayDraft with { LockUI = locked });
|
||||
|
||||
try
|
||||
{
|
||||
_settingsStore?.SaveGameplay(_persistedGameplay);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"settings: radar lock save failed: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplySavedRadarPosition()
|
||||
{
|
||||
if (_radarRoot is null || _settingsStore is null || _window is null)
|
||||
return;
|
||||
|
||||
var saved = _settingsStore.LoadWindowPosition(
|
||||
_activeToonKey, AcDream.App.UI.WindowNames.Radar);
|
||||
if (saved is not { } position)
|
||||
return;
|
||||
|
||||
_radarRoot.Left = System.Math.Clamp(
|
||||
position.X, 0f, System.Math.Max(0f, _window.Size.X - _radarRoot.Width));
|
||||
_radarRoot.Top = System.Math.Clamp(
|
||||
position.Y, 0f, System.Math.Max(0f, _window.Size.Y - _radarRoot.Height));
|
||||
}
|
||||
|
||||
private void OnRetailWindowMoved(string name, AcDream.App.UI.UiElement window)
|
||||
{
|
||||
if (name != AcDream.App.UI.WindowNames.Radar || _settingsStore is null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
_settingsStore.SaveWindowPosition(
|
||||
_activeToonKey,
|
||||
name,
|
||||
new AcDream.UI.Abstractions.Panels.Settings.UiWindowPosition(
|
||||
window.Left, window.Top));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"settings: radar position save failed: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateRetailCursorFeedback()
|
||||
{
|
||||
if (_uiHost is null || _cursorFeedbackController is null || _retailCursorManager is null || _input is null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue