From 15efc6145d3a352c8e32ab987feb4db4e0b4ba81 Mon Sep 17 00:00:00 2001 From: Ryan Reed Date: Fri, 28 Mar 2025 15:07:22 -0400 Subject: [PATCH] Renaming date_created to save_date and adding to save file instead of using file modified date --- addons/save_load_system/autoloads/save_game_manager.gd | 5 +++-- .../save_load_system/resources/save_file_details_resource.gd | 2 +- addons/save_load_system/resources/save_game_data_resource.gd | 1 + scenes/ui/menus/saves_manager/save_file.gd | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/save_load_system/autoloads/save_game_manager.gd b/addons/save_load_system/autoloads/save_game_manager.gd index 51374e8..61e4c86 100644 --- a/addons/save_load_system/autoloads/save_game_manager.gd +++ b/addons/save_load_system/autoloads/save_game_manager.gd @@ -85,9 +85,9 @@ func list_saves(include_quick_saves: bool = true, include_autosaves: bool = true # Should work out a better method for getting the save name (filename != save name) var _save_file: SaveGameDataResource = ResourceLoader.load(_save_path) _save_resource.save_name = _save_file.save_name + _save_resource.save_date = _save_file.save_date _save_resource.filename = filename - _save_resource.date_created = Time.get_datetime_string_from_unix_time(FileAccess.get_modified_time(_save_path)) ## In 4.5, this can probably be replaced with FileAccess.get_size(_save_path) ## This should reduce the need for opening the file here @@ -118,7 +118,7 @@ func _create_autosave() -> void: ## Sort the save files list by date created, descending func _custom_save_file_sort(a: SaveFileDetailsResource, b: SaveFileDetailsResource) -> bool: - return a.date_created > b.date_created + return a.save_date > b.save_date ## Save the properties defined on the SaveDataComponents attached to various nodes (such as Block) func _generate_save_game_resource() -> SaveGameDataResource: @@ -214,6 +214,7 @@ func _save_game_as_resource(save_name, resource_filename: String) -> void: var _save_resource: SaveGameDataResource = _generate_save_game_resource() _save_resource.save_name = save_name + _save_resource.save_date = Time.get_datetime_string_from_system(false, true) var result: int = ResourceSaver.save(_save_resource, save_game_file_path) if result != OK: diff --git a/addons/save_load_system/resources/save_file_details_resource.gd b/addons/save_load_system/resources/save_file_details_resource.gd index 882ebd9..bc0b61d 100644 --- a/addons/save_load_system/resources/save_file_details_resource.gd +++ b/addons/save_load_system/resources/save_file_details_resource.gd @@ -6,6 +6,6 @@ extends Node @export var save_name: String = "My Save" @export var filename: String = "" -@export var date_created: String = "" +@export var save_date: String = "" @export var filesize: int = 0 @export var save_icon_texture: Texture2D diff --git a/addons/save_load_system/resources/save_game_data_resource.gd b/addons/save_load_system/resources/save_game_data_resource.gd index 44210ff..3da5a77 100644 --- a/addons/save_load_system/resources/save_game_data_resource.gd +++ b/addons/save_load_system/resources/save_game_data_resource.gd @@ -8,3 +8,4 @@ extends Resource @export var save_data_nodes: Array[Node3DDataResource] @export var save_name: String +@export var save_date: String diff --git a/scenes/ui/menus/saves_manager/save_file.gd b/scenes/ui/menus/saves_manager/save_file.gd index 0f9728f..1a22a55 100644 --- a/scenes/ui/menus/saves_manager/save_file.gd +++ b/scenes/ui/menus/saves_manager/save_file.gd @@ -36,7 +36,7 @@ func initialize(_resource: SaveFileDetailsResource) -> void: set_save_name() func set_save_date() -> void: - save_date_label.text = save_file_details.date_created + save_date_label.text = save_file_details.save_date func set_save_icon() -> void: save_icon.texture = save_file_details.save_icon_texture