This commit is contained in:
Crispy 2021-06-02 15:12:00 +02:00
parent 5766378651
commit 39f34344cd
6 changed files with 15 additions and 9 deletions

View file

@ -1,7 +1,7 @@
[gd_scene load_steps=4 format=2] [gd_scene load_steps=4 format=2]
[ext_resource path="res://addons/openvr_overlay/OverlayInstance.tscn" type="PackedScene" id=1] [ext_resource path="res://addons/openvr_overlay/OverlayInstance.tscn" type="PackedScene" id=1]
[ext_resource path="res://overlays/MainOverlay.tscn" type="PackedScene" id=2] [ext_resource path="res://ui/MainOverlay.tscn" type="PackedScene" id=2]
[ext_resource path="res://overlay_manager.gd" type="Script" id=6] [ext_resource path="res://overlay_manager.gd" type="Script" id=6]
[node name="Main" type="Node"] [node name="Main" type="Node"]

View file

@ -18,7 +18,7 @@ func _load_overlays():
for key in Settings.s.overlays: for key in Settings.s.overlays:
# TODO remove this check, settings should always contain "type" # TODO remove this check, settings should always contain "type"
if Settings.s.overlays[key].has("type"): if Settings.s.overlays[key].has("type"):
if not Settings.s.overlays[key].type == "MainOverlay": if not key == "MainOverlay":
add_overlay(Settings.s.overlays[key].type, key) add_overlay(Settings.s.overlays[key].type, key)
else: else:
print("No type defined for overlay ", key) print("No type defined for overlay ", key)

View file

@ -4,7 +4,8 @@ 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")
for o in Settings.s.overlays: for o in Settings.s.overlays:
_add_overlay_to_list(o) if o != "MainOverlay":
_add_overlay_to_list(o)
$VSplitContainer/Control/Overlays.visible = false $VSplitContainer/Control/Overlays.visible = false
@ -14,10 +15,8 @@ func _add_overlay_to_list(name):
$VSplitContainer/Control/Overlays.add_child(new) $VSplitContainer/Control/Overlays.add_child(new)
func _on_GrabMode_toggled(state: bool) -> void: func _on_GrabMode_toggled(state: bool) -> void:
Settings.s.grab_mode = state Settings.s.grab_mode = state
Settings.emit_signal("settings_changed")
func _on_ShowOverlays_toggled(state: bool) -> void: func _on_ShowOverlays_toggled(state: bool) -> void:
@ -25,5 +24,5 @@ func _on_ShowOverlays_toggled(state: bool) -> void:
func _on_AddOverlay_pressed() -> void: func _on_AddOverlay_pressed() -> void:
$VSplitContainer/Control/AddMenu.visible = true $VSplitContainer/Control/AddMenu.visible = !$VSplitContainer/Control/AddMenu.visible

View file

@ -26,7 +26,7 @@ margin_left = 8.0
margin_top = 16.0 margin_top = 16.0
margin_right = 2040.0 margin_right = 2040.0
margin_bottom = 191.0 margin_bottom = 191.0
text = "BatteryLevel" text = "MainOverlay"
[node name="HBoxContainer" type="HBoxContainer" parent="."] [node name="HBoxContainer" type="HBoxContainer" parent="."]
margin_left = 8.0 margin_left = 8.0

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=2] [gd_scene load_steps=8 format=2]
[ext_resource path="res://overlay_scripts/main_menu.gd" type="Script" id=1] [ext_resource path="res://overlay_scripts/main_menu.gd" type="Script" id=1]
[ext_resource path="res://styles/menu.theme" type="Theme" id=2] [ext_resource path="res://styles/menu.theme" type="Theme" id=2]
@ -6,6 +6,7 @@
[ext_resource path="res://icons/add.svg" type="Texture" id=4] [ext_resource path="res://icons/add.svg" type="Texture" id=4]
[ext_resource path="res://icons/move.svg" type="Texture" id=5] [ext_resource path="res://icons/move.svg" type="Texture" id=5]
[ext_resource path="res://icons/list.svg" type="Texture" id=6] [ext_resource path="res://icons/list.svg" type="Texture" id=6]
[ext_resource path="res://ui/ListOverlayItem.tscn" type="PackedScene" id=7]
[node name="MainOverlay" type="Control"] [node name="MainOverlay" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
@ -37,7 +38,13 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="ListOverlayItem" parent="VSplitContainer/Control/Overlays" instance=ExtResource( 7 )]
margin_top = 1638.0
margin_bottom = 1845.0
overlay_name = "MainOverlay"
[node name="AddMenu" parent="VSplitContainer/Control" instance=ExtResource( 3 )] [node name="AddMenu" parent="VSplitContainer/Control" instance=ExtResource( 3 )]
visible = false
[node name="MainBar" type="HBoxContainer" parent="VSplitContainer"] [node name="MainBar" type="HBoxContainer" parent="VSplitContainer"]
margin_top = 1857.0 margin_top = 1857.0

View file

@ -6,7 +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
$HBoxContainer/Target.selected = overlay.TARGETS.find(overlay.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")