add basic match3 logic

use proper logging everywhere
add gamepad and keyboard control on match3 gameplay
This commit is contained in:
2025-09-24 16:58:08 +04:00
parent e76297b3f3
commit bbf512b675
14 changed files with 466 additions and 63 deletions

View File

@@ -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")

View File

@@ -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()

View File

@@ -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"))