add basic match3 logic
use proper logging everywhere add gamepad and keyboard control on match3 gameplay
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
"allow": [
|
||||
"WebSearch",
|
||||
"Bash(find:*)",
|
||||
"Bash(godot:*)"
|
||||
"Bash(godot:*)",
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
|
||||
@@ -21,6 +21,12 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
- Match-3 debug controls include gem count adjustment and board reroll
|
||||
- Difficulty presets: Easy (3 gems), Normal (5 gems), Hard (8 gems)
|
||||
- Gameplay mode switching: Space+Enter in game scene switches between match-3 and clickomania modes
|
||||
- **Match-3 Gem Movement Testing**:
|
||||
- Keyboard: Arrow keys or WASD to navigate, Enter to select/confirm
|
||||
- Gamepad: D-pad to navigate, A button to select/confirm
|
||||
- Visual feedback: Selected tiles glow brighter with scale and color effects
|
||||
- Invalid swaps automatically revert after animation
|
||||
- State machine: WAITING → SELECTING → SWAPPING → PROCESSING
|
||||
- Test scripts located in `tests/` directory for system validation
|
||||
- Use `test_logging.gd` to validate the logging system functionality
|
||||
|
||||
@@ -60,11 +66,13 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
- Remove debug prints before committing unless permanently useful
|
||||
|
||||
### Logging System Usage
|
||||
- **CRITICAL**: ALL print() and push_error() statements have been migrated to DebugManager
|
||||
- **ALWAYS** use `DebugManager` logging functions instead of `print()`, `push_error()`, etc.
|
||||
- Use appropriate log levels: INFO for general messages, WARN for issues, ERROR for failures
|
||||
- Include meaningful categories to organize log output: `"GameManager"`, `"Match3"`, `"Settings"`
|
||||
- Include meaningful categories to organize log output: `"GameManager"`, `"Match3"`, `"Settings"`, `"Game"`, `"MainMenu"`, `"PressAnyKey"`, `"Clickomania"`, `"DebugMenu"`
|
||||
- Leverage structured logging for better debugging and production monitoring
|
||||
- Use `DebugManager.set_log_level()` to control verbosity during development and testing
|
||||
- The logging system provides unified output across all game systems
|
||||
|
||||
## Important File References
|
||||
|
||||
@@ -78,9 +86,11 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
- `src/autoloads/GameManager.gd` - Scene transition patterns and gameplay mode management
|
||||
- `src/autoloads/DebugManager.gd` - Debug system integration
|
||||
- `scenes/game/game.gd` - Main game scene with modular gameplay system
|
||||
- `scenes/game/gameplays/match3_gameplay.gd` - Match-3 implementation reference
|
||||
- `scenes/game/gameplays/match3_gameplay.gd` - Match-3 implementation with keyboard/gamepad gem movement system
|
||||
- `scenes/game/gameplays/tile.gd` - Individual tile behavior with visual feedback and input handling
|
||||
- `scenes/game/gameplays/` - Individual gameplay mode implementations
|
||||
- `project.godot` - Input actions and autoload definitions
|
||||
- Gem movement actions: `select_gem`, `move_up/down/left/right`
|
||||
|
||||
## Development Workflow
|
||||
|
||||
|
||||
38
docs/MAP.md
38
docs/MAP.md
@@ -133,12 +133,23 @@ The game now uses a modular gameplay architecture where different game modes can
|
||||
- Gem pool management (3-8 gem types)
|
||||
- Debug UI integration
|
||||
- Score reporting via `score_changed` signal
|
||||
- **Gem Movement System**: Keyboard and gamepad input for tile selection and swapping
|
||||
- State machine: WAITING → SELECTING → SWAPPING → PROCESSING
|
||||
- Adjacent tile validation (horizontal/vertical neighbors only)
|
||||
- Match validation (swaps must create matches or revert)
|
||||
- Smooth tile position animations with Tween
|
||||
- Cursor-based navigation with visual highlighting
|
||||
|
||||
2. **Tile System** (`scenes/game/gameplays/tile.gd` + `Tile.tscn`)
|
||||
- Individual tile behavior
|
||||
- Gem type management
|
||||
- Visual representation
|
||||
- Visual representation with scaling and color modulation
|
||||
- Group membership for coordination
|
||||
- **Visual Feedback System**: Multi-state display for game interaction
|
||||
- Selection visual feedback (scale and color modulation)
|
||||
- State management (normal, highlighted, selected)
|
||||
- Signal-based communication with gameplay controller
|
||||
- Smooth animations with Tween system
|
||||
|
||||
#### Clickomania Mode (`scenes/game/gameplays/clickomania_gameplay.tscn`)
|
||||
- Planned implementation for clickomania-style gameplay
|
||||
@@ -233,6 +244,9 @@ sprites:
|
||||
- `project.godot` - Main Godot project settings
|
||||
- Autoload definitions
|
||||
- Input map configurations
|
||||
- **Gem Movement Controls**:
|
||||
- `select_gem`: Enter key, Gamepad A button
|
||||
- `move_up/down/left/right`: Arrow keys, WASD, Gamepad D-pad
|
||||
- Rendering settings
|
||||
- Audio bus references
|
||||
|
||||
@@ -288,8 +302,18 @@ DebugManager.log_error("Failed to load audio resource")
|
||||
|
||||
# Logging with custom categories for better organization
|
||||
DebugManager.log_debug("Grid regenerated with 64 tiles", "Match3")
|
||||
DebugManager.log_info("Language changed to: en", "SettingsManager")
|
||||
DebugManager.log_info("Language changed to: en", "Settings")
|
||||
DebugManager.log_error("Invalid scene path provided", "GameManager")
|
||||
|
||||
# Standard categories in use:
|
||||
# - GameManager: Scene transitions, gameplay mode management
|
||||
# - Match3: Match-3 gameplay, grid operations, tile interactions
|
||||
# - Settings: Settings management, language changes
|
||||
# - Game: Main game scene, mode switching
|
||||
# - MainMenu: Main menu interactions
|
||||
# - PressAnyKey: Press any key screen
|
||||
# - Clickomania: Clickomania gameplay mode
|
||||
# - DebugMenu: Debug menu operations
|
||||
```
|
||||
|
||||
### Log Format
|
||||
@@ -322,6 +346,16 @@ if DebugManager._should_log(DebugManager.LogLevel.DEBUG):
|
||||
### Current Implementation Status
|
||||
- Modular gameplay system with dynamic loading architecture
|
||||
- Match-3 system with 8x8 grid and configurable gem pools
|
||||
- **Interactive Match-3 Gameplay**: Keyboard and gamepad gem movement system
|
||||
- Keyboard: Arrow key navigation with Enter to select/confirm (WASD also supported)
|
||||
- Gamepad: D-pad navigation with A button to select/confirm
|
||||
- Visual feedback: Tile highlighting, selection indicators, smooth animations
|
||||
- Game logic: Adjacent-only swaps, match validation, automatic revert on invalid moves
|
||||
- State machine: WAITING → SELECTING → SWAPPING → PROCESSING states
|
||||
- **Comprehensive Logging System**: All print()/push_error() statements migrated to DebugManager
|
||||
- Structured logging with categories: GameManager, Match3, Settings, Game, MainMenu, etc.
|
||||
- Multiple log levels: TRACE, DEBUG, INFO, WARN, ERROR, FATAL
|
||||
- Debug mode integration with level filtering
|
||||
- Global scoring system integrated across gameplay modes
|
||||
- Debug UI system with F12 toggle functionality across all major scenes
|
||||
- Scene transition system via GameManager with gameplay mode support
|
||||
|
||||
@@ -48,6 +48,41 @@ ui_menu_toggle={
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
select_gem={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_up={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_down={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_left={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_right={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[internationalization]
|
||||
|
||||
|
||||
@@ -24,19 +24,28 @@ func set_gameplay_mode(mode: String) -> void:
|
||||
load_gameplay(mode)
|
||||
|
||||
func load_gameplay(mode: String) -> void:
|
||||
DebugManager.log_debug("Loading gameplay mode: %s" % mode, "Game")
|
||||
|
||||
# Clear existing gameplay
|
||||
for child in gameplay_container.get_children():
|
||||
DebugManager.log_debug("Removing existing child: %s" % child.name, "Game")
|
||||
child.queue_free()
|
||||
|
||||
# Load new gameplay
|
||||
if GAMEPLAY_SCENES.has(mode):
|
||||
DebugManager.log_debug("Found scene path: %s" % GAMEPLAY_SCENES[mode], "Game")
|
||||
var gameplay_scene = load(GAMEPLAY_SCENES[mode])
|
||||
var gameplay_instance = gameplay_scene.instantiate()
|
||||
DebugManager.log_debug("Instantiated gameplay: %s" % gameplay_instance.name, "Game")
|
||||
gameplay_container.add_child(gameplay_instance)
|
||||
DebugManager.log_debug("Added gameplay to container, child count now: %d" % gameplay_container.get_child_count(), "Game")
|
||||
|
||||
# Connect gameplay signals to shared systems
|
||||
if gameplay_instance.has_signal("score_changed"):
|
||||
gameplay_instance.score_changed.connect(_on_score_changed)
|
||||
DebugManager.log_debug("Connected score_changed signal", "Game")
|
||||
else:
|
||||
DebugManager.log_error("Gameplay mode '%s' not found in GAMEPLAY_SCENES" % mode, "Game")
|
||||
|
||||
func set_global_score(value: int) -> void:
|
||||
global_score = value
|
||||
@@ -47,7 +56,7 @@ func _on_score_changed(points: int) -> void:
|
||||
self.global_score += points
|
||||
|
||||
func _on_back_button_pressed() -> void:
|
||||
print("Back button pressed in game scene")
|
||||
DebugManager.log_debug("Back button pressed in game scene", "Game")
|
||||
AudioManager.play_ui_click()
|
||||
GameManager.save_game()
|
||||
GameManager.exit_to_main_menu()
|
||||
@@ -57,7 +66,7 @@ func _input(event: InputEvent) -> void:
|
||||
# Debug: Switch to clickomania when Space+Enter pressed together
|
||||
if current_gameplay_mode == "match3":
|
||||
set_gameplay_mode("clickomania")
|
||||
print("Switched to clickomania gameplay")
|
||||
DebugManager.log_debug("Switched to clickomania gameplay", "Game")
|
||||
else:
|
||||
set_gameplay_mode("match3")
|
||||
print("Switched to match3 gameplay")
|
||||
DebugManager.log_debug("Switched to match3 gameplay", "Game")
|
||||
|
||||
@@ -11,13 +11,13 @@ extends Control
|
||||
var match3_scene: Node2D
|
||||
|
||||
func _ready():
|
||||
print("Match3DebugMenu: _ready() called")
|
||||
DebugManager.log_debug("Match3DebugMenu _ready() called", "Match3")
|
||||
DebugManager.debug_toggled.connect(_on_debug_toggled)
|
||||
# Initialize with current debug state
|
||||
var current_debug_state = DebugManager.is_debug_enabled()
|
||||
print("Match3DebugMenu: Current debug state is ", current_debug_state)
|
||||
DebugManager.log_debug("Match3DebugMenu current debug state is " + str(current_debug_state), "Match3")
|
||||
visible = current_debug_state
|
||||
print("Match3DebugMenu: Initial visibility set to ", visible)
|
||||
DebugManager.log_debug("Match3DebugMenu initial visibility set to " + str(visible), "Match3")
|
||||
if current_debug_state:
|
||||
_on_debug_toggled(true)
|
||||
regenerate_button.pressed.connect(_on_regenerate_pressed)
|
||||
@@ -34,17 +34,17 @@ func _find_match3_scene():
|
||||
if match3_scene and match3_scene.get_script():
|
||||
var script_path = match3_scene.get_script().resource_path
|
||||
if script_path == "res://scenes/game/gameplays/match3_gameplay.gd":
|
||||
print("Debug: Found match3 scene: ", match3_scene.name, " at path: ", match3_scene.get_path())
|
||||
DebugManager.log_debug("Found match3 scene: " + match3_scene.name + " at path: " + str(match3_scene.get_path()), "Match3")
|
||||
return
|
||||
|
||||
# If we couldn't find it, clear the reference
|
||||
match3_scene = null
|
||||
print("Debug: Could not find match3_gameplay scene")
|
||||
DebugManager.log_error("Could not find match3_gameplay scene", "Match3")
|
||||
|
||||
func _on_debug_toggled(enabled: bool):
|
||||
print("Match3DebugMenu: Debug toggled to ", enabled)
|
||||
DebugManager.log_debug("Match3DebugMenu debug toggled to " + str(enabled), "Match3")
|
||||
visible = enabled
|
||||
print("Match3DebugMenu: Visibility set to ", visible)
|
||||
DebugManager.log_debug("Match3DebugMenu visibility set to " + str(visible), "Match3")
|
||||
if enabled:
|
||||
# Always refresh match3 scene reference when debug menu opens
|
||||
if not match3_scene:
|
||||
@@ -67,37 +67,37 @@ func _on_regenerate_pressed():
|
||||
_find_match3_scene()
|
||||
|
||||
if not match3_scene:
|
||||
print("Error: Could not find match3 scene for regeneration")
|
||||
DebugManager.log_error("Could not find match3 scene for regeneration", "Match3")
|
||||
return
|
||||
|
||||
if match3_scene.has_method("regenerate_grid"):
|
||||
print("Debug: Calling regenerate_grid()")
|
||||
DebugManager.log_debug("Calling regenerate_grid()", "Match3")
|
||||
await match3_scene.regenerate_grid()
|
||||
else:
|
||||
print("Error: match3_scene does not have regenerate_grid method")
|
||||
DebugManager.log_error("match3_scene does not have regenerate_grid method", "Match3")
|
||||
|
||||
func _on_gem_types_changed(value: float):
|
||||
if not match3_scene:
|
||||
_find_match3_scene()
|
||||
|
||||
if not match3_scene:
|
||||
print("Error: Could not find match3 scene for gem types change")
|
||||
DebugManager.log_error("Could not find match3 scene for gem types change", "Match3")
|
||||
return
|
||||
|
||||
var new_value = int(value)
|
||||
if match3_scene.has_method("set_tile_types"):
|
||||
print("Debug: Setting tile types to ", new_value)
|
||||
DebugManager.log_debug("Setting tile types to " + str(new_value), "Match3")
|
||||
await match3_scene.set_tile_types(new_value)
|
||||
gem_types_label.text = "Gem Types: " + str(new_value)
|
||||
else:
|
||||
print("Error: match3_scene does not have set_tile_types method")
|
||||
DebugManager.log_error("match3_scene does not have set_tile_types method", "Match3")
|
||||
|
||||
func _on_grid_width_changed(value: float):
|
||||
if not match3_scene:
|
||||
_find_match3_scene()
|
||||
|
||||
if not match3_scene:
|
||||
print("Error: Could not find match3 scene for grid width change")
|
||||
DebugManager.log_error("Could not find match3 scene for grid width change", "Match3")
|
||||
return
|
||||
|
||||
var new_width = int(value)
|
||||
@@ -107,7 +107,7 @@ func _on_grid_width_changed(value: float):
|
||||
var current_height = int(grid_height_spinbox.value)
|
||||
|
||||
if match3_scene.has_method("set_grid_size"):
|
||||
print("Debug: Setting grid size to ", new_width, "x", current_height)
|
||||
DebugManager.log_debug("Setting grid size to " + str(new_width) + "x" + str(current_height), "Match3")
|
||||
await match3_scene.set_grid_size(Vector2i(new_width, current_height))
|
||||
|
||||
func _on_grid_height_changed(value: float):
|
||||
@@ -115,7 +115,7 @@ func _on_grid_height_changed(value: float):
|
||||
_find_match3_scene()
|
||||
|
||||
if not match3_scene:
|
||||
print("Error: Could not find match3 scene for grid height change")
|
||||
DebugManager.log_error("Could not find match3 scene for grid height change", "Match3")
|
||||
return
|
||||
|
||||
var new_height = int(value)
|
||||
@@ -125,5 +125,5 @@ func _on_grid_height_changed(value: float):
|
||||
var current_width = int(grid_width_spinbox.value)
|
||||
|
||||
if match3_scene.has_method("set_grid_size"):
|
||||
print("Debug: Setting grid size to ", current_width, "x", new_height)
|
||||
DebugManager.log_debug("Setting grid size to " + str(current_width) + "x" + str(new_height), "Match3")
|
||||
await match3_scene.set_grid_size(Vector2i(current_width, new_height))
|
||||
|
||||
@@ -3,8 +3,8 @@ extends Node2D
|
||||
signal score_changed(points: int)
|
||||
|
||||
func _ready():
|
||||
print("Clickomania gameplay loaded")
|
||||
DebugManager.log_info("Clickomania gameplay loaded", "Clickomania")
|
||||
# Example: Add some score after a few seconds to test the system
|
||||
await get_tree().create_timer(2.0).timeout
|
||||
score_changed.emit(100)
|
||||
print("Clickomania awarded 100 points")
|
||||
DebugManager.log_info("Clickomania awarded 100 points", "Clickomania")
|
||||
|
||||
@@ -2,6 +2,13 @@ extends Node2D
|
||||
|
||||
signal score_changed(points: int)
|
||||
|
||||
enum GameState {
|
||||
WAITING, # Waiting for player input
|
||||
SELECTING, # First tile selected
|
||||
SWAPPING, # Animating tile swap
|
||||
PROCESSING # Processing matches and cascades
|
||||
}
|
||||
|
||||
var GRID_SIZE := Vector2i(8, 8)
|
||||
var TILE_TYPES := 5
|
||||
const TILE_SCENE := preload("res://scenes/game/gameplays/tile.tscn")
|
||||
@@ -9,8 +16,14 @@ const TILE_SCENE := preload("res://scenes/game/gameplays/tile.tscn")
|
||||
var grid := []
|
||||
var tile_size: float = 48.0
|
||||
var grid_offset: Vector2
|
||||
var current_state: GameState = GameState.WAITING
|
||||
var selected_tile: Node2D = null
|
||||
var cursor_position: Vector2i = Vector2i(0, 0)
|
||||
var keyboard_navigation_enabled: bool = false
|
||||
|
||||
func _ready():
|
||||
DebugManager.log_debug("Match3 _ready() started", "Match3")
|
||||
|
||||
# Set up initial gem pool
|
||||
var gem_indices = []
|
||||
for i in range(TILE_TYPES):
|
||||
@@ -22,6 +35,11 @@ func _ready():
|
||||
_calculate_grid_layout()
|
||||
_initialize_grid()
|
||||
|
||||
DebugManager.log_debug("Match3 _ready() completed, calling debug structure check", "Match3")
|
||||
|
||||
# Debug: Check scene tree structure immediately
|
||||
call_deferred("_debug_scene_structure")
|
||||
|
||||
func _calculate_grid_layout():
|
||||
var viewport_size = get_viewport().get_visible_rect().size
|
||||
var available_width = viewport_size.x * 0.8 # Use 80% of screen width
|
||||
@@ -52,13 +70,16 @@ func _initialize_grid():
|
||||
grid.append([])
|
||||
for x in range(GRID_SIZE.x):
|
||||
var tile = TILE_SCENE.instantiate()
|
||||
tile.position = grid_offset + Vector2(x, y) * tile_size
|
||||
var tile_position = grid_offset + Vector2(x, y) * tile_size
|
||||
tile.position = tile_position
|
||||
tile.grid_position = Vector2i(x, y)
|
||||
add_child(tile)
|
||||
# Set tile type after adding to scene tree so sprite reference is available
|
||||
var new_type = randi() % TILE_TYPES
|
||||
tile.tile_type = new_type
|
||||
# print("Debug: Created tile at (", x, ",", y, ") with type ", new_type)
|
||||
# Connect tile signals
|
||||
tile.tile_selected.connect(_on_tile_selected)
|
||||
DebugManager.log_debug("Created tile at grid(%d,%d) world_pos(%s) with type %d" % [x, y, tile_position, new_type], "Match3")
|
||||
grid[y].append(tile)
|
||||
|
||||
func _has_match_at(pos: Vector2i) -> bool:
|
||||
@@ -176,7 +197,7 @@ func regenerate_grid():
|
||||
# Use time-based seed to ensure different patterns each time
|
||||
var new_seed = Time.get_ticks_msec()
|
||||
seed(new_seed)
|
||||
print("Debug: Regenerating grid with seed: ", new_seed)
|
||||
DebugManager.log_debug("Regenerating grid with seed: " + str(new_seed), "Match3")
|
||||
|
||||
# Fixed: Clear ALL tile children, not just ones in grid array
|
||||
# This handles any orphaned tiles that might not be tracked in the grid
|
||||
@@ -215,7 +236,226 @@ func set_tile_types(new_count: int):
|
||||
await regenerate_grid()
|
||||
|
||||
func set_grid_size(new_size: Vector2i):
|
||||
print("Debug: Changing grid size from ", GRID_SIZE, " to ", new_size)
|
||||
DebugManager.log_debug("Changing grid size from " + str(GRID_SIZE) + " to " + str(new_size), "Match3")
|
||||
GRID_SIZE = new_size
|
||||
# Regenerate grid with new size
|
||||
await regenerate_grid()
|
||||
|
||||
func reset_all_visual_states() -> void:
|
||||
# Debug function to reset all tile visual states
|
||||
DebugManager.log_debug("Resetting all tile visual states", "Match3")
|
||||
for y in range(GRID_SIZE.y):
|
||||
for x in range(GRID_SIZE.x):
|
||||
if grid[y][x] and grid[y][x].has_method("force_reset_visual_state"):
|
||||
grid[y][x].force_reset_visual_state()
|
||||
|
||||
# Reset game state
|
||||
selected_tile = null
|
||||
current_state = GameState.WAITING
|
||||
keyboard_navigation_enabled = false
|
||||
|
||||
func _debug_scene_structure() -> void:
|
||||
DebugManager.log_debug("=== Scene Structure Debug ===", "Match3")
|
||||
DebugManager.log_debug("Match3 node children count: %d" % get_child_count(), "Match3")
|
||||
DebugManager.log_debug("Match3 global position: %s" % global_position, "Match3")
|
||||
DebugManager.log_debug("Match3 scale: %s" % scale, "Match3")
|
||||
|
||||
# Check if grid is properly initialized
|
||||
if not grid or grid.size() == 0:
|
||||
DebugManager.log_error("Grid not initialized when debug structure called", "Match3")
|
||||
return
|
||||
|
||||
# Check tiles
|
||||
var tile_count = 0
|
||||
for y in range(GRID_SIZE.y):
|
||||
for x in range(GRID_SIZE.x):
|
||||
if y < grid.size() and x < grid[y].size() and grid[y][x]:
|
||||
tile_count += 1
|
||||
DebugManager.log_debug("Created %d tiles out of %d expected" % [tile_count, GRID_SIZE.x * GRID_SIZE.y], "Match3")
|
||||
|
||||
# Check first tile in detail
|
||||
if grid.size() > 0 and grid[0].size() > 0 and grid[0][0]:
|
||||
var first_tile = grid[0][0]
|
||||
DebugManager.log_debug("First tile global position: %s" % first_tile.global_position, "Match3")
|
||||
DebugManager.log_debug("First tile local position: %s" % first_tile.position, "Match3")
|
||||
|
||||
# Check parent chain
|
||||
var current_node = self
|
||||
var depth = 0
|
||||
while current_node and depth < 10:
|
||||
DebugManager.log_debug("Parent level %d: %s (type: %s)" % [depth, current_node.name, current_node.get_class()], "Match3")
|
||||
current_node = current_node.get_parent()
|
||||
depth += 1
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
# Debug key to reset all visual states
|
||||
if event.is_action_pressed("ui_menu_toggle") and DebugManager.is_debug_enabled():
|
||||
reset_all_visual_states()
|
||||
return
|
||||
|
||||
if current_state == GameState.SWAPPING or current_state == GameState.PROCESSING:
|
||||
return
|
||||
|
||||
# Handle keyboard/gamepad navigation
|
||||
if event.is_action_pressed("move_up"):
|
||||
_move_cursor(Vector2i.UP)
|
||||
keyboard_navigation_enabled = true
|
||||
elif event.is_action_pressed("move_down"):
|
||||
_move_cursor(Vector2i.DOWN)
|
||||
keyboard_navigation_enabled = true
|
||||
elif event.is_action_pressed("move_left"):
|
||||
_move_cursor(Vector2i.LEFT)
|
||||
keyboard_navigation_enabled = true
|
||||
elif event.is_action_pressed("move_right"):
|
||||
_move_cursor(Vector2i.RIGHT)
|
||||
keyboard_navigation_enabled = true
|
||||
elif event.is_action_pressed("select_gem"):
|
||||
if keyboard_navigation_enabled:
|
||||
_select_tile_at_cursor()
|
||||
|
||||
|
||||
func _move_cursor(direction: Vector2i) -> void:
|
||||
var old_pos = cursor_position
|
||||
var new_pos = cursor_position + direction
|
||||
new_pos.x = clamp(new_pos.x, 0, GRID_SIZE.x - 1)
|
||||
new_pos.y = clamp(new_pos.y, 0, GRID_SIZE.y - 1)
|
||||
|
||||
if new_pos != cursor_position:
|
||||
DebugManager.log_debug("Cursor moved from (%d,%d) to (%d,%d)" % [old_pos.x, old_pos.y, new_pos.x, new_pos.y], "Match3")
|
||||
|
||||
# Clear highlighting from old cursor position (only if not selected)
|
||||
var old_tile = grid[cursor_position.y][cursor_position.x]
|
||||
if old_tile and not old_tile.is_selected:
|
||||
old_tile.is_highlighted = false
|
||||
|
||||
cursor_position = new_pos
|
||||
|
||||
# Highlight new cursor position (only if not selected)
|
||||
var new_tile = grid[cursor_position.y][cursor_position.x]
|
||||
if new_tile and not new_tile.is_selected:
|
||||
new_tile.is_highlighted = true
|
||||
|
||||
func _select_tile_at_cursor() -> void:
|
||||
if cursor_position.x >= 0 and cursor_position.y >= 0 and cursor_position.x < GRID_SIZE.x and cursor_position.y < GRID_SIZE.y:
|
||||
var tile = grid[cursor_position.y][cursor_position.x]
|
||||
if tile:
|
||||
DebugManager.log_debug("Keyboard selection at cursor (%d,%d)" % [cursor_position.x, cursor_position.y], "Match3")
|
||||
_on_tile_selected(tile)
|
||||
|
||||
func _on_tile_selected(tile: Node2D) -> void:
|
||||
if current_state == GameState.SWAPPING or current_state == GameState.PROCESSING:
|
||||
DebugManager.log_debug("Tile selection ignored - game busy (state: %s)" % [GameState.keys()[current_state]], "Match3")
|
||||
return
|
||||
|
||||
DebugManager.log_debug("Tile selected at (%d,%d), gem type: %d" % [tile.grid_position.x, tile.grid_position.y, tile.tile_type], "Match3")
|
||||
|
||||
if current_state == GameState.WAITING:
|
||||
# First tile selection
|
||||
_select_tile(tile)
|
||||
elif current_state == GameState.SELECTING:
|
||||
if tile == selected_tile:
|
||||
# Deselect current tile
|
||||
DebugManager.log_debug("Same tile clicked - deselecting", "Match3")
|
||||
_deselect_tile()
|
||||
else:
|
||||
# Attempt to swap with selected tile
|
||||
DebugManager.log_debug("Attempting swap between (%d,%d) and (%d,%d)" % [selected_tile.grid_position.x, selected_tile.grid_position.y, tile.grid_position.x, tile.grid_position.y], "Match3")
|
||||
_attempt_swap(selected_tile, tile)
|
||||
|
||||
|
||||
func _select_tile(tile: Node2D) -> void:
|
||||
selected_tile = tile
|
||||
tile.is_selected = true
|
||||
current_state = GameState.SELECTING
|
||||
DebugManager.log_debug("Selected tile at (%d, %d)" % [tile.grid_position.x, tile.grid_position.y], "Match3")
|
||||
|
||||
func _deselect_tile() -> void:
|
||||
if selected_tile:
|
||||
DebugManager.log_debug("Deselecting tile at (%d,%d)" % [selected_tile.grid_position.x, selected_tile.grid_position.y], "Match3")
|
||||
|
||||
# Clear selection state
|
||||
selected_tile.is_selected = false
|
||||
|
||||
# Handle cursor highlighting for keyboard navigation
|
||||
if keyboard_navigation_enabled:
|
||||
# Clear all highlighting first to avoid conflicts
|
||||
selected_tile.is_highlighted = false
|
||||
|
||||
# Re-highlight cursor position if it's different from the deselected tile
|
||||
var cursor_tile = grid[cursor_position.y][cursor_position.x]
|
||||
if cursor_tile:
|
||||
cursor_tile.is_highlighted = true
|
||||
DebugManager.log_debug("Restored cursor highlighting at (%d,%d)" % [cursor_position.x, cursor_position.y], "Match3")
|
||||
else:
|
||||
# For mouse navigation, just clear highlighting
|
||||
selected_tile.is_highlighted = false
|
||||
|
||||
selected_tile = null
|
||||
current_state = GameState.WAITING
|
||||
|
||||
func _are_adjacent(tile1: Node2D, tile2: Node2D) -> bool:
|
||||
if not tile1 or not tile2:
|
||||
return false
|
||||
|
||||
var pos1 = tile1.grid_position
|
||||
var pos2 = tile2.grid_position
|
||||
var diff = abs(pos1.x - pos2.x) + abs(pos1.y - pos2.y)
|
||||
return diff == 1
|
||||
|
||||
func _attempt_swap(tile1: Node2D, tile2: Node2D) -> void:
|
||||
if not _are_adjacent(tile1, tile2):
|
||||
DebugManager.log_debug("Tiles are not adjacent, cannot swap", "Match3")
|
||||
return
|
||||
|
||||
DebugManager.log_debug("Starting swap animation: (%d,%d)[type:%d] <-> (%d,%d)[type:%d]" % [tile1.grid_position.x, tile1.grid_position.y, tile1.tile_type, tile2.grid_position.x, tile2.grid_position.y, tile2.tile_type], "Match3")
|
||||
|
||||
current_state = GameState.SWAPPING
|
||||
await _swap_tiles(tile1, tile2)
|
||||
|
||||
# Check if swap creates matches
|
||||
if _has_match_at(tile1.grid_position) or _has_match_at(tile2.grid_position):
|
||||
DebugManager.log_info("Valid swap created matches at (%d,%d) or (%d,%d)" % [tile1.grid_position.x, tile1.grid_position.y, tile2.grid_position.x, tile2.grid_position.y], "Match3")
|
||||
_deselect_tile()
|
||||
current_state = GameState.PROCESSING
|
||||
_clear_matches()
|
||||
await get_tree().create_timer(0.3).timeout
|
||||
current_state = GameState.WAITING
|
||||
else:
|
||||
# Invalid swap - revert
|
||||
DebugManager.log_debug("No matches created, reverting swap", "Match3")
|
||||
await _swap_tiles(tile1, tile2) # Swap back
|
||||
DebugManager.log_debug("Swap reverted successfully", "Match3")
|
||||
_deselect_tile()
|
||||
current_state = GameState.WAITING
|
||||
|
||||
func _swap_tiles(tile1: Node2D, tile2: Node2D) -> void:
|
||||
if not tile1 or not tile2:
|
||||
DebugManager.log_error("Cannot swap tiles - one or both tiles are null", "Match3")
|
||||
return
|
||||
|
||||
# Update grid positions
|
||||
var pos1 = tile1.grid_position
|
||||
var pos2 = tile2.grid_position
|
||||
|
||||
DebugManager.log_debug("Swapping tile positions: (%d,%d) -> (%d,%d), (%d,%d) -> (%d,%d)" % [pos1.x, pos1.y, pos2.x, pos2.y, pos2.x, pos2.y, pos1.x, pos1.y], "Match3")
|
||||
|
||||
tile1.grid_position = pos2
|
||||
tile2.grid_position = pos1
|
||||
|
||||
# Update grid array
|
||||
grid[pos1.y][pos1.x] = tile2
|
||||
grid[pos2.y][pos2.x] = tile1
|
||||
|
||||
# Animate position swap
|
||||
var target_pos1 = grid_offset + Vector2(pos2.x, pos2.y) * tile_size
|
||||
var target_pos2 = grid_offset + Vector2(pos1.x, pos1.y) * tile_size
|
||||
|
||||
DebugManager.log_trace("Animating tile movement over 0.3 seconds", "Match3")
|
||||
|
||||
var tween = create_tween()
|
||||
tween.set_parallel(true)
|
||||
tween.tween_property(tile1, "position", target_pos1, 0.3)
|
||||
tween.tween_property(tile2, "position", target_pos2, 0.3)
|
||||
|
||||
await tween.finished
|
||||
DebugManager.log_trace("Tile swap animation completed", "Match3")
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
extends Node2D
|
||||
|
||||
signal tile_selected(tile: Node2D)
|
||||
|
||||
@export var tile_type: int = 0 : set = _set_tile_type
|
||||
var grid_position: Vector2i
|
||||
var is_selected: bool = false : set = _set_selected
|
||||
var is_highlighted: bool = false : set = _set_highlighted
|
||||
var original_scale: Vector2 = Vector2.ONE # Store the original scale for the board
|
||||
|
||||
@onready var sprite: Sprite2D = $Sprite2D
|
||||
|
||||
@@ -28,7 +33,6 @@ var active_gem_types = [] # Will be set from current_gem_pool
|
||||
|
||||
func _set_tile_type(value: int) -> void:
|
||||
tile_type = value
|
||||
print("Debug: _set_tile_type called with value ", value, ", active_gem_types.size() = ", active_gem_types.size())
|
||||
# Fixed: Add sprite null check to prevent crashes during initialization
|
||||
if not sprite:
|
||||
return
|
||||
@@ -38,7 +42,7 @@ func _set_tile_type(value: int) -> void:
|
||||
# print("Debug: Set texture_index ", texture_index, " for tile_type ", value)
|
||||
_scale_sprite_to_fit()
|
||||
else:
|
||||
push_error("Invalid tile type: " + str(value) + ". Available types: 0-" + str(active_gem_types.size() - 1))
|
||||
DebugManager.log_error("Invalid tile type: " + str(value) + ". Available types: 0-" + str(active_gem_types.size() - 1), "Match3")
|
||||
|
||||
func _scale_sprite_to_fit() -> void:
|
||||
# Fixed: Add additional null checks
|
||||
@@ -46,7 +50,9 @@ func _scale_sprite_to_fit() -> void:
|
||||
var texture_size = sprite.texture.get_size()
|
||||
var max_dimension = max(texture_size.x, texture_size.y)
|
||||
var scale_factor = TILE_SIZE / max_dimension
|
||||
sprite.scale = Vector2(scale_factor, scale_factor)
|
||||
original_scale = Vector2(scale_factor, scale_factor)
|
||||
sprite.scale = original_scale
|
||||
DebugManager.log_debug("Set original scale to %s for tile (%d,%d)" % [original_scale, grid_position.x, grid_position.y], "Match3")
|
||||
|
||||
# Gem pool management functions
|
||||
static func set_active_gem_pool(gem_indices: Array) -> void:
|
||||
@@ -108,9 +114,78 @@ func _remove_gem_type(gem_index: int) -> void:
|
||||
tile_type = 0
|
||||
_set_tile_type(tile_type)
|
||||
|
||||
func _set_selected(value: bool) -> void:
|
||||
var old_value = is_selected
|
||||
is_selected = value
|
||||
DebugManager.log_debug("Tile (%d,%d) selection changed: %s -> %s" % [grid_position.x, grid_position.y, old_value, value], "Match3")
|
||||
_update_visual_feedback()
|
||||
|
||||
func _set_highlighted(value: bool) -> void:
|
||||
var old_value = is_highlighted
|
||||
is_highlighted = value
|
||||
DebugManager.log_debug("Tile (%d,%d) highlight changed: %s -> %s" % [grid_position.x, grid_position.y, old_value, value], "Match3")
|
||||
_update_visual_feedback()
|
||||
|
||||
func _update_visual_feedback() -> void:
|
||||
if not sprite:
|
||||
return
|
||||
|
||||
# Determine target values based on priority: selected > highlighted > normal
|
||||
var target_modulate: Color
|
||||
var target_scale: Vector2
|
||||
var scale_multiplier: float
|
||||
|
||||
if is_selected:
|
||||
# Selected: bright and 20% larger than original board size
|
||||
target_modulate = Color(1.2, 1.2, 1.2, 1.0)
|
||||
scale_multiplier = 1.2
|
||||
DebugManager.log_debug("SELECTING tile (%d,%d): target scale %.2fx, current scale %s" % [grid_position.x, grid_position.y, scale_multiplier, sprite.scale], "Match3")
|
||||
elif is_highlighted:
|
||||
# Highlighted: subtle glow and 10% larger than original board size
|
||||
target_modulate = Color(1.1, 1.1, 1.1, 1.0)
|
||||
scale_multiplier = 1.1
|
||||
DebugManager.log_debug("HIGHLIGHTING tile (%d,%d): target scale %.2fx, current scale %s" % [grid_position.x, grid_position.y, scale_multiplier, sprite.scale], "Match3")
|
||||
else:
|
||||
# Normal state: white and original board size
|
||||
target_modulate = Color.WHITE
|
||||
scale_multiplier = 1.0
|
||||
DebugManager.log_debug("NORMALIZING tile (%d,%d): target scale %.2fx, current scale %s" % [grid_position.x, grid_position.y, scale_multiplier, sprite.scale], "Match3")
|
||||
|
||||
# Calculate target scale relative to original board scale
|
||||
target_scale = original_scale * scale_multiplier
|
||||
|
||||
# Apply modulate immediately
|
||||
sprite.modulate = target_modulate
|
||||
|
||||
# Only animate scale if it's actually changing
|
||||
if sprite.scale != target_scale:
|
||||
DebugManager.log_debug("Animating scale from %s to %s for tile (%d,%d)" % [sprite.scale, target_scale, grid_position.x, grid_position.y], "Match3")
|
||||
|
||||
var tween = create_tween()
|
||||
tween.tween_property(sprite, "scale", target_scale, 0.15)
|
||||
|
||||
# Add completion callback for debugging
|
||||
tween.tween_callback(_on_scale_animation_completed.bind(target_scale))
|
||||
else:
|
||||
DebugManager.log_debug("No scale change needed for tile (%d,%d)" % [grid_position.x, grid_position.y], "Match3")
|
||||
|
||||
func _on_scale_animation_completed(expected_scale: Vector2) -> void:
|
||||
DebugManager.log_debug("Scale animation completed for tile (%d,%d): expected %s, actual %s" % [grid_position.x, grid_position.y, expected_scale, sprite.scale], "Match3")
|
||||
|
||||
func force_reset_visual_state() -> void:
|
||||
# Force reset all visual states - debug function
|
||||
is_selected = false
|
||||
is_highlighted = false
|
||||
if sprite:
|
||||
sprite.modulate = Color.WHITE
|
||||
sprite.scale = original_scale # Reset to original board scale, not 1.0
|
||||
DebugManager.log_debug("Forced visual reset on tile (%d,%d) to original scale %s" % [grid_position.x, grid_position.y, original_scale], "Match3")
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
add_to_group("tiles") # Add to group for gem pool management
|
||||
# Initialize with current static gem pool
|
||||
active_gem_types = current_gem_pool.duplicate()
|
||||
_set_tile_type(tile_type)
|
||||
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ const MAIN_MENU_SCENE = preload("res://scenes/ui/MainMenu.tscn")
|
||||
const SETTINGS_MENU_SCENE = preload("res://scenes/ui/SettingsMenu.tscn")
|
||||
|
||||
func _ready():
|
||||
print("Main scene ready")
|
||||
DebugManager.log_debug("Main scene ready", "Main")
|
||||
press_any_key_screen.any_key_pressed.connect(_on_any_key_pressed)
|
||||
|
||||
func _on_any_key_pressed():
|
||||
print("Transitioning to main menu")
|
||||
DebugManager.log_debug("Transitioning to main menu", "Main")
|
||||
press_any_key_screen.queue_free()
|
||||
show_main_menu()
|
||||
|
||||
@@ -35,9 +35,9 @@ func clear_current_menu():
|
||||
current_menu = null
|
||||
|
||||
func _on_open_settings():
|
||||
print("Opening settings menu")
|
||||
DebugManager.log_debug("Opening settings menu", "Main")
|
||||
show_settings_menu()
|
||||
|
||||
func _on_back_to_main_menu():
|
||||
print("Back to main menu")
|
||||
DebugManager.log_debug("Back to main menu", "Main")
|
||||
show_main_menu()
|
||||
|
||||
@@ -3,12 +3,12 @@ extends Control
|
||||
signal any_key_pressed
|
||||
|
||||
func _ready():
|
||||
print("PressAnyKeyScreen ready")
|
||||
DebugManager.log_debug("PressAnyKeyScreen ready", "PressAnyKey")
|
||||
update_text()
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("any_key") or event is InputEventScreenTouch:
|
||||
print("Any key pressed: ", event)
|
||||
DebugManager.log_debug("Any key pressed: " + str(event), "PressAnyKey")
|
||||
any_key_pressed.emit()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ func _find_match3_scene():
|
||||
break
|
||||
|
||||
if match3_scene:
|
||||
print("Debug: Found match3 scene: ", match3_scene.name)
|
||||
DebugManager.log_debug("Found match3 scene: " + match3_scene.name, "DebugMenu")
|
||||
# Update UI with current values
|
||||
if match3_scene.has_method("get") and "TILE_TYPES" in match3_scene:
|
||||
gem_types_spinbox.value = match3_scene.TILE_TYPES
|
||||
@@ -136,30 +136,30 @@ func _on_regenerate_pressed():
|
||||
_find_match3_scene()
|
||||
|
||||
if not match3_scene:
|
||||
print("Error: Could not find match3 scene for regeneration")
|
||||
DebugManager.log_error("Could not find match3 scene for regeneration", "DebugMenu")
|
||||
return
|
||||
|
||||
if match3_scene.has_method("regenerate_grid"):
|
||||
print("Debug: Calling regenerate_grid()")
|
||||
DebugManager.log_debug("Calling regenerate_grid()", "DebugMenu")
|
||||
await match3_scene.regenerate_grid()
|
||||
else:
|
||||
print("Error: match3_scene does not have regenerate_grid method")
|
||||
DebugManager.log_error("match3_scene does not have regenerate_grid method", "DebugMenu")
|
||||
|
||||
func _on_gem_types_changed(value: float):
|
||||
if not match3_scene:
|
||||
_find_match3_scene()
|
||||
|
||||
if not match3_scene:
|
||||
print("Error: Could not find match3 scene for gem types change")
|
||||
DebugManager.log_error("Could not find match3 scene for gem types change", "DebugMenu")
|
||||
return
|
||||
|
||||
var new_value = int(value)
|
||||
if match3_scene.has_method("set_tile_types"):
|
||||
print("Debug: Setting tile types to ", new_value)
|
||||
DebugManager.log_debug("Setting tile types to " + str(new_value), "DebugMenu")
|
||||
await match3_scene.set_tile_types(new_value)
|
||||
gem_types_label.text = "Gem Types: " + str(new_value)
|
||||
else:
|
||||
print("Error: match3_scene does not have set_tile_types method")
|
||||
DebugManager.log_error("match3_scene does not have set_tile_types method", "DebugMenu")
|
||||
# Fallback: try to set TILE_TYPES directly
|
||||
if "TILE_TYPES" in match3_scene:
|
||||
match3_scene.TILE_TYPES = new_value
|
||||
@@ -170,7 +170,7 @@ func _on_grid_width_changed(value: float):
|
||||
_find_match3_scene()
|
||||
|
||||
if not match3_scene:
|
||||
print("Error: Could not find match3 scene for grid width change")
|
||||
DebugManager.log_error("Could not find match3 scene for grid width change", "DebugMenu")
|
||||
return
|
||||
|
||||
var new_width = int(value)
|
||||
@@ -180,17 +180,17 @@ func _on_grid_width_changed(value: float):
|
||||
var current_height = int(grid_height_spinbox.value)
|
||||
|
||||
if match3_scene.has_method("set_grid_size"):
|
||||
print("Debug: Setting grid size to ", new_width, "x", current_height)
|
||||
DebugManager.log_debug("Setting grid size to " + str(new_width) + "x" + str(current_height), "DebugMenu")
|
||||
await match3_scene.set_grid_size(Vector2i(new_width, current_height))
|
||||
else:
|
||||
print("Error: match3_scene does not have set_grid_size method")
|
||||
DebugManager.log_error("match3_scene does not have set_grid_size method", "DebugMenu")
|
||||
|
||||
func _on_grid_height_changed(value: float):
|
||||
if not match3_scene:
|
||||
_find_match3_scene()
|
||||
|
||||
if not match3_scene:
|
||||
print("Error: Could not find match3 scene for grid height change")
|
||||
DebugManager.log_error("Could not find match3 scene for grid height change", "DebugMenu")
|
||||
return
|
||||
|
||||
var new_height = int(value)
|
||||
@@ -200,7 +200,7 @@ func _on_grid_height_changed(value: float):
|
||||
var current_width = int(grid_width_spinbox.value)
|
||||
|
||||
if match3_scene.has_method("set_grid_size"):
|
||||
print("Debug: Setting grid size to ", current_width, "x", new_height)
|
||||
DebugManager.log_debug("Setting grid size to " + str(current_width) + "x" + str(new_height), "DebugMenu")
|
||||
await match3_scene.set_grid_size(Vector2i(current_width, new_height))
|
||||
else:
|
||||
print("Error: match3_scene does not have set_grid_size method")
|
||||
DebugManager.log_error("match3_scene does not have set_grid_size method", "DebugMenu")
|
||||
|
||||
@@ -3,19 +3,19 @@ extends Control
|
||||
signal open_settings
|
||||
|
||||
func _ready():
|
||||
print("MainMenu ready")
|
||||
DebugManager.log_info("MainMenu ready", "MainMenu")
|
||||
|
||||
func _on_new_game_button_pressed():
|
||||
AudioManager.play_ui_click()
|
||||
print("New Game pressed")
|
||||
DebugManager.log_info("New Game pressed", "MainMenu")
|
||||
GameManager.start_new_game()
|
||||
|
||||
func _on_settings_button_pressed():
|
||||
AudioManager.play_ui_click()
|
||||
print("Settings pressed")
|
||||
DebugManager.log_info("Settings pressed", "MainMenu")
|
||||
open_settings.emit()
|
||||
|
||||
func _on_exit_button_pressed():
|
||||
AudioManager.play_ui_click()
|
||||
print("Exit pressed")
|
||||
DebugManager.log_info("Exit pressed", "MainMenu")
|
||||
get_tree().quit()
|
||||
|
||||
@@ -14,7 +14,7 @@ var language_codes = []
|
||||
|
||||
func _ready():
|
||||
add_to_group("localizable")
|
||||
print("SettingsMenu ready")
|
||||
DebugManager.log_info("SettingsMenu ready", "Settings")
|
||||
setup_language_selector()
|
||||
|
||||
var master_callback = _on_volume_slider_changed.bind("master_volume")
|
||||
@@ -49,19 +49,19 @@ func _on_volume_slider_changed(value, setting_key):
|
||||
settings_manager.set_setting(setting_key, value)
|
||||
|
||||
func _exit_settings():
|
||||
print("Exiting settings")
|
||||
DebugManager.log_info("Exiting settings", "Settings")
|
||||
settings_manager.save_settings()
|
||||
back_to_main_menu.emit()
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("ui_cancel") or event.is_action_pressed("ui_menu_toggle"):
|
||||
print("ESC pressed in settings")
|
||||
DebugManager.log_debug("ESC pressed in settings", "Settings")
|
||||
_exit_settings()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
func _on_back_button_pressed():
|
||||
AudioManager.play_ui_click()
|
||||
print("Back button pressed")
|
||||
DebugManager.log_info("Back button pressed", "Settings")
|
||||
_exit_settings()
|
||||
|
||||
func setup_language_selector():
|
||||
@@ -84,7 +84,7 @@ func _on_language_selector_item_selected(index: int):
|
||||
if index < language_codes.size():
|
||||
var selected_lang = language_codes[index]
|
||||
settings_manager.set_setting("language", selected_lang)
|
||||
print("Language changed to: ", selected_lang)
|
||||
DebugManager.log_info("Language changed to: " + selected_lang, "Settings")
|
||||
localization_manager.change_language(selected_lang)
|
||||
|
||||
func update_text():
|
||||
@@ -98,7 +98,7 @@ func update_text():
|
||||
|
||||
func _on_reset_setting_button_pressed() -> void:
|
||||
AudioManager.play_ui_click()
|
||||
print("Resetting settings")
|
||||
DebugManager.log_info("Resetting settings", "Settings")
|
||||
settings_manager.reset_settings_to_defaults()
|
||||
_update_controls_from_settings()
|
||||
localization_manager.change_language(settings_manager.get_setting("language"))
|
||||
|
||||
Reference in New Issue
Block a user