@ -14,14 +14,12 @@ signal autosave_start ## Autosave has started
signal create_autosave
signal create_save ( save_name : String )
signal delete_save ( filename : String )
signal delete_error ( error_message : String )
signal disable_autosaves
signal enable_autosaves
signal error ( error_message : String )
signal load_complete
signal load_error ( error_message : String )
signal load_save ( filename : String ) ## Loads the save into memory. Does NOT apply the load as this allows for other actions (such as resetting the levle/world).[br]Don't forget to run `apply_save` after loading
signal save_complete
signal save_error ( error_message : String )
signal start_autosave
signal stop_autosave
@ -162,12 +160,12 @@ func _load_game_resource(resource_filename: String) -> void:
var save_game_file_path : String = _save_game_settings . save_game_data_path + resource_filename
if ! FileAccess . file_exists ( save_game_file_path ) :
load_ error. emit ( " Failed to load save. File does not exist: %s " % save_game_file_path )
error . emit ( " Failed to load save. File does not exist: %s " % save_game_file_path )
return
_loaded_save_resource = ResourceLoader . load ( save_game_file_path )
if _loaded_save_resource == null :
load_ error. emit ( " Failed to load save. Unknown format? %s " % save_game_file_path )
error . emit ( " Failed to load save. Unknown format? %s " % save_game_file_path )
return
load_complete . emit ( )
@ -176,7 +174,7 @@ func _load_game_resource(resource_filename: String) -> void:
func _load_save_settings ( ) - > bool :
var _save_level_data_component : SaveLevelDataComponent = get_tree ( ) . get_first_node_in_group ( " save_level_data_component " )
if _save_level_data_component == null :
push_ error( " Could not find SaveLevelDataComponent node in level " )
error . emit ( " Failed to Save Settings. Could not find SaveLevelDataComponent node in tree " )
return false
_save_game_settings = _save_level_data_component . settings
@ -223,7 +221,7 @@ func _save_game_as_resource(save_name, resource_filename: String) -> void:
var result : int = ResourceSaver . save ( _save_resource , save_game_file_path )
if result != OK :
save_ error. emit ( " Failed to save game ( " , result , " ): " + save_game_file_path )
error . emit ( " Failed to save game ( " , result , " ): " + save_game_file_path )
return
_take_save_screenshot ( save_game_file_path )
@ -261,7 +259,7 @@ func _on_autosave_timer_timeout() -> void:
## Delete both the save file and the related screenshot
func _on_delete_save ( filename : String ) - > void :
if filename . length ( ) < 1 :
delete_ error. emit ( " Empty filename provided " )
error . emit ( " Failed to delete save. Empty filename provided. " )
return
var save_file_path : String = _save_game_settings . save_game_data_path + filename