mirror of
https://github.com/CrispyPin/ovr-utils.git
synced 2024-11-10 02:40:25 +01:00
overlay visibility is saved and loaded
This commit is contained in:
parent
e50f85d970
commit
6385d7c165
5 changed files with 37 additions and 10 deletions
|
@ -39,6 +39,7 @@ alignment = 2
|
|||
margin_left = 952.0
|
||||
margin_right = 1128.0
|
||||
margin_bottom = 191.0
|
||||
focus_mode = 0
|
||||
toggle_mode = true
|
||||
icon = ExtResource( 5 )
|
||||
|
||||
|
@ -46,12 +47,14 @@ icon = ExtResource( 5 )
|
|||
margin_left = 1132.0
|
||||
margin_right = 1308.0
|
||||
margin_bottom = 191.0
|
||||
focus_mode = 0
|
||||
icon = ExtResource( 6 )
|
||||
|
||||
[node name="Target" type="OptionButton" parent="HBoxContainer"]
|
||||
margin_left = 1312.0
|
||||
margin_right = 1492.0
|
||||
margin_bottom = 191.0
|
||||
focus_mode = 0
|
||||
text = "Left"
|
||||
icon = ExtResource( 8 )
|
||||
clip_text = true
|
||||
|
@ -62,6 +65,7 @@ selected = 1
|
|||
margin_left = 1496.0
|
||||
margin_right = 1672.0
|
||||
margin_bottom = 191.0
|
||||
focus_mode = 0
|
||||
toggle_mode = true
|
||||
icon = ExtResource( 7 )
|
||||
|
||||
|
@ -69,6 +73,7 @@ icon = ExtResource( 7 )
|
|||
margin_left = 1676.0
|
||||
margin_right = 1852.0
|
||||
margin_bottom = 191.0
|
||||
focus_mode = 0
|
||||
toggle_mode = true
|
||||
icon = ExtResource( 4 )
|
||||
|
||||
|
@ -76,6 +81,7 @@ icon = ExtResource( 4 )
|
|||
margin_left = 1856.0
|
||||
margin_right = 2032.0
|
||||
margin_bottom = 191.0
|
||||
focus_mode = 0
|
||||
toggle_mode = true
|
||||
pressed = true
|
||||
icon = ExtResource( 2 )
|
||||
|
|
|
@ -3,6 +3,7 @@ extends Spatial
|
|||
signal width_changed
|
||||
signal offset_changed
|
||||
signal target_changed
|
||||
signal overlay_visibility_changed
|
||||
|
||||
const TARGETS = ["head", "left", "right", "world"]
|
||||
export (String, "head", "left", "right", "world") var target = "left" setget set_target
|
||||
|
@ -66,17 +67,20 @@ func add_grab():
|
|||
|
||||
func load_settings():
|
||||
if Settings.s.overlays.has(name):
|
||||
if Settings.s.overlays[name].has("fallback"):
|
||||
fallback = Settings.s.overlays[name].fallback
|
||||
set_target(Settings.s.overlays[name].target)
|
||||
var loaded = Settings.s.overlays[name]
|
||||
if loaded.has("fallback"):
|
||||
fallback = loaded.fallback
|
||||
set_target(loaded.target)
|
||||
|
||||
set_width_in_meters(Settings.s.overlays[name].width)
|
||||
set_width_in_meters(loaded.width)
|
||||
|
||||
for t_key in Settings.s.overlays[name].offsets:
|
||||
var t_offset = Settings.s.overlays[name].offsets[t_key]
|
||||
for t_key in loaded.offsets:
|
||||
var t_offset = loaded.offsets[t_key]
|
||||
_offsets[t_key].pos = t_offset.pos
|
||||
_offsets[t_key].rot = t_offset.rot
|
||||
update_offset()
|
||||
if loaded.has("visible"):
|
||||
set_overlay_visible(loaded.visible)
|
||||
else:
|
||||
#TEMP defaults (remove when dragging any overlay is possible)
|
||||
set_offset(current_target, translation, transform.basis.get_rotation_quat())
|
||||
|
@ -143,6 +147,9 @@ func update_current_target():
|
|||
func set_overlay_visible(state: bool):
|
||||
overlay_visible = state
|
||||
$OverlayViewport.overlay_visible = state
|
||||
Settings.s.overlays[name].visible = state
|
||||
emit_signal("overlay_visibility_changed", state)
|
||||
save_settings()
|
||||
|
||||
|
||||
func _tracker_changed(tracker_name: String, type: int, id: int):
|
||||
|
|
|
@ -20,6 +20,11 @@ const DEF = {
|
|||
"type": "string",
|
||||
"default": "UI_demo"
|
||||
},
|
||||
"visible": {
|
||||
"name": "Overlay Visible",
|
||||
"type": "bool",
|
||||
"default": true
|
||||
},
|
||||
"width": {
|
||||
"name": "Width (m)",
|
||||
"type": "number",
|
||||
|
@ -61,6 +66,7 @@ const DEF = {
|
|||
"default": {
|
||||
"MainOverlay": {
|
||||
"type": "MainOverlay",
|
||||
"visible": true,
|
||||
"width": 0.4,
|
||||
"target": "left",
|
||||
"fallback": ["left", "right", "head"],
|
||||
|
|
|
@ -7,14 +7,11 @@ func _ready() -> void:
|
|||
overlay = get_node("/root/Main/OverlayManager").get_node(overlay_name)
|
||||
$Label.text = overlay_name
|
||||
$HBoxContainer/Target.selected = overlay.TARGETS.find(overlay.target)
|
||||
overlay.connect("overlay_visibility_changed", self, "_overlay_visibility_changed")
|
||||
|
||||
|
||||
func _on_Visibility_toggled(state: bool) -> void:
|
||||
overlay.overlay_visible = state
|
||||
if state:
|
||||
$HBoxContainer/Visibility.icon = preload("res://icons/visible.svg")
|
||||
else:
|
||||
$HBoxContainer/Visibility.icon = preload("res://icons/hidden.svg")
|
||||
|
||||
|
||||
func _on_Target_item_selected(index: int) -> void:
|
||||
|
@ -27,3 +24,11 @@ func _on_Reset_pressed() -> void:
|
|||
|
||||
func _on_Grab_toggled(state: bool) -> void:
|
||||
overlay.get_node("OverlayInteraction").grab_mode = state
|
||||
|
||||
|
||||
func _overlay_visibility_changed(state: bool):
|
||||
$HBoxContainer/Visibility.pressed = state
|
||||
if state:
|
||||
$HBoxContainer/Visibility.icon = preload("res://icons/visible.svg")
|
||||
else:
|
||||
$HBoxContainer/Visibility.icon = preload("res://icons/hidden.svg")
|
||||
|
|
|
@ -47,6 +47,7 @@ __meta__ = {
|
|||
[node name="GrabMode" type="Button" parent="VSplitContainer/MainBar"]
|
||||
margin_right = 176.0
|
||||
margin_bottom = 191.0
|
||||
focus_mode = 0
|
||||
toggle_mode = true
|
||||
icon = ExtResource( 5 )
|
||||
|
||||
|
@ -54,6 +55,7 @@ icon = ExtResource( 5 )
|
|||
margin_left = 180.0
|
||||
margin_right = 356.0
|
||||
margin_bottom = 191.0
|
||||
focus_mode = 0
|
||||
toggle_mode = true
|
||||
icon = ExtResource( 6 )
|
||||
|
||||
|
@ -61,6 +63,7 @@ icon = ExtResource( 6 )
|
|||
margin_left = 360.0
|
||||
margin_right = 536.0
|
||||
margin_bottom = 191.0
|
||||
focus_mode = 0
|
||||
icon = ExtResource( 4 )
|
||||
|
||||
[connection signal="toggled" from="VSplitContainer/MainBar/GrabMode" to="." method="_on_GrabMode_toggled"]
|
||||
|
|
Loading…
Reference in a new issue