From 6c1fba9f9e3cecac62a6df34597f754610423b25 Mon Sep 17 00:00:00 2001 From: ThmsKnz <67240202+ThmsKnz@users.noreply.github.com> Date: Sun, 10 Mar 2024 14:28:19 +0100 Subject: [PATCH] fix: enhance cache map size estimation --- .../egoventure/cache/cache_update_dialog.gd | 42 ++++++++++++++----- cache_map.tres | 12 +++--- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/addons/egoventure/cache/cache_update_dialog.gd b/addons/egoventure/cache/cache_update_dialog.gd index f6b09b54..9b48aa0f 100644 --- a/addons/egoventure/cache/cache_update_dialog.gd +++ b/addons/egoventure/cache/cache_update_dialog.gd @@ -179,23 +179,45 @@ func _scan_scene(scene_node: Node) -> Array: var regex_scene = RegEx.new() regex_scene.compile("res:\\/\\/[\\w\\/]*.tscn") - # get all sprites and target scenes listed in nodes + # get all textures and target scenes listed in nodes for node in _get_all_children(scene_node): if node.get_class() == "Sprite" and node.texture != null: if ResourceLoader.exists(node.texture.resource_path): size_estimate += node.texture.get_data().get_data().size() - if ( node.get_class() == "TextureButton" - and "target_scene" in node # include Hotspot (and derived classes) - and not "loading_image" in node # but exclude MapHotspot - ): - var scene_path = node.target_scene - if ( - scene_path != "" - and ResourceLoader.exists(scene_path) + elif node.get_class() == "TextureButton": + if node.texture_normal != null \ + and ResourceLoader.exists(node.texture_normal.resource_path): + size_estimate += node.texture_normal.get_data().get_data().size() + if node.texture_pressed != null \ + and ResourceLoader.exists(node.texture_pressed.resource_path): + size_estimate += node.texture_pressed.get_data().get_data().size() + if node.texture_disabled != null \ + and ResourceLoader.exists(node.texture_disabled.resource_path): + size_estimate += node.texture_disabled.get_data().get_data().size() + if node.texture_hover != null \ + and ResourceLoader.exists(node.texture_hover.resource_path): + size_estimate += node.texture_hover.get_data().get_data().size() + if node.texture_focused != null \ + and ResourceLoader.exists(node.texture_focused.resource_path): + size_estimate += node.texture_focused.get_data().get_data().size() + + if "loading_image" in node and node.loading_image != null \ + and ResourceLoader.exists(node.loading_image.resource_path): + size_estimate += node.loading_image.get_data().get_data().size() + + if( + "target_scene" in node # include Hotspot (and derived classes) + and not "loading_image" in node # but exclude MapHotspot ): - linked_scenes.append(scene_path) + var scene_path = node.target_scene + if ( + scene_path != "" + and not scene_path in linked_scenes + and ResourceLoader.exists(scene_path) + ): + linked_scenes.append(scene_path) # remove comments from source code var scene_script = scene_node.get_script() diff --git a/cache_map.tres b/cache_map.tres index 26c8476f..5309b3c7 100644 --- a/cache_map.tres +++ b/cache_map.tres @@ -6,11 +6,11 @@ script = ExtResource( 1 ) map = { "res://scenes/brother/bro1.tscn": [ 10800, [ "res://scenes/misc/map.tscn" ] ], -"res://scenes/intro.tscn": [ 0, [ "res://scenes/misc/map_info.tscn" ] ], +"res://scenes/intro.tscn": [ 21600, [ "res://scenes/misc/map_info.tscn" ] ], "res://scenes/logo.tscn": [ 10800, [ "res://scenes/menu.tscn" ] ], "res://scenes/man/man01.tscn": [ 54000, [ "res://scenes/man/man02.tscn", "res://scenes/misc/map.tscn" ] ], "res://scenes/man/man02.tscn": [ 43200, [ "res://scenes/man/man01.tscn", "res://scenes/man/man03.tscn" ] ], -"res://scenes/man/man03.tscn": [ 43200, [ "res://scenes/man/man03b_cl.tscn", "res://scenes/man/man02.tscn", "res://scenes/man/man03b_inf.tscn", "res://scenes/man/man03b_inf.tscn", "res://scenes/man/man04.tscn", "res://scenes/man/man04a_inf.tscn" ] ], +"res://scenes/man/man03.tscn": [ 43200, [ "res://scenes/man/man03b_cl.tscn", "res://scenes/man/man02.tscn", "res://scenes/man/man03b_inf.tscn", "res://scenes/man/man04.tscn", "res://scenes/man/man04a_inf.tscn" ] ], "res://scenes/man/man03b_cl.tscn": [ 10800, [ "res://scenes/man/man03.tscn" ] ], "res://scenes/man/man03b_inf.tscn": [ 10800, [ "res://scenes/man/man03b_cl.tscn", "res://scenes/man/man03.tscn" ] ], "res://scenes/man/man04.tscn": [ 43200, [ "res://scenes/man/man05.tscn", "res://scenes/man/man03.tscn", "res://scenes/man/man14.tscn" ] ], @@ -57,7 +57,7 @@ map = { "res://scenes/man/man12d_lift.tscn": [ 10800, [ "res://scenes/man/man12.tscn" ] ], "res://scenes/man/man12f_cl.tscn": [ 12458, [ "res://scenes/man/man12.tscn", "res://scenes/man/man12f_op.tscn" ] ], "res://scenes/man/man12f_lift0.tscn": [ 10800, [ "res://scenes/man/man12f_op.tscn", "res://scenes/man/man12f_lift1.tscn" ] ], -"res://scenes/man/man12f_lift1.tscn": [ 10800, [ "res://scenes/man/man12f_lift3.tscn", "res://scenes/man/man12f_lift2.tscn", "res://scenes/man/man12f_lift0.tscn" ] ], +"res://scenes/man/man12f_lift1.tscn": [ 10886, [ "res://scenes/man/man12f_lift3.tscn", "res://scenes/man/man12f_lift2.tscn", "res://scenes/man/man12f_lift0.tscn" ] ], "res://scenes/man/man12f_lift2.tscn": [ 10800, [ "res://scenes/man/man12f_lift1.tscn" ] ], "res://scenes/man/man12f_lift3.tscn": [ 10886, [ "res://scenes/man/man12f_lift1.tscn" ] ], "res://scenes/man/man12f_lift4.tscn": [ 0, [ ] ], @@ -66,7 +66,7 @@ map = { "res://scenes/man/man13b_cl.tscn": [ 10800, [ "res://scenes/man/man13.tscn", "res://scenes/man/man13b_op.tscn" ] ], "res://scenes/man/man13b_op.tscn": [ 10800, [ "res://scenes/man/man13b_cl.tscn" ] ], "res://scenes/man/man13d_lift1.tscn": [ 10927, [ "res://scenes/man/man13d_op.tscn", "res://scenes/man/man13d_lift2.tscn" ] ], -"res://scenes/man/man13d_lift2.tscn": [ 10800, [ "res://scenes/man/man13d_lift3.tscn" ] ], +"res://scenes/man/man13d_lift2.tscn": [ 10882, [ "res://scenes/man/man13d_lift3.tscn" ] ], "res://scenes/man/man13d_lift3.tscn": [ 10800, [ "res://scenes/man/man13d_lift4.tscn" ] ], "res://scenes/man/man13d_lift4.tscn": [ 10800, [ "res://scenes/misc/license.tscn" ] ], "res://scenes/man/man13d_op.tscn": [ 10800, [ "res://scenes/man/man13.tscn", "res://scenes/man/man13d_lift1.tscn" ] ], @@ -80,7 +80,7 @@ map = { "res://scenes/man/man20.tscn": [ 43200, [ "res://scenes/man/man21.tscn", "res://scenes/man/man19.tscn", "res://scenes/man/man22.tscn" ] ], "res://scenes/man/man21.tscn": [ 43200, [ "res://scenes/man/man20.tscn" ] ], "res://scenes/man/man22.tscn": [ 43200, [ "res://scenes/man/man20.tscn", "res://scenes/man/man22a_cl.tscn" ] ], -"res://scenes/man/man22a_cl.tscn": [ 10800, [ "res://scenes/man/man22a_lift.tscn", "res://scenes/man/man22.tscn", "res://scenes/man/man22a_xcl.tscn" ] ], +"res://scenes/man/man22a_cl.tscn": [ 11177, [ "res://scenes/man/man22a_lift.tscn", "res://scenes/man/man22.tscn", "res://scenes/man/man22a_xcl.tscn" ] ], "res://scenes/man/man22a_inf.tscn": [ 10800, [ "res://scenes/man/man22a_cl.tscn" ] ], "res://scenes/man/man22a_lift.tscn": [ 10800, [ "res://scenes/man/man22a_cl.tscn", "res://scenes/man/man22a_inf.tscn" ] ], "res://scenes/man/man22a_xcl.tscn": [ 10800, [ "res://scenes/man/man22a_cl.tscn" ] ], @@ -90,7 +90,7 @@ map = { "res://scenes/man/man24.tscn": [ 43200, [ "res://scenes/man/man23.tscn" ] ], "res://scenes/menu.tscn": [ 0, [ ] ], "res://scenes/misc/license.tscn": [ 10800, [ ] ], -"res://scenes/misc/map.tscn": [ 10800, [ ] ], +"res://scenes/misc/map.tscn": [ 32720, [ ] ], "res://scenes/misc/map_info.tscn": [ 10800, [ "res://scenes/misc/map.tscn" ] ], "res://scenes/misc/testscene.tscn": [ 0, [ ] ] }