mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 09:04:53 -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
124
cockatrice/src/game_graphics/player/menu/grave_menu.cpp
Normal file
124
cockatrice/src/game_graphics/player/menu/grave_menu.cpp
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
#include "grave_menu.h"
|
||||
|
||||
#include "../../game/abstract_game.h"
|
||||
#include "../../game/player/player_actions.h"
|
||||
#include "../../game/player/player_logic.h"
|
||||
#include "../player_graphics_item.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <libcockatrice/utility/zone_names.h>
|
||||
|
||||
GraveyardMenu::GraveyardMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||
{
|
||||
createMoveActions();
|
||||
createViewActions();
|
||||
|
||||
addAction(aViewGraveyard);
|
||||
|
||||
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
||||
mRevealRandomGraveyardCard = addMenu(QString());
|
||||
connect(mRevealRandomGraveyardCard, &QMenu::aboutToShow, this,
|
||||
&GraveyardMenu::populateRevealRandomMenuWithActivePlayers);
|
||||
|
||||
addSeparator();
|
||||
|
||||
moveGraveMenu = addTearOffMenu(QString());
|
||||
moveGraveMenu->addAction(aMoveGraveToTopLibrary);
|
||||
moveGraveMenu->addAction(aMoveGraveToBottomLibrary);
|
||||
moveGraveMenu->addSeparator();
|
||||
moveGraveMenu->addAction(aMoveGraveToHand);
|
||||
moveGraveMenu->addSeparator();
|
||||
moveGraveMenu->addAction(aMoveGraveToRfg);
|
||||
}
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
void GraveyardMenu::createMoveActions()
|
||||
{
|
||||
auto grave = player->getLogic()->getGraveZone();
|
||||
|
||||
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
||||
aMoveGraveToTopLibrary = new QAction(this);
|
||||
aMoveGraveToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
||||
|
||||
aMoveGraveToBottomLibrary = new QAction(this);
|
||||
aMoveGraveToBottomLibrary->setData(QList<QVariant>() << ZoneNames::DECK << -1);
|
||||
|
||||
aMoveGraveToHand = new QAction(this);
|
||||
aMoveGraveToHand->setData(QList<QVariant>() << ZoneNames::HAND << 0);
|
||||
|
||||
aMoveGraveToRfg = new QAction(this);
|
||||
aMoveGraveToRfg->setData(QList<QVariant>() << ZoneNames::EXILE << 0);
|
||||
|
||||
connect(aMoveGraveToTopLibrary, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
|
||||
connect(aMoveGraveToBottomLibrary, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
|
||||
connect(aMoveGraveToHand, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
|
||||
connect(aMoveGraveToRfg, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
|
||||
}
|
||||
}
|
||||
|
||||
void GraveyardMenu::createViewActions()
|
||||
{
|
||||
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
||||
|
||||
aViewGraveyard = new QAction(this);
|
||||
connect(aViewGraveyard, &QAction::triggered, playerActions, &PlayerActions::actViewGraveyard);
|
||||
}
|
||||
|
||||
void GraveyardMenu::populateRevealRandomMenuWithActivePlayers()
|
||||
{
|
||||
mRevealRandomGraveyardCard->clear();
|
||||
|
||||
QAction *allPlayers = mRevealRandomGraveyardCard->addAction(tr("&All players"));
|
||||
allPlayers->setData(-1);
|
||||
connect(allPlayers, &QAction::triggered, this, &GraveyardMenu::onRevealRandomTriggered);
|
||||
|
||||
mRevealRandomGraveyardCard->addSeparator();
|
||||
|
||||
const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
||||
for (auto *other : players) {
|
||||
if (other == player->getLogic()) {
|
||||
continue;
|
||||
}
|
||||
QAction *a = mRevealRandomGraveyardCard->addAction(other->getPlayerInfo()->getName());
|
||||
a->setData(other->getPlayerInfo()->getId());
|
||||
connect(a, &QAction::triggered, this, &GraveyardMenu::onRevealRandomTriggered);
|
||||
}
|
||||
}
|
||||
|
||||
void GraveyardMenu::onRevealRandomTriggered()
|
||||
{
|
||||
if (auto *a = qobject_cast<QAction *>(sender())) {
|
||||
player->getLogic()->getPlayerActions()->actRevealRandomGraveyardCard(a->data().toInt());
|
||||
}
|
||||
}
|
||||
|
||||
void GraveyardMenu::retranslateUi()
|
||||
{
|
||||
setTitle(tr("&Graveyard"));
|
||||
|
||||
aViewGraveyard->setText(tr("&View graveyard"));
|
||||
|
||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
||||
moveGraveMenu->setTitle(tr("&Move graveyard to..."));
|
||||
aMoveGraveToTopLibrary->setText(tr("&Top of library"));
|
||||
aMoveGraveToBottomLibrary->setText(tr("&Bottom of library"));
|
||||
aMoveGraveToHand->setText(tr("&Hand"));
|
||||
aMoveGraveToRfg->setText(tr("&Exile"));
|
||||
|
||||
mRevealRandomGraveyardCard->setTitle(tr("Reveal random card to..."));
|
||||
}
|
||||
}
|
||||
|
||||
void GraveyardMenu::setShortcutsActive()
|
||||
{
|
||||
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
|
||||
aViewGraveyard->setShortcuts(shortcuts.getShortcut("Player/aViewGraveyard"));
|
||||
}
|
||||
|
||||
void GraveyardMenu::setShortcutsInactive()
|
||||
{
|
||||
aViewGraveyard->setShortcut(QKeySequence());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue