add alpha setting

This commit is contained in:
Crispy 2021-06-06 13:05:13 +02:00
parent 74f7caed5d
commit 381be25af0
6 changed files with 104 additions and 10 deletions

View file

@ -1,6 +1,7 @@
extends Spatial extends Spatial
signal width_changed signal width_changed
signal alpha_changed
signal offset_changed signal offset_changed
signal target_changed signal target_changed
signal overlay_visibility_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 = \ export var overlay_scene: PackedScene = \
preload("res://addons/openvr_overlay/MissingOverlay.tscn") setget set_overlay_scene preload("res://addons/openvr_overlay/MissingOverlay.tscn") setget set_overlay_scene
export var width_meters := 0.4 setget set_width_in_meters 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_grabbing := true # add grabbing module
export var add_cursor := false # add cursor module export var add_cursor := false # add cursor module
@ -80,6 +82,8 @@ func load_settings():
update_offset() update_offset()
if loaded.has("visible"): if loaded.has("visible"):
set_overlay_visible(loaded.visible) set_overlay_visible(loaded.visible)
if loaded.has("alpha"):
set_alpha(loaded.alpha)
else: else:
save_settings() save_settings()
@ -89,6 +93,7 @@ func save_settings():
Settings.s.overlays[name] = {} Settings.s.overlays[name] = {}
Settings.s.overlays[name].target = target Settings.s.overlays[name].target = target
Settings.s.overlays[name].width = width_meters Settings.s.overlays[name].width = width_meters
Settings.s.overlays[name].alpha = alpha
Settings.s.overlays[name].fallback = fallback Settings.s.overlays[name].fallback = fallback
Settings.s.overlays[name].type = type Settings.s.overlays[name].type = type
@ -191,6 +196,12 @@ func set_overlay_scene(scene: PackedScene) -> void:
container.add_child(overlay_scene.instance()) 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: func reset_offset() -> void:
_offsets[current_target].rot = Quat() _offsets[current_target].rot = Quat()
_offsets[current_target].pos = Vector3() _offsets[current_target].pos = Vector3()

View file

@ -30,6 +30,11 @@ const DEF = {
"type": "number", "type": "number",
"default": 0.4 "default": 0.4
}, },
"alpha": {
"name": "Alpha",
"type": "number",
"default": 1.0
},
"target": { "target": {
"name": "Tracking target", "name": "Tracking target",
"type": "string", "type": "string",
@ -68,6 +73,7 @@ const DEF = {
"type": "MainOverlay", "type": "MainOverlay",
"visible": true, "visible": true,
"width": 0.4, "width": 0.4,
"alpha": 1.0,
"target": "left", "target": "left",
"fallback": ["left", "right", "head"], "fallback": ["left", "right", "head"],
"offsets": { "offsets": {

View file

@ -0,0 +1 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#e0e0e0" fill-rule="evenodd"><path d="m7.9998 2c-2.5567 0-5.7907 1.9477-6.9551 5.7051a1.0001 1.0001 0 0 0 -.00586.5703c1.1244 3.9354 4.4609 5.7246 6.9609 5.7246s5.8365-1.7892 6.9609-5.7246a1.0001 1.0001 0 0 0 0-.5527c-1.1003-3.7876-4.4066-5.7227-6.9609-5.7227zm0 2a4 4 0 0 1 4 4 4 4 0 0 1 -4 4 4 4 0 0 1 -4-4 4 4 0 0 1 4-4zm0 2a2 2 0 0 0 -2 2 2 2 0 0 0 2 2 2 2 0 0 0 2-2 2 2 0 0 0 -2-2z" fill-opacity=".39216"/><path d="m8 2c-2.5567 0-5.7907 1.9477-6.9551 5.7051a1.0001 1.0001 0 0 0 -.00586.57031c1.1244 3.9354 4.4609 5.7246 6.9609 5.7246v-2a4 4 0 0 1 -4-4 4 4 0 0 1 4-4zm0 4a2 2 0 0 0 -2 2 2 2 0 0 0 2 2z" fill-opacity=".99608"/></g></svg>

After

Width:  |  Height:  |  Size: 733 B

View file

@ -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

View file

@ -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://ui/overlay_list_item.gd" type="Script" id=1]
[ext_resource path="res://icons/remove.svg" type="Texture" id=2] [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://styles/menu.theme" type="Theme" id=9]
[ext_resource path="res://icons/list.svg" type="Texture" id=10] [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/close.svg" type="Texture" id=11]
[ext_resource path="res://icons/alpha.svg" type="Texture" id=12]
[node name="ListOverlayItem" type="MarginContainer"] [node name="ListOverlayItem" type="MarginContainer"]
margin_top = 1727.0 margin_top = 1727.0
@ -83,19 +84,19 @@ margin_right = 2040.0
margin_bottom = 215.0 margin_bottom = 215.0
[node name="Spacer" type="Control" parent="MoreOptions"] [node name="Spacer" type="Control" parent="MoreOptions"]
margin_right = 1104.0 margin_right = 924.0
margin_bottom = 207.0 margin_bottom = 207.0
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="Container" type="PanelContainer" parent="MoreOptions"] [node name="Container" type="PanelContainer" parent="MoreOptions"]
margin_left = 1116.0 margin_left = 936.0
margin_right = 2032.0 margin_right = 2032.0
margin_bottom = 207.0 margin_bottom = 207.0
[node name="List" type="HBoxContainer" parent="MoreOptions/Container"] [node name="List" type="HBoxContainer" parent="MoreOptions/Container"]
margin_left = 8.0 margin_left = 8.0
margin_top = 8.0 margin_top = 8.0
margin_right = 908.0 margin_right = 1088.0
margin_bottom = 199.0 margin_bottom = 199.0
alignment = 2 alignment = 2
@ -134,9 +135,39 @@ __meta__ = {
"_edit_use_anchors_": false "_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_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 margin_bottom = 191.0
text = "Left" text = "Left"
icon = ExtResource( 6 ) icon = ExtResource( 6 )
@ -145,14 +176,14 @@ items = [ "Head", ExtResource( 7 ), false, 0, null, "Left", ExtResource( 6 ), fa
selected = 1 selected = 1
[node name="Reset" type="Button" parent="MoreOptions/Container/List"] [node name="Reset" type="Button" parent="MoreOptions/Container/List"]
margin_left = 544.0 margin_left = 724.0
margin_right = 720.0 margin_right = 900.0
margin_bottom = 191.0 margin_bottom = 191.0
icon = ExtResource( 5 ) icon = ExtResource( 5 )
[node name="CloseOptions" type="Button" parent="MoreOptions/Container/List"] [node name="CloseOptions" type="Button" parent="MoreOptions/Container/List"]
margin_left = 724.0 margin_left = 904.0
margin_right = 900.0 margin_right = 1080.0
margin_bottom = 191.0 margin_bottom = 191.0
icon = ExtResource( 11 ) 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="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="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="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="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/Reset" to="." method="_on_Reset_pressed"]
[connection signal="pressed" from="MoreOptions/Container/List/CloseOptions" to="." method="_on_CloseOptions_pressed"] [connection signal="pressed" from="MoreOptions/Container/List/CloseOptions" to="." method="_on_CloseOptions_pressed"]

View file

@ -6,6 +6,7 @@ var overlay
func _ready() -> void: func _ready() -> void:
overlay = OverlayManager.get_node(overlay_name) overlay = OverlayManager.get_node(overlay_name)
$MoreOptions/Container/List/SetSize/PanelContainer.visible = false $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/Container/List/SetSize/PanelContainer/SizeSlider.value = Settings.s.overlays[overlay_name].width
$MoreOptions.visible = false $MoreOptions.visible = false
$BasicOptions/Label.text = overlay_name $BasicOptions/Label.text = overlay_name
@ -56,5 +57,13 @@ func _on_SetSize_toggled(state: bool) -> void:
$MoreOptions/Container/List/SetSize/PanelContainer.visible = state $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: func _on_SizeSlider_value_changed(value: float) -> void:
overlay.width_meters = value overlay.width_meters = value
func _on_AlphaSlider_value_changed(value: float) -> void:
overlay.alpha = value