From 54e7ee1b42bb105a11ab6b57aee0c6b6866f9189 Mon Sep 17 00:00:00 2001 From: DawnFire42 Date: Wed, 25 Feb 2026 13:35:17 -0500 Subject: [PATCH] feat(command-zone): add abstract zone menu base class Introduce AbstractZoneMenu - a base class for zone-specific context menus that provides common functionality. This abstraction: - Reduces code duplication across zone menu implementations - Establishes consistent menu behavior patterns - Provides foundation for CommandZoneMenu implementation Small foundational commit to keep the menu hierarchy clean. --- .../src/game/player/menu/abstract_zone_menu.h | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 cockatrice/src/game/player/menu/abstract_zone_menu.h diff --git a/cockatrice/src/game/player/menu/abstract_zone_menu.h b/cockatrice/src/game/player/menu/abstract_zone_menu.h new file mode 100644 index 000000000..59cc9b531 --- /dev/null +++ b/cockatrice/src/game/player/menu/abstract_zone_menu.h @@ -0,0 +1,54 @@ +/** + * @file abstract_zone_menu.h + * @ingroup GameMenusZones + * @brief Abstract interface for zone menus with common shortcut management. + * + * This interface enables polymorphic iteration over heterogeneous menu types + * for keyboard shortcut activation/deactivation and UI translation. + */ + +#ifndef COCKATRICE_ABSTRACT_ZONE_MENU_H +#define COCKATRICE_ABSTRACT_ZONE_MENU_H + +/** + * @class AbstractZoneMenu + * @brief Interface for zone menus that support keyboard shortcuts and translation. + * + * Provides a common contract for menus that need to: + * - Activate/deactivate keyboard shortcuts based on game focus + * - Update UI text when language changes + * + * Menus implementing this interface can be stored polymorphically + * in PlayerMenu for batch operations. + */ +class AbstractZoneMenu +{ +public: + virtual ~AbstractZoneMenu() = default; + + /** + * @brief Enable keyboard shortcuts for this menu's actions. + * + * Called when this player becomes the active/focused player. + * Implementations should apply shortcut keys to their QActions. + */ + virtual void setShortcutsActive() = 0; + + /** + * @brief Disable keyboard shortcuts for this menu's actions. + * + * Called when focus moves away from this player. + * Implementations should clear shortcut keys from their QActions. + */ + virtual void setShortcutsInactive() = 0; + + /** + * @brief Update all translatable text in the menu. + * + * Called when the application language changes. + * Implementations should update menu titles, action text, and tooltips. + */ + virtual void retranslateUi() = 0; +}; + +#endif // COCKATRICE_ABSTRACT_ZONE_MENU_H