This commit is contained in:
Crispy 2021-06-29 01:37:37 +02:00
parent 01c11ffd32
commit 727e559396
5 changed files with 16 additions and 11 deletions

View file

@ -1,6 +1,6 @@
extends Spatial
signal type_changed
signal path_changed
signal overlay_visible_changed
signal width_changed
signal alpha_changed
@ -11,8 +11,7 @@ signal offset_changed
const TARGETS = ["head", "left", "right", "world"]
export (String, "head", "left", "right", "world") var target = "left" setget set_target
export var overlay_scene: PackedScene# = \
# preload("res://addons/openvr_overlay/MissingOverlay.tscn") setget set_overlay_scene
export var overlay_scene: PackedScene
export var width_meters := 0.4 setget set_width_in_meters
export var alpha := 1.0 setget set_alpha
export var add_grabbing := true # add grabbing module
@ -31,8 +30,8 @@ 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 type := "main"
var path := "res://special_overlays/MainOverlay.tscn" setget set_path
var path_invalid := false
onready var container = $OverlayViewport/Container
@ -151,12 +150,17 @@ func set_width_in_meters(width: float) -> void:
func set_path(new: String) -> void:
path = new
path_invalid = false
overlay_scene = load(path)
if not container:
return
if not overlay_scene:
path_invalid = true
overlay_scene = load("res://special_overlays/UnknownType.tscn")
if container.get_child_count() > 0:
container.get_child(0).queue_free()
container.add_child(overlay_scene.instance())
emit_signal("path_changed")
func set_alpha(val: float):

View file

@ -13,7 +13,6 @@ func _on_Open_pressed() -> void:
func _on_FileDialog_file_selected(path: String) -> void:
# var img = load(path)
var tex = ImageTexture.new()
tex.load(path)
$Image.texture = tex

View file

@ -8,7 +8,7 @@ var _needs_sync := true
func _ready() -> void:
p = get_parent()
call_deferred("load_all")
p.connect("type_changed", self, "_prop_changed")
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")

View file

@ -28,7 +28,7 @@ func get_overlay_paths(root := "res://overlays/"):
var file_name = dir.get_next()
while file_name != "":
if dir.current_is_dir():
# TODO make recursive, must include folder as prefix for type
# TODO make recursive
pass
else:
found.append(root + file_name)

View file

@ -15,9 +15,11 @@ func _ready() -> void:
name = overlay_name
$MoreOptions/Container/List/Target.selected = overlay.TARGETS.find(overlay.target)
overlay.connect("overlay_visible_changed", self, "_overlay_visible_changed")
overlay.connect("path_changed", self, "_update_warning")
#TODO use signal to activate warning
# $BasicOptions/List/Warning.visible = overlay.overlay_scene == preload("res://special_overlays/UnknownType.tscn")
func _update_warning():
$BasicOptions/List/Warning.visible = overlay.path_invalid
$BasicOptions/List/Warning/WarningInfo/Label.text = overlay.path + "\nnot found"