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

@ -11,6 +11,7 @@
#include "../board/card_list.h"
#include "../board/counter_general.h"
#include "../game_scene.h"
#include "../keyboard_card_navigator.h"
#include "player_actions.h"
#include "player_target.h"
@ -323,6 +324,9 @@ bool PlayerLogic::clearCardsToDelete()
void PlayerLogic::setActive(bool _active)
{
active = _active;
if (_active == true) {
hoverFirstCardInHand();
}
emit activeChanged(active);
}
@ -348,3 +352,20 @@ void PlayerLogic::setGameStarted()
}
setConceded(false);
}
void PlayerLogic::hoverFirstCardInHand()
{
HandZoneLogic *handZone = getHandZone();
if (!handZone) {
return;
}
const CardList &handCards = handZone->getCards();
if (!handCards.isEmpty()) {
CardItem *firstCard = handCards.at(0);
if (firstCard) {
firstCard->setHovered(true);
getGameScene()->getCardNavigator()->unhoverCard();
getGameScene()->getCardNavigator()->setHoveredCardIndex(0);
}
}
}

View file

@ -229,6 +229,8 @@ public:
void setZoneId(int _zoneId);
void hoverFirstCardInHand();
private:
AbstractGame *game;
PlayerInfo *playerInfo;