Fix Command Zone graphics/logic layers separation

1. CommandZoneMenu: Changed to take PlayerGraphicsItem* instead of
     PlayerLogic*, accessing logic via player->getLogic()

  2. Removed getCounterWidget() from PlayerLogic;
     method already exists correctly in PlayerGraphicsItem

  3. PlayerMenu: CommandZoneMenu, fixed signal
     connection to use player->getLogic() for commandZoneSupportChanged

  4. AbstractCounter: Connects to CounterState::activeChanged signal,
     removing direct graphics calls from PlayerEventHandler

  5. CommandZone: Explicit tax counter registration via registerTaxCounter()
     with auto-cleanup, replacing childItems()/dynamic_cast iteration

  Also fixed PlayerActions to query CounterState instead of AbstractCounter
  for proper layer separation.
This commit is contained in:
DawnFire42 2026-06-09 14:29:20 -04:00
parent 8ca693ef70
commit b0ed79d9c3
No known key found for this signature in database
GPG key ID: 24BB855EE2911B33
11 changed files with 55 additions and 56 deletions

View file

@ -4,11 +4,11 @@
#include "../../game/player/player_actions.h"
#include "../../game/player/player_logic.h"
#include "../../interface/theme_manager.h"
#include "../board/abstract_counter.h"
#include "../board/card_drag_item.h"
#include "../board/card_item.h"
#include "../board/commander_tax_counter.h"
#include "../z_values.h"
#include "select_zone.h"
#include <QGraphicsSceneMouseEvent>
#include <QPainter>
@ -138,18 +138,21 @@ void CommandZone::reorganizeCards()
update();
}
void CommandZone::rearrangeTaxCounters()
void CommandZone::registerTaxCounter(AbstractCounter *counter)
{
// TODO
/*bool commandZoneVisible = isVisible();
int activeTaxCounterCount = 0;
auto *graphicsItem = getLogic()->getPlayer()->getGraphicsItem();
if (!graphicsItem) {
if (!counter || taxCounters.contains(counter)) {
return;
}
taxCounters.append(counter);
connect(counter, &QObject::destroyed, this, [this, counter]() { taxCounters.removeOne(counter); });
}
for (AbstractCounter *ctr : graphicsItem->getTaxCounterWidgets()) {
void CommandZone::rearrangeTaxCounters()
{
bool commandZoneVisible = isVisible();
int activeTaxCounterCount = 0;
for (AbstractCounter *ctr : taxCounters) {
qreal y = TaxCounterSizes::TAX_COUNTER_MARGIN +
activeTaxCounterCount * (TaxCounterSizes::TAX_COUNTER_SIZE + TaxCounterSizes::TAX_COUNTER_MARGIN);
ctr->setPos(TaxCounterSizes::TAX_COUNTER_MARGIN, y);
@ -163,7 +166,7 @@ void CommandZone::rearrangeTaxCounters()
int minHeight = activeTaxCounterCount * (TaxCounterSizes::TAX_COUNTER_SIZE + TaxCounterSizes::TAX_COUNTER_MARGIN) +
TaxCounterSizes::TAX_COUNTER_MARGIN;
setMinimumHeight(minHeight);*/
setMinimumHeight(minHeight);
}
void CommandZone::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)