Implement in-game navigation with keyboard

Implements a start to the keyboard navigation with the direction arrows
and the space key for card selection.
Some binds are still needed, but navigating the board is now possible.
The feature includes tests for the implemented feature.

Closes #5043

Co-authored-by: Manuel Ramos Monge <manuel.monge@tecnico.ulisboa.pt>
This commit is contained in:
Vasco Guerreiro Vintém Morais 2026-06-02 17:09:39 +01:00
parent 3fa377a11c
commit 5acce8998e
22 changed files with 1023 additions and 46 deletions

View file

@ -23,6 +23,7 @@ class CardItem;
class ServerInfo_Card;
class PhasesToolbar;
class QBasicTimer;
class KeyboardCardNavigator;
/**
* @class GameScene
@ -52,6 +53,7 @@ private:
QBasicTimer *animationTimer; ///< Timer for card animations
QSet<CardItem *> cardsToAnimate; ///< Cards currently animating
int playerRotation; ///< Rotation offset for player layout
KeyboardCardNavigator *cardNavigator; ///< Handles keyboard-based card navigation
/**
* @brief Updates which card is currently hovered based on scene coordinates.
@ -171,6 +173,12 @@ public:
/** @brief Updates hovered card highlighting. */
void updateHoveredCard(CardItem *newCard);
/** @brief Gets the keyboard card navigator. */
KeyboardCardNavigator *getCardNavigator() const
{
return cardNavigator;
}
/** @brief Registers a card for animation updates. */
void registerAnimationItem(AbstractCardItem *card);
@ -206,6 +214,17 @@ public slots:
void deleteArrow(int arrowId);
void clearArrowsForPlayer(int playerId);
/** @brief Handles left arrow key for card navigation. */
void handleLeftArrow();
/** @brief Handles right arrow key for card navigation. */
void handleRightArrow();
/** @brief Handles up arrow key for zone navigation. */
void handleUpArrow();
/** @brief Handles down arrow key for zone navigation. */
void handleDownArrow();
/** @brief Sets the active player for keyboard navigation. */
void setActivePlayer(PlayerLogic *player);
/// Queues up arrow deletion but doesn't directly modify the scene
void requestArrowDeletion(int arrowId);
void requestClearArrowsForPlayer(int playerId);