|
|
@ -9,20 +9,22 @@ extends Node |
|
|
|
## * macOS: ~/Library/Application Support/Godot/app_userdata/[project_name][br] |
|
|
|
## * Linux: ~/.local/share/godot/app_userdata/[project_name][br] |
|
|
|
@export var save_game_data_path: String = "user://game_data/" |
|
|
|
@export var save_file_name: String = "save_%s_game_data.tres" |
|
|
|
@export var quicksave_file_name: String = "quicksave_%s_game_data.tres" |
|
|
|
@export var max_auto_saves: int = 5 |
|
|
|
|
|
|
|
@export_group("Save File Names") |
|
|
|
@export var save_file_name: String = "save_%s_game_data.tres" ## %s is the level name |
|
|
|
@export var quicksave_file_name: String = "quicksave_game_data.tres" |
|
|
|
@export var autosave_file_name: String = "autosave_%s_game_data.tres" ## %s is the save number (probably 01) |
|
|
|
|
|
|
|
var level_scene_name: String |
|
|
|
var game_data_resource: SaveGameDataResource |
|
|
|
#var level_save_file_name: String |
|
|
|
#var save_game_file_path: String |
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void: |
|
|
|
add_to_group("save_level_data_component") |
|
|
|
level_scene_name = get_parent().name |
|
|
|
|
|
|
|
|
|
|
|
SaveGameManager.create_auto_save_file.connect(_on_create_auto_save_file) |
|
|
|
|
|
|
|
|
|
|
|
func list_saves() -> Array[SaveFileDetailsResource]: # TODO: Update hints |
|
|
@ -54,13 +56,10 @@ func load_game() -> void: |
|
|
|
_load_game_resource(save_file_name % level_scene_name) |
|
|
|
|
|
|
|
func quick_load_game() -> void: |
|
|
|
# TODO: Change this to a dynamic quick save file |
|
|
|
# This might be left as 01 (01 always the last quicksave) |
|
|
|
_load_game_resource(quicksave_file_name % "01") |
|
|
|
_load_game_resource(quicksave_file_name) |
|
|
|
|
|
|
|
func quick_save_game() -> void: |
|
|
|
# TODO: Change this to a dynamic quick save file |
|
|
|
_save_game_as_resource(quicksave_file_name % "01") |
|
|
|
_save_game_as_resource(quicksave_file_name) |
|
|
|
|
|
|
|
func save_game() -> void: |
|
|
|
_save_game_as_resource(save_file_name % level_scene_name) |
|
|
@ -79,7 +78,6 @@ func save_node_data() -> void: |
|
|
|
game_data_resource.save_data_nodes.append(save_final_resource) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _save_game_as_resource(resource_filename: String) -> void: |
|
|
|
if !DirAccess.dir_exists_absolute(save_game_data_path): |
|
|
|
DirAccess.make_dir_absolute(save_game_data_path) |
|
|
@ -106,3 +104,8 @@ func _load_game_resource(resource_filename: String) -> void: |
|
|
|
for resource: Resource in game_data_resource.save_data_nodes: |
|
|
|
if resource is Node3DDataResource: |
|
|
|
(resource as Node3DDataResource)._load_data(root_node) |
|
|
|
|
|
|
|
|
|
|
|
func _on_create_auto_save_file() -> void: |
|
|
|
# TODO: Check max number of autosaves, increment existing autosaves, etc |
|
|
|
_save_game_as_resource(autosave_file_name % "01") |