mirror of
https://github.com/CrispyPin/ovr-utils.git
synced 2024-11-10 02:40:25 +01:00
remove overlay button now works
This commit is contained in:
parent
39f34344cd
commit
33da1d0ff7
5 changed files with 26 additions and 8 deletions
|
@ -15,7 +15,7 @@ export var add_grabbing := true # add grabbing module
|
||||||
export var add_cursor := false # add cursor module
|
export var add_cursor := false # add cursor module
|
||||||
|
|
||||||
# if this is exported, all overlays sync offset when a controller is turned off/on
|
# if this is exported, all overlays sync offset when a controller is turned off/on
|
||||||
# this seems to be a bug with the godot editor-
|
# this seems to be a bug with the godot editor
|
||||||
var _offsets:Dictionary = {
|
var _offsets:Dictionary = {
|
||||||
"head": {"pos": Vector3(0,0,-0.4), "rot": Quat()},
|
"head": {"pos": Vector3(0,0,-0.4), "rot": Quat()},
|
||||||
"left": {"pos": Vector3(), "rot": Quat()},
|
"left": {"pos": Vector3(), "rot": Quat()},
|
||||||
|
@ -24,7 +24,7 @@ var _offsets:Dictionary = {
|
||||||
}
|
}
|
||||||
|
|
||||||
# what's actually tracking
|
# what's actually tracking
|
||||||
var current_target: String = "world" setget _set_current_target# most of the time the actual target, but will fall back
|
var current_target: String = "world" setget _set_current_target
|
||||||
var fallback = ["left", "right", "head"] # TODO setget that updates tracking (not important)
|
var fallback = ["left", "right", "head"] # TODO setget that updates tracking (not important)
|
||||||
var interaction_handler: Node
|
var interaction_handler: Node
|
||||||
var overlay_visible := true setget set_overlay_visible
|
var overlay_visible := true setget set_overlay_visible
|
||||||
|
|
|
@ -25,12 +25,9 @@ func _load_overlays():
|
||||||
|
|
||||||
|
|
||||||
func add_overlay(type, name):
|
func add_overlay(type, name):
|
||||||
if type == "":
|
|
||||||
print("no type specified for overlay ", name)
|
|
||||||
return
|
|
||||||
var scene = load("res://overlays/" + type + ".tscn")
|
var scene = load("res://overlays/" + type + ".tscn")
|
||||||
if scene == null:
|
if not scene:
|
||||||
print("Unknown overlay type: ", type, ". Skipping overlay \"", name, "\"")
|
print("Unknown overlay type: '", type, "'. Skipping overlay '", name, "'")
|
||||||
return
|
return
|
||||||
var instance = preload("res://addons/openvr_overlay/OverlayInstance.tscn").instance()
|
var instance = preload("res://addons/openvr_overlay/OverlayInstance.tscn").instance()
|
||||||
instance.name = name
|
instance.name = name
|
||||||
|
@ -38,3 +35,14 @@ func add_overlay(type, name):
|
||||||
instance.type = type
|
instance.type = type
|
||||||
add_child(instance)
|
add_child(instance)
|
||||||
emit_signal("added_overlay", name)
|
emit_signal("added_overlay", name)
|
||||||
|
|
||||||
|
|
||||||
|
func remove_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)
|
||||||
|
Settings.save_settings()
|
||||||
|
|
|
@ -3,6 +3,7 @@ extends Control
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
get_node("/root/Main/OverlayManager").connect("added_overlay", self, "_add_overlay_to_list")
|
get_node("/root/Main/OverlayManager").connect("added_overlay", self, "_add_overlay_to_list")
|
||||||
|
get_node("/root/Main/OverlayManager").connect("removed_overlay", self, "_remove_overlay_from_list")
|
||||||
for o in Settings.s.overlays:
|
for o in Settings.s.overlays:
|
||||||
if o != "MainOverlay":
|
if o != "MainOverlay":
|
||||||
_add_overlay_to_list(o)
|
_add_overlay_to_list(o)
|
||||||
|
@ -14,6 +15,9 @@ func _add_overlay_to_list(name):
|
||||||
new.overlay_name = name
|
new.overlay_name = name
|
||||||
$VSplitContainer/Control/Overlays.add_child(new)
|
$VSplitContainer/Control/Overlays.add_child(new)
|
||||||
|
|
||||||
|
func _remove_overlay_from_list(name):
|
||||||
|
$VSplitContainer/Control/Overlays.get_node(name).queue_free()
|
||||||
|
|
||||||
|
|
||||||
func _on_GrabMode_toggled(state: bool) -> void:
|
func _on_GrabMode_toggled(state: bool) -> void:
|
||||||
Settings.s.grab_mode = state
|
Settings.s.grab_mode = state
|
||||||
|
|
|
@ -40,7 +40,6 @@ margin_left = 952.0
|
||||||
margin_right = 1128.0
|
margin_right = 1128.0
|
||||||
margin_bottom = 191.0
|
margin_bottom = 191.0
|
||||||
focus_mode = 0
|
focus_mode = 0
|
||||||
toggle_mode = true
|
|
||||||
icon = ExtResource( 2 )
|
icon = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="Reset" type="Button" parent="HBoxContainer"]
|
[node name="Reset" type="Button" parent="HBoxContainer"]
|
||||||
|
@ -86,6 +85,7 @@ toggle_mode = true
|
||||||
pressed = true
|
pressed = true
|
||||||
icon = ExtResource( 8 )
|
icon = ExtResource( 8 )
|
||||||
|
|
||||||
|
[connection signal="pressed" from="HBoxContainer/Remove" to="." method="_on_Remove_pressed"]
|
||||||
[connection signal="pressed" from="HBoxContainer/Reset" to="." method="_on_Reset_pressed"]
|
[connection signal="pressed" from="HBoxContainer/Reset" to="." method="_on_Reset_pressed"]
|
||||||
[connection signal="item_selected" from="HBoxContainer/Target" to="." method="_on_Target_item_selected"]
|
[connection signal="item_selected" from="HBoxContainer/Target" to="." method="_on_Target_item_selected"]
|
||||||
[connection signal="toggled" from="HBoxContainer/Grab" to="." method="_on_Grab_toggled"]
|
[connection signal="toggled" from="HBoxContainer/Grab" to="." method="_on_Grab_toggled"]
|
||||||
|
|
|
@ -6,6 +6,7 @@ var overlay
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
overlay = get_node("/root/Main/OverlayManager").get_node(overlay_name)
|
overlay = get_node("/root/Main/OverlayManager").get_node(overlay_name)
|
||||||
$Label.text = overlay_name
|
$Label.text = overlay_name
|
||||||
|
name = overlay_name
|
||||||
$HBoxContainer/Target.selected = overlay.TARGETS.find(Settings.s.overlays[overlay_name].target)
|
$HBoxContainer/Target.selected = overlay.TARGETS.find(Settings.s.overlays[overlay_name].target)
|
||||||
overlay.connect("overlay_visibility_changed", self, "_overlay_visibility_changed")
|
overlay.connect("overlay_visibility_changed", self, "_overlay_visibility_changed")
|
||||||
|
|
||||||
|
@ -32,3 +33,8 @@ func _overlay_visibility_changed(state: bool):
|
||||||
$HBoxContainer/Visibility.icon = preload("res://icons/visible.svg")
|
$HBoxContainer/Visibility.icon = preload("res://icons/visible.svg")
|
||||||
else:
|
else:
|
||||||
$HBoxContainer/Visibility.icon = preload("res://icons/hidden.svg")
|
$HBoxContainer/Visibility.icon = preload("res://icons/hidden.svg")
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Remove_pressed() -> void:
|
||||||
|
get_node("/root/Main/OverlayManager").remove_overlay(overlay_name)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue