diff --git a/ovr-utils/Main.tscn b/ovr-utils/Main.tscn index d317809..4d049e1 100644 --- a/ovr-utils/Main.tscn +++ b/ovr-utils/Main.tscn @@ -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 ) diff --git a/ovr-utils/OLD.tscn b/ovr-utils/OLD.tscn new file mode 100644 index 0000000..31a38ba --- /dev/null +++ b/ovr-utils/OLD.tscn @@ -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 diff --git a/ovr-utils/addons/openvr_overlay/overlay_instance.gd b/ovr-utils/addons/openvr_overlay/overlay_instance.gd index 11ef5d5..1ddbd60 100644 --- a/ovr-utils/addons/openvr_overlay/overlay_instance.gd +++ b/ovr-utils/addons/openvr_overlay/overlay_instance.gd @@ -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() diff --git a/ovr-utils/addons/settings-manager/settings_definition.gd b/ovr-utils/addons/settings-manager/settings_definition.gd index fc37833..dedbdf5 100644 --- a/ovr-utils/addons/settings-manager/settings_definition.gd +++ b/ovr-utils/addons/settings-manager/settings_definition.gd @@ -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"], diff --git a/ovr-utils/overlay_manager.gd b/ovr-utils/overlay_manager.gd new file mode 100644 index 0000000..5f56f08 --- /dev/null +++ b/ovr-utils/overlay_manager.gd @@ -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) + diff --git a/ovr-utils/overlays/battery.gd b/ovr-utils/overlay_scripts/battery.gd similarity index 100% rename from ovr-utils/overlays/battery.gd rename to ovr-utils/overlay_scripts/battery.gd diff --git a/ovr-utils/overlays/time.gd b/ovr-utils/overlay_scripts/time.gd similarity index 100% rename from ovr-utils/overlays/time.gd rename to ovr-utils/overlay_scripts/time.gd diff --git a/ovr-utils/overlays/move_overlay.gd b/ovr-utils/overlay_scripts/ui_demo.gd similarity index 100% rename from ovr-utils/overlays/move_overlay.gd rename to ovr-utils/overlay_scripts/ui_demo.gd diff --git a/ovr-utils/overlays/BatteryOverlay.tscn b/ovr-utils/overlays/BatteryLevel.tscn similarity index 95% rename from ovr-utils/overlays/BatteryOverlay.tscn rename to ovr-utils/overlays/BatteryLevel.tscn index b18d419..0ddfc84 100644 --- a/ovr-utils/overlays/BatteryOverlay.tscn +++ b/ovr-utils/overlays/BatteryLevel.tscn @@ -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] diff --git a/ovr-utils/overlays/TimeOverlay.tscn b/ovr-utils/overlays/Clock.tscn similarity index 93% rename from ovr-utils/overlays/TimeOverlay.tscn rename to ovr-utils/overlays/Clock.tscn index 96e8846..d594de1 100644 --- a/ovr-utils/overlays/TimeOverlay.tscn +++ b/ovr-utils/overlays/Clock.tscn @@ -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] diff --git a/ovr-utils/overlays/FPSOverlay.tscn b/ovr-utils/overlays/FPSOverlay.tscn deleted file mode 100644 index c3f7a0a..0000000 --- a/ovr-utils/overlays/FPSOverlay.tscn +++ /dev/null @@ -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 -} diff --git a/ovr-utils/overlays/UI_demo.tscn b/ovr-utils/overlays/UI_demo.tscn index 1799787..bb2e3b0 100644 --- a/ovr-utils/overlays/UI_demo.tscn +++ b/ovr-utils/overlays/UI_demo.tscn @@ -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 } diff --git a/ovr-utils/overlays/fps.gd b/ovr-utils/overlays/fps.gd deleted file mode 100644 index 3a0a20f..0000000 --- a/ovr-utils/overlays/fps.gd +++ /dev/null @@ -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)) diff --git a/ovr-utils/overlays/xyz_widget/XYZ Widget.tscn b/ovr-utils/overlays/xyz_widget/XYZ Widget.tscn deleted file mode 100644 index 8003a5c..0000000 --- a/ovr-utils/overlays/xyz_widget/XYZ Widget.tscn +++ /dev/null @@ -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 diff --git a/ovr-utils/overlays/xyz_widget/yz.tscn b/ovr-utils/overlays/yz.tscn similarity index 84% rename from ovr-utils/overlays/xyz_widget/yz.tscn rename to ovr-utils/overlays/yz.tscn index d0799b4..e9da146 100644 --- a/ovr-utils/overlays/xyz_widget/yz.tscn +++ b/ovr-utils/overlays/yz.tscn @@ -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 diff --git a/ovr-utils/overlays/xyz_widget/zx.tscn b/ovr-utils/overlays/zx.tscn similarity index 84% rename from ovr-utils/overlays/xyz_widget/zx.tscn rename to ovr-utils/overlays/zx.tscn index ed482de..289f097 100644 --- a/ovr-utils/overlays/xyz_widget/zx.tscn +++ b/ovr-utils/overlays/zx.tscn @@ -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 diff --git a/ovr-utils/project.godot b/ovr-utils/project.godot index 5d2801a..77c6449 100644 --- a/ovr-utils/project.godot +++ b/ovr-utils/project.godot @@ -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] diff --git a/ovr-utils/icon.png b/ovr-utils/textures/icon.png similarity index 100% rename from ovr-utils/icon.png rename to ovr-utils/textures/icon.png diff --git a/ovr-utils/icon.png.import b/ovr-utils/textures/icon.png.import similarity index 72% rename from ovr-utils/icon.png.import rename to ovr-utils/textures/icon.png.import index 96cbf46..6a55f13 100644 --- a/ovr-utils/icon.png.import +++ b/ovr-utils/textures/icon.png.import @@ -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] diff --git a/ovr-utils/overlays/xyz_widget/yz_widget.png b/ovr-utils/textures/yz_widget.png similarity index 100% rename from ovr-utils/overlays/xyz_widget/yz_widget.png rename to ovr-utils/textures/yz_widget.png diff --git a/ovr-utils/overlays/xyz_widget/yz_widget.png.import b/ovr-utils/textures/yz_widget.png.import similarity index 68% rename from ovr-utils/overlays/xyz_widget/yz_widget.png.import rename to ovr-utils/textures/yz_widget.png.import index 31b0345..50ea98d 100644 --- a/ovr-utils/overlays/xyz_widget/yz_widget.png.import +++ b/ovr-utils/textures/yz_widget.png.import @@ -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] diff --git a/ovr-utils/overlays/xyz_widget/zx_widget.png b/ovr-utils/textures/zx_widget.png similarity index 100% rename from ovr-utils/overlays/xyz_widget/zx_widget.png rename to ovr-utils/textures/zx_widget.png diff --git a/ovr-utils/overlays/xyz_widget/zx_widget.png.import b/ovr-utils/textures/zx_widget.png.import similarity index 68% rename from ovr-utils/overlays/xyz_widget/zx_widget.png.import rename to ovr-utils/textures/zx_widget.png.import index 9faf420..26d22ba 100644 --- a/ovr-utils/overlays/xyz_widget/zx_widget.png.import +++ b/ovr-utils/textures/zx_widget.png.import @@ -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]