130 lines
4.8 KiB
GDScript
130 lines
4.8 KiB
GDScript
extends Control
|
|
|
|
@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 grid_width_spinbox: SpinBox = $VBoxContainer/GridSizeContainer/GridWidthContainer/GridWidthSpinBox
|
|
@onready var grid_height_spinbox: SpinBox = $VBoxContainer/GridSizeContainer/GridHeightContainer/GridHeightSpinBox
|
|
@onready var grid_width_label: Label = $VBoxContainer/GridSizeContainer/GridWidthContainer/GridWidthLabel
|
|
@onready var grid_height_label: Label = $VBoxContainer/GridSizeContainer/GridHeightContainer/GridHeightLabel
|
|
|
|
var match3_scene: Node2D
|
|
|
|
func _ready():
|
|
print("Match3DebugMenu: _ready() called")
|
|
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)
|
|
visible = current_debug_state
|
|
print("Match3DebugMenu: Initial visibility set to ", visible)
|
|
if current_debug_state:
|
|
_on_debug_toggled(true)
|
|
regenerate_button.pressed.connect(_on_regenerate_pressed)
|
|
gem_types_spinbox.value_changed.connect(_on_gem_types_changed)
|
|
grid_width_spinbox.value_changed.connect(_on_grid_width_changed)
|
|
grid_height_spinbox.value_changed.connect(_on_grid_height_changed)
|
|
|
|
func _find_match3_scene():
|
|
# Debug menu is now: Match3 -> UILayer -> Match3DebugMenu
|
|
# So we need to go up two levels: get_parent() = UILayer, get_parent().get_parent() = Match3
|
|
var ui_layer = get_parent()
|
|
if ui_layer and ui_layer is CanvasLayer:
|
|
match3_scene = ui_layer.get_parent()
|
|
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())
|
|
return
|
|
|
|
# If we couldn't find it, clear the reference
|
|
match3_scene = null
|
|
print("Debug: Could not find match3_gameplay scene")
|
|
|
|
func _on_debug_toggled(enabled: bool):
|
|
print("Match3DebugMenu: Debug toggled to ", enabled)
|
|
visible = enabled
|
|
print("Match3DebugMenu: Visibility set to ", visible)
|
|
if enabled:
|
|
# Always refresh match3 scene reference when debug menu opens
|
|
if not match3_scene:
|
|
_find_match3_scene()
|
|
# Update display values
|
|
if match3_scene and match3_scene.has_method("get") and "TILE_TYPES" in match3_scene:
|
|
gem_types_spinbox.value = match3_scene.TILE_TYPES
|
|
gem_types_label.text = "Gem Types: " + str(match3_scene.TILE_TYPES)
|
|
|
|
# Update grid size display values
|
|
if match3_scene and "GRID_SIZE" in match3_scene:
|
|
var grid_size = match3_scene.GRID_SIZE
|
|
grid_width_spinbox.value = grid_size.x
|
|
grid_height_spinbox.value = grid_size.y
|
|
grid_width_label.text = "Width: " + str(grid_size.x)
|
|
grid_height_label.text = "Height: " + str(grid_size.y)
|
|
|
|
func _on_regenerate_pressed():
|
|
if not match3_scene:
|
|
_find_match3_scene()
|
|
|
|
if not match3_scene:
|
|
print("Error: Could not find match3 scene for regeneration")
|
|
return
|
|
|
|
if match3_scene.has_method("regenerate_grid"):
|
|
print("Debug: Calling regenerate_grid()")
|
|
await match3_scene.regenerate_grid()
|
|
else:
|
|
print("Error: match3_scene does not have regenerate_grid method")
|
|
|
|
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")
|
|
return
|
|
|
|
var new_value = int(value)
|
|
if match3_scene.has_method("set_tile_types"):
|
|
print("Debug: Setting tile types to ", new_value)
|
|
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")
|
|
|
|
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")
|
|
return
|
|
|
|
var new_width = int(value)
|
|
grid_width_label.text = "Width: " + str(new_width)
|
|
|
|
# Get current height
|
|
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)
|
|
await match3_scene.set_grid_size(Vector2i(new_width, current_height))
|
|
|
|
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")
|
|
return
|
|
|
|
var new_height = int(value)
|
|
grid_height_label.text = "Height: " + str(new_height)
|
|
|
|
# Get current width
|
|
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)
|
|
await match3_scene.set_grid_size(Vector2i(current_width, new_height))
|