This commit is contained in:
Adrien Ufferte
2025-12-18 16:00:00 +01:00
parent 4c4c023fc9
commit 5a23c4dd45
3 changed files with 23 additions and 2 deletions
+14 -1
View File
@@ -31,6 +31,7 @@ func _ready() -> void:
# Check if the database is connected, if not go to loader
if not Database.is_open:
Log.warn("LoginScreen: Database closed, redirecting to package loader")
await get_tree().process_frame
get_tree().change_scene_to_file(PACKAGE_LOADER_SCENE_PATH)
@@ -43,6 +44,7 @@ func _ready() -> void:
version_label.text = ProjectSettings.get_setting("application/config/version")
version_label.gui_input.connect(_on_version_label_gui_input)
Log.info("LoginScreen: Ready (device_id=%s, version=%s)" % [UserDataManager.get_device_settings().device_id, version_label.text])
await OpeningCurtain.open()
@@ -54,24 +56,30 @@ func _ready() -> void:
func _on_code_keyboard_password_entered(password: String) -> void:
Log.info("LoginScreen: Student code entered (length=%d)" % password.length())
if UserDataManager.student_exists(password):
Log.info("LoginScreen: Student code %s found locally, synchronizing before login" % password)
await UserDataManager.user_database_synchronizer.synchronize()
UserDataManager.login_student(password)
var login_success: bool = UserDataManager.login_student(password)
Log.info("LoginScreen: Login attempt for student code %s returned %s" % [password, str(login_success)])
kalulu_button.hide()
await kalulu.play_kalulu_speech(right_password_speech)
await OpeningCurtain.close()
get_tree().change_scene_to_file(NEXT_SCENE_PATH)
else:
Log.warn("LoginScreen: Unknown student code entered (length=%d)" % password.length())
kalulu_button.hide()
await kalulu.play_kalulu_speech(wrong_password_speech)
keyboard.reset_password()
func _on_back_button_pressed() -> void:
Log.trace("LoginScreen: Back button pressed, returning to main menu")
get_tree().change_scene_to_file(BACK_SCENE_PATH)
func _on_kalulu_button_pressed() -> void:
Log.trace("LoginScreen: Help speech requested")
kalulu_button.hide()
await kalulu.play_kalulu_speech(help_speech)
kalulu_button.show()
@@ -79,16 +87,20 @@ func _on_kalulu_button_pressed() -> void:
func _on_teacher_button_button_down() -> void:
if keyboard.get_password_as_string() != TEACHER_PASSWORD:
Log.warn("LoginScreen: Teacher button pressed with incorrect password")
return
Log.info("LoginScreen: Teacher button pressed with correct password, starting timer")
teacher_timer.start()
func _on_teacher_button_button_up() -> void:
Log.trace("LoginScreen: Teacher button released, showing help label")
teacher_help_label.show()
teacher_timer.stop()
func _on_teacher_timer_timeout() -> void:
Log.info("LoginScreen: Teacher timer elapsed, opening teacher settings")
teacher_help_label.hide()
await OpeningCurtain.close()
get_tree().change_scene_to_file(TEACHER_SCENE_PATH)
@@ -105,6 +117,7 @@ func _on_version_label_gui_input(event: InputEvent) -> void:
dev_click_count = 1
dev_last_click_time = now
if dev_click_count >= DEV_CLICK_THRESHOLD:
Log.info("LoginScreen: Developer click threshold reached, opening Developer Settings")
dev_click_count = 0
await OpeningCurtain.close()
DeveloperSettings.return_path = get_tree().current_scene.scene_file_path
+4
View File
@@ -56,6 +56,8 @@ var current_lives: int = 0:
set(value):
var previous_lives: int = current_lives
current_lives = value
if current_lives != previous_lives:
Log.debug("BaseMinigame: Lives changed from %d to %d (max %d) for %s" % [previous_lives, current_lives, max_number_of_lives, Type.keys()[minigame_name]])
if current_lives < previous_lives:
consecutive_errors += previous_lives - current_lives
if current_lives <= max_number_of_lives - errors_before_help_speech:
@@ -393,6 +395,7 @@ func _play_stimulus() -> void:
func _pause_game() -> bool:
var pause: bool = not get_tree().paused
get_tree().paused = pause
Log.trace("BaseMinigame: Pause toggled to %s for %s" % [str(pause), Type.keys()[minigame_name]])
return pause
@@ -416,6 +419,7 @@ func _play_kalulu_help_speech() -> void:
func set_current_progression(p_current_progression: int) -> void:
var previous_progression: int = current_progression
current_progression = p_current_progression
Log.debug("BaseMinigame: Progression changed from %d to %d/%d for %s" % [previous_progression, current_progression, max_progression, Type.keys()[minigame_name]])
consecutive_errors = 0
is_highlighting = false
@@ -7,12 +7,16 @@ extends Resource
func add_log(lesson_nb: int, new_log: Dictionary, time: String) -> void:
if not logs.has(lesson_nb):
logs[lesson_nb] = {}
Log.trace("LogResource: Created log bucket for lesson %d" % lesson_nb)
var lesson_logs: Dictionary = logs[lesson_nb]
if not lesson_logs.has(time):
logs[lesson_nb][time] = new_log
Log.trace("LogResource: Added log for lesson %d at %s" % [lesson_nb, time])
else:
var index: int = 2
while lesson_logs.has(time + "_" + str(index)):
index += 1
logs[lesson_nb][time + "_" + str(index)] = new_log
var new_key: String = time + "_" + str(index)
logs[lesson_nb][new_key] = new_log
Log.warn("LogResource: Duplicate log time %s for lesson %d. Stored as %s" % [time, lesson_nb, new_key])