Clean & debug

This commit is contained in:
Adrien Ufferte
2025-06-24 15:52:19 +02:00
parent c56fa06211
commit deda564993
26 changed files with 66 additions and 65 deletions
+2 -2
View File
@@ -64,7 +64,7 @@ func set_flowers(p_flowers: Array[GardenLayout.Flower], default_size: FlowerSize
func update_flowers() -> void:
for index: int in flowers.size():
for index: int in range(flowers.size()):
if index >= flower_controls.size():
break
var flower: GardenLayout.Flower = flowers[index]
@@ -81,7 +81,7 @@ func update_flowers() -> void:
func set_lesson_buttons(p_lesson_buttons: Array[GardenLayout.GardenLayoutLessonButton]) -> void:
for lesson_button_control: LessonButton in lesson_button_controls:
lesson_button_control.visible = false
for index: int in p_lesson_buttons.size():
for index: int in range(p_lesson_buttons.size()):
if index >= lesson_button_controls.size():
break
var lesson_button: GardenLayout.GardenLayoutLessonButton = p_lesson_buttons[index]
+1 -1
View File
@@ -27,7 +27,7 @@ func init_unlocks() -> bool:
# Verify the lessons
var number_of_lessons: int = Database.get_lessons_count()
if unlocks.size() != number_of_lessons:
for index: int in number_of_lessons:
for index: int in range(number_of_lessons):
if not unlocks.has(index+1):
unlocks[index + 1] = {
"look_and_learn": Status.Locked,
+2 -2
View File
@@ -138,7 +138,7 @@ func get_all_students_data() -> Array[StudentData]:
func delete_student(student_code: int) -> void:
for device: int in students.keys():
for index: int in students[device].size():
for index: int in range(students[device].size()):
if students[device][index].code == student_code:
students[device].remove_at(index)
if students[device].is_empty():
@@ -154,7 +154,7 @@ func get_student_with_code(student_code: int) -> StudentData:
func get_student_device(student_code: int) -> int:
for device: int in students.keys():
for index: int in students[device].size():
for index: int in range(students[device].size()):
if students[device][index].code == student_code:
return device
return -1
+7 -7
View File
@@ -129,7 +129,7 @@ func _ready() -> void:
for garden_control: Garden in garden_parent.get_children():
# Handles the lesson buttons and calculate the progression of the garden
for index: int in garden_control.lesson_button_controls.size():
for index: int in range(garden_control.lesson_button_controls.size()):
var button: LessonButton = garden_control.lesson_button_controls[index]
if not lesson_ind in lessons:
button.disabled = true
@@ -217,7 +217,7 @@ func _ready() -> void:
break
if not lesson_ind in lessons:
break
for index: int in garden_control.lesson_button_controls.size():
for index: int in range(garden_control.lesson_button_controls.size()):
if not lesson_ind in lessons:
break
@@ -320,7 +320,7 @@ func _ready() -> void:
var new_lesson_button: LessonButton
var is_last_lesson_of_garden: bool = false
for garden_control: Garden in garden_parent.get_children():
for index: int in garden_control.lesson_button_controls.size():
for index: int in range(garden_control.lesson_button_controls.size()):
if lesson_ind == max_lesson + 1:
new_lesson_button = garden_control.lesson_button_controls[index]
if lesson_ind == max_lesson:
@@ -543,7 +543,7 @@ func _set_up_lessons() -> void:
var garden_control: Garden = garden_parent.get_child(garden_ind)
for index: int in garden_control.lesson_button_controls.size():
for index: int in range(garden_control.lesson_button_controls.size()):
if not lesson_ind in lessons:
break
garden_control.set_lesson_label(index, lessons[lesson_ind][0].grapheme as String)
@@ -576,7 +576,7 @@ func add_gardens() -> void:
garden.garden_index = garden_index
garden_index += 1
for index: int in garden_layout.lesson_buttons.size():
for index: int in range(garden_layout.lesson_buttons.size()):
if current_lesson_count >= lessons.size():
garden_layout.lesson_buttons.resize(index)
break
@@ -596,7 +596,7 @@ func set_up_path() -> void:
points = []
var curve: Curve2D = Curve2D.new()
for index: int in gardens_layout.gardens.size():
for index: int in range(gardens_layout.gardens.size()):
if index >= garden_parent.get_child_count():
break
var garden_layout: GardenLayout = gardens_layout.gardens[index]
@@ -625,7 +625,7 @@ func _unlock() -> void:
func _get_current_lesson_button(lesson: int) -> LessonButton:
var lesson_ind: int = 1
for garden_control: Garden in garden_parent.get_children():
for index: int in garden_control.lesson_button_controls.size():
for index: int in range(garden_control.lesson_button_controls.size()):
if lesson_ind == lesson:
return garden_control.lesson_button_controls[index]
lesson_ind += 1
+5 -5
View File
@@ -15,7 +15,7 @@ func _ready() -> void:
line_particles.hide()
back_button.hide()
for index: int in MAX_LESSON_NUMBER:
for index: int in range(MAX_LESSON_NUMBER):
lessons[index] = index
# Checks if a configuration exists
@@ -32,7 +32,7 @@ func _init_gardens_layout() -> void:
# Empty the gardens configuration
gardens_layout.gardens.clear()
for index: int in MAX_LESSON_NUMBER:
for index: int in range(MAX_LESSON_NUMBER):
var garden_layout: GardenLayout
@@ -235,13 +235,13 @@ func _on_reset_garden_button_pressed() -> void:
var garden: Garden = garden_parent.get_child(garden_ind)
var flowers: Array[GardenLayout.Flower] = gardens_layout.gardens[garden_ind].flowers
for index: int in flowers.size():
for index: int in range(flowers.size()):
flowers[index] = GardenLayout.Flower.new()
gardens_layout.gardens[garden_ind].flowers = flowers
garden.set_flowers(flowers, Garden.FlowerSizes.LARGE)
var lesson_buttons: = gardens_layout.gardens[garden_ind].lesson_buttons
for index: int in lesson_buttons.size():
var lesson_buttons: Array = gardens_layout.gardens[garden_ind].lesson_buttons
for index: int in range(lesson_buttons.size()):
lesson_buttons[index] = GardenLayout.GardenLayoutLessonButton.new()
gardens_layout.gardens[garden_ind].lesson_buttons = lesson_buttons
garden.set_lesson_buttons(lesson_buttons)
@@ -35,7 +35,7 @@ func set_image_preview(img_path: String) -> void:
image_upload_button.show()
image_preview.texture = null
else:
var image: = Image.load_from_file(img_path)
var image: Image = Image.load_from_file(img_path)
image_preview.texture = ImageTexture.create_from_image(image)
image_clear_button.show()
image_upload_button.hide()
@@ -48,8 +48,8 @@ func set_sound_preview(sound_path: String) -> void:
sound_player.stream = null
sound_preview.hide()
else:
var file = FileAccess.open(sound_path, FileAccess.READ)
var sound = AudioStreamMP3.new()
var file: FileAccess = FileAccess.open(sound_path, FileAccess.READ)
var sound: AudioStreamMP3 = AudioStreamMP3.new()
sound.data = file.get_buffer(file.get_length())
sound_player.stream = sound
sound_clear_button.show()
@@ -93,8 +93,8 @@ func _on_image_upload_button_pressed() -> void:
file_dialog.filters = []
file_dialog.add_filter("*" + Database.IMAGE_EXTENSION, "Images")
for connection in file_dialog.file_selected.get_connections():
connection["signal"].disconnect(connection["callable"])
for connection: Dictionary in file_dialog.file_selected.get_connections():
(connection["signal"] as Signal).disconnect(connection["callable"] as Callable)
file_dialog.file_selected.connect(_image_file_selected)
@@ -106,8 +106,8 @@ func _on_sound_upload_button_pressed() -> void:
file_dialog.filters = []
file_dialog.add_filter("*" + Database.SOUND_EXTENSION, "Sounds")
for connection in file_dialog.file_selected.get_connections():
connection["signal"].disconnect(connection["callable"])
for connection: Dictionary in file_dialog.file_selected.get_connections():
(connection["signal"] as Signal).disconnect(connection["callable"] as Callable)
file_dialog.file_selected.connect(_sound_file_selected)
@@ -140,4 +140,4 @@ func _on_sound_clear_button_pressed() -> void:
func hide_image_part() -> void:
%ImageContainer.hide()
(%ImageContainer as MarginContainer).hide()
+1 -1
View File
@@ -36,7 +36,7 @@ func _on_gp_dropped(before: bool, data: Dictionary, gp_label: Control) -> void:
new_gp_label.gp_dropped.connect(_on_gp_dropped.bind(new_gp_label))
gp_container.add_child(new_gp_label)
var children: Array[Node] = gp_container.get_children()
for index: int in children.size():
for index: int in range(children.size()):
var child: Node = children[index]
if child == gp_label:
if before:
+2 -2
View File
@@ -23,7 +23,7 @@ func set_phoneme(p_phoneme: String) -> void:
func _get_drag_data(_at_position: Vector2) -> Variant:
is_being_dragged = true
set_drag_preview(self.duplicate())
set_drag_preview(self.duplicate() as Control)
return {
gp_id = gp_id,
grapheme = grapheme,
@@ -38,7 +38,7 @@ func _can_drop_data(_at_position: Vector2, data: Variant) -> bool:
func _drop_data(at_position: Vector2, data: Variant) -> void:
if not data.has("gp_id"):
return
var before: = at_position.x < size.x / 2
var before: bool = at_position.x < size.x / 2
gp_dropped.emit(before, data)
+1 -1
View File
@@ -25,7 +25,7 @@ func add_point_at(point: Vector2, ind: int) -> void:
func remove_point(point: Vector2) -> int:
var ind: = points.find(point)
var ind: int = points.find(point)
points.erase(point)
return ind
@@ -1,12 +1,13 @@
extends HBoxContainer
class_name VideoGPDescription
@warning_ignore("unused_signal")
signal delete
@onready var gp_menu_button: = %GPMenuButton
@onready var video_player: = %VideoStreamPlayer
@onready var video_upload_button: = %VideoUploadButton
@onready var file_dialog: = $FileDialog
@onready var gp_menu_button: MenuButton = %GPMenuButton
@onready var video_player: VideoStreamPlayer = %VideoStreamPlayer
@onready var video_upload_button: PlusButton = %VideoUploadButton
@onready var file_dialog: FileDialog = $FileDialog
var gp: Dictionary = {}
@@ -14,7 +15,7 @@ var gp: Dictionary = {}
func _video_file_selected(file_path: String) -> void:
file_dialog.files_selected.connect(_video_file_selected.bind(file_dialog))
if FileAccess.file_exists(file_path):
var current_file: = Database.get_gp_look_and_learn_video_path(gp)
var current_file: String = Database.get_gp_look_and_learn_video_path(gp)
if FileAccess.file_exists(current_file):
DirAccess.remove_absolute(current_file)
@@ -41,8 +42,8 @@ func _on_video_upload_button_pressed() -> void:
file_dialog.filters = []
file_dialog.add_filter("*" + Database.VIDEO_EXTENSION, "Videos")
for connection in file_dialog.file_selected.get_connections():
connection["signal"].disconnect(connection["callable"])
for connection: Dictionary in file_dialog.file_selected.get_connections():
(connection["signal"] as Signal).disconnect(connection["callable"] as Callable)
file_dialog.file_selected.connect(_video_file_selected)
@@ -52,7 +53,7 @@ func _on_video_upload_button_pressed() -> void:
func _on_button_pressed() -> void:
video_player.stream = null
video_player.visible = false
var current_file: = Database.get_gp_look_and_learn_video_path(gp)
var current_file: String = Database.get_gp_look_and_learn_video_path(gp)
if FileAccess.file_exists(current_file):
DirAccess.remove_absolute(current_file)
+3 -3
View File
@@ -209,7 +209,7 @@ func gp_ids_from_string(p_gp_ids: String) -> Array[int]:
var res: Array[int] = []
var pack: PackedStringArray = p_gp_ids.split(" ")
res.resize(pack.size())
for index: int in pack.size():
for index: int in range(pack.size()):
res[index] = int(pack[index])
return res
@@ -249,7 +249,7 @@ func insert_in_database() -> void:
var gps_in_words_ids: Array[String] = Array((element[relational_table + "IDs"] as String).split(" "))
while gps_in_words_ids.size() > gp_ids.size():
Database.db.delete_rows(relational_table, "ID=%s" % int(gps_in_words_ids.pop_back() as String))
for index: int in gps_in_words_ids.size():
for index: int in range(gps_in_words_ids.size()):
var gps_in_words_id: int = int(gps_in_words_ids[index])
Database.db.update_rows(relational_table, "ID=%s" % gps_in_words_id, {
table_graph_column + "ID": id,
@@ -281,7 +281,7 @@ func insert_in_database() -> void:
if Database.db.query_result.is_empty():
Database.db.insert_row(table, {table_graph_column: word})
id = Database.db.last_insert_rowid
for index: int in gp_ids.size():
for index: int in range(gp_ids.size()):
Database.db.insert_row(relational_table, {
table_graph_column + "ID": id,
sub_table_id: gp_ids[index],
+1 -1
View File
@@ -76,7 +76,7 @@ func _tracing_process() -> void:
should_play_effects = true
var remove_up_to: int = 0
for index: int in curve_points.size():
for index: int in range(curve_points.size()):
var offset: float = curve.get_closest_offset(curve_points[index])
if offset > guide.progress:
remove_up_to = index
+3 -3
View File
@@ -41,7 +41,7 @@ func _find_stimuli_and_distractions() -> void:
# If there is no previous stimuli, only adds from current lesson
if not previous_lesson_sentences:
if current_lesson_sentences.size() >= max_progression:
for index: int in max_progression:
for index: int in range(max_progression):
stimuli.append(current_lesson_sentences[index])
else:
while stimuli.size() < max_progression:
@@ -50,7 +50,7 @@ func _find_stimuli_and_distractions() -> void:
if current_lesson_sentences:
# If there are more stimuli in current lesson than needed
if current_lesson_sentences.size() >= current_lesson_stimuli_number:
for index: int in current_lesson_stimuli_number:
for index: int in range(current_lesson_stimuli_number):
stimuli.append(current_lesson_sentences[index])
else:
stimuli.append_array(current_lesson_sentences)
@@ -64,7 +64,7 @@ func _find_stimuli_and_distractions() -> void:
# Gets other stimuli from previous errors or lessons
var spaces_left: int = max_progression - stimuli.size()
if previous_lesson_sentences.size() >= spaces_left:
for index: int in spaces_left:
for index: int in range(spaces_left):
stimuli.append(previous_lesson_sentences[index])
else:
stimuli.append_array(previous_lesson_sentences)
@@ -63,7 +63,7 @@ func _find_stimuli_and_distractions() -> void:
if current_lesson_stimuli:
# If there are more stimuli in current lesson than needed
if current_lesson_stimuli.size() >= current_lesson_stimuli_number:
for index: int in current_lesson_stimuli_number:
for index: int in range(current_lesson_stimuli_number):
stimuli.append(current_lesson_stimuli[index])
else:
stimuli.append_array(current_lesson_stimuli)
@@ -78,7 +78,7 @@ func _find_stimuli_and_distractions() -> void:
# Gets other stimuli from previous errors or lessons
var spaces_left: int = max_progression - stimuli.size()
if previous_lesson_stimuli.size() >= spaces_left:
for index: int in spaces_left:
for index: int in range(spaces_left):
stimuli.append(previous_lesson_stimuli[index])
else:
stimuli.append_array(previous_lesson_stimuli)
@@ -212,7 +212,7 @@ func _on_stimulus_pressed(stimulus: Dictionary, _node: Node) -> bool:
# Handles the right answer GPs
# RA os - stimulus à
for index: int in right_answer_gps.size():
for index: int in range(right_answer_gps.size()):
if not stimulus_gps or (index < stimulus_gps.size() and stimulus_gps[index] == right_answer_gps[index]):
continue
_update_gp_score(right_answer_gps[index].ID as int, -1)
@@ -221,7 +221,7 @@ func _on_stimulus_pressed(stimulus: Dictionary, _node: Node) -> bool:
# Handles the pressed stimulus Gps
if stimulus_gps:
for index: int in stimulus_gps.size():
for index: int in range(stimulus_gps.size()):
if index < right_answer_gps.size() and stimulus_gps[index] == right_answer_gps[index]:
continue
_update_gp_score(stimulus_gps[index].ID as int, -1)
+1 -1
View File
@@ -104,7 +104,7 @@ func set_progression(new_progression: int) -> void:
if new_progression > max_progression:
set_max_progression(new_progression)
var progression_rects: Array[Node] = progression_container.get_children()
for index: int in max_progression:
for index: int in range(max_progression):
var progression_rect: TextureRect = progression_rects[index]
if index < new_progression:
progression_rect.texture = full_progression_icon
@@ -50,7 +50,7 @@ func _find_stimuli_and_distractions() -> void:
if not current_lesson_words.is_empty():
# If there are more stimuli in current lesson than needed
if current_lesson_words.size() >= current_lesson_stimuli_number:
for index: int in current_lesson_stimuli_number:
for index: int in range(current_lesson_stimuli_number):
stimuli.append(current_lesson_words[index])
else:
stimuli.append_array(current_lesson_words)
@@ -64,7 +64,7 @@ func _find_stimuli_and_distractions() -> void:
# Gets other stimuli from previous errors or lessons
var spaces_left: int = max_progression - stimuli.size()
if previous_lesson_words.size() >= spaces_left:
for index: int in spaces_left:
for index: int in range(spaces_left):
stimuli.append(previous_lesson_words[index])
else:
stimuli.append_array(previous_lesson_words)
+1 -1
View File
@@ -39,7 +39,7 @@ func move(distance: float) -> void:
coroutine.add_future(_tween_body_part(head, distance).finished)
# Move body
for index: int in body_parts.get_child_count(false):
for index: int in range(body_parts.get_child_count(false)):
await get_tree().create_timer(BODY_PART_WAIT_TIME).timeout
var body_part: CaterpillarBody = body_parts.get_child(-index-1)
coroutine.add_future(_tween_body_part(body_part, distance).finished)
@@ -44,7 +44,7 @@ func _setup_minigame() -> void:
# Spawn the right amount of branches
var branch_size: float = branches_zone.size.y / (settings.branches + 1)
for index: int in settings.branches:
for index: int in range(settings.branches):
var branch: Branch = BRANCH_SCENE.instantiate()
branch.velocity = settings.velocity
branches_zone.add_child(branch)
@@ -104,7 +104,7 @@ func _spawn() -> void:
# Insert the new jellyfish on the right spot in the blocking array
var found_ind: int = -1
for index: int in blocking_jellyfish.size():
for index: int in range(blocking_jellyfish.size()):
var blocking: Jellyfish = blocking_jellyfish[index]
if blocking.position.x > new_jellyfish.position.x:
found_ind = index
@@ -57,7 +57,7 @@ func _setup_minigame() -> void:
var settings: DifficultySettings = difficulty_settings[difficulty]
for index: int in settings.distractors_count + 1:
for index: int in range(settings.distractors_count + 1):
var monkey: Monkey = MONKEY_SCENE.instantiate()
monkeys_node.add_child(monkey)
monkeys.append(monkey)
@@ -90,7 +90,7 @@ func _highlight() -> void:
func _update_label(progress: int) -> void:
var gps_count: int = self._get_current_stimulus().GPsCount as int
word_label.text = ""
for index: int in gps_count:
for index: int in range(gps_count):
if progress > index or progress == gps_count:
word_label.text += self._get_current_stimulus().GPs[index].Grapheme
else:
@@ -210,7 +210,7 @@ func _on_current_word_progression_changed() -> void:
super()
var ind_good: int = randi_range(0, monkeys.size() - 1)
for index: int in monkeys.size():
for index: int in range(monkeys.size()):
var monkey: Monkey = monkeys[index]
if index == ind_good:
monkey.stimulus = _get_gp()
@@ -78,7 +78,7 @@ func _setup_minigame() -> void:
stimuli2.shuffle()
max_progression = pairs_count
var color: Parakeet.Colors = randi_range(0, Parakeet.Colors.size() - 1) as Parakeet.Colors
for index: int in pairs_count:
for index: int in range(pairs_count):
var new_parakeet1: Parakeet = Parakeet.instantiate()
var new_parakeet2: Parakeet = Parakeet.instantiate()
parakeets_node.add_child(new_parakeet1)
@@ -243,7 +243,7 @@ func _flying_arrival(to: Array[Vector2]) -> void:
audio_player.stream = AUDIO_STREAMS[Audio.Fly]
audio_player.play()
coroutine.add_future(audio_player.finished)
for index: int in parakeets.size():
for index: int in range(parakeets.size()):
coroutine.add_future(parakeets[index].fly_to.bind(to[index], fly_duration))
await coroutine.join_all()
for parakeet: Parakeet in parakeets:
@@ -40,7 +40,7 @@ func _find_stimuli_and_distractions() -> void:
if not current_lesson_sentences.is_empty():
# If there are more stimuli in current lesson than needed
if current_lesson_sentences.size() >= current_lesson_stimuli_number:
for index: int in current_lesson_stimuli_number:
for index: int in range(current_lesson_stimuli_number):
stimuli.append(current_lesson_sentences[index])
else:
stimuli.append_array(current_lesson_sentences)
@@ -54,7 +54,7 @@ func _find_stimuli_and_distractions() -> void:
# Gets other stimuli from previous errors or lessons
var spaces_left: int = max_progression - stimuli.size()
if previous_lesson_sentences.size() >= spaces_left:
for index: int in spaces_left:
for index: int in range(spaces_left):
stimuli.append(previous_lesson_sentences[index])
else:
stimuli.append_array(previous_lesson_sentences)
+1 -1
View File
@@ -21,7 +21,7 @@ func set_enabled(is_enabled: bool) -> void:
func _update_label() -> void:
label.text = ""
for index: int in stimulus.GPsCount:
for index: int in range(stimulus.GPsCount):
if progress > index or progress == stimulus.GPsCount:
label.text += stimulus.GPs[index].Grapheme
else:
+1 -1
View File
@@ -1,5 +1,5 @@
extends ItemList
func _ready() -> void:
for index: int in self.item_count:
for index: int in range(self.item_count):
self.set_item_text(index, tr(self.get_item_text(index)))
+1 -1
View File
@@ -616,7 +616,7 @@ func _import_word_from_csv(ortho: String, gpmatch: String, is_word: bool = true)
Word = ortho,
})
word_id = db.last_insert_rowid
for index: int in gp_ids.size():
for index: int in range(gp_ids.size()):
var gp_id: int = gp_ids[index]
db.insert_row("GPsInWords", {
WordID = word_id,
@@ -397,7 +397,7 @@ func _apply_server_response(response_body: Dictionary) -> void:
# TODO ADD SECURITY
var new_array: Array = JSON.parse_string(response_student_data.remediation_syllables.score_remediation as String) as Array
var new_syllables_scores: Dictionary[int, int] = {}
for index: int in new_array.size():
for index: int in range(new_array.size()):
# TODO ADD SECURITY
new_syllables_scores[int(new_array[index][0] as float)] = int(new_array[index][1] as float)
UserDataManager.set_student_remediation_syllables_data(int(response_student_code), new_syllables_scores, response_student_data.remediation_syllables.updated_at as String)