From ba1a388e5d913c96cfe7e36ad984c543aa97e8c4 Mon Sep 17 00:00:00 2001 From: DawnFire42 Date: Thu, 26 Feb 2026 18:30:27 -0500 Subject: [PATCH] feat(command-zone): add Z-value constants for command zones Extend z_values.h with command-zone specific constants: ZValues namespace additions: - TOGGLE_BUTTON (0.5): Button above zone background, below cards - PARTNER_ZONE (1.0): Partner zone level within command zone - COMMAND_ZONE (1.0): Standard zone level for command zones - TAX_COUNTERS (overlay+2): Commander tax counter overlay layer ZoneSizes namespace (new): - COMMAND_ZONE_HEIGHT: Card height plus 8px padding - MINIMUM_STACK_HEIGHT: 100px minimum for usability - TAX_COUNTER_SIZE: 24px for tax counter icons - COMMAND_ZONE_WIDTH: 100.0 pixels - MINIMIZED_HEIGHT_RATIO: 25% when minimized GameColors namespace (new): - OVERLAY_ALPHA: 191 (75% opaque) - OVERLAY_BG_NORMAL/HOVERED: Consistent overlay styling These constants enable visual consistency across command zone components. --- cockatrice/src/game/z_values.h | 114 ++++++++++++++++++++++++++++++--- 1 file changed, 104 insertions(+), 10 deletions(-) diff --git a/cockatrice/src/game/z_values.h b/cockatrice/src/game/z_values.h index 01e08bf75..ef762b709 100644 --- a/cockatrice/src/game/z_values.h +++ b/cockatrice/src/game/z_values.h @@ -1,8 +1,11 @@ #ifndef Z_VALUES_H #define Z_VALUES_H +#include "board/abstract_card_item.h" #include "z_value_layer_manager.h" +#include + /** * @file z_values.h * @brief Centralized Z-value constants for rendering layer order. @@ -27,21 +30,112 @@ namespace ZValues { -// Expose base for callers that need it +// ============================================================================ +// Zone-Level Layering (relative to parent containers) +// ============================================================================ + +/// Toggle button renders above zone background but below cards (child of partner zone) +constexpr qreal TOGGLE_BUTTON = 0.5; + +/// Partner zone level within command zone +constexpr qreal PARTNER_ZONE = 1.0; + +/// Command zone sits at standard zone level +constexpr qreal COMMAND_ZONE = 1.0; + +// ============================================================================ +// Card Layering (cards use sequential indices starting from this base) +// ============================================================================ + +/// Base Z-value for cards in zones (actual Z = CARD_BASE + index) +constexpr qreal CARD_BASE = 1.0; + +/// Maximum Z-value for cards on the table zone (see ZValueLayerManager for formula) +constexpr qreal CARD_MAX = ZValueLayerManager::CARD_Z_VALUE_MAX; + +// ============================================================================ +// Overlay Elements (always on top of regular game elements) +// ============================================================================ + +/// Base z-value for overlay elements. Uses ZValueLayerManager::OVERLAY_BASE. +/// Must exceed CARD_MAX to ensure overlays render above all cards. constexpr qreal OVERLAY_BASE = ZValueLayerManager::OVERLAY_BASE; -// Overlay layer Z-values for items that should appear above normal cards +/// Hovered card temporarily promotes to this layer constexpr qreal HOVERED_CARD = ZValueLayerManager::overlayZValue(1.0); -constexpr qreal ARROWS = ZValueLayerManager::overlayZValue(3.0); -constexpr qreal ZONE_VIEW_WIDGET = ZValueLayerManager::overlayZValue(4.0); -constexpr qreal DRAG_ITEM = ZValueLayerManager::overlayZValue(5.0); -constexpr qreal DRAG_ITEM_CHILD = ZValueLayerManager::overlayZValue(6.0); -constexpr qreal TOP_UI = ZValueLayerManager::overlayZValue(7.0); -// Card layering (general architecture, not command-zone specific) -constexpr qreal CARD_BASE = 1.0; -constexpr qreal CARD_MAX = ZValueLayerManager::CARD_Z_VALUE_MAX; +/// Commander and partner tax counters overlay +constexpr qreal TAX_COUNTERS = ZValueLayerManager::overlayZValue(2.0); + +/// Targeting arrows between cards/players +constexpr qreal ARROWS = ZValueLayerManager::overlayZValue(3.0); + +/// Zone view widget (deck/graveyard viewer) +constexpr qreal ZONE_VIEW_WIDGET = ZValueLayerManager::overlayZValue(4.0); + +/// Drag items and search UI elements +constexpr qreal DRAG_ITEM = ZValueLayerManager::overlayZValue(5.0); + +/// Child drag items (stacked above parent drag) +constexpr qreal DRAG_ITEM_CHILD = ZValueLayerManager::overlayZValue(6.0); + +/// Highest layer - group selectors +constexpr qreal TOP_UI = ZValueLayerManager::overlayZValue(7.0); } // namespace ZValues +// ============================================================================ +// Zone Size Constants +// ============================================================================ + +/** + * @namespace ZoneSizes + * @brief Centralized size constants for game zone dimensions. + * + * These constants define the dimensions of various zones to ensure + * consistent sizing across the codebase and prevent duplication. + */ +namespace ZoneSizes +{ + +/// Height of the command zone (accommodates a card plus padding) +constexpr int COMMAND_ZONE_HEIGHT = CARD_HEIGHT + 8; + +/// Minimum height for the stack zone to ensure usability +constexpr int MINIMUM_STACK_HEIGHT = 100; + +/// Size of commander tax counter icons +constexpr int TAX_COUNTER_SIZE = 24; + +/// Width of the command zone +constexpr qreal COMMAND_ZONE_WIDTH = 100.0; + +/// Height ratio when command zone is minimized (25%) +constexpr qreal MINIMIZED_HEIGHT_RATIO = 0.25; + +} // namespace ZoneSizes + +// ============================================================================ +// Game Color Constants +// ============================================================================ + +/** + * @namespace GameColors + * @brief Centralized color constants for overlay UI elements. + * + * These constants ensure visual consistency between related UI elements + * like the partner zone toggle button and commander tax counters. + */ +namespace GameColors +{ + +/// Alpha value for overlay elements (75% opaque) +constexpr int OVERLAY_ALPHA = 191; + +/// Background colors for overlay elements +inline const QColor OVERLAY_BG_NORMAL{40, 40, 40, OVERLAY_ALPHA}; +inline const QColor OVERLAY_BG_HOVERED{70, 70, 70, OVERLAY_ALPHA}; + +} // namespace GameColors + #endif // Z_VALUES_H