Collapsable options panel

This commit is contained in:
Luke Hubmayer-Werner 2021-01-24 15:30:20 +10:30
parent 224c388915
commit f96f3344aa
3 changed files with 199 additions and 100 deletions

View File

@ -24,7 +24,6 @@ var fps: float = 0.0
func _draw(): func _draw():
set_text('FPS: %.0f' % fps) set_text('FPS: %.0f' % fps)
var last_latency_check := 0.0
func _process(delta): func _process(delta):
fps = Engine.get_frames_per_second() fps = Engine.get_frames_per_second()
update() update()
@ -38,15 +37,17 @@ func _draw():
set_text('Audio Latency: %.2fms' % (audio_latency*1000)) set_text('Audio Latency: %.2fms' % (audio_latency*1000))
var last_latency_check := 0.0 var last_latency_check := 0.0
export var poll_seconds := 5.0
func _process(delta): func _process(delta):
last_latency_check += delta last_latency_check += delta
if last_latency_check > 5.0: if last_latency_check > poll_seconds:
last_latency_check = 0.0 last_latency_check = 0.0
audio_latency = AudioServer.get_output_latency() # Note that on official godot builds this will only work ONCE for PulseAudio audio_latency = AudioServer.get_output_latency() # Note that on official godot builds this will only work ONCE for PulseAudio
update() update()
" "
[node name="OptionPanel" type="VBoxContainer"] [node name="OptionPanel" type="VBoxContainer"]
margin_left = 2.0
margin_right = 269.0 margin_right = 269.0
margin_bottom = 234.0 margin_bottom = 234.0
size_flags_horizontal = 3 size_flags_horizontal = 3
@ -58,7 +59,7 @@ __meta__ = {
} }
[node name="lbl_fps" type="Label" parent="."] [node name="lbl_fps" type="Label" parent="."]
margin_right = 281.0 margin_right = 267.0
margin_bottom = 34.0 margin_bottom = 34.0
custom_fonts/font = SubResource( 3 ) custom_fonts/font = SubResource( 3 )
text = "FPS: " text = "FPS: "
@ -67,22 +68,179 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="lbl_audiolatency" type="Label" parent="."] [node name="PanelContainer" type="PanelContainer" parent="."]
margin_top = 38.0 margin_top = 38.0
margin_right = 281.0 margin_right = 267.0
margin_bottom = 61.0 margin_bottom = 374.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
margin_left = 7.0
margin_top = 7.0
margin_right = 260.0
margin_bottom = 329.0
[node name="cb_qsettings" type="CheckBox" parent="PanelContainer/VBoxContainer"]
margin_right = 253.0
margin_bottom = 31.0
pressed = true
text = "Quick Settings"
[node name="vbox_qsettings" type="VBoxContainer" parent="PanelContainer/VBoxContainer"]
margin_top = 35.0
margin_right = 253.0
margin_bottom = 279.0
[node name="hbox_language" type="HBoxContainer" parent="PanelContainer/VBoxContainer/vbox_qsettings"]
margin_right = 253.0
margin_bottom = 29.0
custom_constants/separation = 12
[node name="lbl_language" type="Label" parent="PanelContainer/VBoxContainer/vbox_qsettings/hbox_language"]
margin_top = 3.0
margin_right = 75.0
margin_bottom = 26.0
text = "Language"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="btn_language" type="OptionButton" parent="PanelContainer/VBoxContainer/vbox_qsettings/hbox_language"]
margin_left = 87.0
margin_right = 253.0
margin_bottom = 29.0
size_flags_horizontal = 3
text = "Native"
align = 1
items = [ "Native", null, false, 0, null, "Romaji", null, false, 1, null, "English", null, false, 2, null ]
selected = 0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="lbl_volume" type="Label" parent="PanelContainer/VBoxContainer/vbox_qsettings"]
margin_top = 33.0
margin_right = 253.0
margin_bottom = 56.0
text = "Main Volume"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="sl_volume" type="HSlider" parent="PanelContainer/VBoxContainer/vbox_qsettings"]
margin_top = 60.0
margin_right = 253.0
margin_bottom = 76.0
min_value = -40.0
max_value = 0.0
tick_count = 9
ticks_on_borders = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="lbl_vol_music" type="Label" parent="PanelContainer/VBoxContainer/vbox_qsettings"]
margin_top = 80.0
margin_right = 253.0
margin_bottom = 103.0
text = "Music Volume"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="sl_vol_music" type="HSlider" parent="PanelContainer/VBoxContainer/vbox_qsettings"]
margin_top = 107.0
margin_right = 253.0
margin_bottom = 123.0
min_value = -20.0
max_value = 0.0
value = -6.0
tick_count = 5
ticks_on_borders = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="lbl_vol_sfx" type="Label" parent="PanelContainer/VBoxContainer/vbox_qsettings"]
margin_top = 127.0
margin_right = 253.0
margin_bottom = 150.0
text = "Feedback Volume"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="sl_vol_sfx" type="HSlider" parent="PanelContainer/VBoxContainer/vbox_qsettings"]
margin_top = 154.0
margin_right = 253.0
margin_bottom = 170.0
min_value = -40.0
max_value = 0.0
tick_count = 9
ticks_on_borders = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="lbl_screenfilter" type="Label" parent="PanelContainer/VBoxContainer/vbox_qsettings"]
margin_top = 174.0
margin_right = 253.0
margin_bottom = 197.0
text = "Background Video Darkening"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="sl_screenfilter" type="HSlider" parent="PanelContainer/VBoxContainer/vbox_qsettings"]
margin_top = 201.0
margin_right = 253.0
margin_bottom = 217.0
max_value = 1.0
step = 0.02
value = 0.2
tick_count = 11
ticks_on_borders = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="lbl_audiolatency" type="Label" parent="PanelContainer/VBoxContainer/vbox_qsettings"]
margin_top = 221.0
margin_right = 253.0
margin_bottom = 244.0
text = "Audio Latency: " text = "Audio Latency: "
script = SubResource( 5 ) script = SubResource( 5 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="HBoxContainer" type="HBoxContainer" parent="."] [node name="HSeparator" type="HSeparator" parent="PanelContainer/VBoxContainer"]
margin_top = 65.0 margin_top = 283.0
margin_right = 281.0 margin_right = 253.0
margin_bottom = 105.0 margin_bottom = 287.0
[node name="btn_vsync" type="CheckButton" parent="HBoxContainer"] [node name="cb_graphics" type="CheckBox" parent="PanelContainer/VBoxContainer"]
margin_top = 291.0
margin_right = 253.0
margin_bottom = 322.0
text = "Graphics"
[node name="vbox_graphics" type="VBoxContainer" parent="PanelContainer/VBoxContainer"]
visible = false
margin_top = 326.0
margin_right = 281.0
margin_bottom = 433.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="hbox" type="HBoxContainer" parent="PanelContainer/VBoxContainer/vbox_graphics"]
margin_right = 281.0
margin_bottom = 40.0
[node name="btn_vsync" type="CheckButton" parent="PanelContainer/VBoxContainer/vbox_graphics/hbox"]
margin_right = 124.0 margin_right = 124.0
margin_bottom = 40.0 margin_bottom = 40.0
pressed = true pressed = true
@ -91,7 +249,7 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="btn_wakelock" type="CheckButton" parent="HBoxContainer"] [node name="btn_wakelock" type="CheckButton" parent="PanelContainer/VBoxContainer/vbox_graphics/hbox"]
margin_left = 128.0 margin_left = 128.0
margin_right = 281.0 margin_right = 281.0
margin_bottom = 40.0 margin_bottom = 40.0
@ -101,20 +259,20 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="lbl_subsampling" type="Label" parent="."] [node name="lbl_subsampling" type="Label" parent="PanelContainer/VBoxContainer/vbox_graphics"]
margin_top = 109.0 margin_top = 44.0
margin_right = 281.0 margin_right = 281.0
margin_bottom = 132.0 margin_bottom = 67.0
size_flags_vertical = 0 size_flags_vertical = 0
text = "Subsampling (X, Y)" text = "Subsampling (X, Y)"
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="sl_SSX" type="HSlider" parent="."] [node name="sl_SSX" type="HSlider" parent="PanelContainer/VBoxContainer/vbox_graphics"]
margin_top = 136.0 margin_top = 71.0
margin_right = 281.0 margin_right = 281.0
margin_bottom = 152.0 margin_bottom = 87.0
size_flags_vertical = 1 size_flags_vertical = 1
min_value = 0.1 min_value = 0.1
max_value = 1.0 max_value = 1.0
@ -126,10 +284,10 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="sl_SSY" type="HSlider" parent="."] [node name="sl_SSY" type="HSlider" parent="PanelContainer/VBoxContainer/vbox_graphics"]
margin_top = 156.0 margin_top = 91.0
margin_right = 281.0 margin_right = 281.0
margin_bottom = 172.0 margin_bottom = 107.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
size_flags_vertical = 1 size_flags_vertical = 1
@ -143,79 +301,14 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="lbl_screenfilter" type="Label" parent="."] [connection signal="toggled" from="PanelContainer/VBoxContainer/cb_qsettings" to="PanelContainer/VBoxContainer/vbox_qsettings" method="set_visible"]
margin_top = 176.0 [connection signal="item_selected" from="PanelContainer/VBoxContainer/vbox_qsettings/hbox_language/btn_language" to="." method="_on_btn_language_item_selected"]
margin_right = 281.0 [connection signal="value_changed" from="PanelContainer/VBoxContainer/vbox_qsettings/sl_volume" to="." method="_on_sl_volume_value_changed"]
margin_bottom = 199.0 [connection signal="value_changed" from="PanelContainer/VBoxContainer/vbox_qsettings/sl_vol_music" to="." method="_on_sl_vol_music_value_changed"]
text = "Screen Filter Opacity" [connection signal="value_changed" from="PanelContainer/VBoxContainer/vbox_qsettings/sl_vol_sfx" to="." method="_on_sl_vol_sfx_value_changed"]
__meta__ = { [connection signal="value_changed" from="PanelContainer/VBoxContainer/vbox_qsettings/sl_screenfilter" to="." method="_on_sl_screenfilter_value_changed"]
"_edit_use_anchors_": false [connection signal="toggled" from="PanelContainer/VBoxContainer/cb_graphics" to="PanelContainer/VBoxContainer/vbox_graphics" method="set_visible"]
} [connection signal="toggled" from="PanelContainer/VBoxContainer/vbox_graphics/hbox/btn_vsync" to="." method="_on_btn_vsync_toggled"]
[connection signal="toggled" from="PanelContainer/VBoxContainer/vbox_graphics/hbox/btn_wakelock" to="." method="_on_btn_wakelock_toggled"]
[node name="sl_screenfilter" type="HSlider" parent="."] [connection signal="value_changed" from="PanelContainer/VBoxContainer/vbox_graphics/sl_SSX" to="." method="_on_sl_SSX_value_changed"]
margin_top = 203.0 [connection signal="value_changed" from="PanelContainer/VBoxContainer/vbox_graphics/sl_SSY" to="." method="_on_sl_SSY_value_changed"]
margin_right = 281.0
margin_bottom = 219.0
max_value = 1.0
step = 0.01
value = 0.2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="lbl_volume" type="Label" parent="."]
margin_top = 223.0
margin_right = 281.0
margin_bottom = 246.0
text = "Main Volume"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="sl_volume" type="HSlider" parent="."]
margin_top = 250.0
margin_right = 281.0
margin_bottom = 266.0
min_value = -40.0
max_value = 0.0
tick_count = 9
ticks_on_borders = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="hbox_language" type="HBoxContainer" parent="."]
margin_top = 270.0
margin_right = 281.0
margin_bottom = 299.0
custom_constants/separation = 12
[node name="lbl_language" type="Label" parent="hbox_language"]
margin_top = 3.0
margin_right = 75.0
margin_bottom = 26.0
text = "Language"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="btn_language" type="OptionButton" parent="hbox_language"]
margin_left = 87.0
margin_right = 281.0
margin_bottom = 29.0
size_flags_horizontal = 3
text = "Native"
align = 1
items = [ "Native", null, false, 0, null, "Romaji", null, false, 1, null, "English", null, false, 2, null ]
selected = 0
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="toggled" from="HBoxContainer/btn_vsync" to="." method="_on_btn_vsync_toggled"]
[connection signal="toggled" from="HBoxContainer/btn_wakelock" to="." method="_on_btn_wakelock_toggled"]
[connection signal="value_changed" from="sl_SSX" to="." method="_on_sl_SSX_value_changed"]
[connection signal="value_changed" from="sl_SSY" to="." method="_on_sl_SSY_value_changed"]
[connection signal="value_changed" from="sl_screenfilter" to="." method="_on_sl_screenfilter_value_changed"]
[connection signal="value_changed" from="sl_volume" to="." method="_on_sl_volume_value_changed"]
[connection signal="item_selected" from="hbox_language/btn_language" to="." method="_on_btn_language_item_selected"]

View File

@ -7,7 +7,7 @@ bus/1/mute = false
bus/1/bypass_fx = false bus/1/bypass_fx = false
bus/1/volume_db = -6.0 bus/1/volume_db = -6.0
bus/1/send = "Master" bus/1/send = "Master"
bus/2/name = "Hits" bus/2/name = "Effects"
bus/2/solo = false bus/2/solo = false
bus/2/mute = false bus/2/mute = false
bus/2/bypass_fx = false bus/2/bypass_fx = false

View File

@ -12,6 +12,12 @@ func _on_btn_language_item_selected(index: int) -> void:
func _on_sl_volume_value_changed(value: float) -> void: func _on_sl_volume_value_changed(value: float) -> void:
AudioServer.set_bus_volume_db(0, value) AudioServer.set_bus_volume_db(0, value)
func _on_sl_vol_music_value_changed(value: float) -> void:
AudioServer.set_bus_volume_db(1, value)
func _on_sl_vol_sfx_value_changed(value: float) -> void:
AudioServer.set_bus_volume_db(2, value)
func _on_sl_screenfilter_value_changed(value: float) -> void: func _on_sl_screenfilter_value_changed(value: float) -> void:
GameTheme.screen_filter_min_alpha = value GameTheme.screen_filter_min_alpha = value