@@ -55,7 +55,7 @@ void CDialogHolder::StartMenu(CUIDialogWnd* pDialog, bool bDoHideIndicators)
5555 CurrentGameUI ()->ShowGameIndicators (false );
5656 }
5757 }
58- SetFocused (nullptr );
58+ UI (). Focus (). SetFocused (nullptr );
5959 pDialog->SetHolder (this );
6060
6161 if (pDialog->NeedCursor ())
@@ -248,6 +248,9 @@ void CDialogHolder::OnFrame()
248248 (*it).wnd ->Update ();
249249 }
250250
251+ if (m_is_foremost)
252+ UI ().Focus ().Update (wnd);
253+
251254 m_b_in_update = false ;
252255 if (!m_dialogsToRender_new.empty ())
253256 {
@@ -316,6 +319,33 @@ bool CDialogHolder::IR_UIOnKeyboardPress(int dik)
316319 if (TIR->OnKeyboardAction (dik, WINDOW_KEY_PRESSED))
317320 return true ;
318321
322+ if (dik > XR_CONTROLLER_BUTTON_INVALID && dik < XR_CONTROLLER_BUTTON_MAX)
323+ {
324+ FocusDirection direction = FocusDirection::Same;
325+ switch (GetBindedAction (dik, EKeyContext::UI))
326+ {
327+ case kUI_MOVE_LEFT : direction = FocusDirection::Left; break ;
328+ case kUI_MOVE_RIGHT : direction = FocusDirection::Right; break ;
329+ case kUI_MOVE_UP : direction = FocusDirection::Up; break ;
330+ case kUI_MOVE_DOWN : direction = FocusDirection::Down; break ;
331+ }
332+
333+ if (direction != FocusDirection::Same)
334+ {
335+ auto & focus = UI ().Focus ();
336+ const auto focused = focus.GetFocused ();
337+ const Fvector2 vec = focused ? focused->GetWndPos () : UI ().GetUICursor ().GetCursorPosition ();
338+ const auto [target, direct] = focus.FindClosestFocusable (vec, direction);
339+
340+ if (target)
341+ {
342+ focus.SetFocused (target);
343+ GetUICursor ().WarpToWindow (target, true );
344+ return true ;
345+ }
346+ }
347+ }
348+
319349 if (!TIR->StopAnyMove () && g_pGameLevel)
320350 {
321351 IGameObject* O = Level ().CurrentEntity ();
@@ -334,24 +364,6 @@ bool CDialogHolder::IR_UIOnKeyboardPress(int dik)
334364 }
335365 }
336366
337- /* if (const auto focused = GetFocused())
338- {
339- CUIWindow* target{};
340- switch (GetBindedAction(dik, EKeyContext::UI))
341- {
342- case kUI_MOVE_LEFT: target = FindClosestFocusable(focused, FocusDirection::Left); break;
343- case kUI_MOVE_RIGHT: target = FindClosestFocusable(focused, FocusDirection::Right); break;
344- case kUI_MOVE_UP: target = FindClosestFocusable(focused, FocusDirection::Up); break;
345- case kUI_MOVE_DOWN: target = FindClosestFocusable(focused, FocusDirection::Down); break;
346- }
347-
348- if (target)
349- {
350- SetFocused(target);
351- GetUICursor().WarpToWindow(target, true);
352- }
353- }*/
354-
355367 return true ;
356368}
357369
@@ -574,6 +586,7 @@ bool CDialogHolder::IR_UIOnControllerHold(int dik, float x, float y)
574586
575587bool CDialogHolder::FillDebugTree (const CUIDebugState& debugState)
576588{
589+ #ifndef MASTER_GOLD
577590 // XXX: Was this meant to be used somewhere here? Because currently its unused and could also be constexpr
578591 // ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_OpenOnArrow;
579592
@@ -600,6 +613,7 @@ bool CDialogHolder::FillDebugTree(const CUIDebugState& debugState)
600613 ImGui::TreePop ();
601614 }
602615 }
616+ #endif
603617 return true ;
604618}
605619
0 commit comments