mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-03 03:53:56 -07:00
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:
parent
3fa377a11c
commit
5acce8998e
22 changed files with 1023 additions and 46 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -229,6 +229,8 @@ public:
|
|||
|
||||
void setZoneId(int _zoneId);
|
||||
|
||||
void hoverFirstCardInHand();
|
||||
|
||||
private:
|
||||
AbstractGame *game;
|
||||
PlayerInfo *playerInfo;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue