From 77971497a452aa7ae5192538e3e64cbf1fdf6bf8 Mon Sep 17 00:00:00 2001 From: Vladimir nett00n Budylnikov Date: Sat, 27 Sep 2025 21:20:15 +0400 Subject: [PATCH] move scale factors to constraints --- scenes/game/gameplays/tile.gd | 10 +++++----- scenes/ui/MainMenu.gd | 2 +- scenes/ui/SettingsMenu.gd | 2 +- scenes/ui/components/ValueStepper.gd | 2 +- src/autoloads/UIConstants.gd | 8 ++++++++ 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/scenes/game/gameplays/tile.gd b/scenes/game/gameplays/tile.gd index 2bc29bf..cf4f7db 100644 --- a/scenes/game/gameplays/tile.gd +++ b/scenes/game/gameplays/tile.gd @@ -170,9 +170,9 @@ func _update_visual_feedback() -> void: var scale_multiplier: float if is_selected: - # Selected: bright and 20% larger than original board size + # Selected: bright and larger than original board size target_modulate = Color(1.2, 1.2, 1.2, 1.0) - scale_multiplier = 1.2 + scale_multiplier = UIConstants.TILE_SELECTED_SCALE DebugManager.log_debug( ( "SELECTING tile (%d,%d): target scale %.2fx, current scale %s" @@ -181,9 +181,9 @@ func _update_visual_feedback() -> void: "Match3" ) elif is_highlighted: - # Highlighted: subtle glow and 10% larger than original board size + # Highlighted: subtle glow and larger than original board size target_modulate = Color(1.1, 1.1, 1.1, 1.0) - scale_multiplier = 1.1 + scale_multiplier = UIConstants.TILE_HIGHLIGHTED_SCALE DebugManager.log_debug( ( "HIGHLIGHTING tile (%d,%d): target scale %.2fx, current scale %s" @@ -194,7 +194,7 @@ func _update_visual_feedback() -> void: else: # Normal state: white and original board size target_modulate = Color.WHITE - scale_multiplier = 1.0 + scale_multiplier = UIConstants.TILE_NORMAL_SCALE DebugManager.log_debug( ( "NORMALIZING tile (%d,%d): target scale %.2fx, current scale %s" diff --git a/scenes/ui/MainMenu.gd b/scenes/ui/MainMenu.gd index 10b870e..95182d1 100644 --- a/scenes/ui/MainMenu.gd +++ b/scenes/ui/MainMenu.gd @@ -87,7 +87,7 @@ func _update_visual_selection() -> void: for i in range(menu_buttons.size()): var button: Button = menu_buttons[i] if i == current_menu_index: - button.scale = original_button_scales[i] * 1.1 + button.scale = original_button_scales[i] * UIConstants.BUTTON_HOVER_SCALE button.modulate = Color(1.2, 1.2, 1.0) else: button.scale = original_button_scales[i] diff --git a/scenes/ui/SettingsMenu.gd b/scenes/ui/SettingsMenu.gd index 7993379..613e5fe 100644 --- a/scenes/ui/SettingsMenu.gd +++ b/scenes/ui/SettingsMenu.gd @@ -212,7 +212,7 @@ func _update_visual_selection() -> void: if control == language_stepper: language_stepper.set_highlighted(true) else: - control.scale = original_control_scales[i] * 1.05 + control.scale = original_control_scales[i] * UIConstants.UI_CONTROL_HIGHLIGHT_SCALE control.modulate = Color(1.1, 1.1, 0.9) else: # Reset highlighting diff --git a/scenes/ui/components/ValueStepper.gd b/scenes/ui/components/ValueStepper.gd index c9af727..a3e6e41 100644 --- a/scenes/ui/components/ValueStepper.gd +++ b/scenes/ui/components/ValueStepper.gd @@ -175,7 +175,7 @@ func set_current_value(value: String) -> void: func set_highlighted(highlighted: bool) -> void: is_highlighted = highlighted if highlighted: - scale = original_scale * 1.05 + scale = original_scale * UIConstants.UI_CONTROL_HIGHLIGHT_SCALE modulate = Color(1.1, 1.1, 0.9) else: scale = original_scale diff --git a/src/autoloads/UIConstants.gd b/src/autoloads/UIConstants.gd index 943a4e9..1eb9f3b 100644 --- a/src/autoloads/UIConstants.gd +++ b/src/autoloads/UIConstants.gd @@ -11,8 +11,16 @@ const MIN_RESOLUTION := Vector2i(720, 480) # Animation constants const FADE_DURATION := 0.3 + +# Scale factor constants for consistent UI interactions const BUTTON_HOVER_SCALE := 1.1 const BUTTON_PRESS_SCALE := 0.95 +const UI_CONTROL_HIGHLIGHT_SCALE := 1.1 + +# Game-specific scale constants +const TILE_SELECTED_SCALE := 1.1 +const TILE_HIGHLIGHTED_SCALE := 1.1 +const TILE_NORMAL_SCALE := 1.0 # UI spacing constants const UI_MARGIN := 20