mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-01 02:53:56 -07:00
Resolve PlayerActions at call time instead of capturing at construction
This commit is contained in:
parent
57fc10dc02
commit
be5c989214
1 changed files with 30 additions and 14 deletions
|
|
@ -31,40 +31,56 @@ CommandZoneMenu::CommandZoneMenu(PlayerGraphicsItem *_player, QMenu *playerMenu)
|
||||||
addAction(aViewZone);
|
addAction(aViewZone);
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
|
||||||
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
|
||||||
|
|
||||||
aIncreaseCommanderTax = new QAction(this);
|
aIncreaseCommanderTax = new QAction(this);
|
||||||
connect(aIncreaseCommanderTax, &QAction::triggered, this,
|
connect(aIncreaseCommanderTax, &QAction::triggered, this, [this]() {
|
||||||
[playerActions]() { playerActions->actModifyTaxCounter(CounterIds::CommanderTax, 1); });
|
if (auto *logic = player->getLogic()) {
|
||||||
|
logic->getPlayerActions()->actModifyTaxCounter(CounterIds::CommanderTax, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
addAction(aIncreaseCommanderTax);
|
addAction(aIncreaseCommanderTax);
|
||||||
|
|
||||||
aDecreaseCommanderTax = new QAction(this);
|
aDecreaseCommanderTax = new QAction(this);
|
||||||
connect(aDecreaseCommanderTax, &QAction::triggered, this,
|
connect(aDecreaseCommanderTax, &QAction::triggered, this, [this]() {
|
||||||
[playerActions]() { playerActions->actModifyTaxCounter(CounterIds::CommanderTax, -1); });
|
if (auto *logic = player->getLogic()) {
|
||||||
|
logic->getPlayerActions()->actModifyTaxCounter(CounterIds::CommanderTax, -1);
|
||||||
|
}
|
||||||
|
});
|
||||||
addAction(aDecreaseCommanderTax);
|
addAction(aDecreaseCommanderTax);
|
||||||
|
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
|
||||||
aIncreasePartnerTax = new QAction(this);
|
aIncreasePartnerTax = new QAction(this);
|
||||||
connect(aIncreasePartnerTax, &QAction::triggered, this,
|
connect(aIncreasePartnerTax, &QAction::triggered, this, [this]() {
|
||||||
[playerActions]() { playerActions->actModifyTaxCounter(CounterIds::PartnerTax, 1); });
|
if (auto *logic = player->getLogic()) {
|
||||||
|
logic->getPlayerActions()->actModifyTaxCounter(CounterIds::PartnerTax, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
addAction(aIncreasePartnerTax);
|
addAction(aIncreasePartnerTax);
|
||||||
|
|
||||||
aDecreasePartnerTax = new QAction(this);
|
aDecreasePartnerTax = new QAction(this);
|
||||||
connect(aDecreasePartnerTax, &QAction::triggered, this,
|
connect(aDecreasePartnerTax, &QAction::triggered, this, [this]() {
|
||||||
[playerActions]() { playerActions->actModifyTaxCounter(CounterIds::PartnerTax, -1); });
|
if (auto *logic = player->getLogic()) {
|
||||||
|
logic->getPlayerActions()->actModifyTaxCounter(CounterIds::PartnerTax, -1);
|
||||||
|
}
|
||||||
|
});
|
||||||
addAction(aDecreasePartnerTax);
|
addAction(aDecreasePartnerTax);
|
||||||
|
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
|
||||||
aToggleCommanderTaxCounter = new QAction(this);
|
aToggleCommanderTaxCounter = new QAction(this);
|
||||||
connect(aToggleCommanderTaxCounter, &QAction::triggered, this,
|
connect(aToggleCommanderTaxCounter, &QAction::triggered, this, [this]() {
|
||||||
[playerActions]() { playerActions->actToggleTaxCounter(CounterIds::CommanderTax); });
|
if (auto *logic = player->getLogic()) {
|
||||||
|
logic->getPlayerActions()->actToggleTaxCounter(CounterIds::CommanderTax);
|
||||||
|
}
|
||||||
|
});
|
||||||
addAction(aToggleCommanderTaxCounter);
|
addAction(aToggleCommanderTaxCounter);
|
||||||
|
|
||||||
aTogglePartnerTaxCounter = new QAction(this);
|
aTogglePartnerTaxCounter = new QAction(this);
|
||||||
connect(aTogglePartnerTaxCounter, &QAction::triggered, this,
|
connect(aTogglePartnerTaxCounter, &QAction::triggered, this, [this]() {
|
||||||
[playerActions]() { playerActions->actToggleTaxCounter(CounterIds::PartnerTax); });
|
if (auto *logic = player->getLogic()) {
|
||||||
|
logic->getPlayerActions()->actToggleTaxCounter(CounterIds::PartnerTax);
|
||||||
|
}
|
||||||
|
});
|
||||||
addAction(aTogglePartnerTaxCounter);
|
addAction(aTogglePartnerTaxCounter);
|
||||||
|
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue