Fix TeacherSettings alignment

This commit is contained in:
Adrien Ufferte
2026-02-24 09:11:22 +01:00
parent 33522ddb9c
commit bb432eeb4b
4 changed files with 87 additions and 75 deletions
+17 -14
View File
@@ -1,5 +1,5 @@
class_name LessonUnlock
extends MarginContainer
extends Node
signal unlocks_changed()
@@ -24,8 +24,18 @@ func _ready() -> void:
exercise_option_button_2.add_item(tr(status))
exercise_option_button_3.add_item(tr(status))
_set_lesson_number(lesson_number)
_set_lesson_gps(lesson_gps)
reload()
func get_grid_cells() -> Array[Control]:
return [
lesson_label,
gps_label,
look_and_learn_option_button,
exercise_option_button_1,
exercise_option_button_2,
exercise_option_button_3,
]
func reload() -> void:
@@ -59,22 +69,19 @@ func _on_look_and_learn_option_button_item_selected(index: int) -> void:
unlocks[lesson_number]["look_and_learn"] = index
if index == StudentProgression.Status.Locked:
# First lesson look&learn can't be locked
if lesson_number == 1:
unlocks[lesson_number]["look_and_learn"] = StudentProgression.Status.Unlocked
# Unlock the previous lesson
else:
unlocks[lesson_number-1]["look_and_learn"] = StudentProgression.Status.Unlocked
unlocks[lesson_number-1]["games"][0] = StudentProgression.Status.Locked
unlocks[lesson_number-1]["games"][1] = StudentProgression.Status.Locked
unlocks[lesson_number-1]["games"][2] = StudentProgression.Status.Locked
unlocks[lesson_number - 1]["look_and_learn"] = StudentProgression.Status.Unlocked
unlocks[lesson_number - 1]["games"][0] = StudentProgression.Status.Locked
unlocks[lesson_number - 1]["games"][1] = StudentProgression.Status.Locked
unlocks[lesson_number - 1]["games"][2] = StudentProgression.Status.Locked
unlocks[lesson_number]["games"][0] = StudentProgression.Status.Locked
unlocks[lesson_number]["games"][1] = StudentProgression.Status.Locked
unlocks[lesson_number]["games"][2] = StudentProgression.Status.Locked
for lesson: int in unlocks.keys():
# Lock everything after
if lesson > lesson_number:
unlocks[lesson]["look_and_learn"] = StudentProgression.Status.Locked
unlocks[lesson]["games"][0] = StudentProgression.Status.Locked
@@ -86,13 +93,11 @@ func _on_look_and_learn_option_button_item_selected(index: int) -> void:
unlocks[lesson_number]["games"][1] = StudentProgression.Status.Locked
unlocks[lesson_number]["games"][2] = StudentProgression.Status.Locked
for lesson: int in unlocks.keys():
# Complete everything before
if lesson < lesson_number:
unlocks[lesson]["look_and_learn"] = StudentProgression.Status.Completed
unlocks[lesson]["games"][0] = StudentProgression.Status.Completed
unlocks[lesson]["games"][1] = StudentProgression.Status.Completed
unlocks[lesson]["games"][2] = StudentProgression.Status.Completed
# Lock everything after
elif lesson > lesson_number:
unlocks[lesson]["look_and_learn"] = StudentProgression.Status.Locked
unlocks[lesson]["games"][0] = StudentProgression.Status.Locked
@@ -103,13 +108,11 @@ func _on_look_and_learn_option_button_item_selected(index: int) -> void:
unlocks[lesson_number]["games"][1] = StudentProgression.Status.Unlocked
unlocks[lesson_number]["games"][2] = StudentProgression.Status.Unlocked
for lesson: int in unlocks.keys():
# Complete everything before
if lesson < lesson_number:
unlocks[lesson]["look_and_learn"] = StudentProgression.Status.Completed
unlocks[lesson]["games"][0] = StudentProgression.Status.Completed
unlocks[lesson]["games"][1] = StudentProgression.Status.Completed
unlocks[lesson]["games"][2] = StudentProgression.Status.Completed
# Lock everything after
elif lesson > lesson_number:
unlocks[lesson]["look_and_learn"] = StudentProgression.Status.Locked
unlocks[lesson]["games"][0] = StudentProgression.Status.Locked
+18 -29
View File
@@ -2,57 +2,46 @@
[ext_resource type="Script" uid="uid://crrnxt5bwa8wi" path="res://sources/menus/settings/lesson_unlock.gd" id="1_rlnlh"]
[node name="LessonUnlock" type="MarginContainer" unique_id=2109971470]
theme_override_constants/margin_left = 25
theme_override_constants/margin_right = 25
[node name="LessonUnlock" type="Node" unique_id=2109971470]
script = ExtResource("1_rlnlh")
[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=745183540]
layout_mode = 2
theme_override_constants/separation = 20
[node name="LessonLabel" type="Label" parent="HBoxContainer" unique_id=1829884836]
[node name="LessonLabel" type="Label" parent="." unique_id=1829884836]
unique_name_in_owner = true
custom_minimum_size = Vector2(100, 0)
layout_mode = 2
layout_mode = 0
theme_override_font_sizes/font_size = 64
[node name="GPsLabel" type="Label" parent="HBoxContainer" unique_id=1674528069]
[node name="GPsLabel" type="Label" parent="." unique_id=1674528069]
unique_name_in_owner = true
layout_mode = 2
layout_mode = 0
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 42
[node name="HBoxContainer" type="HBoxContainer" parent="HBoxContainer" unique_id=164537040]
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 40
[node name="LookAndLearnOptionButton" type="OptionButton" parent="HBoxContainer/HBoxContainer" unique_id=1667465526]
[node name="LookAndLearnOptionButton" type="OptionButton" parent="." unique_id=1667465526]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(200, 0)
layout_mode = 0
size_flags_horizontal = 3
[node name="ExerciseOptionButton1" type="OptionButton" parent="HBoxContainer/HBoxContainer" unique_id=1697241722]
[node name="ExerciseOptionButton1" type="OptionButton" parent="." unique_id=1697241722]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(200, 0)
layout_mode = 0
size_flags_horizontal = 3
disabled = true
[node name="ExerciseOptionButton2" type="OptionButton" parent="HBoxContainer/HBoxContainer" unique_id=796806380]
[node name="ExerciseOptionButton2" type="OptionButton" parent="." unique_id=796806380]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(200, 0)
layout_mode = 0
size_flags_horizontal = 3
disabled = true
[node name="ExerciseOptionButton3" type="OptionButton" parent="HBoxContainer/HBoxContainer" unique_id=2010481864]
[node name="ExerciseOptionButton3" type="OptionButton" parent="." unique_id=2010481864]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(200, 0)
layout_mode = 0
size_flags_horizontal = 3
disabled = true
[node name="Pad" type="MarginContainer" parent="HBoxContainer" unique_id=1969324404]
layout_mode = 2
theme_override_constants/margin_left = 10
[connection signal="item_selected" from="HBoxContainer/HBoxContainer/LookAndLearnOptionButton" to="." method="_on_look_and_learn_option_button_item_selected"]
[connection signal="item_selected" from="LookAndLearnOptionButton" to="." method="_on_look_and_learn_option_button_item_selected"]
+20 -6
View File
@@ -14,7 +14,8 @@ const LESSON_UNLOCK_SCENE: PackedScene = preload("res://sources/menus/settings/l
var progression: StudentProgression
var teacher_settings: SettingsTeacherSettings = null
@onready var lesson_container: VBoxContainer = %LessonContainer
@onready var lessons_grid: GridContainer = %LessonsGrid
@onready var lesson_rows_store: Node = %LessonRowsStore
@onready var name_line_edit: LineEdit = %NameLineEdit
@onready var device_selection_container: PanelContainer = %DeviceSelectionContainer
@onready var container: GridContainer = %GridContainer
@@ -26,9 +27,8 @@ func _ready() -> void:
func _create_lessons() -> void:
for lesson_unlock: Node in lesson_container.get_children():
lesson_unlock.queue_free()
_clear_lessons_grid()
Database.db.query("SELECT LessonNb, group_concat(Grapheme || '-' || Phoneme, ' ') GPs FROM Lessons
INNER JOIN GPsInLessons ON GPsInLessons.LessonID = Lessons.ID
INNER JOIN GPs ON GPsInLessons.GPID = GPs.ID
@@ -42,9 +42,23 @@ ORDER BY LessonNb")
Log.trace("LessonUnlocks: User selected a student with no progression data")
return
student_unlock.unlocks = progression.unlocks
lesson_container.add_child(student_unlock)
lesson_rows_store.add_child(student_unlock)
student_unlock.unlocks_changed.connect(_create_lessons)
_add_row_to_grid(student_unlock)
func _clear_lessons_grid() -> void:
for child: Node in lesson_rows_store.get_children():
child.queue_free()
for child: Node in lessons_grid.get_children():
if child.get_meta("lesson_grid_cell", false):
child.queue_free()
func _add_row_to_grid(lesson_unlock: LessonUnlock) -> void:
for cell: Control in lesson_unlock.get_grid_cells():
cell.set_meta("lesson_grid_cell", true)
cell.reparent(lessons_grid)
func _on_device_changed(value: int)-> void:
+32 -26
View File
@@ -86,65 +86,71 @@ theme_override_constants/margin_bottom = 25
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer/Content" unique_id=1183576919]
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer" unique_id=571960795]
[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer" unique_id=211942115]
layout_mode = 2
size_flags_vertical = 3
[node name="Label" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer/HBoxContainer" unique_id=1531995288]
layout_mode = 2
theme_override_font_sizes/font_size = 64
text = "LESSON"
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer/HBoxContainer" unique_id=771322481]
[node name="LessonsGrid" type="GridContainer" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer/ScrollContainer" unique_id=1896367368]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/margin_right = 60
theme_override_constants/h_separation = 40
theme_override_constants/v_separation = 12
columns = 6
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer/HBoxContainer/MarginContainer" unique_id=1688364131]
[node name="LessonHeaderLabel" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer/ScrollContainer/LessonsGrid" unique_id=1531995288]
custom_minimum_size = Vector2(100, 80)
layout_mode = 2
size_flags_horizontal = 8
theme_override_constants/separation = 32
theme_override_font_sizes/font_size = 48
text = "LESSON"
vertical_alignment = 1
[node name="Label" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer/HBoxContainer/MarginContainer/HBoxContainer" unique_id=682774340]
custom_minimum_size = Vector2(200, 0)
[node name="GraphemeHeaderSpacer" type="Control" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer/ScrollContainer/LessonsGrid" unique_id=771322481]
layout_mode = 2
size_flags_horizontal = 3
[node name="LookAndLearnHeaderLabel" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer/ScrollContainer/LessonsGrid" unique_id=682774340]
custom_minimum_size = Vector2(200, 80)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 34
text = "LOOKANDLEARN"
horizontal_alignment = 1
vertical_alignment = 1
autowrap_mode = 2
[node name="Label2" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer/HBoxContainer/MarginContainer/HBoxContainer" unique_id=40356526]
custom_minimum_size = Vector2(200, 0)
[node name="ExerciseHeaderLabel1" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer/ScrollContainer/LessonsGrid" unique_id=40356526]
custom_minimum_size = Vector2(200, 80)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 34
text = "EXERCISE1"
horizontal_alignment = 1
vertical_alignment = 1
autowrap_mode = 2
[node name="Label3" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer/HBoxContainer/MarginContainer/HBoxContainer" unique_id=933140768]
custom_minimum_size = Vector2(200, 0)
[node name="ExerciseHeaderLabel2" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer/ScrollContainer/LessonsGrid" unique_id=933140768]
custom_minimum_size = Vector2(200, 80)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 34
text = "EXERCISE2"
horizontal_alignment = 1
vertical_alignment = 1
autowrap_mode = 2
[node name="Label4" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer/HBoxContainer/MarginContainer/HBoxContainer" unique_id=476815784]
custom_minimum_size = Vector2(200, 0)
[node name="ExerciseHeaderLabel3" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer/ScrollContainer/LessonsGrid" unique_id=476815784]
custom_minimum_size = Vector2(200, 80)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 34
text = "EXERCISE3"
horizontal_alignment = 1
vertical_alignment = 1
autowrap_mode = 2
[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer" unique_id=211942115]
layout_mode = 2
size_flags_vertical = 3
[node name="LessonContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer/Content/VBoxContainer/ScrollContainer" unique_id=1896367368]
[node name="LessonRowsStore" type="Node" parent="."]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
[node name="HSeparator2" type="HSeparator" parent="MarginContainer/PanelContainer/VBoxContainer" unique_id=180339992]
layout_mode = 2