From 6498e4ad3572ce076f5173719279753caad6c14e Mon Sep 17 00:00:00 2001 From: Ryan Reed Date: Wed, 26 Mar 2025 09:56:01 -0400 Subject: [PATCH] Adding save name and removing icon from save file resource --- save_load/components/save_level_data_component.gd | 11 ++++++++++- save_load/resources/save_file_details_resource.gd | 1 + save_load/resources/save_game_data_resource.gd | 4 +--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/save_load/components/save_level_data_component.gd b/save_load/components/save_level_data_component.gd index b07feca..48075f7 100644 --- a/save_load/components/save_level_data_component.gd +++ b/save_load/components/save_level_data_component.gd @@ -39,10 +39,19 @@ func list_saves() -> Array[SaveFileDetailsResource]: # TODO: Update hints var _save_path: String = save_game_data_path + filename var _save_icon: String = filename.replace(".tres", ".png") var _save_resource: SaveFileDetailsResource = SaveFileDetailsResource.new() - var _loaded_file: FileAccess = FileAccess.open(_save_path, FileAccess.READ) + + # TODO: Reconsider loading the save to get the name + # This could be a large save making opening each one slow + # 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.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 + var _loaded_file: FileAccess = FileAccess.open(_save_path, FileAccess.READ) _save_resource.filesize = _loaded_file.get_length() if FileAccess.file_exists(save_game_data_path + _save_icon): diff --git a/save_load/resources/save_file_details_resource.gd b/save_load/resources/save_file_details_resource.gd index e56bc20..dd90d45 100644 --- a/save_load/resources/save_file_details_resource.gd +++ b/save_load/resources/save_file_details_resource.gd @@ -4,6 +4,7 @@ class_name SaveFileDetailsResource extends Node +@export var save_name: String = "My Save" @export var filename: String = "" @export var date_created: String = "" @export var filesize: int = 0 diff --git a/save_load/resources/save_game_data_resource.gd b/save_load/resources/save_game_data_resource.gd index 6836bd1..44210ff 100644 --- a/save_load/resources/save_game_data_resource.gd +++ b/save_load/resources/save_game_data_resource.gd @@ -7,6 +7,4 @@ extends Resource @export var game_version: String = ProjectSettings.get_setting("application/config/version") @export var save_data_nodes: Array[Node3DDataResource] -## Path to the screenshot/icon[br] -## This should generally be in the following format: e.g. user://game_data/save_my_save_name_screenshot.png -@export var save_icon: String +@export var save_name: String