|
|
@ -70,8 +70,7 @@ func list_saves(include_quick_saves: bool = true, include_auto_saves: bool = tru |
|
|
|
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): |
|
|
|
_save_resource.save_icon = save_game_data_path + _save_icon |
|
|
|
_save_resource.save_icon_texture = _generate_save_icon_texture(save_game_data_path + _save_icon) |
|
|
|
|
|
|
|
save_files.append(_save_resource) |
|
|
|
|
|
|
@ -94,11 +93,26 @@ func quick_load_game() -> void: |
|
|
|
game_loaded.emit() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 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 |
|
|
|
|
|
|
|
## Generate the texture for use in the save file listing |
|
|
|
func _generate_save_icon_texture(save_icon: String) -> Texture2D: |
|
|
|
var _icon_texture: Texture2D = ImageTexture.new() |
|
|
|
if save_icon != null and !FileAccess.file_exists(save_icon): |
|
|
|
_icon_texture = _save_level_data_component.default_save_icon_resource |
|
|
|
elif save_icon == null: |
|
|
|
_icon_texture = _save_level_data_component.default_save_icon_resource |
|
|
|
else: |
|
|
|
var _icon_image: Image = Image.new() |
|
|
|
_icon_image.load(save_icon) |
|
|
|
|
|
|
|
@warning_ignore("unsafe_method_access") |
|
|
|
_icon_texture.set_image(_icon_image) |
|
|
|
|
|
|
|
return _icon_texture |
|
|
|
|
|
|
|
## Generates an icon by taking a screenshot[br] |
|
|
|
## The icon utilizes the same filename as the save file, replacing `.tres` with `.png` |
|
|
|
func _generate_save_icon(save_game_file_path: String) -> void: |
|
|
|