diff --git a/ovr-utils/addons/openvr_overlay/overlay_instance.gd b/ovr-utils/addons/openvr_overlay/overlay_instance.gd index b2e2a05..7e5af57 100644 --- a/ovr-utils/addons/openvr_overlay/overlay_instance.gd +++ b/ovr-utils/addons/openvr_overlay/overlay_instance.gd @@ -1,6 +1,7 @@ extends Spatial signal width_changed +signal alpha_changed signal offset_changed signal target_changed signal overlay_visibility_changed @@ -11,6 +12,7 @@ export (String, "head", "left", "right", "world") var target = "left" setget se export var overlay_scene: PackedScene = \ preload("res://addons/openvr_overlay/MissingOverlay.tscn") setget set_overlay_scene export var width_meters := 0.4 setget set_width_in_meters +export var alpha := 1.0 setget set_alpha export var add_grabbing := true # add grabbing module export var add_cursor := false # add cursor module @@ -80,6 +82,8 @@ func load_settings(): update_offset() if loaded.has("visible"): set_overlay_visible(loaded.visible) + if loaded.has("alpha"): + set_alpha(loaded.alpha) else: save_settings() @@ -89,6 +93,7 @@ func save_settings(): Settings.s.overlays[name] = {} Settings.s.overlays[name].target = target Settings.s.overlays[name].width = width_meters + Settings.s.overlays[name].alpha = alpha Settings.s.overlays[name].fallback = fallback Settings.s.overlays[name].type = type @@ -191,6 +196,12 @@ func set_overlay_scene(scene: PackedScene) -> void: container.add_child(overlay_scene.instance()) +func set_alpha(val: float): + alpha = val + $VROverlayViewport/TextureRect.modulate.a = val + emit_signal("alpha_changed") + + func reset_offset() -> void: _offsets[current_target].rot = Quat() _offsets[current_target].pos = Vector3() diff --git a/ovr-utils/addons/settings-manager/settings_definition.gd b/ovr-utils/addons/settings-manager/settings_definition.gd index 159dc86..17ca4f2 100644 --- a/ovr-utils/addons/settings-manager/settings_definition.gd +++ b/ovr-utils/addons/settings-manager/settings_definition.gd @@ -30,6 +30,11 @@ const DEF = { "type": "number", "default": 0.4 }, + "alpha": { + "name": "Alpha", + "type": "number", + "default": 1.0 + }, "target": { "name": "Tracking target", "type": "string", @@ -68,6 +73,7 @@ const DEF = { "type": "MainOverlay", "visible": true, "width": 0.4, + "alpha": 1.0, "target": "left", "fallback": ["left", "right", "head"], "offsets": { diff --git a/ovr-utils/icons/alpha.svg b/ovr-utils/icons/alpha.svg new file mode 100644 index 0000000..109911d --- /dev/null +++ b/ovr-utils/icons/alpha.svg @@ -0,0 +1 @@ + diff --git a/ovr-utils/icons/alpha.svg.import b/ovr-utils/icons/alpha.svg.import new file mode 100644 index 0000000..81ca4fb --- /dev/null +++ b/ovr-utils/icons/alpha.svg.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/alpha.svg-22384cad50da35235f001642b0f4e493.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icons/alpha.svg" +dest_files=[ "res://.import/alpha.svg-22384cad50da35235f001642b0f4e493.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=10.0 diff --git a/ovr-utils/ui/ListOverlayItem.tscn b/ovr-utils/ui/ListOverlayItem.tscn index 70e2c1d..149ea0c 100644 --- a/ovr-utils/ui/ListOverlayItem.tscn +++ b/ovr-utils/ui/ListOverlayItem.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=2] +[gd_scene load_steps=13 format=2] [ext_resource path="res://ui/overlay_list_item.gd" type="Script" id=1] [ext_resource path="res://icons/remove.svg" type="Texture" id=2] @@ -11,6 +11,7 @@ [ext_resource path="res://styles/menu.theme" type="Theme" id=9] [ext_resource path="res://icons/list.svg" type="Texture" id=10] [ext_resource path="res://icons/close.svg" type="Texture" id=11] +[ext_resource path="res://icons/alpha.svg" type="Texture" id=12] [node name="ListOverlayItem" type="MarginContainer"] margin_top = 1727.0 @@ -83,19 +84,19 @@ margin_right = 2040.0 margin_bottom = 215.0 [node name="Spacer" type="Control" parent="MoreOptions"] -margin_right = 1104.0 +margin_right = 924.0 margin_bottom = 207.0 size_flags_horizontal = 3 [node name="Container" type="PanelContainer" parent="MoreOptions"] -margin_left = 1116.0 +margin_left = 936.0 margin_right = 2032.0 margin_bottom = 207.0 [node name="List" type="HBoxContainer" parent="MoreOptions/Container"] margin_left = 8.0 margin_top = 8.0 -margin_right = 908.0 +margin_right = 1088.0 margin_bottom = 199.0 alignment = 2 @@ -134,9 +135,39 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="Target" type="OptionButton" parent="MoreOptions/Container/List"] +[node name="SetAlpha" type="Button" parent="MoreOptions/Container/List"] margin_left = 360.0 -margin_right = 540.0 +margin_right = 536.0 +margin_bottom = 191.0 +toggle_mode = true +icon = ExtResource( 12 ) + +[node name="PanelContainer" type="PanelContainer" parent="MoreOptions/Container/List/SetAlpha"] +anchor_top = -0.016 +anchor_right = 1.0 +anchor_bottom = -0.016 +margin_top = -448.944 +margin_bottom = 0.0560002 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="AlphaSlider" type="VSlider" parent="MoreOptions/Container/List/SetAlpha/PanelContainer"] +margin_left = 8.0 +margin_top = 8.0 +margin_right = 168.0 +margin_bottom = 441.0 +min_value = 0.2 +max_value = 1.0 +step = 0.05 +value = 1.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Target" type="OptionButton" parent="MoreOptions/Container/List"] +margin_left = 540.0 +margin_right = 720.0 margin_bottom = 191.0 text = "Left" icon = ExtResource( 6 ) @@ -145,14 +176,14 @@ items = [ "Head", ExtResource( 7 ), false, 0, null, "Left", ExtResource( 6 ), fa selected = 1 [node name="Reset" type="Button" parent="MoreOptions/Container/List"] -margin_left = 544.0 -margin_right = 720.0 +margin_left = 724.0 +margin_right = 900.0 margin_bottom = 191.0 icon = ExtResource( 5 ) [node name="CloseOptions" type="Button" parent="MoreOptions/Container/List"] -margin_left = 724.0 -margin_right = 900.0 +margin_left = 904.0 +margin_right = 1080.0 margin_bottom = 191.0 icon = ExtResource( 11 ) @@ -162,6 +193,8 @@ icon = ExtResource( 11 ) [connection signal="pressed" from="MoreOptions/Container/List/Remove" to="." method="_on_Remove_pressed"] [connection signal="toggled" from="MoreOptions/Container/List/SetSize" to="." method="_on_SetSize_toggled"] [connection signal="value_changed" from="MoreOptions/Container/List/SetSize/PanelContainer/SizeSlider" to="." method="_on_SizeSlider_value_changed"] +[connection signal="toggled" from="MoreOptions/Container/List/SetAlpha" to="." method="_on_SetAlpha_toggled"] +[connection signal="value_changed" from="MoreOptions/Container/List/SetAlpha/PanelContainer/AlphaSlider" to="." method="_on_AlphaSlider_value_changed"] [connection signal="item_selected" from="MoreOptions/Container/List/Target" to="." method="_on_Target_item_selected"] [connection signal="pressed" from="MoreOptions/Container/List/Reset" to="." method="_on_Reset_pressed"] [connection signal="pressed" from="MoreOptions/Container/List/CloseOptions" to="." method="_on_CloseOptions_pressed"] diff --git a/ovr-utils/ui/overlay_list_item.gd b/ovr-utils/ui/overlay_list_item.gd index e0e1e8b..1cce6f6 100644 --- a/ovr-utils/ui/overlay_list_item.gd +++ b/ovr-utils/ui/overlay_list_item.gd @@ -6,6 +6,7 @@ var overlay func _ready() -> void: overlay = OverlayManager.get_node(overlay_name) $MoreOptions/Container/List/SetSize/PanelContainer.visible = false + $MoreOptions/Container/List/SetAlpha/PanelContainer.visible = false $MoreOptions/Container/List/SetSize/PanelContainer/SizeSlider.value = Settings.s.overlays[overlay_name].width $MoreOptions.visible = false $BasicOptions/Label.text = overlay_name @@ -56,5 +57,13 @@ func _on_SetSize_toggled(state: bool) -> void: $MoreOptions/Container/List/SetSize/PanelContainer.visible = state +func _on_SetAlpha_toggled(state: bool) -> void: + $MoreOptions/Container/List/SetAlpha/PanelContainer.visible = state + + func _on_SizeSlider_value_changed(value: float) -> void: overlay.width_meters = value + + +func _on_AlphaSlider_value_changed(value: float) -> void: + overlay.alpha = value