From 48e3940655d082f73daa1514795320f4e1668654 Mon Sep 17 00:00:00 2001 From: Dylan Sarrazyn Date: Tue, 30 Jan 2024 15:07:12 +0100 Subject: [PATCH] Fix rebase issues --- project.godot | 2 +- sources/menus/login/login.gd | 2 +- sources/menus/login/login.tscn | 3 +- sources/menus/main/language_field.gd | 2 +- sources/menus/main/main_menu.gd | 6 +- sources/menus/main/main_menu.tscn | 10 ++- .../menus/splash_screen/splash_screen.tscn | 2 +- sources/utils/autoloads/Database.gd | 7 +-- sources/utils/autoloads/user_data_manager.gd | 62 ++++++++++--------- 9 files changed, 53 insertions(+), 43 deletions(-) diff --git a/project.godot b/project.godot index b7f83352..62915957 100644 --- a/project.godot +++ b/project.godot @@ -26,8 +26,8 @@ buses/default_bus_layout="res://resources/audio_buses/main_audio_bus_layout.tres [autoload] LessonLogger="*res://sources/utils/autoloads/lesson_logger.gd" -UserDataManager="*res://sources/utils/autoloads/user_data_manager.gd" Database="*res://sources/utils/autoloads/Database.gd" +UserDataManager="*res://sources/utils/autoloads/user_data_manager.gd" MusicManager="*res://sources/utils/autoloads/music_manager.tscn" [display] diff --git a/sources/menus/login/login.gd b/sources/menus/login/login.gd index 9e8cc093..99c5ff19 100644 --- a/sources/menus/login/login.gd +++ b/sources/menus/login/login.gd @@ -30,7 +30,7 @@ func _ready(): if UserDataManager.teacher_settings.type == TeacherSettings.Type.Teacher: device_number_label.show() - device_number_label.text += str(UserDataManager.device_settings.device_id) + device_number_label.text += str(UserDataManager.get_device_settings().device_id) await kalulu.play_kalulu_speech(Database.get_audio_stream_for_path(help_speech_path)) music_player.play() diff --git a/sources/menus/login/login.tscn b/sources/menus/login/login.tscn index 529ada24..b1436af2 100644 --- a/sources/menus/login/login.tscn +++ b/sources/menus/login/login.tscn @@ -7,7 +7,7 @@ [ext_resource type="Texture2D" uid="uid://wtx3wqs0l4si" path="res://assets/minigames/minigame_ui/graphic/button_back_up.png" id="4_3vuah"] [ext_resource type="Theme" uid="uid://dqjvrt5nrtwn1" path="res://resources/themes/kalulu_theme.tres" id="5_j0bnd"] [ext_resource type="Texture2D" uid="uid://cbhip35yyqneg" path="res://assets/minigames/minigame_ui/graphic/button_back_down.png" id="5_vd33f"] -[ext_resource type="PackedScene" path="res://sources/menus/code_keyboard.tscn" id="5_xwrca"] +[ext_resource type="PackedScene" uid="uid://djduptonofbh4" path="res://sources/menus/code_keyboard.tscn" id="5_xwrca"] [ext_resource type="Texture2D" uid="uid://tcapan0mj64o" path="res://assets/minigames/minigame_ui/graphic/button_back_disabled.png" id="6_0dhup"] [ext_resource type="Texture2D" uid="uid://iw84x6mx8h2g" path="res://assets/minigames/minigame_ui/graphic/button_kalulu_up.png" id="7_2wdoi"] [ext_resource type="Texture2D" uid="uid://ub1dnysbojn8" path="res://assets/minigames/minigame_ui/graphic/button_kalulu_down.png" id="8_nxlxw"] @@ -43,6 +43,7 @@ offset_top = 100.0 offset_right = 158.5 offset_bottom = 176.0 grow_horizontal = 2 +theme_override_font_sizes/font_size = 70 text = "DEVICE n°" [node name="Icons" type="HBoxContainer" parent="."] diff --git a/sources/menus/main/language_field.gd b/sources/menus/main/language_field.gd index 54891a32..cb704ded 100644 --- a/sources/menus/main/language_field.gd +++ b/sources/menus/main/language_field.gd @@ -9,7 +9,7 @@ func _ready(): for language_locale in dir.get_directories(): add_item(TranslationServer.get_locale_name(language_locale), idx) items.append(language_locale) - if language_locale == UserDataManager.device_settings.language: + if language_locale == UserDataManager.get_device_settings().language: select(idx) idx+=1 diff --git a/sources/menus/main/main_menu.gd b/sources/menus/main/main_menu.gd index 0abbcc31..ce10e156 100644 --- a/sources/menus/main/main_menu.gd +++ b/sources/menus/main/main_menu.gd @@ -13,12 +13,12 @@ const next_scene_path: = "res://sources/menus/login/login.tscn" func _ready(): version_label.text = ProjectSettings.get_setting("application/config/version") - teacher_label.text = UserDataManager.device_settings.teacher - device_id_label.text = str(UserDataManager.device_settings.device_id) + teacher_label.text = UserDataManager.get_device_settings().teacher + device_id_label.text = str(UserDataManager.get_device_settings().device_id) func _on_main_button_pressed(): - if UserDataManager.device_settings.teacher: + if UserDataManager.get_device_settings().teacher: get_tree().change_scene_to_file(next_scene_path) else: kalulu.hide() diff --git a/sources/menus/main/main_menu.tscn b/sources/menus/main/main_menu.tscn index 28953302..f54fcfc2 100644 --- a/sources/menus/main/main_menu.tscn +++ b/sources/menus/main/main_menu.tscn @@ -153,6 +153,7 @@ anchors_preset = -1 anchor_right = 1.0 anchor_bottom = 0.168 grow_horizontal = 2 +theme_override_font_sizes/font_size = 70 text = "Sign-in teacher account " metadata/_edit_use_anchors_ = true @@ -165,6 +166,7 @@ anchor_right = 1.0 anchor_bottom = 0.584 grow_horizontal = 2 grow_vertical = 2 +theme_override_font_sizes/font_size = 70 text = "Sign-in parent account " metadata/_edit_use_anchors_ = true @@ -177,6 +179,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 0 +theme_override_font_sizes/font_size = 70 text = "Create an account" metadata/_edit_use_anchors_ = true @@ -241,6 +244,7 @@ layout_mode = 0 offset_top = -80.0 offset_right = 412.0 theme = ExtResource("15_pcmnw") +theme_override_font_sizes/font_size = 70 text = "Login" [node name="PasswordField" type="LineEdit" parent="Login/Form"] @@ -248,8 +252,7 @@ layout_mode = 1 offset_top = 223.0 offset_right = 800.0 offset_bottom = 336.0 -theme_override_colors/font_outline_color = Color(0, 0, 0, 1) -theme_override_constants/outline_size = 1 +theme_override_font_sizes/font_size = 70 placeholder_text = "Password" secret = true @@ -262,6 +265,7 @@ offset_left = -400.0 offset_top = 80.0 offset_bottom = 193.0 grow_horizontal = 0 +theme = ExtResource("15_pcmnw") min_value = 1.0 max_value = 6.0 value = 1.0 @@ -271,6 +275,7 @@ rounded = true layout_mode = 1 offset_top = -80.0 offset_right = 412.0 +theme_override_font_sizes/font_size = 70 text = "Tablet number" [node name="LanguageField" type="OptionButton" parent="Login/Form"] @@ -278,6 +283,7 @@ layout_mode = 0 offset_top = 356.0 offset_right = 800.0 offset_bottom = 469.0 +theme_override_font_sizes/font_size = 70 script = ExtResource("13_rs3hd") [node name="ValidateButton" type="TextureButton" parent="Login/Form"] diff --git a/sources/menus/splash_screen/splash_screen.tscn b/sources/menus/splash_screen/splash_screen.tscn index 7e8921cc..ccf8174a 100644 --- a/sources/menus/splash_screen/splash_screen.tscn +++ b/sources/menus/splash_screen/splash_screen.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://xndd7r8jpai5"] [ext_resource type="Script" path="res://sources/menus/splash_screen/splash_screen.gd" id="1_6qhsg"] -[ext_resource type="Texture2D" uid="uid://b02jd7lxl3n13" path="res://assets/splash_screen_kalulu.png" id="2_2kddp"] +[ext_resource type="Texture2D" path="res://assets/splash_screen_kalulu.png" id="2_2kddp"] [node name="SplashScreen" type="Control"] layout_mode = 3 diff --git a/sources/utils/autoloads/Database.gd b/sources/utils/autoloads/Database.gd index 270585db..4ae3a6dc 100644 --- a/sources/utils/autoloads/Database.gd +++ b/sources/utils/autoloads/Database.gd @@ -35,11 +35,8 @@ var words_path: = base_path + language + "/words/" func _ready() -> void: - language = UserDataManager.device_settings.language - db.path = db_path - db.foreign_keys = true - db.open_db() - #_import_lessons() + language = UserDataManager.get_device_settings().language + db_path = db_path #_import_words_csv() #_import_look_and_learn_data() diff --git a/sources/utils/autoloads/user_data_manager.gd b/sources/utils/autoloads/user_data_manager.gd index e556c4ea..402db29c 100644 --- a/sources/utils/autoloads/user_data_manager.gd +++ b/sources/utils/autoloads/user_data_manager.gd @@ -9,24 +9,20 @@ var student: String = "" : student = student_name if student : - load_student_settings() + _load_student_settings() + _load_student_progression() else : student_settings = null -var device_settings: DeviceSettings +var _device_settings: DeviceSettings var teacher_settings: TeacherSettings var student_settings: UserSettings var student_progression: UserProgression func _ready(): - load_device_settings() - if device_settings.teacher: - load_teacher_settings() - load_student_settings() - load_student_progression() - - student_progression.unlocks_changed.connect(_on_user_progression_unlocks_changed) + if get_device_settings().teacher: + _load_teacher_settings() func login(language : String, teacher : String, password : String, device_id : int) -> bool: @@ -34,50 +30,57 @@ func login(language : String, teacher : String, password : String, device_id : i if teacher not in DeviceSettings.possible_logins or password != DeviceSettings.possible_logins[teacher]: return false - if not device_settings: + if not _device_settings: return false # Handles device settings - device_settings.language = language - device_settings.teacher = teacher - device_settings.device_id = device_id + _device_settings.language = language + _device_settings.teacher = teacher + _device_settings.device_id = device_id _save_device_settings() # Handles teacher settings - load_teacher_settings() + _load_teacher_settings() return true func login_student(code : String) -> bool: - if not device_settings or not teacher_settings: + 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: + if s.code == code and s.device == _device_settings.device_id: student = code return true return false -func load_device_settings() -> void: + +func get_device_settings() -> DeviceSettings: + if not _device_settings: + _load_device_settings() + return _device_settings + + +func _load_device_settings() -> void: if FileAccess.file_exists(get_device_settings_path()): - device_settings = load(get_device_settings_path()) - if not device_settings: - device_settings = DeviceSettings.new() + _device_settings = load(get_device_settings_path()) + if not _device_settings: + _device_settings = DeviceSettings.new() _save_device_settings() func _save_device_settings() -> void: - ResourceSaver.save(device_settings, get_device_settings_path()) + ResourceSaver.save(_device_settings, get_device_settings_path()) func get_device_settings_path() -> String: return "user://device_settings.tres" -func load_teacher_settings() -> void: +func _load_teacher_settings() -> void: if FileAccess.file_exists(get_teacher_settings_path()): teacher_settings = load(get_teacher_settings_path()) if not teacher_settings: @@ -92,9 +95,10 @@ func _save_teacher_settings(): func get_teacher_settings_path() -> String: - return "user://".path_join(device_settings.teacher).path_join("teacher_settings.tres") + return "user://".path_join(_device_settings.teacher).path_join("teacher_settings.tres") -func load_student_settings() -> void: + +func _load_student_settings() -> void: # Load User settings if FileAccess.file_exists(get_student_settings_path()): student_settings = load(get_student_settings_path()) @@ -105,7 +109,7 @@ func load_student_settings() -> void: _save_student_settings() -func load_student_progression() -> void: +func _load_student_progression() -> void: if FileAccess.file_exists(get_student_progression_path()): student_progression = load(get_student_progression_path()) @@ -113,6 +117,8 @@ func load_student_progression() -> void: student_progression = UserProgression.new() DirAccess.make_dir_recursive_absolute(get_student_folder()) _save_student_progression() + + student_progression.unlocks_changed.connect(_on_user_progression_unlocks_changed) func _save_student_settings() -> void: @@ -124,12 +130,12 @@ func _save_student_progression() -> void: func get_teacher_folder() -> String: - var file_path: = "user://" + device_settings.teacher + "/" + var file_path: = "user://" + _device_settings.teacher + "/" return file_path func get_student_folder() -> String: - var file_path: = device_settings.get_folder_path().path_join(student) + var file_path: = _device_settings.get_folder_path().path_join(student) return file_path @@ -139,7 +145,7 @@ func get_student_settings_path() -> String: func get_student_progression_path() -> String: - var file_path: = get_student_folder() + "progression.tres" + var file_path: = get_student_folder().path_join("progression.tres") return file_path