|
|
@ -33,19 +33,19 @@ var _save_level_data_component: SaveLevelDataComponent ## Contains the save path |
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void: |
|
|
|
quick_load.connect(quick_load_game) |
|
|
|
quick_save.connect(quick_save_game) |
|
|
|
apply_save.connect(_on_apply_save) |
|
|
|
create_save.connect(_on_save_game_as_resource) |
|
|
|
load_save.connect(load_game_save) |
|
|
|
delete_save.connect(_on_delete_save) |
|
|
|
load_save.connect(_on_load_game_save) |
|
|
|
quick_load.connect(_on_quick_load) |
|
|
|
quick_save.connect(_on_quick_save) |
|
|
|
toggle_save_icon_generation.connect(_on_toggle_save_icon_generation) |
|
|
|
apply_save.connect(_on_apply_save) |
|
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void: |
|
|
|
if event.is_action_pressed("quick_save"): |
|
|
|
quick_save_game() |
|
|
|
_on_quick_save() |
|
|
|
if event.is_action_pressed("quick_load"): |
|
|
|
quick_load_game() |
|
|
|
_on_quick_load() |
|
|
|
|
|
|
|
|
|
|
|
func list_saves(include_quick_saves: bool = true, include_auto_saves: bool = true) -> Array[SaveFileDetailsResource]: |
|
|
@ -88,20 +88,6 @@ func list_saves(include_quick_saves: bool = true, include_auto_saves: bool = tru |
|
|
|
save_files.sort_custom(_custom_save_file_sort) |
|
|
|
return save_files |
|
|
|
|
|
|
|
func load_game_save(resource_filename: String) -> void: |
|
|
|
_load_game_resource(resource_filename) |
|
|
|
|
|
|
|
func quick_save_game() -> void: |
|
|
|
if not _load_save_level_data_component(): return |
|
|
|
|
|
|
|
_game_data_resource.save_name = "Quick Save" |
|
|
|
_save_game_as_resource(_save_level_data_component.settings.quicksave_file_name) |
|
|
|
|
|
|
|
func quick_load_game() -> void: |
|
|
|
if not _load_save_level_data_component(): return |
|
|
|
|
|
|
|
_load_game_resource(_save_level_data_component.settings.quicksave_file_name) |
|
|
|
|
|
|
|
|
|
|
|
## Sort the save files list by date created, descending |
|
|
|
func _custom_save_file_sort(a: SaveFileDetailsResource, b: SaveFileDetailsResource) -> bool: |
|
|
@ -191,8 +177,7 @@ func _take_save_screenshot(save_game_file_path: String) -> void: |
|
|
|
_icon.save_png(_icon_filepath) |
|
|
|
|
|
|
|
|
|
|
|
## Apply the loaded save.[br] |
|
|
|
## Performed after load_save |
|
|
|
## Apply the loaded save. Should be performed after load_save |
|
|
|
func _on_apply_save() -> void: |
|
|
|
if _game_data_resource == null: return |
|
|
|
|
|
|
@ -203,6 +188,29 @@ func _on_apply_save() -> void: |
|
|
|
|
|
|
|
apply_load_complete.emit() |
|
|
|
|
|
|
|
## 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") |
|
|
|
return |
|
|
|
|
|
|
|
var save_file_path: String = _save_level_data_component.settings.save_game_data_path + filename |
|
|
|
DirAccess.remove_absolute(save_file_path) |
|
|
|
DirAccess.remove_absolute(save_file_path.replace(".tres", ".png")) # Delete icon |
|
|
|
|
|
|
|
func _on_load_game_save(resource_filename: String) -> void: |
|
|
|
_load_game_resource(resource_filename) |
|
|
|
|
|
|
|
func _on_quick_load() -> void: |
|
|
|
if not _load_save_level_data_component(): return |
|
|
|
_load_game_resource(_save_level_data_component.settings.quicksave_file_name) |
|
|
|
|
|
|
|
func _on_quick_save() -> void: |
|
|
|
if not _load_save_level_data_component(): return |
|
|
|
|
|
|
|
_game_data_resource.save_name = "Quick Save" |
|
|
|
_save_game_as_resource(_save_level_data_component.settings.quicksave_file_name) |
|
|
|
|
|
|
|
## Save the game, with a filename of `<save_prepend><current_date>.tres |
|
|
|
func _on_save_game_as_resource(save_name: String) -> void: |
|
|
|
if not _load_save_level_data_component(): return |
|
|
@ -214,15 +222,5 @@ func _on_save_game_as_resource(save_name: String) -> void: |
|
|
|
_save_game_as_resource(_filename) |
|
|
|
save_complete.emit() |
|
|
|
|
|
|
|
## 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") |
|
|
|
return |
|
|
|
|
|
|
|
var save_file_path: String = _save_level_data_component.settings.save_game_data_path + filename |
|
|
|
DirAccess.remove_absolute(save_file_path) |
|
|
|
DirAccess.remove_absolute(save_file_path.replace(".tres", ".png")) # Delete icon |
|
|
|
|
|
|
|
func _on_toggle_save_icon_generation(toggled: bool) -> void: |
|
|
|
_enable_save_icon_generation = toggled |