Files
puzzle-quest/scripts/event.gd
T

43 lines
1.5 KiB
GDScript
Raw Normal View History

class_name Event
# UI event handlers, namespaced as static methods so they can be wired
# directly from anywhere without an autoload.
#
# button.pressed.connect(Event._on_main_scene_pressed)
#
# Per-level dispatch goes through `level_pressed(name)` which maps the level
# name to the appropriate handler.
static func _loading_is_started(_anim_name: StringName) -> void:
Global.loaded = false
static func _loading_is_finished(_anim_name: StringName) -> void:
Global.loaded = true
static func _on_warcraft_pressed() -> void:
Global.current_scene_int = 0
Global.goto_scene("res://scenes/levels/warcraft/WarCraft.tscn")
static func _on_home_pressed() -> void:
Global.current_scene_int = 1
Global.goto_scene("res://scenes/levels/home/Home.tscn")
static func _on_reset_level(level: LevelEntry, node: String, index: int, parent) -> void:
Global.current_scene_int = index
level.reset()
parent.configure_reset(level, node, true)
parent.configure_counter(level, node)
Global.current_scene_int = -1
static func _on_main_scene_pressed() -> void:
Global.goto_scene("res://scenes/Main.tscn")
# Returns the press handler for a level by name (used by ChooseScene to wire
# the dynamic level-select buttons). Returns Callable() if unknown.
static func level_pressed(name: String) -> Callable:
match name.to_lower():
"warcraft": return _on_warcraft_pressed
"home": return _on_home_pressed
push_warning("Event.level_pressed: no handler for level '%s'" % name)
return Callable()