Cockatrice/cockatrice/src/game/player/menu/custom_zone_menu.h
DawnFire42 f8b06f28d1
refactor: extract AbstractPlayerComponent interface for polymorphic player component management.
Non-QObject polymorphic interface with setShortcutsActive(), setShortcutsInactive(), and retranslateUi(). Uses regular multiple inheritance to avoid diamond inheritance with Qt's MOC.

All zone menus, SayMenu, and AbstractCounter implement this interface. PlayerMenu manages them via a managedComponents list with two template helpers (addManagedMenu/registerManagedComponent), replacing individual if-guarded lifecycle calls with a single polymorphic loop.

SayMenu now owns its shortcut and translation lifecycle instead of having PlayerMenu manage its title and shortcuts externally.
Counters are iterated via Player::getCounters() rather than managedComponents to avoid duplicating the authoritative owner's map.
2026-03-17 00:24:04 -04:00

36 lines
709 B
C++

/**
* @file custom_zone_menu.h
* @ingroup GameMenusZones
* @brief TODO: Document this.
*/
#ifndef COCKATRICE_CUSTOM_ZONE_MENU_H
#define COCKATRICE_CUSTOM_ZONE_MENU_H
#include "abstract_player_component.h"
#include <QMenu>
class Player;
class CustomZoneMenu : public QMenu, public AbstractPlayerComponent
{
Q_OBJECT
public:
explicit CustomZoneMenu(Player *player);
void retranslateUi() override;
void setShortcutsActive() override
{
}
void setShortcutsInactive() override
{
}
private:
Player *player;
private slots:
void clearCustomZonesMenu();
void addViewCustomZoneActionToCustomZoneMenu(QString zoneName);
};
#endif // COCKATRICE_CUSTOM_ZONE_MENU_H