main menu basic mockup

This commit is contained in:
Crispy 2021-05-30 13:20:34 +02:00
parent 7166f9899f
commit 634ea013b7
9 changed files with 120 additions and 18 deletions

View file

@ -0,0 +1,40 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://menu.theme" type="Theme" id=1]
[ext_resource path="res://icons/visible.svg" type="Texture" id=2]
[ext_resource path="res://overlay_list_item.gd" type="Script" id=3]
[node name="ListOverlayItem" type="PanelContainer"]
margin_top = 1727.0
margin_right = 2048.0
margin_bottom = 1855.0
rect_min_size = Vector2( 100, 128 )
theme = ExtResource( 1 )
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="."]
margin_left = 7.0
margin_top = 10.0
margin_right = 2041.0
margin_bottom = 185.0
text = "BatteryLevel"
[node name="HBoxContainer" type="HBoxContainer" parent="."]
margin_left = 7.0
margin_top = 7.0
margin_right = 2041.0
margin_bottom = 188.0
alignment = 2
[node name="Visibility" type="Button" parent="HBoxContainer"]
margin_left = 1862.0
margin_right = 2034.0
margin_bottom = 181.0
toggle_mode = true
pressed = true
icon = ExtResource( 2 )
[connection signal="toggled" from="HBoxContainer/Visibility" to="." method="_on_Visibility_toggled"]

View file

@ -11,6 +11,7 @@ var trackers = {
} }
func _init() -> void: func _init() -> void:
OS.window_minimized = true
ovr_config = preload("res://addons/godot-openvr/OpenVRConfig.gdns").new() ovr_config = preload("res://addons/godot-openvr/OpenVRConfig.gdns").new()
ovr_config.set_application_type(2) # Set to OVERLAY MODE = 2, NORMAL MODE = 1 ovr_config.set_application_type(2) # Set to OVERLAY MODE = 2, NORMAL MODE = 1
ovr_config.set_tracking_universe(1) # Set to SEATED MODE = 0, STANDING MODE = 1, RAW MODE = 2 ovr_config.set_tracking_universe(1) # Set to SEATED MODE = 0, STANDING MODE = 1, RAW MODE = 2

View file

@ -25,12 +25,12 @@ var _offsets:Dictionary = {
# what's actually tracking # what's actually tracking
var current_target: String = "world" setget _set_current_target# most of the time the actual target, but will fall back var current_target: String = "world" setget _set_current_target# most of the time the actual target, but will fall back
var fallback = ["left", "right", "head"] # TODO setget that updates tracking (not important) var fallback = ["left", "right", "head"] # TODO setget that updates tracking (not important)
var interaction_handler: Node
var _tracker_id: int = 0 var _tracker_id: int = 0
onready var container = $OverlayViewport/Container onready var container = $OverlayViewport/Container
func _ready() -> void: func _ready() -> void:
current_target = target current_target = target
@ -42,12 +42,12 @@ func _ready() -> void:
load_settings() load_settings()
if add_cursor or add_grabbing: if add_cursor or add_grabbing:
var interaction_handler = load("res://addons/openvr_overlay/OverlayInteraction.tscn").instance() interaction_handler = load("res://addons/openvr_overlay/OverlayInteraction.tscn").instance()
add_child(interaction_handler) add_child(interaction_handler)
if add_cursor: if add_cursor:
interaction_handler.add_child(load("res://addons/openvr_overlay/OverlayCursor.tscn").instance()) add_cursor()
if add_grabbing: if add_grabbing:
interaction_handler.add_child(load("res://addons/openvr_overlay/OverlayGrab.tscn").instance()) add_grab()
if overlay_scene: if overlay_scene:
container.add_child(overlay_scene.instance()) container.add_child(overlay_scene.instance())
@ -55,6 +55,14 @@ func _ready() -> void:
update_tracker_id() update_tracker_id()
func add_cursor():
interaction_handler.add_child(load("res://addons/openvr_overlay/OverlayCursor.tscn").instance())
func add_grab():
interaction_handler.add_child(load("res://addons/openvr_overlay/OverlayGrab.tscn").instance())
func load_settings(): func load_settings():
if Settings.s.overlays.has(name): if Settings.s.overlays.has(name):
if Settings.s.overlays[name].has("fallback"): if Settings.s.overlays[name].has("fallback"):

BIN
ovr-utils/menu.theme Normal file

Binary file not shown.

View file

@ -0,0 +1,14 @@
extends PanelContainer
var overlay
func _ready() -> void:
overlay = get_node("/root/Main/OverlayManager").get_child(1)
func _on_Visibility_toggled(state: bool) -> void:
overlay.get_node("OverlayViewport").overlay_visible = state
if state:
$HBoxContainer/Visibility.icon = preload("res://icons/visible.svg")
else:
$HBoxContainer/Visibility.icon = preload("res://icons/hidden.svg")

View file

@ -2,9 +2,13 @@ extends Control
func _ready() -> void: func _ready() -> void:
pass $VSplitContainer/Control/Overlays.visible = false
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") Settings.emit_signal("settings_changed")
func _on_ShowOverlays_toggled(state: bool) -> void:
$VSplitContainer/Control/Overlays.visible = state

View file

@ -7,6 +7,8 @@ var oinst
func _ready() -> void: func _ready() -> void:
oinst = get_viewport().get_parent() oinst = get_viewport().get_parent()
ihandler = get_viewport().get_node("../OverlayInteraction/OverlayGrab") ihandler = get_viewport().get_node("../OverlayInteraction/OverlayGrab")
if not oinst.add_cursor:
oinst.add_cursor()
for t in oinst.TARGETS: for t in oinst.TARGETS:
$OptionButton.add_item(t) $OptionButton.add_item(t)
$OptionButton.selected = oinst.TARGETS.find(oinst.target) $OptionButton.selected = oinst.TARGETS.find(oinst.target)

View file

@ -1,34 +1,62 @@
[gd_scene load_steps=4 format=2] [gd_scene load_steps=4 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://fonts/OpenSans-Bold.ttf" type="DynamicFontData" id=2] [ext_resource path="res://menu.theme" type="Theme" id=2]
[ext_resource path="res://ListOverlayItem.tscn" type="PackedScene" id=3]
[sub_resource type="DynamicFont" id=1]
size = 64
font_data = ExtResource( 2 )
[node name="MainOverlay" type="Control"] [node name="MainOverlay" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
theme = ExtResource( 2 )
script = ExtResource( 1 ) script = ExtResource( 1 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="HBoxContainer" type="HBoxContainer" parent="."] [node name="VSplitContainer" type="VSplitContainer" parent="."]
anchor_top = 1.0
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
margin_top = -99.0
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="GrabMode" type="Button" parent="HBoxContainer"] [node name="Control" type="Control" parent="VSplitContainer"]
margin_right = 366.0 margin_right = 2048.0
margin_bottom = 99.0 margin_bottom = 1855.0
custom_fonts/font = SubResource( 1 ) size_flags_vertical = 3
[node name="Overlays" type="VBoxContainer" parent="VSplitContainer/Control"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_vertical = 3
alignment = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ListOverlayItem" parent="VSplitContainer/Control/Overlays" instance=ExtResource( 3 )]
margin_top = 1660.0
[node name="MainBar" type="HBoxContainer" parent="VSplitContainer"]
margin_top = 1867.0
margin_right = 2048.0
margin_bottom = 2048.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="GrabMode" type="Button" parent="VSplitContainer/MainBar"]
margin_right = 716.0
margin_bottom = 181.0
toggle_mode = true toggle_mode = true
text = "Grab mode" text = "Grab mode"
[connection signal="toggled" from="HBoxContainer/GrabMode" to="." method="_on_GrabMode_toggled"] [node name="ShowOverlays" type="Button" parent="VSplitContainer/MainBar"]
margin_left = 720.0
margin_right = 1294.0
margin_bottom = 181.0
toggle_mode = true
text = "Overlays"
[connection signal="toggled" from="VSplitContainer/MainBar/GrabMode" to="." method="_on_GrabMode_toggled"]
[connection signal="toggled" from="VSplitContainer/MainBar/ShowOverlays" to="." method="_on_ShowOverlays_toggled"]

View file

@ -21,6 +21,11 @@ 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"
[display]
window/size/width=2048
window/size/height=2048
[editor_plugins] [editor_plugins]
enabled=PoolStringArray( "res://addons/godot-openvr/plugin.cfg", "res://addons/openvr_overlay/plugin.cfg", "res://addons/settings-manager/plugin.cfg" ) enabled=PoolStringArray( "res://addons/godot-openvr/plugin.cfg", "res://addons/openvr_overlay/plugin.cfg", "res://addons/settings-manager/plugin.cfg" )