Skip to content

Commit

Permalink
Added ability to open tasks list in the PDA using gamepad and keyboard (
Browse files Browse the repository at this point in the history
#943)

Added two UI actions stubs
  • Loading branch information
Xottab-DUTY committed Aug 11, 2023
1 parent b91375b commit 8eedccb
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/xrEngine/key_binding_registrator_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down Expand Up @@ -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)),
Expand Down
7 changes: 6 additions & 1 deletion src/xrEngine/xr_level_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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 } },
Expand Down Expand Up @@ -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 } },
Expand Down
3 changes: 3 additions & 0 deletions src/xrEngine/xr_level_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ enum EGameActions : u32

kUI_ACCEPT,
kUI_BACK,
kUI_ACTION_1,
kUI_ACTION_2,

kUI_TAB_PREV,
kUI_TAB_NEXT,
Expand Down Expand Up @@ -168,6 +170,7 @@ enum EGameActions : u32
kPDA_MAP_SHOW_LEGEND,

kPDA_FILTER_TOGGLE,
kPDA_TASKS_TOGGLE,

// Talk:
kTALK_SWITCH_TO_TRADE, // _OR_UPGRADE
Expand Down
11 changes: 11 additions & 0 deletions src/xrGame/ui/UISecondTaskWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/xrGame/ui/UISecondTaskWnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions src/xrGame/ui/UITaskWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 8eedccb

Please sign in to comment.