2026-05-16 21:50:00 +02:00
|
|
|
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")
|
|
|
|
|
|
2026-05-16 21:58:11 +02:00
|
|
|
static func _on_reset_level(level: LevelEntry, node: String, index: int, parent) -> void:
|
2026-05-16 21:50:00 +02:00
|
|
|
Global.current_scene_int = index
|
|
|
|
|
level.reset()
|
2026-05-16 21:58:11 +02:00
|
|
|
parent.configure_reset(level, node, true)
|
2026-05-16 21:50:00 +02:00
|
|
|
parent.configure_counter(level, node)
|
2026-05-16 21:58:11 +02:00
|
|
|
Global.current_scene_int = -1
|
2026-05-16 21:50:00 +02:00
|
|
|
|
|
|
|
|
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()
|