diff --git a/src/xrEngine/xr_level_controller.cpp b/src/xrEngine/xr_level_controller.cpp index 01f03d20477..0b1e0177d40 100644 --- a/src/xrEngine/xr_level_controller.cpp +++ b/src/xrEngine/xr_level_controller.cpp @@ -182,6 +182,12 @@ game_action actions[] = { { "pda_filter_toggle", kPDA_FILTER_TOGGLE, _sp, EKeyContext::PDA }, + // Talk: + { "talk_switch_to_trade", kTALK_SWITCH_TO_TRADE, _sp, EKeyContext::Talk }, + { "talk_log_scroll", kTALK_LOG_SCROLL, _sp, EKeyContext::Talk }, + { "talk_log_scroll_up", kTALK_LOG_SCROLL_UP, _sp, EKeyContext::Talk }, + { "talk_log_scroll_down", kTALK_LOG_SCROLL_DOWN, _sp, EKeyContext::Talk }, + { nullptr, kLASTACTION, _both } }; @@ -988,6 +994,12 @@ class CCC_DefControls : public CCC_UnBindAll { kPDA_FILTER_TOGGLE, { SDL_SCANCODE_B, SDL_SCANCODE_UNKNOWN, XR_CONTROLLER_BUTTON_Y } }, + // Talk: + { kTALK_SWITCH_TO_TRADE, { SDL_SCANCODE_X, SDL_SCANCODE_UNKNOWN, XR_CONTROLLER_BUTTON_X } }, + { kTALK_LOG_SCROLL, { SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, XR_CONTROLLER_AXIS_RIGHT } }, + { kTALK_LOG_SCROLL_UP, { SDL_SCANCODE_E, SDL_SCANCODE_PAGEUP, XR_CONTROLLER_AXIS_TRIGGER_LEFT } }, + { kTALK_LOG_SCROLL_DOWN, { SDL_SCANCODE_Q, SDL_SCANCODE_PAGEDOWN, XR_CONTROLLER_AXIS_TRIGGER_RIGHT } }, + { kEDITOR, { SDL_SCANCODE_F10, SDL_SCANCODE_UNKNOWN, XR_CONTROLLER_BUTTON_INVALID } }, }; diff --git a/src/xrEngine/xr_level_controller.h b/src/xrEngine/xr_level_controller.h index a2098ba6030..71f6542b1fd 100644 --- a/src/xrEngine/xr_level_controller.h +++ b/src/xrEngine/xr_level_controller.h @@ -164,6 +164,12 @@ enum EGameActions : u32 kPDA_FILTER_TOGGLE, + // Talk: + kTALK_SWITCH_TO_TRADE, // _OR_UPGRADE + kTALK_LOG_SCROLL, + kTALK_LOG_SCROLL_UP, + kTALK_LOG_SCROLL_DOWN, + kLASTACTION, kNOTBINDED }; @@ -173,6 +179,7 @@ enum class EKeyContext Undefined = 0, // default behaviour UI, // UI overall PDA, + Talk, }; constexpr char GAME_ACTION_MARK = 27; // escape symbol diff --git a/src/xrGame/ui/UITalkDialogWnd.cpp b/src/xrGame/ui/UITalkDialogWnd.cpp index 1ac554116b3..b30c47bd28f 100644 --- a/src/xrGame/ui/UITalkDialogWnd.cpp +++ b/src/xrGame/ui/UITalkDialogWnd.cpp @@ -338,6 +338,14 @@ void CUITalkDialogWnd::UpdateButtonsLayout(bool b_disable_break, bool trade_enab } } +void CUITalkDialogWnd::TryScrollAnswersList(bool down) +{ + if (down) + UIAnswersList->ScrollBar()->TryScrollDec(); + else + UIAnswersList->ScrollBar()->TryScrollInc(); +} + void CUIQuestionItem::SendMessage(CUIWindow* pWnd, s16 msg, void* pData) { CUIWndCallback::OnEvent(pWnd, msg, pData); } CUIQuestionItem::CUIQuestionItem(CUIXml* xml_doc, LPCSTR path) : CUIWindow("CUIQuestionItem") diff --git a/src/xrGame/ui/UITalkDialogWnd.h b/src/xrGame/ui/UITalkDialogWnd.h index 819e76a353a..93c2ddaa1e6 100644 --- a/src/xrGame/ui/UITalkDialogWnd.h +++ b/src/xrGame/ui/UITalkDialogWnd.h @@ -68,6 +68,8 @@ class CUITalkDialogWnd final : public CUIWindow, public CUIWndCallback void SetTradeMode(); void UpdateButtonsLayout(bool b_disable_break, bool trade_enabled); + void TryScrollAnswersList(bool down); + private: // List of questions we can ask the character CUIScrollView* UIQuestionsList; diff --git a/src/xrGame/ui/UITalkWnd.cpp b/src/xrGame/ui/UITalkWnd.cpp index 4d4846ec637..028632fe6f8 100644 --- a/src/xrGame/ui/UITalkWnd.cpp +++ b/src/xrGame/ui/UITalkWnd.cpp @@ -347,7 +347,7 @@ bool CUITalkWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) { if (keyboard_action == WINDOW_KEY_PRESSED) { - if (IsBinded(kUSE, dik) || IsBinded(kQUIT, dik)) + if (IsBinded(kUSE, dik) || IsBinded(kQUIT, dik) || IsBinded(kUI_BACK, dik, EKeyContext::UI)) { if (!b_disable_break) { @@ -355,8 +355,9 @@ bool CUITalkWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) return true; } } - else if (IsBinded(kSPRINT_TOGGLE, dik)) + switch (GetBindedAction(dik, EKeyContext::Talk)) { + case kTALK_SWITCH_TO_TRADE: if (!m_pOthersInvOwner->NeedOsoznanieMode()) { if (UITalkDialogWnd->mechanic_mode) @@ -365,12 +366,39 @@ bool CUITalkWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) SwitchToTrade(); return true; } + break; + } + } + else if (keyboard_action == WINDOW_KEY_HOLD) + { + switch (GetBindedAction(dik, EKeyContext::Talk)) + { + case kTALK_LOG_SCROLL_UP: + UITalkDialogWnd->TryScrollAnswersList(false); + break; + case kTALK_LOG_SCROLL_DOWN: + UITalkDialogWnd->TryScrollAnswersList(true); + break; } } - return inherited::OnKeyboardAction(dik, keyboard_action); } +bool CUITalkWnd::OnControllerAction(int axis, float x, float y, EUIMessages controller_action) +{ + if (controller_action == WINDOW_KEY_PRESSED) + { + switch (GetBindedAction(axis, EKeyContext::Trade)) + { + default: + return OnKeyboardAction(axis, controller_action); + case kTALK_LOG_SCROLL: + return true; + } + } + return inherited::OnControllerAction(axis, x, y, controller_action); +} + void CUITalkWnd::PlaySnd(LPCSTR text) { u32 text_len = xr_strlen(text); diff --git a/src/xrGame/ui/UITalkWnd.h b/src/xrGame/ui/UITalkWnd.h index 91f7b125204..aa46935d148 100644 --- a/src/xrGame/ui/UITalkWnd.h +++ b/src/xrGame/ui/UITalkWnd.h @@ -46,6 +46,7 @@ class CUITalkWnd final : public CUIDialogWnd //инициализации начального диалога собеседника void InitOthersStartDialog(); virtual bool OnKeyboardAction(int dik, EUIMessages keyboard_action); + bool OnControllerAction(int axis, float x, float y, EUIMessages controller_action) override; void SwitchToTrade(); void SwitchToUpgrade(); void AddIconedMessage(LPCSTR caption, LPCSTR text, LPCSTR texture_name, LPCSTR templ_name);