fix(ui): select items before drag mesh
Port ItemList_BeginDrag's select-before-waiting order so a direct press-drag shows the selection indicator on its first frame across inventory, paperdoll, and toolbar item lists. Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
parent
64a056e656
commit
609ed8bfc2
10 changed files with 71 additions and 14 deletions
|
|
@ -422,9 +422,15 @@ public sealed class InventoryController : IItemListDragHandler, IRetainedPanelCo
|
|||
}
|
||||
|
||||
// ── IItemListDragHandler (B-Drag) — drop an item to move it (optimistic + wire) ──────────────
|
||||
/// <summary>Inventory items do NOT lift-remove (unlike the toolbar): the item stays in its slot
|
||||
/// while <see cref="UiItemSlot"/> reveals retail's waiting/ghosted mesh until release.</summary>
|
||||
public void OnDragLift(UiItemList sourceList, UiItemSlot sourceCell, ItemDragPayload payload) { }
|
||||
/// <summary>Retail ItemList_BeginDrag selects an unselected item before enabling its waiting
|
||||
/// mesh. Inventory items do not lift-remove (unlike the toolbar): the item stays in its slot
|
||||
/// until the server confirms the eventual drop.</summary>
|
||||
public void OnDragLift(UiItemList sourceList, UiItemSlot sourceCell, ItemDragPayload payload)
|
||||
{
|
||||
// UIElement_ItemList::ItemList_BeginDrag @ 0x004E32D0.
|
||||
if (payload.ObjId != 0 && _selection.SelectedObjectId != payload.ObjId)
|
||||
_selection.Select(payload.ObjId, SelectionChangeSource.Inventory);
|
||||
}
|
||||
|
||||
/// <summary>Advisory neutral/accept/reject overlay. Shortcut aliases stay neutral; physical grid
|
||||
/// drops accept; a side-bag/main-pack drop rejects only when that container is known full.</summary>
|
||||
|
|
|
|||
|
|
@ -283,9 +283,15 @@ public sealed class PaperdollController : IItemListDragHandler, IRetainedPanelCo
|
|||
}
|
||||
|
||||
// ── IItemListDragHandler ──────────────────────────────────────────────────────────────────────
|
||||
/// <summary>No-op: a wielded item stays put until the server confirms (same as the inventory grid,
|
||||
/// unlike the toolbar's remove-on-lift). Unwield happens on DROP onto the pack grid — InventoryController.</summary>
|
||||
public void OnDragLift(UiItemList sourceList, UiItemSlot sourceCell, ItemDragPayload payload) { }
|
||||
/// <summary>Selects the wielded item before the waiting mesh appears. The item itself stays put
|
||||
/// until the server confirms, like the inventory grid and unlike the toolbar's remove-on-lift.
|
||||
/// Unwield happens on DROP onto the pack grid — InventoryController.</summary>
|
||||
public void OnDragLift(UiItemList sourceList, UiItemSlot sourceCell, ItemDragPayload payload)
|
||||
{
|
||||
// UIElement_ItemList::ItemList_BeginDrag @ 0x004E32D0.
|
||||
if (payload.ObjId != 0 && _selection.SelectedObjectId != payload.ObjId)
|
||||
_selection.Select(payload.ObjId, SelectionChangeSource.Paperdoll);
|
||||
}
|
||||
|
||||
/// <summary>Accept iff the dragged item can be worn here (its ValidLocations intersects the slot mask).
|
||||
/// Retail: gmPaperDollUI::OnItemListDragOver (decomp 174302).</summary>
|
||||
|
|
|
|||
|
|
@ -615,6 +615,11 @@ public sealed class ToolbarController : IItemListDragHandler, IRetainedPanelCont
|
|||
/// <inheritdoc/>
|
||||
public void OnDragLift(UiItemList sourceList, UiItemSlot sourceCell, ItemDragPayload payload)
|
||||
{
|
||||
// UIElement_ItemList::ItemList_BeginDrag @ 0x004E32D0 selects first; the toolbar's
|
||||
// RecvNotice_ItemListBeginDrag handler then removes the shortcut alias.
|
||||
if (payload.ObjId != 0 && _selectedObjectId() != payload.ObjId)
|
||||
_selectItem?.Invoke(payload.ObjId);
|
||||
|
||||
// Retail RecvNotice_ItemListBeginDrag → RemoveShortcut (0x004bd930/0x004bd450): the lifted
|
||||
// shortcut leaves the bar (+ wire) the instant the drag starts; it's re-placed only on a
|
||||
// drop onto a slot. Off-bar release leaves it removed.
|
||||
|
|
|
|||
|
|
@ -757,9 +757,12 @@ public sealed class UiRoot : UiElement
|
|||
DragSource = source;
|
||||
DragPayload = payload;
|
||||
_dragGhost = source.GetDragGhost(); // snapshot NOW — the DragBegin handler may empty the source cell
|
||||
source.SetDragSourceActive(true, payload);
|
||||
var e = new UiEvent(source.EventId, source, UiEventType.DragBegin, Payload: payload);
|
||||
source.OnEvent(in e);
|
||||
// Retail UIElement_ItemList::ItemList_BeginDrag @ 0x004E32D0 selects an
|
||||
// unselected item before enabling its waiting mesh. Keep that order so a
|
||||
// press-drag shows the selection indicator on its very first frame.
|
||||
source.SetDragSourceActive(true, payload);
|
||||
}
|
||||
|
||||
private void UpdateDragHover(int x, int y)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue