Skip to content

Commit

Permalink
fix: enhance cache map size estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
ThmsKnz authored and dploeger committed Mar 22, 2024
1 parent 604aab6 commit 6c1fba9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
42 changes: 32 additions & 10 deletions addons/egoventure/cache/cache_update_dialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 6 additions & 6 deletions cache_map.tres
Original file line number Diff line number Diff line change
Expand Up @@ -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" ] ],
Expand Down Expand Up @@ -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, [ ] ],
Expand All @@ -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" ] ],
Expand All @@ -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" ] ],
Expand All @@ -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, [ ] ]
}

0 comments on commit 6c1fba9

Please sign in to comment.