feature/list-object-counter (#60)

Co-authored-by: VAILLANT Jeremy <vaillant.jeremy@dev-crea.com>
Reviewed-on: Athena/game-source#60
Co-authored-by: darknight <vaillant.jeremy@dev-crea.com>
Co-committed-by: darknight <vaillant.jeremy@dev-crea.com>
This commit is contained in:
darknight
2021-05-29 21:09:10 +02:00
parent 80890cbdce
commit ed20465f39
22 changed files with 475 additions and 165 deletions
+35 -7
View File
@@ -1,19 +1,25 @@
extends Node
func _ready():
print("[Settings#_ready]")
_translation()
_apply_translation()
_apply_settings_language()
_apply_settings_gyroscope()
_apply_settings_sound_ambient()
_apply_settings_resolution()
_apply_settings_fullscreen()
## PRIVATE
func _translation():
$VBoxContainer/Langue/HBoxContainer/Label.text = tr("SETTINGS_LABEL_LANGUE")
func _apply_translation():
$VBoxContainer/langue/VBoxContainer/Label.text = tr("SETTINGS_LABEL_LANGUE")
$VBoxContainer/gyroscope/HBoxContainer/Label.text = tr("SETTINGS_LABEL_GYROSCOPE")
func _apply_settings_language():
$VBoxContainer/Langue/HBoxContainer/data.set_text(Global.get_setting_language())
var data = $VBoxContainer/langue/VBoxContainer/data
data.add_item("English", load("res://assets/ui/flags/english.png"), true) # id : 0
data.add_item("Français", load("res://assets/ui/flags/french.png"), true) # id : 1
data.select(Global.get_setting_language())
func _apply_settings_gyroscope():
$VBoxContainer/gyroscope/HBoxContainer/data.set_pressed(Global.get_setting_gyrosocpe())
@@ -21,10 +27,32 @@ func _apply_settings_gyroscope():
func _apply_settings_sound_ambient():
$VBoxContainer/ambient_sound/HBoxContainer/data.set_pressed(Global.get_setting_ambient_sound())
func _apply_settings_resolution():
var data = $VBoxContainer/resolution/VBoxContainer/data
data.add_item("2560 x 1440", null, true) # id : 0
data.add_item("1920 x 1080", null, true) # id : 1
data.add_item("1280 x 720", null, true) # id : 2
data.add_item("854 x 576", null, true) # id : 3
for index in range(4):
if data.get_item_text(index).split(' x ') == Global.get_setting_resolution():
data.select(index)
func _apply_settings_fullscreen():
$VBoxContainer/fullscreen/HBoxContainer/data.set_pressed(Global.get_setting_fullscreen())
func _on_gyroscope_pressed():
print("[Settings#_on_gyroscope_pressed] change value to database ...........")
Global.set_setting_gyroscope(int($VBoxContainer/gyroscope/HBoxContainer/data.pressed))
func _on_ambient_sound_pressed():
print("[Settings#_on_ambient_sound_pressed] change value to database ...........")
Global.set_setting_ambient_sound(int($VBoxContainer/ambient_sound/HBoxContainer/data.pressed))
func _on_langue_item_selected(index):
Global.set_setting_language(index)
func _on_resolution_item_selected(index):
Global.set_setting_resolution($VBoxContainer/resolution/VBoxContainer/data.get_item_text(index))
func _on_fullscreen_item_selected():
Global.set_setting_fullscreen(int($VBoxContainer/fullscreen/HBoxContainer/data.pressed))
+79 -21
View File
@@ -14,38 +14,48 @@ __meta__ = {
[node name="VBoxContainer" type="VBoxContainer" parent="."]
margin_left = 547.0
margin_top = 309.0
margin_top = 265.0
margin_right = 732.0
margin_bottom = 411.0
margin_bottom = 455.0
alignment = 1
[node name="Langue" type="CenterContainer" parent="VBoxContainer"]
[node name="langue" type="CenterContainer" parent="VBoxContainer"]
margin_right = 185.0
margin_bottom = 14.0
margin_bottom = 27.0
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/Langue"]
margin_left = 58.0
margin_right = 127.0
margin_bottom = 14.0
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/langue"]
margin_left = 67.0
margin_right = 117.0
margin_bottom = 27.0
__meta__ = {
"_editor_description_": ""
}
[node name="Label" type="Label" parent="VBoxContainer/Langue/HBoxContainer"]
[node name="Label" type="Label" parent="VBoxContainer/langue/VBoxContainer"]
margin_right = 50.0
margin_bottom = 14.0
text = "langue :"
align = 1
[node name="data" type="Label" parent="VBoxContainer/Langue/HBoxContainer"]
margin_left = 54.0
margin_right = 69.0
margin_bottom = 14.0
text = "FR"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="data" type="ItemList" parent="VBoxContainer/langue/VBoxContainer"]
margin_top = 18.0
margin_right = 50.0
margin_bottom = 27.0
auto_height = true
max_columns = 2
same_column_width = true
fixed_icon_size = Vector2( 32, 32 )
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/langue"]
margin_left = 92.0
margin_top = 13.0
margin_right = 92.0
margin_bottom = 13.0
[node name="gyroscope" type="CenterContainer" parent="VBoxContainer"]
margin_top = 18.0
margin_top = 31.0
margin_right = 185.0
margin_bottom = 58.0
margin_bottom = 71.0
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/gyroscope"]
margin_left = 16.0
@@ -65,9 +75,9 @@ margin_bottom = 40.0
align = 1
[node name="ambient_sound" type="CenterContainer" parent="VBoxContainer"]
margin_top = 62.0
margin_top = 75.0
margin_right = 185.0
margin_bottom = 102.0
margin_bottom = 115.0
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/ambient_sound"]
margin_right = 185.0
@@ -84,5 +94,53 @@ margin_left = 109.0
margin_right = 185.0
margin_bottom = 40.0
[node name="resolution" type="CenterContainer" parent="VBoxContainer"]
margin_top = 119.0
margin_right = 185.0
margin_bottom = 146.0
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/resolution"]
margin_left = 54.0
margin_right = 130.0
margin_bottom = 27.0
[node name="Label" type="Label" parent="VBoxContainer/resolution/VBoxContainer"]
margin_right = 76.0
margin_bottom = 14.0
text = "Resolution :"
[node name="data" type="ItemList" parent="VBoxContainer/resolution/VBoxContainer"]
margin_top = 18.0
margin_right = 76.0
margin_bottom = 27.0
size_flags_horizontal = 3
size_flags_vertical = 3
auto_height = true
same_column_width = true
[node name="fullscreen" type="CenterContainer" parent="VBoxContainer"]
margin_top = 150.0
margin_right = 185.0
margin_bottom = 190.0
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/fullscreen"]
margin_left = 15.0
margin_right = 169.0
margin_bottom = 40.0
[node name="Label" type="Label" parent="VBoxContainer/fullscreen/HBoxContainer"]
margin_top = 13.0
margin_right = 74.0
margin_bottom = 27.0
text = "Fullscreen :"
[node name="data" type="CheckButton" parent="VBoxContainer/fullscreen/HBoxContainer"]
margin_left = 78.0
margin_right = 154.0
margin_bottom = 40.0
[connection signal="item_selected" from="VBoxContainer/langue/VBoxContainer/data" to="." method="_on_langue_item_selected"]
[connection signal="pressed" from="VBoxContainer/gyroscope/HBoxContainer/data" to="." method="_on_gyroscope_pressed"]
[connection signal="pressed" from="VBoxContainer/ambient_sound/HBoxContainer/data" to="." method="_on_ambient_sound_pressed"]
[connection signal="item_selected" from="VBoxContainer/resolution/VBoxContainer/data" to="." method="_on_resolution_item_selected"]
[connection signal="pressed" from="VBoxContainer/fullscreen/HBoxContainer/data" to="." method="_on_fullscreen_item_selected"]