Finishes register form. Saves register data

This commit is contained in:
Dylan Sarrazyn
2024-02-20 16:10:53 +01:00
parent b73eebddc1
commit 0274f251d5
22 changed files with 423 additions and 229 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ var password : Array = []
func _ready():
if UserDataManager.teacher_settings.type == TeacherSettings.Type.Teacher:
if UserDataManager.teacher_settings.account_type == TeacherSettings.AccountType.Teacher:
device_number_label.show()
device_number_label.text += str(UserDataManager.get_device_settings().device_id)
+46 -42
View File
@@ -1,5 +1,8 @@
extends Control
const main_menu_path := "res://sources/menus/main/main_menu.tscn"
const login_menu_path := "res://sources/menus/login/login.tscn"
@onready var teacher_steps : Array[PackedScene] = [
preload("res://sources/menus/register/steps/teacher/method_step.tscn"),
preload("res://sources/menus/register/steps/teacher/devices_count_step.tscn")
@@ -16,24 +19,23 @@ extends Control
var current_steps : Array[Step]
@onready var kalulu := %Kalulu
@onready var register_data := UserSettings.new() # TODO Change the resource
@onready var register_data := TeacherSettings.new()
@onready var progress_bar := %ProgressBar
@onready var steps := %Steps
func _ready():
kalulu.play("Tc_Idle1")
current_steps = [account_type_step.instantiate()]
_go_to_step(progress_bar.value)
func _go_to_step(step_index: int):
# Clear the steps
for step in steps.get_children(false):
step.completed.disconnect(_on_step_completed)
steps.remove_child(step)
if step is Step:
step.back.disconnect(_on_step_back)
step.next.disconnect(_on_step_completed)
steps.remove_child(step)
# Instantiate the step
var next_step = current_steps[step_index]
@@ -42,61 +44,63 @@ func _go_to_step(step_index: int):
steps.add_child(next_step)
# Connect the step
next_step.completed.connect(_on_step_completed)
next_step.back.connect(_on_step_back)
next_step.next.connect(_on_step_completed)
# Handles progress bar
progress_bar.set_value_with_tween(step_index)
func _on_back_button_pressed():
func _on_step_back(_step : Step):
if progress_bar.value == 0:
print("Back to title screen")
get_tree().change_scene_to_file(main_menu_path)
else:
_go_to_step(progress_bar.value-1)
func _on_step_completed(step : Step, values : Dictionary):
func _on_step_completed(step : Step):
match step.step_name:
"type":
# Adds teacher or parent steps
if "type" in values:
_remove_future_steps()
if values["type"] == 0:
for scene in teacher_steps:
current_steps.append(scene.instantiate())
else:
for scene in parent_steps:
current_steps.append(scene.instantiate())
progress_bar.max_value = current_steps.size()
_remove_future_steps()
if register_data.account_type == TeacherSettings.AccountType.Teacher:
for scene in teacher_steps:
current_steps.append(scene.instantiate())
elif register_data.account_type == TeacherSettings.AccountType.Parent:
for scene in parent_steps:
current_steps.append(scene.instantiate())
progress_bar.max_value = current_steps.size()
"devices":
# Adds students steps for teachers
if "devices_count" in values:
_remove_future_steps()
var count = values["devices_count"] as int
if count:
for device in count:
var students_step_scene := students_step.instantiate()
students_step_scene.question = students_step_scene.question % (device + 1)
current_steps.append(students_step_scene)
current_steps.append(credential_step.instantiate())
progress_bar.max_value = current_steps.size()
_remove_future_steps()
for device in register_data.devices_count:
var students_step_scene = students_step.instantiate()
if students_step_scene is StudentsCountStep:
students_step_scene.question = students_step_scene.question % (device + 1)
students_step_scene.device_id = device + 1
current_steps.append(students_step_scene)
else:
students_step_scene.queue_free()
current_steps.append(credential_step.instantiate())
progress_bar.max_value = current_steps.size()
"players":
# Adds students steps for parents
if "students_count" in values:
_remove_future_steps()
var count = values["students_count"] as int
if count:
for student in count:
var student_step_scene := player_step.instantiate()
student_step_scene.question = student_step_scene.question % (student + 1)
current_steps.append(student_step_scene)
current_steps.append(credential_step.instantiate())
progress_bar.max_value = current_steps.size()
_remove_future_steps()
var student_count := 1
for student in register_data.students[1]:
var student_step_scene := player_step.instantiate()
student_step_scene.question = student_step_scene.question % student_count
student_step_scene.data = student
current_steps.append(student_step_scene)
student_count += 1
current_steps.append(credential_step.instantiate())
progress_bar.max_value = current_steps.size()
if progress_bar.value == current_steps.size()-1:
print("Registering complete !")
if UserDataManager.register(register_data):
get_tree().change_scene_to_file(login_menu_path)
else:
print("Impossible to register")
else:
_go_to_step(progress_bar.value+1)
+7 -27
View File
@@ -1,12 +1,9 @@
[gd_scene load_steps=11 format=3 uid="uid://b7cfjs2iipagq"]
[gd_scene load_steps=8 format=3 uid="uid://b7cfjs2iipagq"]
[ext_resource type="Script" path="res://sources/menus/register/register.gd" id="1_jsnxc"]
[ext_resource type="PackedScene" uid="uid://wdjp1sv55q4f" path="res://sources/menus/night_sky/night_sky.tscn" id="2_tirf6"]
[ext_resource type="PackedScene" uid="uid://dxc82xcl7jncd" path="res://sources/menus/main/plants/palm.tscn" id="3_25mko"]
[ext_resource type="PackedScene" uid="uid://dnuny6200v5b0" path="res://sources/kalulu.tscn" id="4_tnnid"]
[ext_resource type="Texture2D" uid="uid://wtx3wqs0l4si" path="res://assets/minigames/minigame_ui/graphic/button_back_up.png" id="5_cac24"]
[ext_resource type="Texture2D" uid="uid://cbhip35yyqneg" path="res://assets/minigames/minigame_ui/graphic/button_back_down.png" id="6_6v5qs"]
[ext_resource type="Texture2D" uid="uid://tcapan0mj64o" path="res://assets/minigames/minigame_ui/graphic/button_back_disabled.png" id="7_hg5ef"]
[ext_resource type="Script" path="res://sources/menus/register/ProgressBar.gd" id="8_h8kqu"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0rcyk"]
@@ -38,39 +35,24 @@ scale = Vector2(2, 2)
[node name="Kalulu" parent="." instance=ExtResource("4_tnnid")]
unique_name_in_owner = true
position = Vector2(231, 1488)
position = Vector2(256, 1320)
animation = &"Tc_Idle1"
[node name="ProgressBarContainer" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 256.0
offset_bottom = 173.0
grow_horizontal = 2
theme_override_constants/margin_left = 25
theme_override_constants/margin_left = 150
theme_override_constants/margin_top = 50
theme_override_constants/margin_right = 231
theme_override_constants/margin_right = 150
theme_override_constants/margin_bottom = 50
[node name="HBoxContainer" type="HBoxContainer" parent="ProgressBarContainer"]
layout_mode = 2
theme_override_constants/separation = 50
[node name="BackButton" type="TextureButton" parent="ProgressBarContainer/HBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(156, 156)
layout_mode = 2
size_flags_horizontal = 0
texture_normal = ExtResource("5_cac24")
texture_pressed = ExtResource("6_6v5qs")
texture_disabled = ExtResource("7_hg5ef")
stretch_mode = 5
[node name="ProgressBar" type="ProgressBar" parent="ProgressBarContainer/HBoxContainer"]
[node name="ProgressBar" type="ProgressBar" parent="ProgressBarContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 4
size_flags_vertical = 1
theme_override_colors/font_color = Color(0, 0, 0, 0)
theme_override_colors/font_outline_color = Color(0, 0, 0, 0)
theme_override_font_sizes/font_size = 50
@@ -89,5 +71,3 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
metadata/_edit_use_anchors_ = true
[connection signal="pressed" from="ProgressBarContainer/HBoxContainer/BackButton" to="." method="_on_back_button_pressed"]
@@ -0,0 +1,10 @@
extends Step
func _on_next() -> bool:
var register_data = data as TeacherSettings
if register_data:
if register_data.account_type == TeacherSettings.AccountType.Parent:
register_data.education_method = TeacherSettings.EducationMethod.AppOnly
else:
return false
return true
@@ -1,7 +1,8 @@
[gd_scene load_steps=8 format=3 uid="uid://c73wkbttv0ou0"]
[gd_scene load_steps=9 format=3 uid="uid://c73wkbttv0ou0"]
[ext_resource type="PackedScene" uid="uid://bxd3i06rqpxf0" path="res://sources/menus/register/steps/base_step.tscn" id="1_g51ml"]
[ext_resource type="Script" path="res://addons/godot-form-validator/control_validator.gd" id="2_hidu6"]
[ext_resource type="Script" path="res://sources/menus/register/steps/account_type_step.gd" id="2_k6524"]
[ext_resource type="Script" path="res://addons/godot-form-validator/rules/required_rule.gd" id="3_54aao"]
[ext_resource type="Script" path="res://sources/menus/register/steps/validation/item_list_validator.gd" id="4_bdvqa"]
[ext_resource type="Script" path="res://sources/utils/binder/control_binder.gd" id="5_w7o0m"]
@@ -18,19 +19,26 @@ skip_validation = false
rules = Array[Resource("res://addons/godot-form-validator/rules/validator_rule.gd")]([SubResource("Resource_kw8sn")])
[node name="AccountTypeStep" instance=ExtResource("1_g51ml")]
script = ExtResource("2_k6524")
step_name = "type"
question = "Choose the type of account"
[node name="TypeContainer" type="VBoxContainer" parent="FormValidator/FormBinder/FormContainer" index="0"]
[node name="BackButton" parent="LeftMargin/LeftContainer" index="0"]
text = "Cancel"
[node name="QuestionLabel" parent="PanelContainer/QuestionContainer" index="0"]
text = "Choose the type of account"
[node name="TypeContainer" type="VBoxContainer" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer" index="0"]
layout_mode = 2
[node name="TypeSelectError" type="Label" parent="FormValidator/FormBinder/FormContainer/TypeContainer" index="0"]
[node name="TypeSelectError" type="Label" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/TypeContainer" index="0"]
visible = false
layout_mode = 2
text = "Test"
vertical_alignment = 1
[node name="TypeSelect" type="ItemList" parent="FormValidator/FormBinder/FormContainer/TypeContainer" index="1"]
[node name="TypeSelect" type="ItemList" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/TypeContainer" index="1"]
layout_mode = 2
theme_override_font_sizes/font_size = 70
auto_height = true
@@ -38,11 +46,11 @@ item_count = 2
item_0/text = "Teacher"
item_1/text = "Parent"
[node name="ControlValidator" type="Node" parent="FormValidator/FormBinder/FormContainer/TypeContainer/TypeSelect" index="1"]
[node name="ControlValidator" type="Node" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/TypeContainer/TypeSelect" index="1"]
script = ExtResource("2_hidu6")
validator = SubResource("Resource_n0ht0")
[node name="ControlBinder" type="Control" parent="FormValidator/FormBinder/FormContainer/TypeContainer/TypeSelect" index="2"]
[node name="ControlBinder" type="Control" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/TypeContainer/TypeSelect" index="2"]
anchors_preset = 0
script = ExtResource("5_w7o0m")
property_name = "type"
property_name = "account_type"
+16 -6
View File
@@ -2,7 +2,8 @@
extends Control
class_name Step
signal completed(step : Step, values : Dictionary)
signal back(step : Step)
signal next(step : Step)
@onready var question_label : Label = %QuestionLabel
@onready var form_validator : FormValidator = %FormValidator
@@ -18,6 +19,13 @@ func _ready():
question_label.text = question
func _on_back() -> bool:
return true
func _on_next() -> bool:
return true
# Display error messages
func _on_form_validator_control_validated(control, passed, messages):
var label = find_child(control.name + "Error", true, false) as Label
@@ -31,11 +39,14 @@ func _on_form_validator_control_validated(control, passed, messages):
label.show()
func _on_back_button_pressed():
if _on_back():
back.emit(self)
func _on_validate_button_pressed():
# Validate the fields
if not form_validator.validate():
print(form_validator._control_validator_map)
print(form_validator.get_messages())
push_warning("Validation failed (" + str(self) + ")")
return
@@ -44,6 +55,5 @@ func _on_validate_button_pressed():
push_warning("Impossible to write data in object (" + str(self) + ")")
return
# Emit completed signal
emit_signal("completed", self, form_binder.values_changed)
if _on_next():
next.emit(self)
+64 -23
View File
@@ -1,8 +1,11 @@
[gd_scene load_steps=4 format=3 uid="uid://bxd3i06rqpxf0"]
[gd_scene load_steps=7 format=3 uid="uid://bxd3i06rqpxf0"]
[ext_resource type="Script" path="res://sources/menus/register/steps/base_step.gd" id="1_02ocl"]
[ext_resource type="Texture2D" uid="uid://d1tsqdom1rra1" path="res://assets/theme/arrow_back.svg" id="2_41tvo"]
[ext_resource type="Script" path="res://addons/godot-form-validator/form_validator.gd" id="2_nw61e"]
[ext_resource type="Texture2D" uid="uid://doql1x228r1bv" path="res://assets/look_and_learn/arrow.svg" id="3_17uns"]
[ext_resource type="Script" path="res://sources/utils/binder/form_binder.gd" id="3_mk32l"]
[ext_resource type="Texture2D" uid="uid://d3rhl050u0ahl" path="res://assets/menus/login/password_background.png" id="4_h32tf"]
[node name="BaseRegisterForm" type="Control"]
layout_mode = 3
@@ -13,6 +16,32 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_02ocl")
[node name="LeftMargin" type="MarginContainer" parent="."]
custom_minimum_size = Vector2(450, 2.08165e-12)
layout_mode = 1
anchors_preset = 9
anchor_bottom = 1.0
offset_right = 240.0
grow_vertical = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 2.0
mouse_filter = 2
theme_override_constants/margin_left = 50
theme_override_constants/margin_top = 50
theme_override_constants/margin_right = 50
theme_override_constants/margin_bottom = 50
[node name="LeftContainer" type="VBoxContainer" parent="LeftMargin"]
layout_mode = 2
mouse_filter = 2
alignment = 2
[node name="BackButton" type="Button" parent="LeftMargin/LeftContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 70
text = "Back"
icon = ExtResource("2_41tvo")
[node name="RightMargin" type="MarginContainer" parent="."]
custom_minimum_size = Vector2(450, 2.08165e-12)
layout_mode = 1
@@ -40,6 +69,8 @@ alignment = 2
layout_mode = 2
theme_override_font_sizes/font_size = 70
text = "Next"
icon = ExtResource("3_17uns")
icon_alignment = 2
[node name="PanelContainer" type="PanelContainer" parent="."]
layout_mode = 1
@@ -66,49 +97,59 @@ horizontal_alignment = 1
vertical_alignment = 1
autowrap_mode = 2
[node name="FormValidator" type="Control" parent="."]
unique_name_in_owner = true
[node name="Background" type="TextureRect" parent="."]
custom_minimum_size = Vector2(1624, 812)
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -20.0
offset_top = -40.0
offset_right = 20.0
offset_left = -812.0
offset_top = -812.0
offset_right = 812.0
grow_horizontal = 2
grow_vertical = 0
texture = ExtResource("4_h32tf")
[node name="FormMargin" type="MarginContainer" parent="Background"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 50
theme_override_constants/margin_top = 50
theme_override_constants/margin_right = 50
theme_override_constants/margin_bottom = 50
[node name="FormValidator" type="Control" parent="Background/FormMargin"]
unique_name_in_owner = true
layout_mode = 2
script = ExtResource("2_nw61e")
[node name="FormBinder" type="Control" parent="FormValidator"]
[node name="FormBinder" type="Control" parent="Background/FormMargin/FormValidator"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 0
grow_vertical = 2
script = ExtResource("3_mk32l")
[node name="FormContainer" type="VBoxContainer" parent="FormValidator/FormBinder"]
[node name="FormContainer" type="VBoxContainer" parent="Background/FormMargin/FormValidator/FormBinder"]
unique_name_in_owner = true
custom_minimum_size = Vector2(812, 812)
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -406.0
offset_top = -812.0
offset_right = 406.0
grow_horizontal = 2
grow_vertical = 0
grow_vertical = 2
theme_override_constants/separation = 20
alignment = 1
[connection signal="pressed" from="LeftMargin/LeftContainer/BackButton" to="." method="_on_back_button_pressed"]
[connection signal="pressed" from="RightMargin/RightContainer/ValidateButton" to="." method="_on_validate_button_pressed"]
[connection signal="control_validated" from="FormValidator" to="." method="_on_form_validator_control_validated"]
[connection signal="control_validated" from="Background/FormMargin/FormValidator" to="." method="_on_form_validator_control_validated"]
@@ -46,53 +46,56 @@ question = "Enter your credentials"
[node name="ValidateButton" parent="RightMargin/RightContainer" index="0"]
text = "Validate"
[node name="EmailContainer" type="VBoxContainer" parent="FormValidator/FormBinder/FormContainer" index="0"]
[node name="QuestionLabel" parent="PanelContainer/QuestionContainer" index="0"]
text = "Enter your credentials"
[node name="EmailContainer" type="VBoxContainer" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer" index="0"]
layout_mode = 2
[node name="EmailFieldError" type="Label" parent="FormValidator/FormBinder/FormContainer/EmailContainer" index="0"]
[node name="EmailFieldError" type="Label" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/EmailContainer" index="0"]
visible = false
layout_mode = 2
vertical_alignment = 1
[node name="EmailField" type="LineEdit" parent="FormValidator/FormBinder/FormContainer/EmailContainer" index="1"]
[node name="EmailField" type="LineEdit" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/EmailContainer" index="1"]
layout_mode = 2
theme_override_font_sizes/font_size = 70
placeholder_text = "Email*"
[node name="ControlValidator" type="Node" parent="FormValidator/FormBinder/FormContainer/EmailContainer/EmailField" index="0"]
[node name="ControlValidator" type="Node" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/EmailContainer/EmailField" index="0"]
script = ExtResource("3_hblcf")
validator = SubResource("Resource_84kj5")
[node name="ControlBinder" type="Control" parent="FormValidator/FormBinder/FormContainer/EmailContainer/EmailField" index="1"]
[node name="ControlBinder" type="Control" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/EmailContainer/EmailField" index="1"]
anchors_preset = 0
script = ExtResource("6_ugvpe")
property_name = "email"
[node name="PasswordContainer" type="VBoxContainer" parent="FormValidator/FormBinder/FormContainer" index="1"]
[node name="PasswordContainer" type="VBoxContainer" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer" index="1"]
layout_mode = 2
theme_override_constants/separation = 20
[node name="PasswordFieldError" type="Label" parent="FormValidator/FormBinder/FormContainer/PasswordContainer" index="0"]
[node name="PasswordFieldError" type="Label" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/PasswordContainer" index="0"]
visible = false
layout_mode = 2
vertical_alignment = 1
[node name="PasswordField" type="LineEdit" parent="FormValidator/FormBinder/FormContainer/PasswordContainer" index="1"]
[node name="PasswordField" type="LineEdit" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/PasswordContainer" index="1"]
layout_mode = 2
theme_override_font_sizes/font_size = 70
placeholder_text = "Password*"
secret = true
[node name="ControlValidator" type="Node" parent="FormValidator/FormBinder/FormContainer/PasswordContainer/PasswordField" index="0"]
[node name="ControlValidator" type="Node" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/PasswordContainer/PasswordField" index="0"]
script = ExtResource("3_hblcf")
validator = SubResource("Resource_icogs")
[node name="ControlBinder" type="Control" parent="FormValidator/FormBinder/FormContainer/PasswordContainer/PasswordField" index="1"]
[node name="ControlBinder" type="Control" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/PasswordContainer/PasswordField" index="1"]
anchors_preset = 0
script = ExtResource("6_ugvpe")
property_name = "password"
[node name="PasswordConfirmField" type="LineEdit" parent="FormValidator/FormBinder/FormContainer/PasswordContainer" index="2"]
[node name="PasswordConfirmField" type="LineEdit" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/PasswordContainer" index="2"]
layout_mode = 2
theme_override_font_sizes/font_size = 70
placeholder_text = "Confirm password*"
@@ -1,10 +1,13 @@
[gd_scene load_steps=8 format=3 uid="uid://dc4eaxcunpmke"]
[gd_scene load_steps=15 format=3 uid="uid://dc4eaxcunpmke"]
[ext_resource type="PackedScene" uid="uid://bxd3i06rqpxf0" path="res://sources/menus/register/steps/base_step.tscn" id="1_ggdon"]
[ext_resource type="Script" path="res://addons/godot-form-validator/control_validator.gd" id="2_6d1eh"]
[ext_resource type="Script" path="res://addons/godot-form-validator/rules/required_rule.gd" id="3_pj58p"]
[ext_resource type="Script" path="res://sources/menus/register/steps/validation/item_list_validator.gd" id="4_fcdvy"]
[ext_resource type="Script" path="res://sources/utils/binder/control_binder.gd" id="5_kb1ut"]
[ext_resource type="Script" path="res://addons/godot-form-validator/rules/length_rule.gd" id="6_qcc6t"]
[ext_resource type="Script" path="res://addons/godot-form-validator/rules/alpha_rule.gd" id="7_0a041"]
[ext_resource type="Script" path="res://addons/godot-form-validator/validators/line_edit_validator.gd" id="7_22xb4"]
[sub_resource type="Resource" id="Resource_kw8sn"]
script = ExtResource("3_pj58p")
@@ -17,22 +20,43 @@ validation_method = 1
skip_validation = false
rules = Array[Resource("res://addons/godot-form-validator/rules/validator_rule.gd")]([SubResource("Resource_kw8sn")])
[sub_resource type="Resource" id="Resource_fybs1"]
script = ExtResource("3_pj58p")
fail_message = "A value is required."
[sub_resource type="Resource" id="Resource_y65lh"]
script = ExtResource("6_qcc6t")
min_length = 2
max_length = 30
fail_message = "Name length must be between 2 and 30 characters"
[sub_resource type="Resource" id="Resource_g77h5"]
script = ExtResource("7_0a041")
fail_message = "Value must contain only alpha characters."
[sub_resource type="Resource" id="Resource_40trb"]
script = ExtResource("7_22xb4")
validation_order = 1
validation_method = 1
skip_validation = false
rules = Array[Resource("res://addons/godot-form-validator/rules/validator_rule.gd")]([SubResource("Resource_fybs1"), SubResource("Resource_y65lh"), SubResource("Resource_g77h5")])
[node name="PlayerStep" instance=ExtResource("1_ggdon")]
question = "Enter the informations of player %d"
[node name="QuestionLabel" parent="PanelContainer/QuestionContainer" index="0"]
text = "Enter the informations of player %d"
[node name="LevelContainer" type="VBoxContainer" parent="FormValidator/FormBinder/FormContainer" index="0"]
[node name="LevelContainer" type="VBoxContainer" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer" index="0"]
layout_mode = 2
[node name="LevelSelectError" type="Label" parent="FormValidator/FormBinder/FormContainer/LevelContainer" index="0"]
[node name="LevelSelectError" type="Label" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/LevelContainer" index="0"]
visible = false
layout_mode = 2
text = "Test"
vertical_alignment = 1
[node name="LevelSelect" type="ItemList" parent="FormValidator/FormBinder/FormContainer/LevelContainer" index="1"]
[node name="LevelSelect" type="ItemList" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/LevelContainer" index="1"]
layout_mode = 2
theme_override_font_sizes/font_size = 70
auto_height = true
@@ -41,21 +65,44 @@ item_0/text = "Beginner"
item_1/text = "Reviewer"
item_2/text = "Adult"
[node name="ControlValidator" type="Node" parent="FormValidator/FormBinder/FormContainer/LevelContainer/LevelSelect" index="1"]
[node name="ControlValidator" type="Node" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/LevelContainer/LevelSelect" index="1"]
script = ExtResource("2_6d1eh")
validator = SubResource("Resource_pdktm")
[node name="ControlBinder" type="Control" parent="FormValidator/FormBinder/FormContainer/LevelContainer/LevelSelect" index="2"]
[node name="ControlBinder" type="Control" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/LevelContainer/LevelSelect" index="2"]
anchors_preset = 0
script = ExtResource("5_kb1ut")
property_name = "level"
[node name="AgeField" type="SpinBox" parent="FormValidator/FormBinder/FormContainer" index="1"]
[node name="NameContainer" type="VBoxContainer" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer" index="1"]
layout_mode = 2
[node name="NameFieldError" type="Label" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/NameContainer" index="0"]
visible = false
layout_mode = 2
[node name="NameField" type="LineEdit" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/NameContainer" index="1"]
layout_mode = 2
theme_override_font_sizes/font_size = 70
placeholder_text = "Name"
[node name="ControlValidator" type="Node" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/NameContainer/NameField" index="0"]
script = ExtResource("2_6d1eh")
validator = SubResource("Resource_40trb")
[node name="ControlBinder" type="Control" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/NameContainer/NameField" index="1"]
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
script = ExtResource("5_kb1ut")
property_name = "name"
[node name="AgeField" type="SpinBox" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer" index="2"]
layout_mode = 2
min_value = 1.0
value = 1.0
[node name="ControlBinder" type="Control" parent="FormValidator/FormBinder/FormContainer/AgeField" index="2"]
[node name="ControlBinder" type="Control" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/AgeField" index="2"]
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
@@ -1,21 +1,8 @@
[gd_scene load_steps=3 format=3 uid="uid://irtjwltfbatm"]
[gd_scene load_steps=2 format=3 uid="uid://irtjwltfbatm"]
[ext_resource type="PackedScene" uid="uid://bxd3i06rqpxf0" path="res://sources/menus/register/steps/base_step.tscn" id="1_nli7s"]
[ext_resource type="Script" path="res://sources/utils/binder/control_binder.gd" id="2_u3nk8"]
[ext_resource type="PackedScene" uid="uid://cyhoa68y1yyyg" path="res://sources/menus/register/steps/teacher/students_count_step.tscn" id="1_6th8p"]
[node name="PlayersCountStep" instance=ExtResource("1_nli7s")]
[node name="PlayersCountStep" instance=ExtResource("1_6th8p")]
device_id = 1
step_name = "players"
question = "Choose the number of players"
[node name="PlayersCountField" type="SpinBox" parent="FormValidator/FormBinder/FormContainer" index="0"]
layout_mode = 2
min_value = 1.0
max_value = 10.0
value = 1.0
[node name="ControlBinder" type="Control" parent="FormValidator/FormBinder/FormContainer/PlayersCountField" index="2"]
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
script = ExtResource("2_u3nk8")
property_name = "students_count"
question = "Choose the number of splayers"
@@ -7,13 +7,16 @@
step_name = "devices"
question = "Choose the number of devices"
[node name="DevicesCountField" type="SpinBox" parent="FormValidator/FormBinder/FormContainer" index="0"]
[node name="QuestionLabel" parent="PanelContainer/QuestionContainer" index="0"]
text = "Choose the number of devices"
[node name="DevicesCountField" type="SpinBox" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer" index="0"]
layout_mode = 2
min_value = 1.0
max_value = 90.0
value = 1.0
[node name="ControlBinder" type="Control" parent="FormValidator/FormBinder/FormContainer/DevicesCountField" index="2"]
[node name="ControlBinder" type="Control" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/DevicesCountField" index="2"]
anchors_preset = 0
script = ExtResource("2_asuou")
property_name = "devices_count"
@@ -18,31 +18,33 @@ skip_validation = false
rules = Array[Resource("res://addons/godot-form-validator/rules/validator_rule.gd")]([SubResource("Resource_kw8sn")])
[node name="MethodStep" instance=ExtResource("1_ksrhk")]
step_name = ""
question = "Choose the education method"
[node name="MethodContainer" type="VBoxContainer" parent="FormValidator/FormBinder/FormContainer" index="0"]
[node name="QuestionLabel" parent="PanelContainer/QuestionContainer" index="0"]
text = "Choose the education method"
[node name="MethodContainer" type="VBoxContainer" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer" index="0"]
layout_mode = 2
[node name="MethodSelectError" type="Label" parent="FormValidator/FormBinder/FormContainer/MethodContainer" index="0"]
[node name="MethodSelectError" type="Label" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/MethodContainer" index="0"]
visible = false
layout_mode = 2
text = "Test"
vertical_alignment = 1
[node name="MethodSelect" type="ItemList" parent="FormValidator/FormBinder/FormContainer/MethodContainer" index="1"]
[node name="MethodSelect" type="ItemList" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/MethodContainer" index="1"]
layout_mode = 2
theme_override_font_sizes/font_size = 70
auto_height = true
item_count = 2
item_0/text = "Complete"
item_1/text = "App Only"
item_0/text = "App Only"
item_1/text = "Complete"
[node name="ControlValidator" type="Node" parent="FormValidator/FormBinder/FormContainer/MethodContainer/MethodSelect" index="1"]
[node name="ControlValidator" type="Node" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/MethodContainer/MethodSelect" index="1"]
script = ExtResource("2_03dua")
validator = SubResource("Resource_ar6ux")
[node name="ControlBinder" type="Control" parent="FormValidator/FormBinder/FormContainer/MethodContainer/MethodSelect" index="2"]
[node name="ControlBinder" type="Control" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer/MethodContainer/MethodSelect" index="2"]
anchors_preset = 0
script = ExtResource("4_1k1yt")
property_name = "method"
property_name = "education_method"
@@ -1,8 +1,28 @@
extends Step
class_name StudentsCountStep
@export var device_id : int
@onready var students_count_field := %StudentsCountField
func _ready():
super._ready()
if data and "devices_count" in data:
students_count_field.min_value = data.devices_count
func _on_back() -> bool:
var register_data = data as TeacherSettings
if register_data:
register_data.students.erase(device_id)
return true
return false
func _on_next() -> bool:
var register_data = data as TeacherSettings
if register_data:
var students : Array[StudentData] = []
for student in students_count_field.value:
var student_data = StudentData.new()
student_data.code = register_data.get_new_code()
if student_data.code:
students.append(student_data)
else:
return false
register_data.students[device_id] = students
return true
return false
@@ -1,22 +1,17 @@
[gd_scene load_steps=4 format=3 uid="uid://cyhoa68y1yyyg"]
[gd_scene load_steps=3 format=3 uid="uid://cyhoa68y1yyyg"]
[ext_resource type="PackedScene" uid="uid://bxd3i06rqpxf0" path="res://sources/menus/register/steps/base_step.tscn" id="1_par6r"]
[ext_resource type="Script" path="res://sources/utils/binder/control_binder.gd" id="2_hpxb0"]
[ext_resource type="Script" path="res://sources/menus/register/steps/teacher/students_count_step.gd" id="2_susi5"]
[node name="StudentsCountStep" instance=ExtResource("1_par6r")]
script = ExtResource("2_susi5")
device_id = 0
step_name = "students"
question = "Choose the number of students on device %d"
[node name="StudentsCountField" type="SpinBox" parent="FormValidator/FormBinder/FormContainer" index="0"]
[node name="StudentsCountField" type="SpinBox" parent="Background/FormMargin/FormValidator/FormBinder/FormContainer" index="0"]
unique_name_in_owner = true
layout_mode = 2
min_value = 1.0
max_value = 90.0
value = 1.0
[node name="ControlBinder" type="Control" parent="FormValidator/FormBinder/FormContainer/StudentsCountField" index="2"]
anchors_preset = 0
script = ExtResource("2_hpxb0")
property_name = "students_count"
+31 -9
View File
@@ -25,6 +25,28 @@ func _ready():
_load_teacher_settings()
func register(register_settings : TeacherSettings) -> bool:
if not register_settings:
return false
print(register_settings)
# TODO Register on the distant server (Nakama ?)
# Handles device settings
var device_settings := get_device_settings()
device_settings.teacher = register_settings.email
device_settings.device_id = 1
_save_device_settings()
# Save the teacher settings on disk
DirAccess.make_dir_recursive_absolute(get_teacher_folder())
teacher_settings = register_settings
_save_teacher_settings()
return true
func login(language : String, teacher : String, password : String, device_id : int) -> bool:
if teacher not in DeviceSettings.possible_logins or password != DeviceSettings.possible_logins[teacher]:
return false
@@ -46,14 +68,15 @@ func login(language : String, teacher : String, password : String, device_id : i
func login_student(code : String) -> bool:
if not _device_settings or not teacher_settings:
return false
for s in teacher_settings.students:
if s.code == code and s.device == _device_settings.device_id:
student = code
return true
var students = teacher_settings.students[_device_settings.device_id] as Array[StudentData]
if students:
for s in students:
if s.code == code:
student = code
return true
return false
@@ -85,10 +108,9 @@ func _load_teacher_settings() -> void:
if FileAccess.file_exists(get_teacher_settings_path()):
teacher_settings = load(get_teacher_settings_path())
if not teacher_settings:
teacher_settings = TeacherSettings.new()
# Default values for now
teacher_settings.setup_students(15, 90)
_save_teacher_settings()
_device_settings.teacher = ""
_device_settings.device_id = 0
_save_device_settings()
func _save_teacher_settings():
+7 -4
View File
@@ -30,13 +30,16 @@ func get_value():
func set_value(value):
print("Writing " + str(value) + " in " + str(self.owner))
if not control:
return
if control is Range:
control.value = float(value)
if value is float:
control.value = value
elif value is int:
control.value = float(value)
elif control is LineEdit or control is TextEdit:
control.text = str(value)
elif control is ItemList:
if value is int:
control.select(value, true)
+2 -6
View File
@@ -4,7 +4,6 @@ class_name FormBinder
@export var data : Resource
var values_changed: Dictionary = {}
var _control_binder_map: Dictionary = {}
func _ready():
@@ -33,10 +32,8 @@ func read(resource : Resource) -> void:
if binder.property_name in data:
var property_value = data.get(binder.property_name)
if typeof(property_value) == typeof(binder.get_value()):
binder.set_value(property_value)
else:
push_warning("Property typing and control doesn't match for property '" + binder.property_name + "' (" + str(binder.control) + ")")
binder.set_value(property_value)
#push_warning("Property typing and control doesn't match for property '" + binder.property_name + "' (" + str(property_value) + ") and " + str(binder.control))
else:
push_warning("Property " + binder.property_name + " not found in " + data.get_class())
@@ -47,7 +44,6 @@ func write() -> bool:
for control in _control_binder_map.keys():
var binder = _control_binder_map[control]
values_changed[binder.property_name] = binder.get_value()
if binder.property_name in data:
data.set(binder.property_name, binder.get_value())
else: