From b3e5e8b0f74c1177aec781cd25a5a31514d131a2 Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 16 Jun 2026 22:52:28 +0200 Subject: [PATCH] fix(D.5.1): toolbar use-item gates on in-world + logs; store controller field (review) Co-Authored-By: Claude Opus 4.8 (1M context) --- src/AcDream.App/Rendering/GameWindow.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/AcDream.App/Rendering/GameWindow.cs b/src/AcDream.App/Rendering/GameWindow.cs index 2c19fde5..9690e3d1 100644 --- a/src/AcDream.App/Rendering/GameWindow.cs +++ b/src/AcDream.App/Rendering/GameWindow.cs @@ -617,6 +617,8 @@ public sealed class GameWindow : IDisposable private AcDream.UI.Abstractions.Panels.Vitals.VitalsVM? _vitalsVm; // Phase D.2b — retail-look UI tree (dormant UiHost wired here). Null unless ACDREAM_RETAIL_UI=1. private AcDream.App.UI.UiHost? _uiHost; + // Phase D.5.1 — toolbar controller (kept for lifetime clarity; mirrors _chatWindowController pattern). + private AcDream.App.UI.Layout.ToolbarController? _toolbarController; // Phase D.2b Task 9 — plugin UI registrations buffered before OnLoad; drained in OnLoad. private readonly AcDream.App.Plugins.BufferedUiRegistry? _uiRegistry; // Phase I.2: ImGui debug panel ViewModel. Lives for as long as @@ -1915,7 +1917,7 @@ public sealed class GameWindow : IDisposable _dats!, 0x21000016u, ResolveChrome, vitalsDatFont); if (toolbarLayout is not null) { - AcDream.App.UI.Layout.ToolbarController.Bind( + _toolbarController = AcDream.App.UI.Layout.ToolbarController.Bind( toolbarLayout, Items, () => Shortcuts, iconIds: (icon, under, over) => iconComposer.GetIcon(icon, under, over), @@ -11627,10 +11629,13 @@ public sealed class GameWindow : IDisposable // for items already in the player's inventory. private void UseItemByGuid(uint guid) { - if (_liveSession is null) return; + if (_liveSession is null + || _liveSession.CurrentState != AcDream.Core.Net.WorldSession.State.InWorld) + return; var seq = _liveSession.NextGameActionSequence(); var body = AcDream.Core.Net.Messages.InteractRequests.BuildUse(seq, guid); _liveSession.SendGameAction(body); + Console.WriteLine($"[D.5.1] toolbar use-item guid=0x{guid:X8} seq={seq}"); } private void SendPickUp(uint itemGuid)