fix(ui): select retained items on mouse down
Port UIElement_ListBox's press-time selection ordering through the shared retained item-list contract. Inventory, loot, paperdoll, and physical shortcuts now update canonical selection before release or drag promotion, while target-mode consumption suppresses drag and release-time activation. Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
parent
2dd5cb80d2
commit
043ab10b3c
18 changed files with 292 additions and 62 deletions
|
|
@ -153,9 +153,21 @@ public sealed class InventoryController : IItemListDragHandler, IRetainedPanelCo
|
|||
_contentsGrid?.RegisterDragHandler(this);
|
||||
_containerList?.RegisterDragHandler(this);
|
||||
_topContainer?.RegisterDragHandler(this);
|
||||
if (_contentsGrid is not null) _contentsGrid.ExamineItemRequested = ExamineItem;
|
||||
if (_containerList is not null) _containerList.ExamineItemRequested = ExamineItem;
|
||||
if (_topContainer is not null) _topContainer.ExamineItemRequested = ExamineItem;
|
||||
if (_contentsGrid is not null)
|
||||
{
|
||||
_contentsGrid.PrimaryItemPressed = PressItem;
|
||||
_contentsGrid.ExamineItemRequested = ExamineItem;
|
||||
}
|
||||
if (_containerList is not null)
|
||||
{
|
||||
_containerList.PrimaryItemPressed = PressItem;
|
||||
_containerList.ExamineItemRequested = ExamineItem;
|
||||
}
|
||||
if (_topContainer is not null)
|
||||
{
|
||||
_topContainer.PrimaryItemPressed = PressSelfItem;
|
||||
_topContainer.ExamineItemRequested = ExamineItem;
|
||||
}
|
||||
|
||||
// Burden meter: vertical 11×58 bar (gmBackpackUI m_burdenMeter, retail direction 4).
|
||||
_burdenMeter = layout.FindElement(BurdenMeterId) as UiMeter;
|
||||
|
|
@ -432,12 +444,7 @@ public sealed class InventoryController : IItemListDragHandler, IRetainedPanelCo
|
|||
dragIconTexture: _dragIconIds?.Invoke(
|
||||
ItemType.Container, PlayerPackBaseIcon, 0u, 0u, 0u) ?? 0u);
|
||||
main.DragAcceptSprite = 0x060011F7u; main.DragRejectSprite = 0x060011F8u;
|
||||
main.Clicked = () =>
|
||||
{
|
||||
if (_itemInteraction?.OfferSelfPrimaryClick()
|
||||
is not null and not ItemPrimaryClickResult.NotActive) return;
|
||||
OpenContainer(p);
|
||||
};
|
||||
main.Clicked = () => OpenContainer(p);
|
||||
main.DoubleClicked = () => _itemInteraction?.ActivateItem(p);
|
||||
SetCapacityBar(main, p); // main-pack fullness (items / ItemsCapacity)
|
||||
_topContainer.AddItem(main);
|
||||
|
|
@ -480,22 +487,28 @@ public sealed class InventoryController : IItemListDragHandler, IRetainedPanelCo
|
|||
cell.DoubleClicked = () => _itemInteraction?.ActivateItem(guid);
|
||||
if (isContainer)
|
||||
{
|
||||
cell.Clicked = () => HandlePrimaryClick(guid, () => OpenContainer(guid));
|
||||
cell.Clicked = () => OpenContainer(guid);
|
||||
SetCapacityBar(cell, guid);
|
||||
}
|
||||
else
|
||||
{
|
||||
cell.Clicked = () => HandlePrimaryClick(guid, () => SelectItem(guid));
|
||||
}
|
||||
list.AddItem(cell);
|
||||
}
|
||||
|
||||
private void HandlePrimaryClick(uint guid, Action fallback)
|
||||
private bool PressItem(uint guid)
|
||||
{
|
||||
if (_itemInteraction?.OfferPrimaryClick(guid)
|
||||
is not null and not ItemPrimaryClickResult.NotActive)
|
||||
return;
|
||||
fallback();
|
||||
return true;
|
||||
SelectItem(guid);
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool PressSelfItem(uint guid)
|
||||
{
|
||||
if (_itemInteraction?.OfferSelfPrimaryClick()
|
||||
is not null and not ItemPrimaryClickResult.NotActive)
|
||||
return true;
|
||||
SelectItem(guid);
|
||||
return false;
|
||||
}
|
||||
|
||||
private void AddEmptyCell(UiItemList list)
|
||||
|
|
@ -931,9 +944,21 @@ public sealed class InventoryController : IItemListDragHandler, IRetainedPanelCo
|
|||
_objects.ObjectUpdated -= OnObjectChanged;
|
||||
_objects.Cleared -= OnObjectsCleared;
|
||||
_selection.Changed -= OnSelectionChanged;
|
||||
if (_contentsGrid is not null) _contentsGrid.ExamineItemRequested = null;
|
||||
if (_containerList is not null) _containerList.ExamineItemRequested = null;
|
||||
if (_topContainer is not null) _topContainer.ExamineItemRequested = null;
|
||||
if (_contentsGrid is not null)
|
||||
{
|
||||
_contentsGrid.PrimaryItemPressed = null;
|
||||
_contentsGrid.ExamineItemRequested = null;
|
||||
}
|
||||
if (_containerList is not null)
|
||||
{
|
||||
_containerList.PrimaryItemPressed = null;
|
||||
_containerList.ExamineItemRequested = null;
|
||||
}
|
||||
if (_topContainer is not null)
|
||||
{
|
||||
_topContainer.PrimaryItemPressed = null;
|
||||
_topContainer.ExamineItemRequested = null;
|
||||
}
|
||||
if (_itemInteraction is not null)
|
||||
{
|
||||
_itemInteraction.StateChanged -= OnInteractionStateChanged;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue