Resolve PlayerActions at call time instead of capturing at construction

This commit is contained in:
DawnFire42 2026-06-15 11:21:46 -04:00
parent 57fc10dc02
commit be5c989214
No known key found for this signature in database
GPG key ID: 24BB855EE2911B33

View file

@ -31,40 +31,56 @@ CommandZoneMenu::CommandZoneMenu(PlayerGraphicsItem *_player, QMenu *playerMenu)
addAction(aViewZone);
addSeparator();
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
aIncreaseCommanderTax = new QAction(this);
connect(aIncreaseCommanderTax, &QAction::triggered, this,
[playerActions]() { playerActions->actModifyTaxCounter(CounterIds::CommanderTax, 1); });
connect(aIncreaseCommanderTax, &QAction::triggered, this, [this]() {
if (auto *logic = player->getLogic()) {
logic->getPlayerActions()->actModifyTaxCounter(CounterIds::CommanderTax, 1);
}
});
addAction(aIncreaseCommanderTax);
aDecreaseCommanderTax = new QAction(this);
connect(aDecreaseCommanderTax, &QAction::triggered, this,
[playerActions]() { playerActions->actModifyTaxCounter(CounterIds::CommanderTax, -1); });
connect(aDecreaseCommanderTax, &QAction::triggered, this, [this]() {
if (auto *logic = player->getLogic()) {
logic->getPlayerActions()->actModifyTaxCounter(CounterIds::CommanderTax, -1);
}
});
addAction(aDecreaseCommanderTax);
addSeparator();
aIncreasePartnerTax = new QAction(this);
connect(aIncreasePartnerTax, &QAction::triggered, this,
[playerActions]() { playerActions->actModifyTaxCounter(CounterIds::PartnerTax, 1); });
connect(aIncreasePartnerTax, &QAction::triggered, this, [this]() {
if (auto *logic = player->getLogic()) {
logic->getPlayerActions()->actModifyTaxCounter(CounterIds::PartnerTax, 1);
}
});
addAction(aIncreasePartnerTax);
aDecreasePartnerTax = new QAction(this);
connect(aDecreasePartnerTax, &QAction::triggered, this,
[playerActions]() { playerActions->actModifyTaxCounter(CounterIds::PartnerTax, -1); });
connect(aDecreasePartnerTax, &QAction::triggered, this, [this]() {
if (auto *logic = player->getLogic()) {
logic->getPlayerActions()->actModifyTaxCounter(CounterIds::PartnerTax, -1);
}
});
addAction(aDecreasePartnerTax);
addSeparator();
aToggleCommanderTaxCounter = new QAction(this);
connect(aToggleCommanderTaxCounter, &QAction::triggered, this,
[playerActions]() { playerActions->actToggleTaxCounter(CounterIds::CommanderTax); });
connect(aToggleCommanderTaxCounter, &QAction::triggered, this, [this]() {
if (auto *logic = player->getLogic()) {
logic->getPlayerActions()->actToggleTaxCounter(CounterIds::CommanderTax);
}
});
addAction(aToggleCommanderTaxCounter);
aTogglePartnerTaxCounter = new QAction(this);
connect(aTogglePartnerTaxCounter, &QAction::triggered, this,
[playerActions]() { playerActions->actToggleTaxCounter(CounterIds::PartnerTax); });
connect(aTogglePartnerTaxCounter, &QAction::triggered, this, [this]() {
if (auto *logic = player->getLogic()) {
logic->getPlayerActions()->actToggleTaxCounter(CounterIds::PartnerTax);
}
});
addAction(aTogglePartnerTaxCounter);
addSeparator();