ChronoChamber/Scripts/menu.gd

46 lines
1.4 KiB
GDScript3
Raw Normal View History

2024-08-11 22:19:23 +10:00
extends Control
var credits_shown : bool = false
@export var level_node : Control
@export var credits_node : Control
@export var credits_button : Button
2024-08-13 01:24:47 +10:00
@export var levels_vbox : VBoxContainer
2024-08-11 22:19:23 +10:00
# Called when the node enters the scene tree for the first time.
func _ready():
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
2024-08-13 01:24:47 +10:00
for level_num in GameManager.levels.size():
var new_button : Button = Button.new()
new_button.text = "Level " + str(level_num) + " : " + GameManager.levels[level_num].level_name
new_button.pressed.connect(func(): pick_level(GameManager.levels[level_num].level_name))
levels_vbox.add_child(new_button)
2024-08-11 22:19:23 +10:00
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if credits_shown:
credits_node.visible = true
level_node.visible = false
credits_button.text = "Back to Level Select"
else:
credits_node.visible = false
level_node.visible = true
credits_button.text = "Credits"
2024-08-13 01:24:47 +10:00
func pick_level(picked_level:String):
for level_num in GameManager.levels.size():
if GameManager.levels[level_num].level_name == picked_level:
get_tree().change_scene_to_file(GameManager.levels[level_num].level_path)
GameManager.current_level = level_num
2024-08-13 01:24:47 +10:00
2024-08-11 22:19:23 +10:00
func _on_credits_button_pressed():
credits_shown = !credits_shown
func _on_credits_page_meta_clicked(meta):
OS.shell_open(str(meta))