Adds login form.

This commit is contained in:
Dylan Sarrazyn
2024-01-30 12:16:48 +01:00
parent 87eb64cda9
commit 67bffff2bd
9 changed files with 302 additions and 73 deletions
-17
View File
@@ -1,17 +0,0 @@
[gd_resource type="FontFile" format=3 uid="uid://chvjcf6ahlxx0"]
[resource]
cache/0/42/0/ascent = 0.0
cache/0/42/0/descent = 0.0
cache/0/42/0/underline_position = 0.0
cache/0/42/0/underline_thickness = 0.0
cache/0/42/0/scale = 1.0
cache/0/42/0/kerning_overrides/42/0 = Vector2(0, 0)
cache/0/42/0/kerning_overrides/16/0 = Vector2(0, 0)
cache/0/16/0/ascent = 0.0
cache/0/16/0/descent = 0.0
cache/0/16/0/underline_position = 0.0
cache/0/16/0/underline_thickness = 0.0
cache/0/16/0/scale = 1.0
cache/0/16/0/kerning_overrides/42/0 = Vector2(0, 0)
cache/0/16/0/kerning_overrides/16/0 = Vector2(0, 0)
+3
View File
@@ -6,6 +6,9 @@ class_name LanguageSettings
language = value
Database.language = value
@export var teacher : String
@export var device_id : String
func _init():
var osLanguage = OS.get_locale_language();
if osLanguage:
+21
View File
@@ -1,5 +1,6 @@
[gd_resource type="Theme" load_steps=9 format=3 uid="uid://dqjvrt5nrtwn1"]
[ext_resource type="FontFile" uid="uid://b74ghiuvt8u45" path="res://assets/fonts/ScriptEcoleNormal.otf" id="1_shpmh"]
[ext_resource type="Texture2D" uid="uid://2pldpmhcg6v4" path="res://assets/theme/previous.svg" id="1_mdn6k"]
[ext_resource type="Texture2D" uid="uid://c156h72ld8d4s" path="res://assets/theme/next.svg" id="2_hbp6q"]
[ext_resource type="Texture2D" uid="uid://cacy10k45kq6u" path="res://assets/theme/up.svg" id="3_1nwm4"]
@@ -30,14 +31,34 @@ FileDialog/icons/parent_folder = ExtResource("3_1nwm4")
FileDialog/icons/reload = ExtResource("4_ymfot")
FileDialog/icons/toggle_hidden = ExtResource("5_yja2v")
Label/font_sizes/font_size = 42
Label/fonts/font = ExtResource("1_shpmh")
LineEdit/colors/font_color = Color(1, 1, 1, 1)
LineEdit/colors/font_outline_color = Color(0, 0, 0, 1)
LineEdit/colors/font_placeholder_color = Color(1, 1, 1, 0.6)
LineEdit/constants/caret_width = 4
LineEdit/constants/outline_size = 1
LineEdit/font_sizes/font_size = 32
LineEdit/fonts/font = ExtResource("1_shpmh")
OptionButton/colors/font_color = Color(1, 1, 1, 1)
OptionButton/colors/font_outline_color = Color(0, 0, 0, 1)
OptionButton/constants/arrow_margin = 20
OptionButton/constants/modulate_arrow = 1
OptionButton/constants/outline_size = 1
OptionButton/font_sizes/font_size = 70
OptionButton/fonts/font = ExtResource("1_shpmh")
Panel/styles/panel = SubResource("StyleBoxFlat_sfncn")
PanelContainer/styles/panel = SubResource("StyleBoxFlat_3gh3j")
MenuBar/font_sizes/font_size = 32
MenuButton/font_sizes/font_size = 32
OptionButton/font_sizes/font_size = 32
Panel/styles/panel = SubResource("StyleBoxFlat_sfncn")
PanelContainer/styles/panel = SubResource("StyleBoxFlat_3gh3j")
PopupMenu/colors/font_color = Color(1, 1, 1, 1)
PopupMenu/colors/font_outline_color = Color(0, 0, 0, 1)
PopupMenu/constants/outline_size = 1
PopupMenu/font_sizes/font_size = 100
PopupMenu/fonts/font = ExtResource("1_shpmh")
PopupMenu/fonts/font_separator = ExtResource("1_shpmh")
TextEdit/font_sizes/font_size = 32
TooltipLabel/font_sizes/font_size = 80
Tree/font_sizes/font_size = 32
+19 -7
View File
@@ -3,23 +3,25 @@ extends Control
@onready var speech_player : AudioStreamPlayer = $SpeechPlayer
@onready var sprite: = $Sprite
var tuto_speech_path : String = "main_menu/audio/title_screen_tuto_welcome_oneshot.mp3"
var feedback_speech :String = "main_menu/audio/title_screen_feedback_welcome.mp3"
const tuto_speech_path : String = "main_menu/audio/title_screen_tuto_welcome_oneshot.mp3"
const feedback_speech_path :String = "main_menu/audio/title_screen_feedback_welcome.mp3"
var isSpeaking : bool = false
var isSpeaking : bool = false :
set(value):
isSpeaking = value
elapsedTime = 0
var elapsedTime : float = 0.0
func _ready():
# TODO Revoir quel speech lancer au démarrage
_play_speech(Database.get_audio_stream_for_path(tuto_speech_path))
start_speech()
func _process(delta):
if not isSpeaking:
elapsedTime += delta
if elapsedTime > 20:
_play_speech(Database.get_audio_stream_for_path(feedback_speech))
elapsedTime = 0.0
_play_speech(Database.get_audio_stream_for_path(feedback_speech_path))
func _play_speech(speech : AudioStream):
@@ -34,3 +36,13 @@ func _play_speech(speech : AudioStream):
sprite.play("Tc_Idle1")
isSpeaking = false
func start_speech():
_play_speech(Database.get_audio_stream_for_path(tuto_speech_path))
func stop_speech():
sprite.stop()
speech_player.stop()
isSpeaking = false
+19
View File
@@ -0,0 +1,19 @@
extends OptionButton
var items : Array
func _ready():
# Check the language_resources directory to fetch supported languages
var dir = DirAccess.open("res://language_resources")
var idx : int = 0
for language_locale in dir.get_directories():
add_item(TranslationServer.get_locale_name(language_locale), idx)
items.append(language_locale)
if language_locale == UserDataManager.language_settings.language:
select(idx)
idx+=1
func get_selected_language() -> String:
var id = get_selected_id()
return items[id]
+22
View File
@@ -0,0 +1,22 @@
extends Control
@onready var language_field : OptionButton = $LanguageField
@onready var email_field : LineEdit = $EmailField
@onready var password_field : LineEdit = $PasswordField
@onready var device_id_field : LineEdit = $DeviceIDField
@onready var error_message : Label = $ErrorMessage
func _on_validate_button_pressed() -> void:
# Check if all the values are given
if not email_field.text or not password_field.text or not device_id_field.text:
error_message.visible = true
return
# TODO Check login and password
# Login
UserDataManager.login(language_field.get_selected_language(), email_field.text, device_id_field.text)
# TODO Load next scene
+17 -1
View File
@@ -2,15 +2,31 @@ extends Control
@onready var music_player : AudioStreamPlayer = $MusicStreamPlayer
@onready var version_label : Label = $Informations/BuildVersionValue
@onready var teacher_label : Label = $Informations/TeacherValue
@onready var device_id_label : Label = $Informations/DeviceIDValue
@onready var kalulu : Control = $Kalulu
@onready var login : Control = $Login
func _ready():
version_label.text = ProjectSettings.get_setting("application/config/version")
teacher_label.text = UserDataManager.language_settings.teacher
device_id_label.text = UserDataManager.language_settings.device_id
func _on_main_button_pressed():
print(UserDataManager.teacher)
if kalulu.visible:
kalulu.visible = false
kalulu.stop_speech()
login.visible = true
func _on_music_stream_player_finished():
music_player.stream_paused = false
music_player.play()
func _on_back_button_pressed():
login.visible = false
kalulu.visible = true
kalulu.start_speech()
+193 -48
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=3 uid="uid://6v3nachs7j71"]
[gd_scene load_steps=22 format=3 uid="uid://6v3nachs7j71"]
[ext_resource type="Script" path="res://sources/menus/main/main_menu.gd" id="1_0r1ij"]
[ext_resource type="PackedScene" uid="uid://wdjp1sv55q4f" path="res://sources/menus/night_sky/night_sky.tscn" id="1_afd4d"]
@@ -10,6 +10,14 @@
[ext_resource type="Texture2D" uid="uid://cgwun1jhj53bi" path="res://assets/menus/main/play_button.png" id="7_lr7j4"]
[ext_resource type="Script" path="res://sources/menus/main/kalulu.gd" id="8_cxg8l"]
[ext_resource type="PackedScene" uid="uid://dnuny6200v5b0" path="res://sources/kalulu.tscn" id="10_icqmp"]
[ext_resource type="Script" path="res://sources/menus/main/login.gd" id="12_6bu7q"]
[ext_resource type="Texture2D" uid="uid://bsojx7tmm435x" path="res://assets/minigames/minigame_ui/graphic/button_next_up.png" id="12_km7h0"]
[ext_resource type="Texture2D" uid="uid://wtx3wqs0l4si" path="res://assets/minigames/minigame_ui/graphic/button_back_up.png" id="13_j3nb7"]
[ext_resource type="Texture2D" uid="uid://brrxuaco0l85j" path="res://assets/minigames/minigame_ui/graphic/button_next_down.png" id="13_oqjai"]
[ext_resource type="Script" path="res://sources/menus/main/language_field.gd" id="13_rs3hd"]
[ext_resource type="Texture2D" uid="uid://cbhip35yyqneg" path="res://assets/minigames/minigame_ui/graphic/button_back_down.png" id="14_3lr3g"]
[ext_resource type="Texture2D" uid="uid://bsmq426v8148w" path="res://assets/minigames/minigame_ui/graphic/button_next_disabled.png" id="14_11c6x"]
[ext_resource type="Theme" uid="uid://dqjvrt5nrtwn1" path="res://resources/themes/kalulu_theme.tres" id="15_pcmnw"]
[ext_resource type="Texture2D" uid="uid://bbip3wpyidt1q" path="res://assets/menus/main/play_button_mask.png" id="20_oqrk5"]
[ext_resource type="FontFile" uid="uid://b74ghiuvt8u45" path="res://assets/fonts/ScriptEcoleNormal.otf" id="22_jby16"]
[ext_resource type="AudioStream" uid="uid://b8pn5vqgp6jlt" path="res://assets/menus/main/ui_title_card_music.mp3" id="23_ajpnn"]
@@ -55,17 +63,6 @@ scale = Vector2(2, 2)
position = Vector2(2000, 1875)
scale = Vector2(2, 2)
[node name="Title" type="TextureRect" parent="."]
layout_mode = 2
offset_left = 956.0
offset_top = 256.0
offset_right = 1603.0
offset_bottom = 428.0
grow_horizontal = 2
size_flags_horizontal = 4
size_flags_vertical = 0
texture = ExtResource("7_ftt26")
[node name="Kalulu" type="Control" parent="."]
layout_mode = 1
anchors_preset = 8
@@ -77,6 +74,17 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("8_cxg8l")
[node name="Title" type="TextureRect" parent="Kalulu"]
layout_mode = 2
offset_left = -324.0
offset_top = -644.0
offset_right = 323.0
offset_bottom = -472.0
grow_horizontal = 2
size_flags_horizontal = 4
size_flags_vertical = 0
texture = ExtResource("7_ftt26")
[node name="Background" type="TextureRect" parent="Kalulu"]
custom_minimum_size = Vector2(868, 868)
layout_mode = 2
@@ -103,74 +111,211 @@ blend_mode = 2
range_item_cull_mask = 2
texture = ExtResource("20_oqrk5")
[node name="Button" type="Button" parent="Kalulu"]
modulate = Color(1, 1, 1, 0)
self_modulate = Color(1, 1, 1, 0)
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -1280.0
offset_top = -904.0
offset_right = 1280.0
offset_bottom = 904.0
grow_horizontal = 2
grow_vertical = 2
[node name="SpeechPlayer" type="AudioStreamPlayer" parent="Kalulu"]
[node name="Login" type="Control" parent="."]
visible = false
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -649.0
offset_top = -308.0
offset_right = 649.0
offset_bottom = 308.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("12_6bu7q")
[node name="BackButton" type="TextureButton" parent="Login"]
layout_mode = 0
offset_left = -567.0
offset_top = -528.0
offset_right = -427.0
offset_bottom = -388.0
scale = Vector2(1.5, 1.5)
texture_normal = ExtResource("13_j3nb7")
texture_pressed = ExtResource("14_3lr3g")
[node name="EmailField" type="LineEdit" parent="Login"]
layout_mode = 1
offset_top = 80.0
offset_right = 800.0
offset_bottom = 193.0
theme = ExtResource("15_pcmnw")
theme_type_variation = &"1"
theme_override_font_sizes/font_size = 70
placeholder_text = "Email"
[node name="Label" type="Label" parent="Login/EmailField"]
layout_mode = 0
offset_top = -80.0
offset_right = 412.0
theme = ExtResource("15_pcmnw")
text = "Teacher login"
[node name="PasswordField" type="LineEdit" parent="Login"]
layout_mode = 1
offset_top = 223.0
offset_right = 800.0
offset_bottom = 336.0
theme = ExtResource("15_pcmnw")
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 1
placeholder_text = "Password"
secret = true
[node name="DeviceIDField" type="LineEdit" parent="Login"]
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -400.0
offset_top = 80.0
offset_bottom = 193.0
grow_horizontal = 0
theme = ExtResource("15_pcmnw")
[node name="Label" type="Label" parent="Login/DeviceIDField"]
layout_mode = 1
offset_top = -80.0
offset_right = 412.0
theme = ExtResource("15_pcmnw")
text = "Tablet number"
[node name="LanguageField" type="OptionButton" parent="Login"]
layout_mode = 0
offset_top = 356.0
offset_right = 800.0
offset_bottom = 469.0
theme = ExtResource("15_pcmnw")
script = ExtResource("13_rs3hd")
[node name="ValidateButton" type="TextureButton" parent="Login"]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -321.0
offset_top = -310.0
offset_right = -181.0
offset_bottom = -170.0
grow_horizontal = 0
grow_vertical = 0
scale = Vector2(2, 2)
texture_normal = ExtResource("12_km7h0")
texture_pressed = ExtResource("13_oqjai")
texture_disabled = ExtResource("14_11c6x")
[node name="ErrorMessage" type="Label" parent="Login"]
visible = false
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -76.0
grow_horizontal = 2
grow_vertical = 0
text = "Please verify your data"
[node name="Informations" type="Control" parent="."]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -112.0
offset_right = 467.0
offset_top = -176.0
offset_right = 624.0
grow_vertical = 0
[node name="BuildVersionTitle" type="Label" parent="Informations"]
layout_mode = 2
offset_right = 251.0
offset_left = 10.0
offset_right = 261.0
offset_bottom = 56.0
theme_override_fonts/font = ExtResource("22_jby16")
text = " Build Version :"
theme_override_font_sizes/font_size = 30
text = "Build Version :"
vertical_alignment = 1
[node name="BuildVersionValue" type="Label" parent="Informations"]
layout_mode = 2
anchor_left = 1.0
anchor_right = 1.0
offset_left = -150.0
layout_mode = 1
offset_left = 250.0
offset_right = 400.0
offset_bottom = 56.0
grow_horizontal = 0
theme_override_fonts/font = ExtResource("22_jby16")
theme_override_font_sizes/font_size = 30
text = "?"
vertical_alignment = 1
[node name="TeacherTitle" type="Label" parent="Informations"]
layout_mode = 0
offset_left = 10.0
offset_top = 56.0
offset_right = 261.0
offset_bottom = 112.0
theme_override_font_sizes/font_size = 30
text = "Logged as :"
vertical_alignment = 1
[node name="TeacherValue" type="Label" parent="Informations"]
layout_mode = 1
offset_left = 250.0
offset_top = 56.0
offset_right = 500.0
offset_bottom = 112.0
theme_override_fonts/font = ExtResource("22_jby16")
theme_override_font_sizes/font_size = 30
text = "?"
vertical_alignment = 1
[node name="DeviceIDTitle" type="Label" parent="Informations"]
layout_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -56.0
offset_right = 193.0
grow_vertical = 0
layout_mode = 1
offset_left = 10.0
offset_top = 112.0
offset_right = 261.0
offset_bottom = 168.0
theme_override_fonts/font = ExtResource("22_jby16")
text = " Device Id :"
theme_override_font_sizes/font_size = 30
text = "Device Id :"
vertical_alignment = 1
[node name="DeviceIDValue" type="Label" parent="Informations"]
layout_mode = 2
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -150.0
offset_top = -56.0
grow_horizontal = 0
grow_vertical = 0
layout_mode = 1
offset_left = 250.0
offset_top = 112.0
offset_right = 400.0
offset_bottom = 168.0
theme_override_fonts/font = ExtResource("22_jby16")
theme_override_font_sizes/font_size = 30
text = "?"
vertical_alignment = 1
[node name="Button" type="Button" parent="."]
modulate = Color(1, 1, 1, 0)
self_modulate = Color(1, 1, 1, 0)
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="MusicStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource("23_ajpnn")
autoplay = true
[connection signal="pressed" from="Button" to="." method="_on_main_button_pressed"]
[connection signal="pressed" from="Kalulu/Button" to="." method="_on_main_button_pressed"]
[connection signal="pressed" from="Login/BackButton" to="." method="_on_back_button_pressed"]
[connection signal="pressed" from="Login/ValidateButton" to="Login" method="_on_validate_button_pressed"]
[connection signal="finished" from="MusicStreamPlayer" to="." method="_on_music_stream_player_finished"]
@@ -56,6 +56,14 @@ func set_language(language : String) -> void:
_save_language_settings()
func login(language : String, teacher : String, device_id : String) -> void:
if language_settings:
language_settings.language = language
language_settings.teacher = teacher
language_settings.device_id = device_id
_save_language_settings()
func load_student_settings() -> void:
# Load User settings
if FileAccess.file_exists(get_student_settings_path()):