diff --git a/save_load/autoloads/save_game_manager.gd b/save_load/autoloads/save_game_manager.gd index 7ea9c41..e97bf1a 100644 --- a/save_load/autoloads/save_game_manager.gd +++ b/save_load/autoloads/save_game_manager.gd @@ -116,15 +116,6 @@ func _generate_save_icon_texture(save_icon: String) -> Texture2D: 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: - # TODO: Hide the UI before taking the screenshot - var _icon_filepath: String = save_game_file_path.replace(".tres", ".png") - - var _icon: Image = get_viewport().get_texture().get_image() - _icon.save_png(_icon_filepath) - ## Find the SaveLevelDataComponent within the level which stores the save paths and filenames func _load_save_level_data_component() -> bool: _save_level_data_component = get_tree().get_first_node_in_group("save_level_data_component") @@ -169,7 +160,7 @@ func _save_game_as_resource(resource_filename: String) -> void: if result != OK: printerr("Failed to save game (" , result, "): ", save_game_file_path) - _generate_save_icon(save_game_file_path) + _take_save_screenshot(save_game_file_path) ## Save the properties defined on the SaveDataComponents attached to various nodes (such as Block) func _save_node_data() -> void: @@ -184,6 +175,15 @@ func _save_node_data() -> void: var save_final_resource: Node3DDataResource = save_data_resource.duplicate() _game_data_resource.save_data_nodes.append(save_final_resource) +## Takes a screenshot and saves next to the save file[br] +## The icon utilizes the same filename as the save file, replacing `.tres` with `.png` +func _take_save_screenshot(save_game_file_path: String) -> void: + # TODO: Hide the UI before taking the screenshot + var _icon_filepath: String = save_game_file_path.replace(".tres", ".png") + + var _icon: Image = get_viewport().get_texture().get_image() + _icon.save_png(_icon_filepath) + func _on_save_game_as_resource(save_name: String) -> void: if not _load_save_level_data_component(): return