Skip to content

Commit

Permalink
Fix #5085 and #5152
Browse files Browse the repository at this point in the history
- In the pause menu, the buttons are part of ribbon widgets. Under certain conditions, the game could incorrectly select the underlying back button as active instead of its ribbon. Because the icon buttons that constitute a ribbon widget don't have their x or y property set, a check that x or y are not negative ensures that keyboard navigation doesn't select them.
- The multiplayer focus dispatcher button is made invisible if there is only one player in the kart selection screen.
- Add a getName() function to the Widget class, to help when debugging GUI.
  • Loading branch information
Alayan-stk-2 committed Aug 11, 2024
1 parent 5fe2e9e commit 427455a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/guiengine/event_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,12 @@ int EventHandler::findIDClosestWidget(const NavigationDirection nav, const int p
// - it corresponds to the current widget
// - it corresponds to an invisible or disabled widget
// - the player is not allowed to select it
// - Its base coordinates are negative (such as buttons within ribbons)
if (w_test == NULL || !Widget::isFocusableId(i) || w == w_test ||
(!w_test->isVisible() && ignore_disabled) ||
(!w_test->isActivated() && ignore_disabled) ||
(playerID != PLAYER_ID_GAME_MASTER && !w_test->m_supports_multiplayer))
(playerID != PLAYER_ID_GAME_MASTER && !w_test->m_supports_multiplayer) ||
(w_test->m_x < 0) || (w_test->m_y < 0))
continue;

// Ignore empty ribbon widgets and lists
Expand Down
4 changes: 4 additions & 0 deletions src/guiengine/widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,10 @@ namespace GUIEngine
*/
int getID() const { return m_id; }

/** Get the name used for this widget in the GUI files or set in the code
* Use only for debugging. */
std::string getName() { return m_properties[PROP_ID]; }

/** Get whether this object is allowed to receive focus */
bool isFocusable() const { return m_focusable; }

Expand Down
6 changes: 3 additions & 3 deletions src/states_screens/kart_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ EventPropagation FocusDispatcher::focused(const int player_id)
// ->getIrrlichtElement()->getID() <<
// ")" << std::endl;

m_parent->m_kart_widgets[n].m_player_ident_spinner
->setFocusForPlayer(player_id);

m_parent->m_kart_widgets[n].m_player_ident_spinner->setFocusForPlayer(player_id);

return GUIEngine::EVENT_BLOCK;
}
Expand Down Expand Up @@ -438,6 +436,8 @@ void KartSelectionScreen::init()
// if kart from config not found, select the first instead
w->setSelection(0, 0, true);
}

m_dispatcher->setVisible(false);
}
else
{
Expand Down

0 comments on commit 427455a

Please sign in to comment.