format
Some checks failed
Continuous Integration / Code Formatting (push) Successful in 33s
Continuous Integration / Code Quality Check (push) Successful in 28s
Continuous Integration / Test Execution (push) Failing after 16s
Continuous Integration / CI Summary (push) Failing after 3s

This commit is contained in:
2025-10-01 15:35:34 +04:00
parent 1f1c394587
commit 35ee2f9a5e
28 changed files with 1962 additions and 663 deletions

View File

@@ -8,7 +8,8 @@ const MIN_GRID_SIZE := 3
const MIN_TILE_TYPES := 3
const SCENE_SEARCH_COOLDOWN := 0.5
@export var target_script_path: String = "res://scenes/game/gameplays/Match3Gameplay.gd"
@export
var target_script_path: String = "res://scenes/game/gameplays/Match3Gameplay.gd"
@export var log_category: String = "DebugMenu"
var match3_scene: Node2D
@@ -16,8 +17,10 @@ var search_timer: Timer
var last_scene_search_time: float = 0.0
@onready var regenerate_button: Button = $VBoxContainer/RegenerateButton
@onready var gem_types_spinbox: SpinBox = $VBoxContainer/GemTypesContainer/GemTypesSpinBox
@onready var gem_types_label: Label = $VBoxContainer/GemTypesContainer/GemTypesLabel
@onready
var gem_types_spinbox: SpinBox = $VBoxContainer/GemTypesContainer/GemTypesSpinBox
@onready
var gem_types_label: Label = $VBoxContainer/GemTypesContainer/GemTypesLabel
@onready
var grid_width_spinbox: SpinBox = $VBoxContainer/GridSizeContainer/GridWidthContainer/GridWidthSpinBox
@onready
@@ -86,7 +89,9 @@ func _setup_scene_finding() -> void:
# Virtual method - override in derived classes for specific finding logic
func _find_target_scene() -> void:
DebugManager.log_error("_find_target_scene() not implemented in derived class", log_category)
DebugManager.log_error(
"_find_target_scene() not implemented in derived class", log_category
)
func _find_node_by_script(node: Node, script_path: String) -> Node:
@@ -114,10 +119,14 @@ func _update_ui_from_scene() -> void:
# Connect to grid state loaded signal if not already connected
if (
match3_scene.has_signal("grid_state_loaded")
and not match3_scene.grid_state_loaded.is_connected(_on_grid_state_loaded)
and not match3_scene.grid_state_loaded.is_connected(
_on_grid_state_loaded
)
):
match3_scene.grid_state_loaded.connect(_on_grid_state_loaded)
DebugManager.log_debug("Connected to grid_state_loaded signal", log_category)
DebugManager.log_debug(
"Connected to grid_state_loaded signal", log_category
)
# Update gem types display
if match3_scene.has_method("get") and "TILE_TYPES" in match3_scene:
@@ -135,7 +144,10 @@ func _update_ui_from_scene() -> void:
func _on_grid_state_loaded(grid_size: Vector2i, tile_types: int) -> void:
DebugManager.log_debug(
"Grid state loaded signal received: size=%s, types=%d" % [grid_size, tile_types],
(
"Grid state loaded signal received: size=%s, types=%d"
% [grid_size, tile_types]
),
log_category
)
@@ -155,7 +167,10 @@ func _stop_search_timer() -> void:
func _start_search_timer() -> void:
if search_timer and not search_timer.timeout.is_connected(_find_target_scene):
if (
search_timer
and not search_timer.timeout.is_connected(_find_target_scene)
):
search_timer.timeout.connect(_find_target_scene)
search_timer.start()
@@ -176,7 +191,8 @@ func _refresh_current_values() -> void:
# Refresh UI with current values from the scene
if match3_scene:
DebugManager.log_debug(
"Refreshing debug menu values from current scene state", log_category
"Refreshing debug menu values from current scene state",
log_category
)
_update_ui_from_scene()
@@ -186,14 +202,18 @@ func _on_regenerate_pressed() -> void:
_find_target_scene()
if not match3_scene:
DebugManager.log_error("Could not find target scene for regeneration", log_category)
DebugManager.log_error(
"Could not find target scene for regeneration", log_category
)
return
if match3_scene.has_method("regenerate_grid"):
DebugManager.log_debug("Calling regenerate_grid()", log_category)
await match3_scene.regenerate_grid()
else:
DebugManager.log_error("Target scene does not have regenerate_grid method", log_category)
DebugManager.log_error(
"Target scene does not have regenerate_grid method", log_category
)
func _on_gem_types_changed(value: float) -> void:
@@ -207,7 +227,9 @@ func _on_gem_types_changed(value: float) -> void:
last_scene_search_time = current_time
if not match3_scene:
DebugManager.log_error("Could not find target scene for gem types change", log_category)
DebugManager.log_error(
"Could not find target scene for gem types change", log_category
)
return
var new_value: int = int(value)
@@ -221,15 +243,21 @@ func _on_gem_types_changed(value: float) -> void:
log_category
)
# Reset to valid value
gem_types_spinbox.value = clamp(new_value, MIN_TILE_TYPES, MAX_TILE_TYPES)
gem_types_spinbox.value = clamp(
new_value, MIN_TILE_TYPES, MAX_TILE_TYPES
)
return
if match3_scene.has_method("set_tile_types"):
DebugManager.log_debug("Setting tile types to " + str(new_value), log_category)
DebugManager.log_debug(
"Setting tile types to " + str(new_value), log_category
)
await match3_scene.set_tile_types(new_value)
gem_types_label.text = "Gem Types: " + str(new_value)
else:
DebugManager.log_error("Target scene does not have set_tile_types method", log_category)
DebugManager.log_error(
"Target scene does not have set_tile_types method", log_category
)
# Fallback: try to set TILE_TYPES directly
if "TILE_TYPES" in match3_scene:
match3_scene.TILE_TYPES = new_value
@@ -247,7 +275,9 @@ func _on_grid_width_changed(value: float) -> void:
last_scene_search_time = current_time
if not match3_scene:
DebugManager.log_error("Could not find target scene for grid width change", log_category)
DebugManager.log_error(
"Could not find target scene for grid width change", log_category
)
return
var new_width: int = int(value)
@@ -261,7 +291,9 @@ func _on_grid_width_changed(value: float) -> void:
log_category
)
# Reset to valid value
grid_width_spinbox.value = clamp(new_width, MIN_GRID_SIZE, MAX_GRID_SIZE)
grid_width_spinbox.value = clamp(
new_width, MIN_GRID_SIZE, MAX_GRID_SIZE
)
return
grid_width_label.text = "Width: " + str(new_width)
@@ -271,11 +303,19 @@ func _on_grid_width_changed(value: float) -> void:
if match3_scene.has_method("set_grid_size"):
DebugManager.log_debug(
"Setting grid size to " + str(new_width) + "x" + str(current_height), log_category
(
"Setting grid size to "
+ str(new_width)
+ "x"
+ str(current_height)
),
log_category
)
await match3_scene.set_grid_size(Vector2i(new_width, current_height))
else:
DebugManager.log_error("Target scene does not have set_grid_size method", log_category)
DebugManager.log_error(
"Target scene does not have set_grid_size method", log_category
)
func _on_grid_height_changed(value: float) -> void:
@@ -289,7 +329,9 @@ func _on_grid_height_changed(value: float) -> void:
last_scene_search_time = current_time
if not match3_scene:
DebugManager.log_error("Could not find target scene for grid height change", log_category)
DebugManager.log_error(
"Could not find target scene for grid height change", log_category
)
return
var new_height: int = int(value)
@@ -303,7 +345,9 @@ func _on_grid_height_changed(value: float) -> void:
log_category
)
# Reset to valid value
grid_height_spinbox.value = clamp(new_height, MIN_GRID_SIZE, MAX_GRID_SIZE)
grid_height_spinbox.value = clamp(
new_height, MIN_GRID_SIZE, MAX_GRID_SIZE
)
return
grid_height_label.text = "Height: " + str(new_height)
@@ -313,8 +357,16 @@ func _on_grid_height_changed(value: float) -> void:
if match3_scene.has_method("set_grid_size"):
DebugManager.log_debug(
"Setting grid size to " + str(current_width) + "x" + str(new_height), log_category
(
"Setting grid size to "
+ str(current_width)
+ "x"
+ str(new_height)
),
log_category
)
await match3_scene.set_grid_size(Vector2i(current_width, new_height))
else:
DebugManager.log_error("Target scene does not have set_grid_size method", log_category)
DebugManager.log_error(
"Target scene does not have set_grid_size method", log_category
)