mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-29 17:32:17 -07:00
Harden command zone tax counter handling and more clean up
- Initialize commandZoneGraphicsItem to nullptr so the pervasive null
checks have defined behavior before initializeZones() runs
- Remove unused getTaxCounterWidgets()
- Enforce the "reset tax to 0 before deactivating" invariant server-side
in cmdSetCounterActive, not just in the UI
- Hide tax increment/decrement menu actions at their bounds (0 and
MAX_COUNTER_VALUE) to avoid sending no-op commands
- Drop redundant/inconsistent toggle labels from CommandZoneMenu::
retranslateUi(); updateTaxCounterActionStates() owns them
- Add default=-1 to Event_SetCounterActive.counter_id for parity with
Command_SetCounterActive
This commit is contained in:
parent
39ede08326
commit
5e84b5edf6
5 changed files with 13 additions and 25 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include "../player_graphics_item.h"
|
||||
|
||||
#include <libcockatrice/utility/counter_ids.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/zone_names.h>
|
||||
|
||||
CommandZoneMenu::CommandZoneMenu(PlayerGraphicsItem *_player, QMenu *playerMenu) : QMenu(playerMenu), player(_player)
|
||||
|
|
@ -107,18 +108,13 @@ void CommandZoneMenu::retranslateUi()
|
|||
if (aDecreaseCommanderTax) {
|
||||
aDecreaseCommanderTax->setText(tr("&Decrease Commander Tax (-1)"));
|
||||
}
|
||||
if (aToggleCommanderTaxCounter) {
|
||||
aToggleCommanderTaxCounter->setText(tr("&Remove Commander Tax"));
|
||||
}
|
||||
if (aIncreasePartnerTax) {
|
||||
aIncreasePartnerTax->setText(tr("Increase &Partner Tax (+1)"));
|
||||
}
|
||||
if (aDecreasePartnerTax) {
|
||||
aDecreasePartnerTax->setText(tr("Decrease P&artner Tax (-1)"));
|
||||
}
|
||||
if (aTogglePartnerTaxCounter) {
|
||||
aTogglePartnerTaxCounter->setText(tr("&Add Partner Tax"));
|
||||
}
|
||||
// Toggle action labels are derived dynamically in updateTaxCounterActionStates()
|
||||
if (aToggleMinimized) {
|
||||
aToggleMinimized->setText(tr("&Minimize"));
|
||||
}
|
||||
|
|
@ -138,10 +134,10 @@ void CommandZoneMenu::updateTaxCounterActionStates()
|
|||
AbstractCounter *partnerTax = player->getTaxCounterIfActive(CounterIds::PartnerTax);
|
||||
|
||||
if (aIncreaseCommanderTax) {
|
||||
aIncreaseCommanderTax->setVisible(cmdTax != nullptr);
|
||||
aIncreaseCommanderTax->setVisible(cmdTax && cmdTax->getValue() < MAX_COUNTER_VALUE);
|
||||
}
|
||||
if (aDecreaseCommanderTax) {
|
||||
aDecreaseCommanderTax->setVisible(cmdTax != nullptr);
|
||||
aDecreaseCommanderTax->setVisible(cmdTax && cmdTax->getValue() > 0);
|
||||
}
|
||||
if (aToggleCommanderTaxCounter) {
|
||||
aToggleCommanderTaxCounter->setText(cmdTax ? tr("&Remove Commander Tax") : tr("&Add Commander Tax"));
|
||||
|
|
@ -149,10 +145,10 @@ void CommandZoneMenu::updateTaxCounterActionStates()
|
|||
}
|
||||
|
||||
if (aIncreasePartnerTax) {
|
||||
aIncreasePartnerTax->setVisible(partnerTax != nullptr);
|
||||
aIncreasePartnerTax->setVisible(partnerTax && partnerTax->getValue() < MAX_COUNTER_VALUE);
|
||||
}
|
||||
if (aDecreasePartnerTax) {
|
||||
aDecreasePartnerTax->setVisible(partnerTax != nullptr);
|
||||
aDecreasePartnerTax->setVisible(partnerTax && partnerTax->getValue() > 0);
|
||||
}
|
||||
if (aTogglePartnerTaxCounter) {
|
||||
aTogglePartnerTaxCounter->setText(partnerTax ? tr("R&emove Partner Tax") : tr("&Add Partner Tax"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue