load overlays from file at startup

This commit is contained in:
Crispy 2021-05-29 22:53:28 +02:00
parent 97a3fb5e80
commit 031a48ffdc
23 changed files with 99 additions and 123 deletions

View file

@ -1,30 +1,8 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/openvr_overlay/OverlayInstance.tscn" type="PackedScene" id=1]
[ext_resource path="res://overlays/FPSOverlay.tscn" type="PackedScene" id=2]
[ext_resource path="res://overlays/TimeOverlay.tscn" type="PackedScene" id=3]
[ext_resource path="res://overlays/xyz_widget/XYZ Widget.tscn" type="PackedScene" id=4]
[ext_resource path="res://overlays/UI_demo.tscn" type="PackedScene" id=5]
[ext_resource path="res://overlays/BatteryOverlay.tscn" type="PackedScene" id=7]
[ext_resource path="res://overlay_manager.gd" type="Script" id=6]
[node name="Overlays" type="Node"]
[node name="Main" type="Node"]
[node name="OverlayInstance FPS" parent="." instance=ExtResource( 1 )]
transform = Transform( -4.37114e-08, -0.707107, -0.707107, 0, -0.707107, 0.707107, -1, 3.09086e-08, 3.09086e-08, 0.05, -0.01, 0.15 )
overlay_scene = ExtResource( 2 )
[node name="OverlayInstance Time" parent="." instance=ExtResource( 1 )]
transform = Transform( -4.37114e-08, -0.707107, -0.707107, 0, -0.707107, 0.707107, -1, 3.09086e-08, 3.09086e-08, -0.05, 0.02, 0.15 )
overlay_scene = ExtResource( 3 )
width_meters = 0.1
[node name="OverlayInstance UI demo" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.25 )
overlay_scene = ExtResource( 5 )
add_cursor = true
[node name="XYZ Widget" parent="." instance=ExtResource( 4 )]
[node name="OverlayInstance Battery" parent="." instance=ExtResource( 1 )]
transform = Transform( -4.37114e-08, -0.707107, -0.707107, 0, -0.707107, 0.707107, -1, 3.09086e-08, 3.09086e-08, -0.12, 0, 0.1 )
overlay_scene = ExtResource( 7 )
[node name="OverlayManager" type="Node" parent="."]
script = ExtResource( 6 )

40
ovr-utils/OLD.tscn Normal file
View file

@ -0,0 +1,40 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://addons/openvr_overlay/overlay_instance.gd" type="Script" id=1]
[ext_resource path="res://overlays/Clock.tscn" type="PackedScene" id=2]
[ext_resource path="res://overlays/zx.tscn" type="PackedScene" id=3]
[ext_resource path="res://overlays/UI_demo.tscn" type="PackedScene" id=4]
[ext_resource path="res://addons/openvr_overlay/OverlayInstance.tscn" type="PackedScene" id=5]
[ext_resource path="res://overlays/yz.tscn" type="PackedScene" id=6]
[ext_resource path="res://overlays/BatteryLevel.tscn" type="PackedScene" id=7]
[node name="OLD" type="Node"]
[node name="OverlayInstance Time" type="Spatial" parent="." instance=ExtResource( 5 )]
transform = Transform( -4.37114e-08, -0.707107, -0.707107, 0, -0.707107, 0.707107, -1, 3.09086e-08, 3.09086e-08, -0.05, 0.02, 0.15 )
script = ExtResource( 1 )
overlay_scene = ExtResource( 2 )
width_meters = 0.1
[node name="OverlayInstance UI demo" type="Spatial" parent="." instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.25 )
script = ExtResource( 1 )
overlay_scene = ExtResource( 4 )
add_cursor = true
[node name="OverlayInstance Battery" type="Spatial" parent="." instance=ExtResource( 5 )]
transform = Transform( -4.37114e-08, -0.707107, -0.707107, 0, -0.707107, 0.707107, -1, 3.09086e-08, 3.09086e-08, -0.12, 0, 0.1 )
script = ExtResource( 1 )
overlay_scene = ExtResource( 7 )
[node name="YZ" type="Spatial" parent="." instance=ExtResource( 5 )]
transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0 )
script = ExtResource( 1 )
overlay_scene = ExtResource( 6 )
width_meters = 0.25
[node name="ZX" type="Spatial" parent="." instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0 )
script = ExtResource( 1 )
overlay_scene = ExtResource( 3 )
width_meters = 0.25

View file

@ -37,12 +37,9 @@ func _ready() -> void:
ARVRServer.connect("tracker_added", self, "_tracker_changed")
ARVRServer.connect("tracker_removed", self, "_tracker_changed")
# $OverlayViewport.overlay_width_in_meters = width_meters
$OverlayViewport.size = OverlayInit.ovr_interface.get_render_targetsize()
# emit_signal("target_changed")
set_notify_transform(true)
# call_deferred("load_settings") # TODO call directly (when overlays are loaded at runtime, after settings have loaded
load_settings()
if add_cursor or add_grabbing:
var interaction_handler = load("res://addons/openvr_overlay/OverlayInteraction.tscn").instance()

View file

@ -15,6 +15,11 @@ const DEF = {
"definition": {
"type": "dict",
"definition": {
"type": {
"name": "Overlay type",
"type": "string",
"default": "UI_demo"
},
"width": {
"name": "Width (m)",
"type": "number",
@ -55,6 +60,7 @@ const DEF = {
},
"default": {
"main": {
"type": "MainOverlay",
"width": 0.4,
"target": "left",
"fallback": ["left", "right", "head"],

View file

@ -0,0 +1,33 @@
extends Node
var loaded := false
func _init() -> void:
Settings.connect("settings_loaded", self, "_load_overlays")
func _load_overlays():
if loaded:
return
loaded = true
print("Loading in overlays")
for key in Settings.s.overlays:
# TODO remove this check, settings should always contain "type"
if Settings.s.overlays[key].has("type"):
add_overlay(Settings.s.overlays[key].type, key)
else:
print("No type defined for overlay ", key)
func add_overlay(type, name):
var scene = load("res://overlays/" + type + ".tscn")
if scene == null:
print("Unknown overlay type; ", type, ". Skipping overlay \"", name, "\"")
return
var instance = preload("res://addons/openvr_overlay/OverlayInstance.tscn").instance()
instance.name = name
instance.overlay_scene = scene
add_child(instance)

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://overlays/battery.gd" type="Script" id=1]
[ext_resource path="res://overlay_scripts/battery.gd" type="Script" id=1]
[ext_resource path="res://fonts/OpenSans-Regular.ttf" type="DynamicFontData" id=2]
[sub_resource type="StyleBoxEmpty" id=3]

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://overlays/time.gd" type="Script" id=1]
[ext_resource path="res://overlay_scripts/time.gd" type="Script" id=1]
[ext_resource path="res://fonts/OpenSans-Regular.ttf" type="DynamicFontData" id=2]
[sub_resource type="StyleBoxFlat" id=1]

View file

@ -1,49 +0,0 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://overlays/fps.gd" type="Script" id=1]
[ext_resource path="res://fonts/OpenSans-Regular.ttf" type="DynamicFontData" id=2]
[sub_resource type="DynamicFont" id=1]
size = 48
font_data = ExtResource( 2 )
[node name="Overlay" type="Control"]
modulate = Color( 1, 1, 1, 0.490196 )
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ColorRect" type="ColorRect" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -222.0
margin_top = -32.0
margin_right = 222.0
margin_bottom = 32.0
color = Color( 0, 0, 0, 0.392157 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="ColorRect"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -512.0
margin_top = -33.5
margin_right = 512.0
margin_bottom = 33.5
custom_fonts/font = SubResource( 1 )
text = "Overlay FPS: 60"
align = 1
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://overlays/move_overlay.gd" type="Script" id=1]
[ext_resource path="res://overlay_scripts/ui_demo.gd" type="Script" id=1]
[ext_resource path="res://fonts/OpenSans-Regular.ttf" type="DynamicFontData" id=2]
[ext_resource path="res://fonts/OpenSans-Bold.ttf" type="DynamicFontData" id=3]
@ -47,7 +47,6 @@ margin_right = 111.0
margin_bottom = 41.0
theme = SubResource( 2 )
text = "Item 0"
selected = 0
__meta__ = {
"_edit_use_anchors_": false
}

View file

@ -1,9 +0,0 @@
extends Label
func _ready() -> void:
pass
func _process(delta: float) -> void:
if delta > 0:
text = "Overlay FPS: " + str(round(1/delta))

View file

@ -1,19 +0,0 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://overlays/xyz_widget/zx.tscn" type="PackedScene" id=2]
[ext_resource path="res://overlays/xyz_widget/yz.tscn" type="PackedScene" id=7]
[ext_resource path="res://addons/openvr_overlay/OverlayInstance.tscn" type="PackedScene" id=9]
[node name="XYZ Widget" type="Spatial"]
[node name="YZ" parent="." instance=ExtResource( 9 )]
transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0 )
target = 1
overlay_scene = ExtResource( 7 )
width_meters = 0.25
[node name="ZX" parent="." instance=ExtResource( 9 )]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0 )
target = 1
overlay_scene = ExtResource( 2 )
width_meters = 0.25

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://overlays/xyz_widget/yz_widget.png" type="Texture" id=1]
[ext_resource path="res://textures/yz_widget.png" type="Texture" id=1]
[node name="Control" type="Control"]
anchor_right = 1.0

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://overlays/xyz_widget/zx_widget.png" type="Texture" id=1]
[ext_resource path="res://textures/zx_widget.png" type="Texture" id=1]
[node name="Control" type="Control"]
anchor_right = 1.0

View file

@ -14,7 +14,7 @@ config/name="ovr-utils"
run/main_scene="res://Main.tscn"
config/use_custom_user_dir=true
config/custom_user_dir_name="ovr-utils"
config/icon="res://icon.png"
config/icon="res://textures/icon.png"
[autoload]

View file

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

@ -2,15 +2,15 @@
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
path="res://.import/icon.png-f931f6b997c470ed41f337ac62349254.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
source_file="res://textures/icon.png"
dest_files=[ "res://.import/icon.png-f931f6b997c470ed41f337ac62349254.stex" ]
[params]

View file

Before

Width:  |  Height:  |  Size: 103 B

After

Width:  |  Height:  |  Size: 103 B

View file

@ -2,15 +2,15 @@
importer="texture"
type="StreamTexture"
path="res://.import/yz_widget.png-b9fa885c579466828b6d0caddc809e49.stex"
path="res://.import/yz_widget.png-601835b538a8dc18e155517b6b8d1aa6.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://overlays/xyz_widget/yz_widget.png"
dest_files=[ "res://.import/yz_widget.png-b9fa885c579466828b6d0caddc809e49.stex" ]
source_file="res://textures/yz_widget.png"
dest_files=[ "res://.import/yz_widget.png-601835b538a8dc18e155517b6b8d1aa6.stex" ]
[params]

View file

Before

Width:  |  Height:  |  Size: 94 B

After

Width:  |  Height:  |  Size: 94 B

View file

@ -2,15 +2,15 @@
importer="texture"
type="StreamTexture"
path="res://.import/zx_widget.png-b7f8f97d1c970429dd17d72af3b467a5.stex"
path="res://.import/zx_widget.png-5f9e84560ac9e1e5c37ee8a06256191f.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://overlays/xyz_widget/zx_widget.png"
dest_files=[ "res://.import/zx_widget.png-b7f8f97d1c970429dd17d72af3b467a5.stex" ]
source_file="res://textures/zx_widget.png"
dest_files=[ "res://.import/zx_widget.png-5f9e84560ac9e1e5c37ee8a06256191f.stex" ]
[params]