mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-26 00:23:55 -07:00
[Game] Move graphics out of game and into game_graphics (#6928)
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 15 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 15 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run
* [Game][Player] Pull out graphics_items out of player_logic Took 25 seconds Took 9 minutes * [Game] Move graphics files into game_graphics Took 1 minute Took 2 minutes Took 23 seconds Took 1 minute Took 2 seconds * Include. Took 4 minutes Took 3 minutes Took 4 minutes Took 1 minute Took 3 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
cbfd286908
commit
da4ba222c0
116 changed files with 208 additions and 198 deletions
|
|
@ -1,139 +0,0 @@
|
|||
#include "player_menu.h"
|
||||
|
||||
#include "../../../game_graphics/zones/hand_zone.h"
|
||||
#include "../../../game_graphics/zones/pile_zone.h"
|
||||
#include "../../../game_graphics/zones/table_zone.h"
|
||||
#include "../../../interface/widgets/tabs/tab_game.h"
|
||||
#include "../../board/card_item.h"
|
||||
#include "card_menu.h"
|
||||
#include "hand_menu.h"
|
||||
|
||||
#include <libcockatrice/protocol/pb/command_reveal_cards.pb.h>
|
||||
|
||||
PlayerMenu::PlayerMenu(PlayerGraphicsItem *_player) : QObject(_player), player(_player)
|
||||
{
|
||||
connect(player->getLogic(), &PlayerLogic::requestCardMenuUpdate, this, &PlayerMenu::updateCardMenu);
|
||||
connect(this, &PlayerMenu::cardInfoRequested, player, &PlayerGraphicsItem::cardInfoRequested);
|
||||
|
||||
playerMenu = new TearOffMenu();
|
||||
|
||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
||||
handMenu = addManagedMenu<HandMenu>(player, playerMenu);
|
||||
libraryMenu = addManagedMenu<LibraryMenu>(player, playerMenu);
|
||||
} else {
|
||||
handMenu = nullptr;
|
||||
libraryMenu = nullptr;
|
||||
}
|
||||
|
||||
graveMenu = addManagedMenu<GraveyardMenu>(player, playerMenu);
|
||||
rfgMenu = addManagedMenu<RfgMenu>(player, playerMenu);
|
||||
|
||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
||||
sideboardMenu = addManagedMenu<SideboardMenu>(player, playerMenu);
|
||||
customZonesMenu = addManagedMenu<CustomZoneMenu>(player);
|
||||
playerMenu->addSeparator();
|
||||
|
||||
countersMenu = playerMenu->addMenu(QString());
|
||||
|
||||
utilityMenu = createManagedComponent<UtilityMenu>(player, playerMenu);
|
||||
} else {
|
||||
sideboardMenu = nullptr;
|
||||
customZonesMenu = nullptr;
|
||||
countersMenu = nullptr;
|
||||
utilityMenu = nullptr;
|
||||
}
|
||||
|
||||
if (player->getLogic()->getPlayerInfo()->getLocal()) {
|
||||
sayMenu = addManagedMenu<SayMenu>(player);
|
||||
} else {
|
||||
sayMenu = nullptr;
|
||||
}
|
||||
|
||||
connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
|
||||
&PlayerMenu::refreshShortcuts);
|
||||
refreshShortcuts();
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
void PlayerMenu::setMenusForGraphicItems()
|
||||
{
|
||||
player->getTableZoneGraphicsItem()->setMenu(playerMenu);
|
||||
player->getGraveyardZoneGraphicsItem()->setMenu(graveMenu, graveMenu->aViewGraveyard);
|
||||
player->getRfgZoneGraphicsItem()->setMenu(rfgMenu, rfgMenu->aViewRfg);
|
||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
||||
player->getHandZoneGraphicsItem()->setMenu(handMenu);
|
||||
player->getDeckZoneGraphicsItem()->setMenu(libraryMenu, libraryMenu->aDrawCard);
|
||||
player->getSideboardZoneGraphicsItem()->setMenu(sideboardMenu);
|
||||
}
|
||||
}
|
||||
|
||||
QMenu *PlayerMenu::updateCardMenu(const CardItem *card)
|
||||
{
|
||||
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 ((player->getLogic()->getGame()->getPlayerManager()->isSpectator() &&
|
||||
!player->getLogic()->getGame()->getPlayerManager()->isJudge()) ||
|
||||
player->getLogic()->getGame()->getActiveCard() != card) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CardMenu *menu = new CardMenu(player, card, shortcutsActive);
|
||||
connect(menu, &CardMenu::cardInfoRequested, this, &PlayerMenu::cardInfoRequested);
|
||||
emit cardMenuUpdated(menu);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
void PlayerMenu::retranslateUi()
|
||||
{
|
||||
playerMenu->setTitle(tr("Player \"%1\"").arg(player->getLogic()->getPlayerInfo()->getName()));
|
||||
|
||||
for (auto *component : managedComponents) {
|
||||
component->retranslateUi();
|
||||
}
|
||||
|
||||
if (countersMenu) {
|
||||
countersMenu->setTitle(tr("&Counters"));
|
||||
}
|
||||
|
||||
emit retranslateRequested();
|
||||
}
|
||||
|
||||
void PlayerMenu::refreshShortcuts()
|
||||
{
|
||||
if (shortcutsActive) {
|
||||
// Judges get access to every player's menus but only want shortcuts to be set for their own.
|
||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge() &&
|
||||
!player->getLogic()->getPlayerInfo()->getLocal()) {
|
||||
setShortcutsInactive();
|
||||
} else {
|
||||
setShortcutsActive();
|
||||
}
|
||||
} else {
|
||||
setShortcutsInactive();
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerMenu::setShortcutsActive()
|
||||
{
|
||||
shortcutsActive = true;
|
||||
for (auto *c : managedComponents) {
|
||||
c->setShortcutsActive();
|
||||
}
|
||||
emit shortcutsActivated();
|
||||
}
|
||||
|
||||
void PlayerMenu::setShortcutsInactive()
|
||||
{
|
||||
shortcutsActive = false;
|
||||
for (auto *c : managedComponents) {
|
||||
c->setShortcutsInactive();
|
||||
}
|
||||
emit shortcutsDeactivated();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue