diff --git a/src/xrGame/ui/UIActorMenu.cpp b/src/xrGame/ui/UIActorMenu.cpp index 04681e2f649..7b0ceefde6a 100644 --- a/src/xrGame/ui/UIActorMenu.cpp +++ b/src/xrGame/ui/UIActorMenu.cpp @@ -175,6 +175,25 @@ void CUIActorMenu::Show(bool status) m_message_static = nullptr; } +void CUIActorMenu::ShowDialog(bool bDoHideIndicators) +{ + CUIDialogWnd::ShowDialog(bDoHideIndicators); + + CUIDragDropListEx* bag{}; + switch (m_currMenuMode) + { + case mmInventory: bag = m_pLists[eInventoryBagList]; break; + case mmTrade: bag = m_pLists[eTradeActorBagList]; break; + case mmUpgrade: bag = m_pLists[eInventoryBagList]; break; + case mmDeadBodySearch: bag = m_pLists[eSearchLootActorBagList]; break; + } + + if (bag && bag->ItemsCount() && pInput->IsCurrentInputTypeController()) + { + UI().Focus().SetFocused(bag->GetItemIdx(0)); + } +} + void CUIActorMenu::Draw() { CurrentGameUI()->UIMainIngameWnd->DrawZoneMap(); @@ -262,6 +281,23 @@ bool CUIActorMenu::StopAnyMove() // true = актёр не идёт при от return true; } +bool CUIActorMenu::NeedCenterCursor() const +{ + CUIDragDropListEx* bag{}; + switch (m_currMenuMode) + { + case mmInventory: bag = m_pLists[eInventoryBagList]; break; + case mmTrade: bag = m_pLists[eTradeActorBagList]; break; + case mmUpgrade: bag = m_pLists[eInventoryBagList]; break; + case mmDeadBodySearch: bag = m_pLists[eSearchLootActorBagList]; break; + } + + if (bag) + return bag->ItemsCount() == 0; + + return CUIDialogWnd::NeedCenterCursor(); +} + void CUIActorMenu::CheckDistance() { CGameObject* pActorGO = smart_cast(m_pActorInvOwner); diff --git a/src/xrGame/ui/UIActorMenu.h b/src/xrGame/ui/UIActorMenu.h index a5fe42487ad..224b765c88a 100644 --- a/src/xrGame/ui/UIActorMenu.h +++ b/src/xrGame/ui/UIActorMenu.h @@ -357,10 +357,12 @@ class CUIActorMenu final : public CUIDialogWnd, public CUIWndCallback virtual ~CUIActorMenu(); virtual bool StopAnyMove(); + bool NeedCenterCursor() const override; virtual void SendMessage(CUIWindow* pWnd, s16 msg, void* pData = NULL); virtual void Draw(); virtual void Update(); virtual void Show(bool status); + void ShowDialog(bool bDoHideIndicators) override; virtual bool OnKeyboardAction(int dik, EUIMessages keyboard_action); virtual bool OnMouseAction(float x, float y, EUIMessages mouse_action); diff --git a/src/xrGame/ui/UIActorMenuInitialize.cpp b/src/xrGame/ui/UIActorMenuInitialize.cpp index 25c0617118a..3a172064777 100644 --- a/src/xrGame/ui/UIActorMenuInitialize.cpp +++ b/src/xrGame/ui/UIActorMenuInitialize.cpp @@ -144,6 +144,9 @@ void CUIActorMenu::Construct() DeInitTradeMode(); DeInitUpgradeMode(); DeInitDeadBodySearchMode(); + + // We have shortcuts both for keyboard and gamepad + UI().Focus().UnregisterFocusable(m_exit_button); } void CUIActorMenu::InitializeUniversal(CUIXml& uiXml) diff --git a/src/xrGame/ui/UIActorMenu_action.cpp b/src/xrGame/ui/UIActorMenu_action.cpp index 22e546ee4b1..fedd6e67c00 100644 --- a/src/xrGame/ui/UIActorMenu_action.cpp +++ b/src/xrGame/ui/UIActorMenu_action.cpp @@ -388,6 +388,10 @@ bool CUIActorMenu::OnMouseAction(float x, float y, EUIMessages mouse_action) bool CUIActorMenu::OnKeyboardAction(int dik, EUIMessages keyboard_action) { InfoCurItem(NULL); + + if (inherited::OnKeyboardAction(dik, keyboard_action)) + return true; + if (IsBinded(kDROP, dik)) { if (WINDOW_KEY_PRESSED == keyboard_action && CurrentIItem() && !CurrentIItem()->IsQuestItem() && @@ -425,7 +429,7 @@ bool CUIActorMenu::OnKeyboardAction(int dik, EUIMessages keyboard_action) return true; } - if (IsBinded(kQUIT, dik)) + if (IsBinded(kQUIT, dik) || IsBinded(kUI_BACK, dik, EKeyContext::UI)) { if (WINDOW_KEY_PRESSED == keyboard_action) { @@ -435,9 +439,6 @@ bool CUIActorMenu::OnKeyboardAction(int dik, EUIMessages keyboard_action) return true; } - if (inherited::OnKeyboardAction(dik, keyboard_action)) - return true; - return false; } diff --git a/src/xrGame/ui/UICellItem.cpp b/src/xrGame/ui/UICellItem.cpp index a0f100edd46..a332df38578 100644 --- a/src/xrGame/ui/UICellItem.cpp +++ b/src/xrGame/ui/UICellItem.cpp @@ -179,6 +179,17 @@ bool CUICellItem::OnKeyboardAction(int dik, EUIMessages keyboard_action) GetMessageTarget()->SendMessage(this, DRAG_DROP_ITEM_DB_CLICK, NULL); return true; } + if (CursorOverWindow()) + { + const auto [x, y] = UI().GetUICursor().GetCursorPosition(); + switch (GetBindedAction(dik, EKeyContext::UI)) + { + case kUI_ACCEPT: + return OnMouseAction(x, y, WINDOW_LBUTTON_DB_CLICK); + case kUI_ACTION_1: + return OnMouseAction(x, y, WINDOW_RBUTTON_DOWN); + } // switch (GetBindedAction(dik, EKeyContext::UI)) + } } return inherited::OnKeyboardAction(dik, keyboard_action); }