Cockatrice/cockatrice/src/game/player/menu/custom_zone_menu.cpp
BruebachL 5219cffa6b
[Player] Rename player to player logic (#6913)
Took 13 minutes

Took 6 seconds

Took 2 minutes

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-05-19 12:36:31 +02:00

41 lines
No EOL
1.2 KiB
C++

#include "custom_zone_menu.h"
#include "../player_logic.h"
CustomZoneMenu::CustomZoneMenu(PlayerLogic *_player) : player(_player)
{
menuAction()->setVisible(false);
connect(player, &PlayerLogic::clearCustomZonesMenu, this, &CustomZoneMenu::clearCustomZonesMenu);
connect(player, &PlayerLogic::addViewCustomZoneActionToCustomZoneMenu, this,
&CustomZoneMenu::addViewCustomZoneActionToCustomZoneMenu);
retranslateUi();
}
void CustomZoneMenu::retranslateUi()
{
setTitle(tr("C&ustom Zones"));
if (player->getPlayerInfo()->getLocalOrJudge()) {
for (auto aViewZone : actions()) {
aViewZone->setText(tr("View custom zone '%1'").arg(aViewZone->data().toString()));
}
}
}
void CustomZoneMenu::clearCustomZonesMenu()
{
clear();
menuAction()->setVisible(false);
}
void CustomZoneMenu::addViewCustomZoneActionToCustomZoneMenu(QString zoneName)
{
menuAction()->setVisible(true);
QAction *aViewZone = addAction(tr("View custom zone '%1'").arg(zoneName));
aViewZone->setData(zoneName);
connect(aViewZone, &QAction::triggered, this,
[zoneName, this]() { player->getGameScene()->toggleZoneView(player, zoneName, -1); });
}