feat(engine): drag items from the game or a popped-out Inventory onto Mini Remote slots

- ItemDragBridge republishes popped-out Inventory drags and AC inventory drags in the main ImGui context (RYNTH_INV_ITEM / RYNTH_GAME_ITEM payloads)
- Win32Backend hands a game drag released over ImGui back to AC at its start so items never drop to the ground
- Inventory clicks select the item in the game; right-click 'Add to Mini Remote' (remoteslot command)
- Char menu: Guardian window entry
- Changelog 2026-10-05-guardian-and-remote-slots.md

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
BlankenshipG 2026-10-05 12:19:35 -04:00
commit 0bff493184
7 changed files with 363 additions and 4 deletions

View file

@ -0,0 +1,58 @@
# 2026-10-05 - ILT Guardian window, Mini Remote slot assignment
RynthAi 0.5.11-legacy-ui (previous 0.5.10-legacy-ui) with the RynthCore engine changes below.
Ships in installer 2026.10.5.10.
## Guardian window (ported from UB-IT's Guardian tab)
Open it from the Mini Remote's Options, the dashboard Char button's right-click menu, or
`/ra hub open guardian` (`/ra guardian window`).
- **Riddle translator.** Translates incoming "Guardian of the Temple of Enlightenment" and
"Guardian of Attribute Enlightenment" tells and says (all 18 Temple spell words and the full
attribute-riddle table, typo-tolerant), plus a paste box for manual translation. The answer
shows in the window and as a "Guardian:" row on the Mini Remote for 10 minutes, with a
Give button.
- **Hand-in.** Gives one of the answer item to the guardian (whole item when it isn't a stack).
For the Temple guardian, when you carry none and "Buy if missing" is on, it first buys one
from the open or nearest vendor through the engine's vendor trade API. It waits out the busy
hourglass, has per-step timeouts, and reports every failure in chat. "Auto hand-in" runs it
after each chat answer (off by default).
- **Attribute turn-ins.** One row per Fiun attribute NPC plus the riddle. Counts and cooldowns
come from /myquests when the server reports the flag, otherwise from "/qb list" wait stamps
(a stamp appearing counts a turn-in and starts an estimated cooldown; "Assumed cooldown"
sets its length). Rows can be overridden with `infi attribute.csv` in the RynthAi folder or
UB's `Documents\Asheron's Call` location.
- **Commands:** `/ra guardian [window|translate <text>|handin|stop|chat on|off|auto on|off|buy on|off|refresh|status]`.
- **Not ported:** UB's `/fillcomps` + "buy all" spell-component restock during the Temple
hand-in. It is unrelated to the guardian quest, and the engine buys specific items rather
than the client's buy list.
New files: `IltHub/IltGuardian.cs`, `IltHub/IltGuardianPhrasebook.cs`, `IltHub/IltTempleAttributes.cs`.
Settings persist per character in `ilt-hub.json` (`Guardian` block, `GuardianWindowOpen`).
## Mini Remote slot assignment
Previously, items could not be put into Mini Remote slots from the game inventory or from a
popped-out RynthCore Inventory.
- **Game inventory drag-and-drop (engine `ItemDragBridge`).** A left drag that starts on a
carried item in AC's own inventory is now published to ImGui. Releasing it on an **empty**
Mini Remote slot assigns it. A game drag released over any RynthCore window is handed back
to AC at its starting point, so the item is never dropped on the ground.
- **Popped-out RynthCore Inventory.** Drags from a popped-out Inventory window now reach the
Mini Remote (the pop-out runs in its own ImGui context).
- **Click to assign.** Clicking an item in the RynthCore Inventory also selects it in the game.
The Mini Remote remembers the last carried item you selected for 2 minutes, so the combat
bot re-selecting monsters no longer loses it before you click an empty slot.
- **Inventory right-click: "Add to Mini Remote".** Adds the item to the first empty slot or a
chosen slot (remote command `remoteslot <slot|first> <objectId>`).
- Empty-slot tooltips explain all three ways to assign.
### Known limits
- The engine infers a game-inventory drag from AC's selection. Dragging an AC panel while a
pack item is selected looks the same, which is why game drags only fill empty slots.
Dragging from the RynthCore Inventory can replace a filled slot.
- If an AC panel is dragged and released over a RynthCore window while a pack item is selected,
the panel returns to where the drag started.

View file

@ -691,6 +691,9 @@ internal static class EngineFrameController
ImGuiNET.ImGui.NewFrame();
frameStarted = true;
// Before any window: a drag from a popped-out Inventory or AC's inventory becomes
// a payload the client's drop targets (Mini Remote slots) see this frame.
ItemDragBridge.SubmitMainFrame(io);
ImGuiTextFocus.BeginFrame();
if (_dropImGuiTextFocus)
{

View file

@ -0,0 +1,216 @@
// ============================================================================
// RynthCore.Engine - ImGui/ItemDragBridge.cs
// Carries an item drag into the MAIN ImGui context when it didn't start there,
// so drop targets in the client (RynthAi's Mini Remote slots) can take it:
//
// • A popped-out Inventory: the pop-out has its own ImGui context and holds
// mouse capture for the whole drag, so the main context never sees it.
// The pop-out face reports the dragged item (NotePopOutDrag); the main
// frame republishes it as an extern payload. The main context sees no
// button press, so the payload uses PayloadAutoExpire: it is delivered to
// the hovered target on the first frame it is no longer submitted.
// • AC's own inventory: a press that began on the game belongs to the game,
// and ImGui ignores hovering for it. A left drag that starts with a carried
// item selected (AC selects the item under the press) is republished the
// same way, under NativePayloadType, and delivered when ImGui sees the
// button go up.
//
// A native drag released over an ImGui window would otherwise complete in AC
// as a drop on the 3D view (the item lands on the ground). TryRedirectNativeDrop
// moves that button-up back to where the drag began, which AC treats as
// putting the item back.
//
// Threads: AC's main thread only (game WndProc, EndScene, pop-out frames).
// ============================================================================
using System;
using System.Diagnostics;
using ImGuiNET;
using RynthCore.Engine.Compatibility;
namespace RynthCore.Engine.ImGuiBackend;
internal static unsafe class ItemDragBridge
{
/// <summary>Payload type for one item (uint object id). Must match RynthAi's MiniRemoteHud.ItemPayloadType.</summary>
public const string PayloadType = "RYNTH_INV_ITEM";
/// <summary>
/// Payload type for a drag that began in AC's own UI (uint object id). Any game left-drag with
/// a carried item selected looks like this (moving an AC panel too), so targets should take it
/// only where a wrong item does no harm (RynthAi: empty slots). Must match MiniRemoteHud.GameItemPayloadType.
/// </summary>
public const string NativePayloadType = "RYNTH_GAME_ITEM";
private const uint WM_MOUSEMOVE = 0x0200, WM_LBUTTONDOWN = 0x0201, WM_LBUTTONUP = 0x0202;
private const int MK_LBUTTON = 0x0001, MK_OTHER = 0x0002 | 0x0010 | 0x0020 | 0x0040;
/// <summary>Movement (px, squared) before a game press counts as a drag.</summary>
private const int DragThresholdSq = 5 * 5;
/// <summary>AC may select the pressed item a few messages after the press: keep re-reading it this long.</summary>
private static readonly long SelectionSettleTicks = Stopwatch.Frequency / 2;
/// <summary>A pop-out drag with no report for this long is over (the pop-out closed mid-drag).</summary>
private static readonly long PopOutStaleTicks = Stopwatch.Frequency;
// Popped-out Inventory drag.
private static uint _popOutItem;
private static long _popOutSeenAt;
// Native (AC inventory) drag.
private static bool _pressPending;
private static IntPtr _pressLParam;
private static int _pressX, _pressY;
private static long _pressAt;
private static uint _nativeItem;
private static bool _nativeReleased;
/// <summary>The cursor was over an ImGui window in the last main frame (only tracked during a native drag).</summary>
private static bool _overImGui;
// ── Popped-out Inventory ────────────────────────────────────────────────
/// <summary>A popped-out Inventory is dragging <paramref name="itemId"/> (call every pop-out frame of the drag).</summary>
public static void NotePopOutDrag(uint itemId)
{
if (itemId == 0) return;
if (_popOutItem != itemId)
RynthLog.UI($"ItemDragBridge: pop-out drag 0x{itemId:X8} published to the client.");
_popOutItem = itemId;
_popOutSeenAt = Stopwatch.GetTimestamp();
}
/// <summary>The popped-out Inventory's drag ended (dropped or cancelled).</summary>
public static void EndPopOutDrag() => _popOutItem = 0;
// ── Native drag (game WndProc) ──────────────────────────────────────────
/// <summary>
/// Every game-window mouse message, after the backend decided who owns the held buttons.
/// <paramref name="gameOwned"/>: the current press began on the game, not on ImGui.
/// </summary>
public static void OnGameMouse(uint msg, IntPtr wParam, IntPtr lParam, bool gameOwned)
{
int keys = (int)((long)wParam & 0xFFFF);
switch (msg)
{
case WM_LBUTTONDOWN:
// Only a plain left press that belongs to the game can be an inventory drag.
_pressPending = gameOwned && (keys & MK_OTHER) == 0;
_pressLParam = lParam;
_pressX = LoWord(lParam);
_pressY = HiWord(lParam);
_pressAt = Stopwatch.GetTimestamp();
if (_pressPending) { _nativeItem = 0; _nativeReleased = false; }
break;
case WM_MOUSEMOVE:
if ((keys & MK_LBUTTON) == 0)
{
// A release we never saw (outside the window): finish the drag.
_pressPending = false;
if (_nativeItem != 0) _nativeReleased = true;
break;
}
if (_pressPending)
{
int dx = LoWord(lParam) - _pressX, dy = HiWord(lParam) - _pressY;
if (dx * dx + dy * dy >= DragThresholdSq)
{
_pressPending = false;
_nativeItem = CarriedSelection();
if (_nativeItem != 0)
RynthLog.UI($"ItemDragBridge: native inventory drag 0x{_nativeItem:X8} published to ImGui.");
}
}
else if (_nativeItem != 0 && !_nativeReleased && Stopwatch.GetTimestamp() - _pressAt < SelectionSettleTicks)
{
// The selection can trail the press by a few messages: follow it while it settles.
uint sel = CarriedSelection();
if (sel != 0) _nativeItem = sel;
}
break;
case WM_LBUTTONUP:
_pressPending = false;
if (_nativeItem != 0) _nativeReleased = true;
break;
}
}
/// <summary>
/// A native item drag is being released over an ImGui window: returns the press position
/// to send AC instead, so AC puts the item back rather than dropping it on the ground.
/// </summary>
public static bool TryRedirectNativeDrop(uint msg, out IntPtr pressLParam)
{
pressLParam = _pressLParam;
if (msg != WM_LBUTTONUP || _nativeItem == 0 || !_overImGui) return false;
RynthLog.UI($"ItemDragBridge: native drag 0x{_nativeItem:X8} released over an ImGui window; AC gets the drop back at its start ({_pressX},{_pressY}).");
return true;
}
// ── Main frame (after ImGui.NewFrame, before any window) ────────────────
/// <summary>Republishes a pop-out or native drag in the main context for this frame.</summary>
public static void SubmitMainFrame(ImGuiIOPtr io)
{
uint id = 0;
string type = PayloadType;
if (_popOutItem != 0)
{
if (Stopwatch.GetTimestamp() - _popOutSeenAt > PopOutStaleTicks) _popOutItem = 0;
else id = _popOutItem;
}
if (id == 0 && _nativeItem != 0)
{
type = NativePayloadType;
// After the button-up, stop once ImGui itself sees the button up: that frame
// delivers the drop (the payload outlives its last submission by one frame).
if (_nativeReleased && !io.MouseDown[0])
{
_nativeItem = 0;
_nativeReleased = false;
_overImGui = false;
return;
}
id = _nativeItem;
_overImGui = ImGuiNET.ImGui.IsWindowHovered(ImGuiHoveredFlags.AnyWindow | ImGuiHoveredFlags.AllowWhenBlockedByActiveItem);
}
if (id == 0) return;
const ImGuiDragDropFlags flags = ImGuiDragDropFlags.SourceExtern | ImGuiDragDropFlags.SourceNoPreviewTooltip
| ImGuiDragDropFlags.PayloadAutoExpire;
if (ImGuiNET.ImGui.BeginDragDropSource(flags))
{
ImGuiNET.ImGui.SetDragDropPayload(type, (IntPtr)(&id), sizeof(uint));
ImGuiNET.ImGui.EndDragDropSource();
}
}
/// <summary>Forget every drag (focus lost, logout, engine shutdown).</summary>
public static void Reset()
{
_popOutItem = 0;
_pressPending = false;
_nativeItem = 0;
_nativeReleased = false;
_overImGui = false;
}
/// <summary>The game's selected object when the player carries it (pack, side pack or worn), else 0.</summary>
private static uint CarriedSelection()
{
uint id = ClientHelperHooks.GetSelectedItemId();
if (id == 0 || !ClientHelperHooks.HasGetPlayerId) return 0;
uint player = ClientHelperHooks.GetPlayerId();
if (player == 0 || id == player) return 0;
if (!ClientObjectHooks.TryGetObjectOwnershipInfo(id, out uint container, out uint wielder, out _)) return 0;
if (wielder == player || container == player) return id;
// Side pack in the main pack.
if (container != 0 && ClientObjectHooks.TryGetObjectOwnershipInfo(container, out uint outer, out _, out _) && outer == player)
return id;
return 0;
}
private static int LoWord(IntPtr l) => unchecked((short)((long)l & 0xFFFF));
private static int HiWord(IntPtr l) => unchecked((short)(((long)l >> 16) & 0xFFFF));
}

View file

@ -620,7 +620,7 @@ internal sealed partial class InventoryFace
_hover = it;
if (ImGuiNET.ImGui.IsMouseClicked(ImGuiMouseButton.Left))
{
_selected = it.Id;
SelectItem(it);
_pressItem = it;
_pressAt = ImGuiNET.ImGui.GetMousePos();
}

View file

@ -122,6 +122,7 @@ internal sealed partial class InventoryFace : IImGuiPanel
InventoryModel.Hover(0);
InventoryModel.Unsubscribe();
_dragItem = _pressItem = null;
ItemDragBridge.EndPopOutDrag();
_lootAdd.Cancel();
}
@ -475,7 +476,7 @@ internal sealed partial class InventoryFace : IImGuiPanel
if (hot != null && ImGuiNET.ImGui.IsMouseClicked(ImGuiMouseButton.Left))
{
_selected = hot.Id;
SelectItem(hot);
_pressItem = hot;
_pressAt = mouse;
}
@ -749,6 +750,7 @@ internal sealed partial class InventoryFace : IImGuiPanel
_dragItem = null;
_pressItem = null;
if (item == null) return;
ItemDragBridge.EndPopOutDrag();
Vector2 m = ImGuiNET.ImGui.GetMousePos();
foreach (Target t in _targets)
{
@ -759,13 +761,50 @@ internal sealed partial class InventoryFace : IImGuiPanel
}
}
private void DrawDragGhost()
/// <summary>
/// ImGui drag-and-drop payload type for one item (uint object id), published while an item is
/// dragged so other ImGui windows (RynthAi's Mini Remote slots) can accept the drop. Must
/// match MiniRemoteHud.ItemPayloadType in RynthAi.
/// </summary>
public const string ItemPayloadType = "RYNTH_INV_ITEM";
/// <summary>
/// Selects <paramref name="it"/> here and in the game, like a click in the retail inventory, so
/// "selected item" features (Mini Remote slots, item info, loot rules) see it too.
/// </summary>
private void SelectItem(InventoryItem it)
{
_selected = it.Id;
// Queued, not called inline: Draw runs inside EndScene, and AC's SetSelectedObject rebuilds
// UI elements, so it runs at the main-thread queue's drain point instead.
if (ClientHelperHooks.GetSelectedItemId() != it.Id)
AcMainThreadQueue.EnqueueSetSelectedObject(it.Id);
}
private unsafe void DrawDragGhost()
{
if (_dragItem == null) return;
var fg = ImGuiNET.ImGui.GetForegroundDrawList();
Vector2 m = ImGuiNET.ImGui.GetMousePos() - new Vector2(Icon * 0.5f, Icon * 0.5f);
DrawItemIcon(fg, _dragItem.Id, m, Icon, 0xD0FFFFFF);
ImGuiNET.ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
// A popped-out Inventory draws in its own ImGui context: the client's drop targets
// only see the drag through the bridge, which republishes it in the main context.
if (ImGuiPopOuts.InPopOutFrame)
{
ItemDragBridge.NotePopOutDrag(_dragItem.Id);
return;
}
// Re-submitted every frame of the drag (an extern source expires when it isn't); the
// ghost above is the preview, so no ImGui tooltip.
if (ImGuiNET.ImGui.BeginDragDropSource(ImGuiDragDropFlags.SourceExtern | ImGuiDragDropFlags.SourceNoPreviewTooltip))
{
uint id = _dragItem.Id;
ImGuiNET.ImGui.SetDragDropPayload(ItemPayloadType, (IntPtr)(&id), sizeof(uint));
ImGuiNET.ImGui.EndDragDropSource();
}
}
// ── Tooltip ─────────────────────────────────────────────────────────
@ -896,6 +935,7 @@ internal sealed partial class InventoryFace : IImGuiPanel
UI.Data.RynthAiCommands.ApplyRemoteCommand("itemhudadd", it.Name);
if (ImGuiNET.ImGui.IsItemHovered())
ImGuiNET.ImGui.SetTooltip("Track how many of these you carry on RynthAi's floating item count HUD (/ra itemhud add)");
if (!it.IsPack) MiniRemoteMenu(it);
if (!idle)
ImGuiNET.ImGui.TextDisabled("(an item action is waiting)");
}
@ -906,6 +946,36 @@ internal sealed partial class InventoryFace : IImGuiPanel
}
}
/// <summary>RynthAi Mini Remote quick-use grid size (HudState.MiniRemoteSlotCount, 6 rows of 5).</summary>
private const int MiniRemoteSlots = 30, MiniRemoteColumns = 5;
/// <summary>
/// "Add to Mini Remote" submenu: first empty slot, or a numbered grid laid out like the
/// remote's own slots. RynthAi validates the item and reports the result in chat.
/// </summary>
private static void MiniRemoteMenu(InventoryItem it)
{
if (!ImGuiNET.ImGui.BeginMenu("Add to Mini Remote")) return;
if (ImGuiNET.ImGui.MenuItem("First empty slot"))
UI.Data.RynthAiCommands.ApplyRemoteCommand("remoteslot", "first " + it.Id.ToString(CultureInfo.InvariantCulture));
ImGuiNET.ImGui.Separator();
ImGuiNET.ImGui.TextDisabled("Or pick a slot (replaces what's there):");
for (int i = 0; i < MiniRemoteSlots; i++)
{
if (i % MiniRemoteColumns != 0) ImGuiNET.ImGui.SameLine();
string label = (i + 1).ToString("00", CultureInfo.InvariantCulture);
if (ImGuiNET.ImGui.Button(label, new Vector2(28, 0)))
{
UI.Data.RynthAiCommands.ApplyRemoteCommand("remoteslot",
(i + 1).ToString(CultureInfo.InvariantCulture) + " " + it.Id.ToString(CultureInfo.InvariantCulture));
ImGuiNET.ImGui.CloseCurrentPopup();
}
}
ImGuiNET.ImGui.Separator();
ImGuiNET.ImGui.TextDisabled("Tip: you can also drag the item onto a slot.");
ImGuiNET.ImGui.EndMenu();
}
// ── Split dialog ────────────────────────────────────────────────────
private void SplitDialog(InventoryView view)

View file

@ -708,7 +708,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
private static readonly (string Label, string Section)[] HubSections =
{
("Character", "character"), ("Quests", "quests"), ("Pets", "pets"),
("Banking", "banking"), ("Gear", "gear"), ("Games", "games"),
("Banking", "banking"), ("Gear", "gear"), ("Games", "games"), ("Guardian", "guardian"),
};
private static void CharMenu()

View file

@ -971,11 +971,15 @@ internal static unsafe class Win32Backend
// HUD drag (keeps our SetCapture from fighting NewFrame's). No-op
// unless the HUD is drawn.
if (IsMouseMessage(msg))
{
TrackMouseButtons(msg, wParam);
ItemDragBridge.OnGameMouse(msg, wParam, lParam, _heldButtonsBelongToGame);
}
else if (msg == WM_KILLFOCUS)
{
_heldMouseButtons = 0;
_heldButtonsBelongToGame = false;
ItemDragBridge.Reset();
}
// ── Avalonia panel hit-test & input forwarding ────────────────
@ -1075,6 +1079,14 @@ internal static unsafe class Win32Backend
}
}
// An AC inventory item dragged onto an ImGui window: AC must not drop it on the
// ground behind the window. It gets the release where the drag began instead.
if (ItemDragBridge.TryRedirectNativeDrop(msg, out IntPtr pressLParam))
{
CallWindowProcA(_originalWndProc, hWnd, WM_MOUSEMOVE, (IntPtr)MK_LBUTTON, pressLParam);
return CallWindowProcA(_originalWndProc, hWnd, msg, wParam, pressLParam);
}
// Pass through to original WndProc
return CallWindowProcA(_originalWndProc, hWnd, msg, wParam, lParam);
}