mirror of
https://github.com/deunix-educ/aventuriers-des-mots.git
synced 2026-10-13 10:21:58 +02:00
42dd170a5d
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
65 lines
2.4 KiB
GDScript
65 lines
2.4 KiB
GDScript
extends Control
|
|
## Ecran de selection de profil : un profil par enfant. La suppression d'un
|
|
## profil appartient a l'adulte (espace adulte, derriere sa barriere).
|
|
|
|
@onready var _title_label: Label = %TitleLabel
|
|
@onready var _profile_list: VBoxContainer = %ProfileList
|
|
@onready var _empty_state_label: Label = %EmptyStateLabel
|
|
@onready var _new_profile_button: Button = %NewProfileButton
|
|
@onready var _settings_button: Button = %SettingsButton
|
|
@onready var _quit_button: Button = %QuitButton
|
|
@onready var _quit_dialog: ConfirmationDialog = %QuitDialog
|
|
|
|
|
|
func _ready() -> void:
|
|
_title_label.text = UIText.get_text("profile_select.title")
|
|
_new_profile_button.text = UIText.get_text("profile_select.new_profile_button")
|
|
_empty_state_label.text = UIText.get_text("profile_select.empty_state")
|
|
_settings_button.text = UIText.get_text("profile_select.settings_button")
|
|
_settings_button.pressed.connect(_on_settings_pressed)
|
|
_quit_button.text = UIText.get_text("quit.button")
|
|
_quit_button.pressed.connect(_quit_dialog.request)
|
|
_new_profile_button.pressed.connect(_on_new_profile_pressed)
|
|
|
|
AudioManager.play_region_music("forest")
|
|
_refresh_profile_list()
|
|
|
|
|
|
func _refresh_profile_list() -> void:
|
|
for child in _profile_list.get_children():
|
|
child.queue_free()
|
|
|
|
var summaries := ProfileManager.list_profile_summaries()
|
|
_empty_state_label.visible = summaries.is_empty()
|
|
|
|
for summary: Dictionary in summaries:
|
|
_profile_list.add_child(_build_profile_row(summary))
|
|
|
|
|
|
func _build_profile_row(summary: Dictionary) -> Control:
|
|
var row := HBoxContainer.new()
|
|
row.add_theme_constant_override("separation", 10)
|
|
|
|
var select_button := Button.new()
|
|
select_button.text = "%s (%s)" % [summary["display_name"], summary["school_level"]]
|
|
select_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
select_button.custom_minimum_size = Vector2(0, 56)
|
|
select_button.pressed.connect(_on_profile_selected.bind(summary["profile_id"]))
|
|
row.add_child(select_button)
|
|
|
|
return row
|
|
|
|
|
|
func _on_profile_selected(profile_id: String) -> void:
|
|
if ProfileManager.select_profile(profile_id):
|
|
GameManager.goto(GameManager.SCENE_WORLD_MAP)
|
|
|
|
|
|
func _on_new_profile_pressed() -> void:
|
|
GameManager.goto(GameManager.SCENE_PROFILE_CREATE)
|
|
|
|
|
|
func _on_settings_pressed() -> void:
|
|
GameManager.settings_return_scene = GameManager.SCENE_PROFILE_SELECT
|
|
GameManager.goto(GameManager.SCENE_SETTINGS)
|