mirror of
https://github.com/CrispyPin/ovr-utils.git
synced 2024-11-25 00:30:25 +01:00
overlays can no longer change path (this was a pretty useless feature)
This commit is contained in:
parent
08cb7dc283
commit
2bac6afcdc
6 changed files with 40 additions and 53 deletions
|
@ -42,7 +42,6 @@ onready var tracker_nodes = {
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
#add_child(_overlay_area)
|
||||
_overlay_area = $OverlayArea
|
||||
_overlay_area.get_node("AreaNear"). connect("area_entered", self, "_on_Near_entered")
|
||||
_overlay_area.get_node("AreaNear"). connect("area_exited", self, "_on_Near_exited")
|
||||
|
@ -52,14 +51,12 @@ func _ready() -> void:
|
|||
get_parent().connect("width_changed", self, "_update_width")
|
||||
get_parent().connect("offset_changed", self, "_update_offset")
|
||||
get_parent().connect("target_changed", self, "_update_target")
|
||||
get_parent().connect("path_changed", self, "_update_modules")
|
||||
get_parent().connect("path_changed", self, "_update_target")
|
||||
|
||||
OverlayManager.connect("grab_mode_changed", self, "update_selection")
|
||||
|
||||
_update_width()
|
||||
_update_offset()
|
||||
_update_target()
|
||||
call_deferred("_update_width")
|
||||
call_deferred("_update_offset")
|
||||
call_deferred("_update_target")
|
||||
|
||||
|
||||
func _trigger_on(controller):
|
||||
|
@ -151,27 +148,17 @@ func _update_target():
|
|||
_overlay_area.get_node("AreaNear").collision_mask += int(t!="left")*16 # detect left hand
|
||||
|
||||
|
||||
func _update_modules():
|
||||
# this should be handled better, DRY
|
||||
# called by overlay_instance after properties are loaded and before overlay scene enters the tree
|
||||
func spawn_modules():
|
||||
# grab module
|
||||
var grab_module_exists: bool = get_node_or_null("OverlayGrab") != null
|
||||
|
||||
if get_parent().get_property("has_grab"):
|
||||
if !grab_module_exists:
|
||||
var module = preload("res://addons/openvr_overlay/OverlayGrab.tscn")
|
||||
add_child(module.instance())
|
||||
elif grab_module_exists:
|
||||
get_node("OverlayGrab").queue_free()
|
||||
|
||||
# cursor module
|
||||
var cursor_module_exists: bool = get_node_or_null("OverlayCursor") != null
|
||||
|
||||
if get_parent().get_property("has_cursor"):
|
||||
if !cursor_module_exists:
|
||||
var module = preload("res://addons/openvr_overlay/OverlayCursor.tscn")
|
||||
add_child(module.instance())
|
||||
elif cursor_module_exists:
|
||||
get_node("OverlayCursor").queue_free()
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
extends Spatial
|
||||
|
||||
signal path_changed
|
||||
#signal path_changed
|
||||
signal overlay_visible_changed
|
||||
signal width_changed
|
||||
signal alpha_changed
|
||||
|
@ -28,7 +28,7 @@ var current_target: String = "world" setget _set_current_target
|
|||
var fallback = ["left", "right", "head"] # TODO setget that updates tracking (not important)
|
||||
var interaction_handler: Node
|
||||
var overlay_visible := true setget set_overlay_visible
|
||||
var path := "res://special_overlays/MainOverlay.tscn" setget set_path
|
||||
var path : String = "res://special_overlays/MainOverlay.tscn"# setget set_path
|
||||
var path_invalid := false
|
||||
var OVERLAY_PROPERTIES: Dictionary # defined in overlay root script (optional)
|
||||
|
||||
|
@ -37,6 +37,8 @@ var overlay_scene: Node
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
container = $OverlayViewport/Container
|
||||
load_overlay()
|
||||
current_target = target
|
||||
|
||||
ARVRServer.connect("tracker_added", self, "_tracker_changed")
|
||||
|
@ -48,6 +50,24 @@ func _ready() -> void:
|
|||
update_tracker_id()
|
||||
call_deferred("update_offset")
|
||||
|
||||
func load_overlay() -> void:
|
||||
path_invalid = false
|
||||
|
||||
var packed_overlay = load(path)
|
||||
if not packed_overlay:
|
||||
path_invalid = true
|
||||
overlay_scene = load("res://special_overlays/UnknownType.tscn").instance()
|
||||
else:
|
||||
overlay_scene = packed_overlay.instance()
|
||||
|
||||
if overlay_scene.get("OVERLAY_PROPERTIES") != null:
|
||||
OVERLAY_PROPERTIES = overlay_scene.OVERLAY_PROPERTIES
|
||||
|
||||
$OverlayInteraction.spawn_modules()
|
||||
|
||||
if container.get_child_count() > 0:
|
||||
container.get_child(0).queue_free()
|
||||
container.add_child(overlay_scene)
|
||||
|
||||
func update_tracker_id():
|
||||
_tracker_id = -1
|
||||
|
@ -129,26 +149,6 @@ func set_width_in_meters(width: float) -> void:
|
|||
emit_signal("width_changed")
|
||||
|
||||
|
||||
func set_path(new: String) -> void:
|
||||
path = new
|
||||
path_invalid = false
|
||||
|
||||
var packed_overlay = load(path)
|
||||
if not packed_overlay:
|
||||
path_invalid = true
|
||||
overlay_scene = load("res://special_overlays/UnknownType.tscn").instance()
|
||||
else:
|
||||
overlay_scene = packed_overlay.instance()
|
||||
if overlay_scene.get("OVERLAY_PROPERTIES") != null:
|
||||
OVERLAY_PROPERTIES = overlay_scene.OVERLAY_PROPERTIES
|
||||
|
||||
emit_signal("path_changed")
|
||||
|
||||
if container.get_child_count() > 0:
|
||||
container.get_child(0).queue_free()
|
||||
container.add_child(overlay_scene)
|
||||
|
||||
|
||||
func set_alpha(val: float):
|
||||
alpha = val
|
||||
$VROverlayViewport/TextureRect.modulate.a = val
|
||||
|
@ -168,8 +168,8 @@ func _notification(what: int) -> void:
|
|||
emit_signal("offset_changed")
|
||||
|
||||
|
||||
func get_property(name: String):
|
||||
if OVERLAY_PROPERTIES.has(name):
|
||||
return OVERLAY_PROPERTIES[name]
|
||||
func get_property(p_name: String):
|
||||
if OVERLAY_PROPERTIES.has(p_name):
|
||||
return OVERLAY_PROPERTIES[p_name]
|
||||
|
||||
return OverlayInit.OVERLAY_PROPERTIES_DEFAULT[name]
|
||||
return OverlayInit.OVERLAY_PROPERTIES_DEFAULT[p_name]
|
||||
|
|
|
@ -29,6 +29,7 @@ func add_overlay(name):
|
|||
print("Adding overlay '", name, "'")
|
||||
var instance = preload("res://addons/openvr_overlay/OverlayInstance.tscn").instance()
|
||||
instance.name = name
|
||||
instance.path = Settings.s.overlays[name].path
|
||||
instance.add_child(preload("res://OverlaySettingsSync.tscn").instance())
|
||||
add_child(instance)
|
||||
emit_signal("added_overlay", name)
|
||||
|
|
|
@ -10,7 +10,6 @@ var _needs_sync := true
|
|||
func _ready() -> void:
|
||||
p = get_parent()
|
||||
call_deferred("load_all")
|
||||
p.connect("path_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")
|
||||
|
@ -46,8 +45,8 @@ func load_all() -> void:
|
|||
if Settings.s.overlays.has(p.name):
|
||||
var new = Settings.s.overlays[p.name]
|
||||
|
||||
if new.has("path"):
|
||||
p.path = new.path
|
||||
#if new.has("path"):
|
||||
# p.path = new.path
|
||||
if new.has("visible"):
|
||||
p.overlay_visible = new.visible
|
||||
if new.has("width"):
|
||||
|
|
|
@ -25,6 +25,7 @@ OverlayManager="*res://OverlayManager.tscn"
|
|||
|
||||
[debug]
|
||||
|
||||
gdscript/warnings/unused_signal=false
|
||||
gdscript/warnings/return_value_discarded=false
|
||||
|
||||
[display]
|
||||
|
|
|
@ -14,7 +14,6 @@ func _ready() -> void:
|
|||
$BasicOptions/Label.text = overlay_name
|
||||
name = overlay_name
|
||||
overlay.connect("overlay_visible_changed", self, "_overlay_visible_changed")
|
||||
overlay.connect("path_changed", self, "_update_warning")
|
||||
|
||||
|
||||
func _apply_loaded():
|
||||
|
|
Loading…
Reference in a new issue