mirror of
https://github.com/CrispyPin/ovr-utils.git
synced 2024-11-09 18:40:24 +01:00
add timer to sync overlay properties at most every 0.2s
This commit is contained in:
parent
2ff72e5023
commit
078cd11e5e
3 changed files with 27 additions and 9 deletions
|
@ -4,3 +4,9 @@
|
|||
|
||||
[node name="OverlaySettingsSync" type="Node"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="SyncTimer" type="Timer" parent="."]
|
||||
wait_time = 0.2
|
||||
autostart = true
|
||||
|
||||
[connection signal="timeout" from="SyncTimer" to="." method="_on_SyncTimer_timeout"]
|
||||
|
|
|
@ -14,7 +14,7 @@ export (String, "head", "left", "right", "world") var target = "left" setget se
|
|||
export var overlay_scene: PackedScene = \
|
||||
preload("res://addons/openvr_overlay/MissingOverlay.tscn") setget set_overlay_scene
|
||||
export var width_meters := 0.4 setget set_width_in_meters
|
||||
export var alpha := 1.0 setget set_alpha
|
||||
export var alpha := 1.0 setget set_alpha
|
||||
export var add_grabbing := true # add grabbing module
|
||||
export var add_cursor := false # add cursor module
|
||||
|
||||
|
|
|
@ -3,20 +3,25 @@ extends Node
|
|||
|
||||
onready var p = get_parent()
|
||||
var loaded := false
|
||||
var _needs_sync := true
|
||||
|
||||
func _ready() -> void:
|
||||
p = get_parent()
|
||||
call_deferred("load_all")
|
||||
p.connect("type_changed", self, "save_all")
|
||||
p.connect("overlay_visible_changed", self, "save_all")
|
||||
p.connect("width_changed", self, "save_all")
|
||||
p.connect("alpha_changed", self, "save_all")
|
||||
p.connect("target_changed", self, "save_all")
|
||||
p.connect("fallback_changed", self, "save_all")
|
||||
p.connect("offset_changed", self, "save_all")
|
||||
p.connect("type_changed", self, "_prop_changed")
|
||||
p.connect("overlay_visible_changed", self, "_prop_changed")
|
||||
p.connect("width_changed", self, "_prop_changed")
|
||||
p.connect("alpha_changed", self, "_prop_changed")
|
||||
p.connect("target_changed", self, "_prop_changed")
|
||||
p.connect("fallback_changed", self, "_prop_changed")
|
||||
p.connect("offset_changed", self, "_prop_changed")
|
||||
|
||||
|
||||
func save_all(_args=null) -> void:
|
||||
func _prop_changed(_val=null):
|
||||
_needs_sync = true
|
||||
|
||||
|
||||
func save_all() -> void:
|
||||
if not loaded:
|
||||
return
|
||||
if not Settings.s.overlays.has(p.name):
|
||||
|
@ -28,6 +33,7 @@ func save_all(_args=null) -> void:
|
|||
_save_prop("target", p.target)
|
||||
_save_prop("fallback", p.fallback)
|
||||
_save_prop("offsets", p._offsets.duplicate(true))
|
||||
_needs_sync = false
|
||||
|
||||
|
||||
func _save_prop(prop_name: String, prop_value) -> void:
|
||||
|
@ -58,3 +64,9 @@ func load_all() -> void:
|
|||
print("FAILED")
|
||||
save_all()
|
||||
loaded = true
|
||||
|
||||
|
||||
func _on_SyncTimer_timeout() -> void:
|
||||
if _needs_sync:
|
||||
save_all()
|
||||
|
||||
|
|
Loading…
Reference in a new issue