Added Level Loading

This commit is contained in:
Willow Behar
2024-05-09 15:46:13 -05:00
parent 48817f3958
commit 65de7f3966
4 changed files with 28 additions and 11 deletions

View File

@ -1,18 +1,27 @@
extends Control
signal startGame
signal startGame(path)
var load_list = ["Back"]
@export var level_folder = "res://Assets/Levels"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
var dir = DirAccess.open(level_folder)
if dir:
dir.list_dir_begin()
var file_name = dir.get_next()
while file_name != "":
load_list.append(file_name)
$ItemList.add_item(file_name.replace(".tscn", ""),null,false)
file_name = dir.get_next()
func _on_exit_pressed():
get_tree().quit()
func _on_start_pressed():
emit_signal("startGame")
emit_signal("startGame", "res://Assets/Levels/TestMapHospitalTextures.tscn")
GlobalSettings.current_map = "res://Assets/Levels/TestMapHospitalTextures.tscn"
func _on_settings_pressed():
pass # Replace with function body.
@ -26,3 +35,6 @@ func _on_item_list_item_clicked(index, at_position, mouse_button_index):
if index == 0:
$ItemList.hide()
$VBoxContainer.show()
else:
GlobalSettings.current_map = "res://Assets/Levels/" + load_list[index]
emit_signal("startGame", GlobalSettings.current_map)