mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 22:42:14 -07:00
move checking to updateCardMenu
This commit is contained in:
parent
32d13062ff
commit
5e028abee3
1 changed files with 15 additions and 8 deletions
|
|
@ -3892,9 +3892,7 @@ void Player::refreshShortcuts()
|
|||
|
||||
QMenu *Player::createCardMenu(const CardItem *card)
|
||||
{
|
||||
// If bad card OR is a spectator (as spectators don't need card menus), return
|
||||
// only update the menu if the card is actually selected
|
||||
if (card == nullptr || (game->isSpectator() && !judge) || game->getActiveCard() != card) {
|
||||
if (card == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -4218,18 +4216,27 @@ void Player::addRelatedCardActions(const CardItem *card, QMenu *cardMenu)
|
|||
|
||||
/**
|
||||
* Creates a card menu from the given card and sets it as the currently active card menu.
|
||||
* Will first check if the card should have a card menu, and no-ops if not.
|
||||
*
|
||||
* @param card The card to create the menu for. Pass nullptr to disable the card menu.
|
||||
* @return The new card menu
|
||||
* @return The new card menu, or nullptr if failed.
|
||||
*/
|
||||
QMenu *Player::updateCardMenu(const CardItem *card)
|
||||
{
|
||||
QMenu *menu = createCardMenu(card);
|
||||
|
||||
if (menu) {
|
||||
emit cardMenuUpdated(menu);
|
||||
if (!card) {
|
||||
emit cardMenuUpdated(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If is spectator (as spectators don't need card menus), return
|
||||
// only update the menu if the card is actually selected
|
||||
if ((game->isSpectator() && !judge) || game->getActiveCard() != card) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QMenu *menu = createCardMenu(card);
|
||||
emit cardMenuUpdated(menu);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue