|
|
@ -1,8 +1,8 @@ |
|
|
|
## Performs the actual Saving[br][br] |
|
|
|
## Performs the managing of saves by saving, loading, and returning a list of saves[br][br] |
|
|
|
## |
|
|
|
## Below is a basic definition of various components and resources for reference:[br] |
|
|
|
## * SaveLevelDataComponent - The root save component that performs saving and loading of the actual data from disk |
|
|
|
## * SaveDataComponent - Attached to a node that has properties that need to be saved |
|
|
|
## * SaveLevelDataComponent - The root save component that provides the Save Settings[br] |
|
|
|
## * SaveDataComponent - Attached to a node that has properties that need to be saved[br] |
|
|
|
## * Node Type Resources - Each type of node that requires saving, such as a TileMapLayer, needs a resource created |
|
|
|
extends Node |
|
|
|
|
|
|
@ -51,7 +51,7 @@ func list_saves(include_quick_saves: bool = true, include_auto_saves: bool = tru |
|
|
|
return save_files |
|
|
|
|
|
|
|
for filename: String in ResourceLoader.list_directory(save_game_data_path): |
|
|
|
# TODO: Rework so the settings determine the file_name prepends |
|
|
|
# TODO: Rework so the settings determine the file_name using prepends |
|
|
|
if filename.begins_with("quicksave_") and not include_quick_saves: continue |
|
|
|
elif filename.begins_with("autosave_") and not include_auto_saves: continue |
|
|
|
elif !filename.begins_with("save_") and !filename.begins_with("quicksave_") and !filename.begins_with("autosave_"): continue |
|
|
@ -95,7 +95,6 @@ func quick_save_game() -> void: |
|
|
|
func quick_load_game() -> void: |
|
|
|
if not _load_save_level_data_component(): return |
|
|
|
|
|
|
|
# TODO: Don't reset world if quicksave not found |
|
|
|
_load_game_resource(_save_level_data_component.settings.quicksave_file_name) |
|
|
|
game_loaded.emit() |
|
|
|
|
|
|
@ -120,7 +119,7 @@ func _generate_save_icon_texture(save_icon: String) -> Texture2D: |
|
|
|
|
|
|
|
return _icon_texture |
|
|
|
|
|
|
|
## Find the SaveLevelDataComponent within the level which stores the save paths and filenames |
|
|
|
## Find the SaveLevelDataComponent within the level which stores the save settings |
|
|
|
func _load_save_level_data_component() -> bool: |
|
|
|
_save_level_data_component = get_tree().get_first_node_in_group("save_level_data_component") |
|
|
|
if _save_level_data_component == null: |
|
|
@ -191,6 +190,7 @@ func _take_save_screenshot(save_game_file_path: String) -> void: |
|
|
|
_icon.save_png(_icon_filepath) |
|
|
|
|
|
|
|
|
|
|
|
## 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 |
|
|
|
|
|
|
@ -201,6 +201,7 @@ func _on_save_game_as_resource(save_name: String) -> void: |
|
|
|
_save_game_as_resource(_filename) |
|
|
|
game_saved.emit() |
|
|
|
|
|
|
|
## Delete both the save file and the related screenshot |
|
|
|
func _on_delete_save_file(filename: String) -> void: |
|
|
|
if filename.length() < 1: |
|
|
|
printerr("_on_delete_save_file(): Empty filename provided") |
|
|
|