Configure gyroscope and settings
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
onready var language_id = null
|
||||||
|
onready var gyroscope_id = null
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
print("[Settings#_ready]")
|
||||||
|
_translation()
|
||||||
|
_apply_settings()
|
||||||
|
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
func _translation():
|
||||||
|
print("[Settings#_translation]")
|
||||||
|
$CenterContainer/VBoxContainer/Langue/HBoxContainer/Label.text = tr("SETTINGS_LABEL_LANGUE")
|
||||||
|
$CenterContainer/VBoxContainer/gyroscope/HBoxContainer/Label.text = tr("SETTINGS_LABEL_GYROSCOPE")
|
||||||
|
|
||||||
|
func _apply_settings():
|
||||||
|
print("[Settings#_apply_settings]")
|
||||||
|
var lang = _get_settings_data("langue", Global.table_settings, Global.data_settings)
|
||||||
|
var gyro = _get_settings_data("gyroscope", Global.table_settings, Global.data_settings)
|
||||||
|
|
||||||
|
$CenterContainer/VBoxContainer/Langue/HBoxContainer/data.set_text(lang)
|
||||||
|
$CenterContainer/VBoxContainer/gyroscope/HBoxContainer/data.set_pressed(int(gyro) as bool)
|
||||||
|
|
||||||
|
func _get_settings_data(name, table, datas):
|
||||||
|
for index in range(0, Global.table_settings.get_props_count()):
|
||||||
|
if table.get_prop_at(index).get_prop_name() == name:
|
||||||
|
_save_id(name, table.get_prop_at(index).get_prop_id())
|
||||||
|
return datas[index].get_data()
|
||||||
|
|
||||||
|
func _save_id(name, id):
|
||||||
|
if name == "langue":
|
||||||
|
language_id = id
|
||||||
|
if name == "gyroscope":
|
||||||
|
gyroscope_id = id
|
||||||
|
|
||||||
|
func _on_gyroscope_pressed():
|
||||||
|
print("[Settings#_on_gyroscop_toggled] change value to database ...........")
|
||||||
|
Global.table_settings.edit_data(gyroscope_id,
|
||||||
|
gddb_types.e_prop_type_bool,
|
||||||
|
int($CenterContainer/VBoxContainer/gyroscope/HBoxContainer/data.pressed) as String)
|
||||||
|
Global.database.save_db()
|
||||||
+42
-30
@@ -1,18 +1,12 @@
|
|||||||
[gd_scene load_steps=2 format=2]
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
[sub_resource type="GDScript" id=1]
|
[ext_resource path="res://scenes/UI/Settings.gd" type="Script" id=1]
|
||||||
script/source = "extends Node
|
|
||||||
|
|
||||||
func _ready():
|
[node name="Settings" type="Control"]
|
||||||
$CenterContainer/VBoxContainer/Langue/Label.text = tr(\"SETTINGS_LABEL_LANGUE\")
|
script = ExtResource( 1 )
|
||||||
$CenterContainer/VBoxContainer/gyroscope/Label.text = tr(\"SETTINGS_LABEL_GYROSCOPE\")
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
func _on_Gyroscope_pressed():
|
}
|
||||||
print(\"[Settings#_on_Gyroscope_pressed]\")
|
|
||||||
"
|
|
||||||
|
|
||||||
[node name="About" type="Node"]
|
|
||||||
script = SubResource( 1 )
|
|
||||||
|
|
||||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||||
margin_left = 150.0
|
margin_left = 150.0
|
||||||
@@ -23,36 +17,54 @@ __meta__ = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
|
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
|
||||||
margin_left = 400.0
|
margin_left = 360.0
|
||||||
margin_top = 284.0
|
margin_top = 271.0
|
||||||
margin_right = 473.0
|
margin_right = 513.0
|
||||||
margin_bottom = 316.0
|
margin_bottom = 329.0
|
||||||
alignment = 1
|
alignment = 1
|
||||||
|
|
||||||
[node name="Langue" type="CenterContainer" parent="CenterContainer/VBoxContainer"]
|
[node name="Langue" type="CenterContainer" parent="CenterContainer/VBoxContainer"]
|
||||||
margin_right = 73.0
|
margin_right = 153.0
|
||||||
margin_bottom = 14.0
|
margin_bottom = 14.0
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="CenterContainer/VBoxContainer/Langue"]
|
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer/Langue"]
|
||||||
margin_left = 11.0
|
margin_left = 42.0
|
||||||
margin_right = 61.0
|
margin_right = 111.0
|
||||||
|
margin_bottom = 14.0
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="CenterContainer/VBoxContainer/Langue/HBoxContainer"]
|
||||||
|
margin_right = 50.0
|
||||||
margin_bottom = 14.0
|
margin_bottom = 14.0
|
||||||
text = "langue :"
|
text = "langue :"
|
||||||
|
|
||||||
|
[node name="data" type="Label" parent="CenterContainer/VBoxContainer/Langue/HBoxContainer"]
|
||||||
|
margin_left = 54.0
|
||||||
|
margin_right = 69.0
|
||||||
|
margin_bottom = 14.0
|
||||||
|
text = "FR"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
[node name="gyroscope" type="CenterContainer" parent="CenterContainer/VBoxContainer"]
|
[node name="gyroscope" type="CenterContainer" parent="CenterContainer/VBoxContainer"]
|
||||||
margin_top = 18.0
|
margin_top = 18.0
|
||||||
margin_right = 73.0
|
margin_right = 153.0
|
||||||
margin_bottom = 32.0
|
margin_bottom = 58.0
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="CenterContainer/VBoxContainer/gyroscope"]
|
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer/gyroscope"]
|
||||||
|
margin_right = 153.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="CenterContainer/VBoxContainer/gyroscope/HBoxContainer"]
|
||||||
|
margin_top = 13.0
|
||||||
margin_right = 73.0
|
margin_right = 73.0
|
||||||
margin_bottom = 14.0
|
margin_bottom = 27.0
|
||||||
text = "gyroscope :"
|
text = "gyroscope :"
|
||||||
|
|
||||||
[node name="TextureButton" type="TextureButton" parent="CenterContainer/VBoxContainer/gyroscope"]
|
[node name="data" type="CheckButton" parent="CenterContainer/VBoxContainer/gyroscope/HBoxContainer"]
|
||||||
margin_left = 36.0
|
margin_left = 77.0
|
||||||
margin_top = 7.0
|
margin_right = 153.0
|
||||||
margin_right = 36.0
|
margin_bottom = 40.0
|
||||||
margin_bottom = 7.0
|
align = 1
|
||||||
|
|
||||||
[connection signal="pressed" from="CenterContainer/VBoxContainer/gyroscope/TextureButton" to="." method="_on_Gyroscope_pressed"]
|
[connection signal="pressed" from="CenterContainer/VBoxContainer/gyroscope/HBoxContainer/data" to="." method="_on_gyroscope_pressed"]
|
||||||
|
|||||||
Reference in New Issue
Block a user