From 2ff72e5023fa9ba5115cf863852c112d2c77d87c Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Sat, 26 Jun 2021 23:32:22 +0200 Subject: [PATCH] fix overlays not being deleted because of spammed signal --- .../addons/openvr_overlay/overlay_instance.gd | 4 +-- ovr-utils/overlay_manager.gd | 4 ++- ovr-utils/overlay_settings_sync.gd | 28 +++++++++---------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/ovr-utils/addons/openvr_overlay/overlay_instance.gd b/ovr-utils/addons/openvr_overlay/overlay_instance.gd index 0136010..b3a75ec 100644 --- a/ovr-utils/addons/openvr_overlay/overlay_instance.gd +++ b/ovr-utils/addons/openvr_overlay/overlay_instance.gd @@ -57,7 +57,8 @@ func _ready() -> void: container.add_child(overlay_scene.instance()) update_tracker_id() - update_offset() + call_deferred("update_offset") + func add_cursor(): @@ -173,5 +174,4 @@ func reset_offset() -> void: func _notification(what: int) -> void: if what == NOTIFICATION_TRANSFORM_CHANGED: - update_offset() emit_signal("offset_changed") diff --git a/ovr-utils/overlay_manager.gd b/ovr-utils/overlay_manager.gd index b5a0b1e..5fa92e9 100644 --- a/ovr-utils/overlay_manager.gd +++ b/ovr-utils/overlay_manager.gd @@ -44,10 +44,12 @@ func add_overlay(type, name): func remove_overlay(name): + print("Removing overlay '", name, "'") var to_remove = get_node(name) if not to_remove: print("Could not remove overlay '", name, "'") return to_remove.queue_free() - emit_signal("removed_overlay", name) Settings.s.overlays.erase(name) + emit_signal("removed_overlay", name) + diff --git a/ovr-utils/overlay_settings_sync.gd b/ovr-utils/overlay_settings_sync.gd index 277dd89..6d3bea1 100644 --- a/ovr-utils/overlay_settings_sync.gd +++ b/ovr-utils/overlay_settings_sync.gd @@ -35,23 +35,23 @@ func _save_prop(prop_name: String, prop_value) -> void: func load_all() -> void: if Settings.s.overlays.has(p.name): - var loaded = Settings.s.overlays[p.name] + var new = Settings.s.overlays[p.name] # type is assigned at creation - if loaded.has("visible"): - p.overlay_visible = loaded.visible - if loaded.has("width"): - p.width_meters = loaded.width - if loaded.has("alpha"): - p.alpha = loaded.alpha - if loaded.has("target"): - p.target = loaded.target - if loaded.has("fallback"): - p.fallback = loaded.fallback + if new.has("visible"): + p.overlay_visible = new.visible + if new.has("width"): + p.width_meters = new.width + if new.has("alpha"): + p.alpha = new.alpha + if new.has("target"): + p.target = new.target + if new.has("fallback"): + p.fallback = new.fallback - if loaded.has("offsets"):# thorough in case some values are missing in file - for t_key in loaded.offsets: - var offset = loaded.offsets[t_key] + if new.has("offsets"):# thorough in case some values are missing in file + for t_key in new.offsets: + var offset = new.offsets[t_key] p.set_offset(t_key, offset.pos, offset.rot) else: