mirror of
https://github.com/CrispyPin/ovr-utils.git
synced 2024-11-10 02:40:25 +01:00
made overlaymanager an autoload/singleton
This commit is contained in:
parent
271352bf16
commit
1375ebbaeb
7 changed files with 25 additions and 17 deletions
|
@ -1,14 +1,3 @@
|
||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene format=2]
|
||||||
|
|
||||||
[ext_resource path="res://addons/openvr_overlay/OverlayInstance.tscn" type="PackedScene" id=1]
|
|
||||||
[ext_resource path="res://ui/MainOverlay.tscn" type="PackedScene" id=2]
|
|
||||||
[ext_resource path="res://overlay_manager.gd" type="Script" id=6]
|
|
||||||
|
|
||||||
[node name="Main" type="Node"]
|
[node name="Main" type="Node"]
|
||||||
|
|
||||||
[node name="OverlayManager" type="Node" parent="."]
|
|
||||||
script = ExtResource( 6 )
|
|
||||||
|
|
||||||
[node name="MainOverlay" parent="OverlayManager" instance=ExtResource( 1 )]
|
|
||||||
overlay_scene = ExtResource( 2 )
|
|
||||||
add_cursor = true
|
|
||||||
|
|
14
ovr-utils/OverlayManager.tscn
Normal file
14
ovr-utils/OverlayManager.tscn
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://ui/MainOverlay.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://addons/openvr_overlay/OverlayInstance.tscn" type="PackedScene" id=2]
|
||||||
|
[ext_resource path="res://addons/openvr_overlay/overlay_instance.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://overlay_manager.gd" type="Script" id=4]
|
||||||
|
|
||||||
|
[node name="OverlayManager" type="Node"]
|
||||||
|
script = ExtResource( 4 )
|
||||||
|
|
||||||
|
[node name="MainOverlay" type="Spatial" parent="." instance=ExtResource( 2 )]
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
overlay_scene = ExtResource( 1 )
|
||||||
|
add_cursor = true
|
|
@ -10,6 +10,10 @@ func _init() -> void:
|
||||||
Settings.connect("settings_loaded", self, "_load_overlays")
|
Settings.connect("settings_loaded", self, "_load_overlays")
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
randomize()
|
||||||
|
|
||||||
|
|
||||||
func _load_overlays():
|
func _load_overlays():
|
||||||
if loaded:
|
if loaded:
|
||||||
return
|
return
|
||||||
|
|
|
@ -2,8 +2,8 @@ extends Control
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
get_node("/root/Main/OverlayManager").connect("added_overlay", self, "_add_overlay_to_list")
|
OverlayManager.connect("added_overlay", self, "_add_overlay_to_list")
|
||||||
get_node("/root/Main/OverlayManager").connect("removed_overlay", self, "_remove_overlay_from_list")
|
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)
|
||||||
|
|
|
@ -20,6 +20,7 @@ config/icon="res://textures/icon.png"
|
||||||
|
|
||||||
Settings="*res://addons/settings-manager/Settings.tscn"
|
Settings="*res://addons/settings-manager/Settings.tscn"
|
||||||
OverlayInit="*res://addons/openvr_overlay/overlay_init.gd"
|
OverlayInit="*res://addons/openvr_overlay/overlay_init.gd"
|
||||||
|
OverlayManager="*res://OverlayManager.tscn"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ func _ready() -> void:
|
||||||
|
|
||||||
|
|
||||||
func add_overlay(type):
|
func add_overlay(type):
|
||||||
get_node("/root/Main/OverlayManager").add_overlay(type, type + str(randi()%100))
|
OverlayManager.add_overlay(type, type + str(randi()%100))
|
||||||
visible = false
|
visible = false
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ export var overlay_name: String
|
||||||
var overlay
|
var overlay
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
overlay = get_node("/root/Main/OverlayManager").get_node(overlay_name)
|
overlay = OverlayManager.get_node(overlay_name)
|
||||||
$Label.text = overlay_name
|
$Label.text = overlay_name
|
||||||
name = 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)
|
||||||
|
@ -36,5 +36,5 @@ func _overlay_visibility_changed(state: bool):
|
||||||
|
|
||||||
|
|
||||||
func _on_Remove_pressed() -> void:
|
func _on_Remove_pressed() -> void:
|
||||||
get_node("/root/Main/OverlayManager").remove_overlay(overlay_name)
|
OverlayManager.remove_overlay(overlay_name)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue