@ -15,6 +15,8 @@ signal create_autosave
signal create_save ( save_name : String )
signal create_save ( save_name : String )
signal delete_save ( filename : String )
signal delete_save ( filename : String )
signal delete_error ( error_message : String )
signal delete_error ( error_message : String )
signal disable_autosaves
signal enable_autosaves
signal load_complete
signal load_complete
signal load_error ( error_message : String )
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 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
@ -28,6 +30,7 @@ signal quick_load
signal toggle_save_icon_generation ( toggled : bool ) ## Enable/Disable the generation of a screenshot during save for the save icon.
signal toggle_save_icon_generation ( toggled : bool ) ## Enable/Disable the generation of a screenshot during save for the save icon.
var _autosaves_enabled : bool = true
var _autosave_timer : Timer = Timer . new ( )
var _autosave_timer : Timer = Timer . new ( )
var _enable_save_icon_generation : bool = true
var _enable_save_icon_generation : bool = true
var _loaded_save_resource : SaveGameDataResource = SaveGameDataResource . new ( )
var _loaded_save_resource : SaveGameDataResource = SaveGameDataResource . new ( )
@ -39,6 +42,8 @@ func _ready() -> void:
apply_save . connect ( _on_apply_save )
apply_save . connect ( _on_apply_save )
create_save . connect ( _on_save_game_as_resource )
create_save . connect ( _on_save_game_as_resource )
delete_save . connect ( _on_delete_save )
delete_save . connect ( _on_delete_save )
disable_autosaves . connect ( _on_disable_autosaves )
enable_autosaves . connect ( _on_enable_autosaves )
load_save . connect ( _on_load_game_save )
load_save . connect ( _on_load_game_save )
quick_load . connect ( _on_quick_load )
quick_load . connect ( _on_quick_load )
quick_save . connect ( _on_quick_save )
quick_save . connect ( _on_quick_save )
@ -250,6 +255,7 @@ func _on_apply_save() -> void:
apply_complete . emit ( )
apply_complete . emit ( )
func _on_autosave_timer_timeout ( ) - > void :
func _on_autosave_timer_timeout ( ) - > void :
if not _autosaves_enabled : return
_create_autosave ( )
_create_autosave ( )
## Delete both the save file and the related screenshot
## Delete both the save file and the related screenshot
@ -262,6 +268,13 @@ func _on_delete_save(filename: String) -> void:
DirAccess . remove_absolute ( save_file_path )
DirAccess . remove_absolute ( save_file_path )
DirAccess . remove_absolute ( save_file_path . replace ( " .tres " , " .png " ) ) # Delete icon
DirAccess . remove_absolute ( save_file_path . replace ( " .tres " , " .png " ) ) # Delete icon
func _on_disable_autosaves ( ) - > void :
_autosaves_enabled = false
stop_autosave . emit ( )
func _on_enable_autosaves ( ) - > void :
_autosaves_enabled = true
func _on_load_game_save ( resource_filename : String ) - > void :
func _on_load_game_save ( resource_filename : String ) - > void :
_load_game_resource ( resource_filename )
_load_game_resource ( resource_filename )
@ -286,6 +299,8 @@ func _on_save_game_as_resource(save_name: String) -> void:
save_complete . emit ( )
save_complete . emit ( )
func _on_start_autosave ( ) - > void :
func _on_start_autosave ( ) - > void :
if not _autosaves_enabled : return
if _save_game_settings == null :
if _save_game_settings == null :
_load_save_settings ( )
_load_save_settings ( )
_autosave_timer . start ( _save_game_settings . autosave_duration )
_autosave_timer . start ( _save_game_settings . autosave_duration )