Add sound volume management and language selection

Not all translated yet though
This commit is contained in:
Julian Murgia
2021-06-01 07:35:50 +02:00
parent 909031f536
commit 5d1df7aaa9
19 changed files with 310 additions and 60 deletions

View File

@@ -1,6 +1,6 @@
:look
> [! dialog_popup_advance]
say player ROOM1_look_wall_item_1"I don't know what that stuff is." dialog_box_inset
say player ROOM1_look_wall_item_1:"I don't know what that stuff is." dialog_box_inset
set_global dialog_popup_advance 1
stop
> [eq dialog_popup_advance 1]

View File

@@ -1,4 +1,6 @@
:use r9_bottle
inventory_remove r9_bottle
set_state r9_stand set_bottle
set_state r9_r_exit r_door_open

View File

@@ -5,3 +5,6 @@ OPTIONS,Options,Options
QUIT,Quit,Quitter
OPTIONS_BACK,Back,Retour
OPTIONS_LANGUAGE,Language,Langue
GENERAL_VOLUME,General,Général
MUSIC_VOLUME,Music,Musique
SOUND_VOLUME,Sound effects,Effets sonores
1 keys en fr
5 QUIT Quit Quitter
6 OPTIONS_BACK Back Retour
7 OPTIONS_LANGUAGE Language Langue
8 GENERAL_VOLUME General Général
9 MUSIC_VOLUME Music Musique
10 SOUND_VOLUME Sound effects Effets sonores

View File

@@ -1,7 +1,12 @@
extends Control
func _ready():
var locale = TranslationServer.get_locale()
initialize_options(escoria.settings)
func initialize_options(p_settings):
$options/general_volume.value = p_settings["master_volume"]
$options/sound_volume.value = p_settings["sfx_volume"]
$options/music_volume.value = p_settings["music_volume"]
func greyout_other_languages(except_lang : String) -> void:
pass
@@ -9,3 +14,22 @@ func greyout_other_languages(except_lang : String) -> void:
func _on_language_input(event : InputEvent, language : String):
if event.is_pressed():
TranslationServer.set_locale(language)
escoria.settings["text_lang"] = language
escoria.esc_runner.save_data.save_settings(escoria.settings, null)
func _on_sound_volume_changed(value):
escoria.settings["sfx_volume"] = value
escoria.esc_runner.save_data.save_settings(escoria.settings, null)
escoria._on_settings_loaded(escoria.settings)
func _on_music_volume_changed(value):
escoria.settings["music_volume"] = value
escoria.esc_runner.save_data.save_settings(escoria.settings, null)
escoria._on_settings_loaded(escoria.settings)
func _on_general_volume_changed(value):
escoria.settings["master_volume"] = value
escoria.esc_runner.save_data.save_settings(escoria.settings, null)
escoria._on_settings_loaded(escoria.settings)

View File

@@ -24,52 +24,109 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="options_grid" type="GridContainer" parent="."]
anchor_left = 0.217
anchor_top = 0.427
anchor_right = 0.803
anchor_bottom = 0.574
margin_left = 0.23999
margin_top = -0.300018
margin_right = 17.1599
margin_bottom = 0.400024
custom_constants/hseparation = 167
[node name="options" type="GridContainer" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -275.5
margin_top = -75.0
margin_right = 275.5
margin_bottom = 75.0
custom_constants/hseparation = 40
columns = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="options_language" type="Label" parent="options_grid"]
margin_top = 56.0
[node name="label" type="Label" parent="options"]
margin_top = 27.0
margin_right = 220.0
margin_bottom = 77.0
margin_bottom = 48.0
custom_fonts/font = ExtResource( 1 )
text = "OPTIONS_LANGUAGE"
[node name="flags" type="HBoxContainer" parent="options_grid"]
margin_left = 387.0
margin_right = 767.0
margin_bottom = 133.0
[node name="flags" type="HBoxContainer" parent="options"]
margin_left = 260.0
margin_right = 553.0
margin_bottom = 75.0
size_flags_vertical = 3
custom_constants/separation = 30
alignment = 1
[node name="fr_FR" type="TextureRect" parent="options_grid/flags"]
margin_right = 150.0
margin_bottom = 133.0
[node name="fr" type="TextureRect" parent="options/flags"]
margin_right = 113.0
margin_bottom = 75.0
texture = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="en_EN" type="TextureRect" parent="options_grid/flags"]
margin_left = 180.0
margin_right = 380.0
margin_bottom = 133.0
[node name="en" type="TextureRect" parent="options/flags"]
margin_left = 143.0
margin_right = 293.0
margin_bottom = 75.0
texture = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="gui_input" from="options_grid/flags/fr_FR" to="." method="_on_language_input" binds= [ "fr_FR" ]]
[connection signal="gui_input" from="options_grid/flags/en_EN" to="." method="_on_language_input" binds= [ "en_EN" ]]
[node name="label2" type="Label" parent="options"]
margin_top = 79.0
margin_right = 220.0
margin_bottom = 100.0
custom_fonts/font = ExtResource( 1 )
text = "GENERAL_VOLUME"
[node name="general_volume" type="HSlider" parent="options"]
margin_left = 260.0
margin_top = 79.0
margin_right = 553.0
margin_bottom = 95.0
size_flags_horizontal = 3
min_value = 0.001
max_value = 1.0
step = 0.001
value = 0.001
[node name="label3" type="Label" parent="options"]
margin_top = 104.0
margin_right = 220.0
margin_bottom = 125.0
custom_fonts/font = ExtResource( 1 )
text = "SOUND_VOLUME"
[node name="sound_volume" type="HSlider" parent="options"]
margin_left = 260.0
margin_top = 104.0
margin_right = 553.0
margin_bottom = 120.0
size_flags_horizontal = 3
min_value = 0.001
max_value = 1.0
step = 0.001
value = 0.001
[node name="label4" type="Label" parent="options"]
margin_top = 129.0
margin_right = 220.0
margin_bottom = 150.0
custom_fonts/font = ExtResource( 1 )
text = "MUSIC_VOLUME"
[node name="music_volume" type="HSlider" parent="options"]
margin_left = 260.0
margin_top = 129.0
margin_right = 553.0
margin_bottom = 145.0
size_flags_horizontal = 3
min_value = 0.001
max_value = 1.0
step = 0.001
value = 0.001
[connection signal="gui_input" from="options/flags/fr" to="." method="_on_language_input" binds= [ "fr" ]]
[connection signal="gui_input" from="options/flags/en" to="." method="_on_language_input" binds= [ "en" ]]
[connection signal="value_changed" from="options/general_volume" to="." method="_on_general_volume_changed"]
[connection signal="value_changed" from="options/sound_volume" to="." method="_on_sound_volume_changed"]
[connection signal="value_changed" from="options/music_volume" to="." method="_on_music_volume_changed"]

View File

@@ -98,7 +98,7 @@ script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
items_container = NodePath("inventory_button/panel/MarginContainer/ScrollContainer/container")
inventory_ui_container = NodePath("inventory_button/panel/MarginContainer/ScrollContainer/container")
[node name="ESCORIA_ALL_ITEMS" parent="." instance=ExtResource( 7 )]
position = Vector2( 269.391, 275.003 )