|
@ -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) |
|
|
# Should work out a better method for getting the save name (filename != save name) |
|
|
var _save_file: SaveGameDataResource = ResourceLoader.load(_save_path) |
|
|
var _save_file: SaveGameDataResource = ResourceLoader.load(_save_path) |
|
|
_save_resource.save_name = _save_file.save_name |
|
|
_save_resource.save_name = _save_file.save_name |
|
|
|
|
|
_save_resource.save_date = _save_file.save_date |
|
|
|
|
|
|
|
|
_save_resource.filename = filename |
|
|
_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) |
|
|
## In 4.5, this can probably be replaced with FileAccess.get_size(_save_path) |
|
|
## This should reduce the need for opening the file here |
|
|
## 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 |
|
|
## Sort the save files list by date created, descending |
|
|
func _custom_save_file_sort(a: SaveFileDetailsResource, b: SaveFileDetailsResource) -> bool: |
|
|
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) |
|
|
## Save the properties defined on the SaveDataComponents attached to various nodes (such as Block) |
|
|
func _generate_save_game_resource() -> SaveGameDataResource: |
|
|
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() |
|
|
var _save_resource: SaveGameDataResource = _generate_save_game_resource() |
|
|
_save_resource.save_name = save_name |
|
|
_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) |
|
|
var result: int = ResourceSaver.save(_save_resource, save_game_file_path) |
|
|
if result != OK: |
|
|
if result != OK: |
|
|