generated from krampus/template-godot4
41 lines
1.0 KiB
GDScript3
41 lines
1.0 KiB
GDScript3
|
extends Control
|
||
|
## Title screen!
|
||
|
|
||
|
@export_category("Game Scenes")
|
||
|
# TODO is there a way to get the appropriate level scene path here without loading the world scene?
|
||
|
@export_file("*.tscn") var level_scene: String
|
||
|
@export_file("*.tscn") var world_scene: String
|
||
|
|
||
|
@export var settings_scene: PackedScene
|
||
|
|
||
|
@onready var continue_button: Button = %Continue
|
||
|
@onready var settings_container: Control = %SettingsContainer
|
||
|
|
||
|
|
||
|
func _ready() -> void:
|
||
|
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||
|
var save_path := _get_save_path()
|
||
|
if FileAccess.file_exists(save_path):
|
||
|
continue_button.disabled = false
|
||
|
|
||
|
|
||
|
func _get_save_path() -> String:
|
||
|
return World.get_save_path(level_scene)
|
||
|
|
||
|
|
||
|
func continue_game() -> void:
|
||
|
LoadingTools.load_save(_get_save_path())
|
||
|
|
||
|
|
||
|
func new_game() -> void:
|
||
|
LoadingTools.load_level(level_scene)
|
||
|
|
||
|
|
||
|
func show_settings() -> void:
|
||
|
var instance: Control = settings_scene.instantiate()
|
||
|
settings_container.add_child(instance)
|
||
|
|
||
|
|
||
|
func quit() -> void:
|
||
|
get_tree().root.propagate_notification(NOTIFICATION_WM_CLOSE_REQUEST)
|