From 8eedccbd2f846b018ca10c101aa6685044dd74eb Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 11 Aug 2023 07:26:01 +0500 Subject: [PATCH] Added ability to open tasks list in the PDA using gamepad and keyboard (#943) Added two UI actions stubs --- src/xrEngine/key_binding_registrator_script.cpp | 3 +++ src/xrEngine/xr_level_controller.cpp | 7 ++++++- src/xrEngine/xr_level_controller.h | 3 +++ src/xrGame/ui/UISecondTaskWnd.cpp | 11 +++++++++++ src/xrGame/ui/UISecondTaskWnd.h | 2 ++ src/xrGame/ui/UITaskWnd.cpp | 8 ++++++++ 6 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/xrEngine/key_binding_registrator_script.cpp b/src/xrEngine/key_binding_registrator_script.cpp index a85dee951d0..fa1b69d44fe 100644 --- a/src/xrEngine/key_binding_registrator_script.cpp +++ b/src/xrEngine/key_binding_registrator_script.cpp @@ -148,6 +148,8 @@ SCRIPT_EXPORT(KeyBindings, (), value("kUI_ACCEPT", int(kUI_ACCEPT)), value("kUI_BACK", int(kUI_BACK)), + value("kUI_ACTION_1", int(kUI_ACTION_1)), + value("kUI_ACTION_2", int(kUI_ACTION_2)), value("kUI_TAB_PREV", int(kUI_TAB_PREV)), value("kUI_TAB_NEXT", int(kUI_TAB_NEXT)), @@ -178,6 +180,7 @@ SCRIPT_EXPORT(KeyBindings, (), value("kPDA_MAP_SHOW_LEGEND", int(kPDA_MAP_SHOW_LEGEND)), value("kPDA_FILTER_TOGGLE", int(kPDA_FILTER_TOGGLE)), + value("kPDA_TASKS_TOGGLE", int(kPDA_TASKS_TOGGLE)), // Talk: value("kTALK_SWITCH_TO_TRADE", int(kTALK_SWITCH_TO_TRADE)), diff --git a/src/xrEngine/xr_level_controller.cpp b/src/xrEngine/xr_level_controller.cpp index 51f4aefdbbd..0cf1222dd19 100644 --- a/src/xrEngine/xr_level_controller.cpp +++ b/src/xrEngine/xr_level_controller.cpp @@ -156,6 +156,8 @@ game_action actions[] = { { "ui_accept", kUI_ACCEPT, _sp, EKeyContext::UI }, { "ui_back", kUI_BACK, _sp, EKeyContext::UI }, + { "ui_action_1", kUI_ACTION_1, _sp, EKeyContext::UI }, + { "ui_action_2", kUI_ACTION_2, _sp, EKeyContext::UI }, { "ui_tab_prev", kUI_TAB_PREV, _sp, EKeyContext::UI }, { "ui_tab_next", kUI_TAB_NEXT, _sp, EKeyContext::UI }, @@ -186,6 +188,7 @@ game_action actions[] = { { "pda_map_show_legend", kPDA_MAP_SHOW_LEGEND, _sp, EKeyContext::PDA }, { "pda_filter_toggle", kPDA_FILTER_TOGGLE, _sp, EKeyContext::PDA }, + { "pda_tasks_toggle", kPDA_TASKS_TOGGLE, _sp, EKeyContext::PDA }, // Talk: { "talk_switch_to_trade", kTALK_SWITCH_TO_TRADE, _sp, EKeyContext::Talk }, @@ -973,6 +976,8 @@ class CCC_DefControls : public CCC_UnBindAll { kUI_ACCEPT, { SDL_SCANCODE_RETURN, SDL_SCANCODE_F, XR_CONTROLLER_BUTTON_A } }, { kUI_BACK, { SDL_SCANCODE_ESCAPE, SDL_SCANCODE_G, XR_CONTROLLER_BUTTON_B } }, + { kUI_ACTION_1, { SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_Y, XR_CONTROLLER_BUTTON_X } }, + { kUI_ACTION_2, { SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_N, XR_CONTROLLER_BUTTON_Y } }, { kUI_TAB_PREV, { SDL_SCANCODE_Q, SDL_SCANCODE_UNKNOWN, XR_CONTROLLER_BUTTON_LEFTSHOULDER } }, { kUI_TAB_NEXT, { SDL_SCANCODE_E, SDL_SCANCODE_UNKNOWN, XR_CONTROLLER_BUTTON_RIGHTSHOULDER } }, @@ -1002,8 +1007,8 @@ class CCC_DefControls : public CCC_UnBindAll { kPDA_MAP_SHOW_ACTOR, { SDL_SCANCODE_R, SDL_SCANCODE_KP_COMMA, XR_CONTROLLER_BUTTON_RIGHTSTICK } }, { kPDA_MAP_SHOW_LEGEND, { SDL_SCANCODE_V, SDL_SCANCODE_KP_MULTIPLY, XR_CONTROLLER_BUTTON_INVALID } }, - { kPDA_FILTER_TOGGLE, { SDL_SCANCODE_B, SDL_SCANCODE_UNKNOWN, XR_CONTROLLER_BUTTON_Y } }, + { kPDA_TASKS_TOGGLE, { SDL_SCANCODE_TAB, SDL_SCANCODE_UNKNOWN, XR_CONTROLLER_BUTTON_X } }, // Talk: { kTALK_SWITCH_TO_TRADE, { SDL_SCANCODE_X, SDL_SCANCODE_UNKNOWN, XR_CONTROLLER_BUTTON_X } }, diff --git a/src/xrEngine/xr_level_controller.h b/src/xrEngine/xr_level_controller.h index 962292c487b..f307e5f201a 100644 --- a/src/xrEngine/xr_level_controller.h +++ b/src/xrEngine/xr_level_controller.h @@ -138,6 +138,8 @@ enum EGameActions : u32 kUI_ACCEPT, kUI_BACK, + kUI_ACTION_1, + kUI_ACTION_2, kUI_TAB_PREV, kUI_TAB_NEXT, @@ -168,6 +170,7 @@ enum EGameActions : u32 kPDA_MAP_SHOW_LEGEND, kPDA_FILTER_TOGGLE, + kPDA_TASKS_TOGGLE, // Talk: kTALK_SWITCH_TO_TRADE, // _OR_UPGRADE diff --git a/src/xrGame/ui/UISecondTaskWnd.cpp b/src/xrGame/ui/UISecondTaskWnd.cpp index 002243e43a3..49f5aef81eb 100644 --- a/src/xrGame/ui/UISecondTaskWnd.cpp +++ b/src/xrGame/ui/UISecondTaskWnd.cpp @@ -78,6 +78,17 @@ void UITaskListWnd::OnMouseScroll(float iDirection) else if (iDirection == WINDOW_MOUSE_WHEEL_DOWN) m_list->ScrollBar()->TryScrollInc(); } + +bool UITaskListWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) +{ + return inherited::OnKeyboardAction(dik, keyboard_action); +} + +bool UITaskListWnd::OnControllerAction(int axis, float x, float y, EUIMessages controller_action) +{ + return inherited::OnControllerAction(axis, x, y, controller_action); +} + void UITaskListWnd::Show(bool status) { inherited::Show(status); diff --git a/src/xrGame/ui/UISecondTaskWnd.h b/src/xrGame/ui/UISecondTaskWnd.h index 1a6be1d9c8a..c738166e184 100644 --- a/src/xrGame/ui/UISecondTaskWnd.h +++ b/src/xrGame/ui/UISecondTaskWnd.h @@ -36,6 +36,8 @@ class UITaskListWnd final : public CUIWindow, public CUIWndCallback virtual bool OnMouseAction(float x, float y, EUIMessages mouse_action); virtual void OnMouseScroll(float iDirection); + bool OnKeyboardAction(int dik, EUIMessages keyboard_action) override; + bool OnControllerAction(int axis, float x, float y, EUIMessages controller_action) override; virtual void Show(bool status); virtual void OnFocusReceive(); virtual void OnFocusLost(); diff --git a/src/xrGame/ui/UITaskWnd.cpp b/src/xrGame/ui/UITaskWnd.cpp index ba957440ba2..e7b0018587a 100644 --- a/src/xrGame/ui/UITaskWnd.cpp +++ b/src/xrGame/ui/UITaskWnd.cpp @@ -161,6 +161,14 @@ bool CUITaskWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) SetKeyboardCapture(&m_filters, true); m_filters.SendMessage(this, PDA_TASK_SELECT_FILTERS, nullptr); return true; + + case kPDA_TASKS_TOGGLE: + if (m_pKeyboardCapturer == m_task_wnd) + SetKeyboardCapture(nullptr, false); + else + SetKeyboardCapture(m_task_wnd, true); + OnShowTaskListWnd(nullptr, nullptr); + return true; } }