imported main menu scene addon

This commit is contained in:
2026-05-10 15:48:56 +02:00
parent 86d9f75161
commit 71c2850a34
458 changed files with 14881 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
extends Node
## A script to add into a level or game scene to display tutorial windows.
## A list of tutorial scenes to open, one after the other.
@export var tutorial_scenes : Array[PackedScene]
## If true, open the tutorials when the scene becomes ready.
@export var auto_open : bool = false
## Delay before opening the tutorials when the scene becomes ready.
@export var auto_open_delay : float = 0.25
func open_tutorials() -> void:
var _initial_focus_control : Control = get_viewport().gui_get_focus_owner()
for tutorial_scene in tutorial_scenes:
var tutorial_menu : Control = tutorial_scene.instantiate()
if tutorial_menu == null:
push_warning("tutorial failed to open %s" % tutorial_scene)
return
get_tree().current_scene.call_deferred("add_child", tutorial_menu)
if tutorial_menu.has_signal(&"closed"):
await tutorial_menu.closed
else:
await tutorial_menu.tree_exited
if is_inside_tree() and _initial_focus_control:
_initial_focus_control.grab_focus()
func _ready() -> void:
if auto_open:
if auto_open_delay > 0.0:
await get_tree().create_timer(auto_open_delay, false).timeout
open_tutorials.call_deferred()