make grid shuffle, grid sizy, gem color types
This commit is contained in:
25
scenes/ui/DebugButton.tscn
Normal file
25
scenes/ui/DebugButton.tscn
Normal file
@@ -0,0 +1,25 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dmjfgs6r4yfwl"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bt6a8gpw1e31c" path="res://scenes/ui/DebugButton.gd" id="1_debug_script"]
|
||||
|
||||
[node name="DebugButton" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -80.0
|
||||
offset_top = -40.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
script = ExtResource("1_debug_script")
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "DEBUG"
|
||||
203
scenes/ui/DebugMenu.gd
Normal file
203
scenes/ui/DebugMenu.gd
Normal file
@@ -0,0 +1,203 @@
|
||||
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
|
||||
var search_timer: Timer
|
||||
|
||||
# Fixed: Add cleanup function
|
||||
func _exit_tree():
|
||||
if search_timer:
|
||||
search_timer.queue_free()
|
||||
|
||||
func _ready():
|
||||
visible = false
|
||||
DebugManager.debug_toggled.connect(_on_debug_toggled)
|
||||
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)
|
||||
|
||||
# Initialize gem types spinbox
|
||||
gem_types_spinbox.min_value = 3
|
||||
gem_types_spinbox.max_value = 8
|
||||
gem_types_spinbox.step = 1
|
||||
gem_types_spinbox.value = 5 # Default value
|
||||
|
||||
# Initialize grid size spinboxes
|
||||
grid_width_spinbox.min_value = 4
|
||||
grid_width_spinbox.max_value = 12
|
||||
grid_width_spinbox.step = 1
|
||||
grid_width_spinbox.value = 8 # Default value
|
||||
|
||||
grid_height_spinbox.min_value = 4
|
||||
grid_height_spinbox.max_value = 12
|
||||
grid_height_spinbox.step = 1
|
||||
grid_height_spinbox.value = 8 # Default value
|
||||
|
||||
# Fixed: Create timer for periodic match3 scene search
|
||||
search_timer = Timer.new()
|
||||
search_timer.wait_time = 0.1
|
||||
search_timer.timeout.connect(_find_match3_scene)
|
||||
add_child(search_timer)
|
||||
|
||||
# Start searching immediately and continue until found
|
||||
_find_match3_scene()
|
||||
|
||||
func _find_match3_scene():
|
||||
# Fixed: Search more thoroughly for match3 scene
|
||||
if match3_scene:
|
||||
# Already found, stop searching
|
||||
if search_timer and search_timer.timeout.is_connected(_find_match3_scene):
|
||||
search_timer.stop()
|
||||
return
|
||||
|
||||
# Search in current scene tree
|
||||
var current_scene = get_tree().current_scene
|
||||
if current_scene:
|
||||
# Try to find match3 by class name first
|
||||
match3_scene = _find_node_by_script(current_scene, "res://scenes/match3/match3.gd")
|
||||
|
||||
# Fallback: search by common node names
|
||||
if not match3_scene:
|
||||
for possible_name in ["Match3", "match3", "Match3Game"]:
|
||||
match3_scene = current_scene.find_child(possible_name, true, false)
|
||||
if match3_scene:
|
||||
break
|
||||
|
||||
if match3_scene:
|
||||
print("Debug: Found match3 scene: ", match3_scene.name)
|
||||
# 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
|
||||
gem_types_label.text = "Gem Types: " + str(match3_scene.TILE_TYPES)
|
||||
|
||||
# Update grid size values
|
||||
if "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)
|
||||
|
||||
# Stop the search timer
|
||||
if search_timer and search_timer.timeout.is_connected(_find_match3_scene):
|
||||
search_timer.stop()
|
||||
else:
|
||||
# Continue searching if not found
|
||||
if search_timer and not search_timer.timeout.is_connected(_find_match3_scene):
|
||||
search_timer.timeout.connect(_find_match3_scene)
|
||||
search_timer.start()
|
||||
|
||||
func _find_node_by_script(node: Node, script_path: String) -> Node:
|
||||
# Helper function to find node by its script path
|
||||
if node.get_script():
|
||||
var node_script = node.get_script()
|
||||
if node_script.resource_path == script_path:
|
||||
return node
|
||||
|
||||
for child in node.get_children():
|
||||
var result = _find_node_by_script(child, script_path)
|
||||
if result:
|
||||
return result
|
||||
|
||||
return null
|
||||
|
||||
func _on_debug_toggled(enabled: bool):
|
||||
visible = enabled
|
||||
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")
|
||||
# Fallback: try to set TILE_TYPES directly
|
||||
if "TILE_TYPES" in match3_scene:
|
||||
match3_scene.TILE_TYPES = new_value
|
||||
gem_types_label.text = "Gem Types: " + str(new_value)
|
||||
|
||||
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))
|
||||
else:
|
||||
print("Error: match3_scene does not have set_grid_size method")
|
||||
|
||||
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))
|
||||
else:
|
||||
print("Error: match3_scene does not have set_grid_size method")
|
||||
83
scenes/ui/DebugMenu.tscn
Normal file
83
scenes/ui/DebugMenu.tscn
Normal file
@@ -0,0 +1,83 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://fax5m4ywp1r3"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b4ppfg1tb0al0" path="res://scenes/ui/DebugMenu.gd" id="1_debug_menu"]
|
||||
|
||||
[node name="DebugMenu" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -201.0
|
||||
offset_top = 59.0
|
||||
offset_right = -11.0
|
||||
offset_bottom = 169.0
|
||||
grow_horizontal = 0
|
||||
script = ExtResource("1_debug_menu")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 10.0
|
||||
offset_top = 10.0
|
||||
offset_right = -10.0
|
||||
offset_bottom = -10.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Debug Menu"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="RegenerateButton" type="Button" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Generate New Grid"
|
||||
|
||||
[node name="GemTypesContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="GemTypesLabel" type="Label" parent="VBoxContainer/GemTypesContainer"]
|
||||
layout_mode = 2
|
||||
text = "Gem Types: 5"
|
||||
|
||||
[node name="GemTypesSpinBox" type="SpinBox" parent="VBoxContainer/GemTypesContainer"]
|
||||
layout_mode = 2
|
||||
min_value = 3.0
|
||||
max_value = 8.0
|
||||
value = 5.0
|
||||
|
||||
[node name="GridSizeContainer" type="VBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="GridSizeLabel" type="Label" parent="VBoxContainer/GridSizeContainer"]
|
||||
layout_mode = 2
|
||||
text = "Grid Size"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="GridWidthContainer" type="HBoxContainer" parent="VBoxContainer/GridSizeContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="GridWidthLabel" type="Label" parent="VBoxContainer/GridSizeContainer/GridWidthContainer"]
|
||||
layout_mode = 2
|
||||
text = "Width: 8"
|
||||
|
||||
[node name="GridWidthSpinBox" type="SpinBox" parent="VBoxContainer/GridSizeContainer/GridWidthContainer"]
|
||||
layout_mode = 2
|
||||
min_value = 4.0
|
||||
max_value = 12.0
|
||||
value = 8.0
|
||||
|
||||
[node name="GridHeightContainer" type="HBoxContainer" parent="VBoxContainer/GridSizeContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="GridHeightLabel" type="Label" parent="VBoxContainer/GridSizeContainer/GridHeightContainer"]
|
||||
layout_mode = 2
|
||||
text = "Height: 8"
|
||||
|
||||
[node name="GridHeightSpinBox" type="SpinBox" parent="VBoxContainer/GridSizeContainer/GridHeightContainer"]
|
||||
layout_mode = 2
|
||||
min_value = 4.0
|
||||
max_value = 12.0
|
||||
value = 8.0
|
||||
12
scenes/ui/DebugToggle.gd
Normal file
12
scenes/ui/DebugToggle.gd
Normal file
@@ -0,0 +1,12 @@
|
||||
extends Button
|
||||
|
||||
func _ready():
|
||||
text = "Debug: OFF"
|
||||
pressed.connect(_on_pressed)
|
||||
DebugManager.debug_toggled.connect(_on_debug_toggled)
|
||||
|
||||
func _on_pressed():
|
||||
DebugManager.toggle_debug()
|
||||
|
||||
func _on_debug_toggled(enabled: bool):
|
||||
text = "Debug: " + ("ON" if enabled else "OFF")
|
||||
18
scenes/ui/DebugToggle.tscn
Normal file
18
scenes/ui/DebugToggle.tscn
Normal file
@@ -0,0 +1,18 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://df2b4wn8j6cxl"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/ui/DebugToggle.gd" id="1_gn2ol"]
|
||||
|
||||
[node name="DebugToggle" type="Button"]
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -110.0
|
||||
offset_top = -40.0
|
||||
offset_right = -10.0
|
||||
offset_bottom = -10.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
text = "Debug: OFF"
|
||||
script = ExtResource("1_gn2ol")
|
||||
Reference in New Issue
Block a user