mirror of
https://github.com/deunix-educ/aventuriers-des-mots.git
synced 2026-10-13 02:11:58 +02:00
Add way back to profile selection and abandoning a mission
World map gets a "Changer de profil" button (saves first). During a mission, a header button asks for confirmation then leaves without stars or items; attempts already made stay recorded and are saved. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,12 @@
|
|||||||
"exercise_host.continue_button": "Continuer",
|
"exercise_host.continue_button": "Continuer",
|
||||||
"exercise_host.finish_mission_button": "Terminer la mission",
|
"exercise_host.finish_mission_button": "Terminer la mission",
|
||||||
"exercise_host.progress_label": "Exercice",
|
"exercise_host.progress_label": "Exercice",
|
||||||
|
"exercise_host.abandon_button": "Quitter la mission",
|
||||||
|
"exercise_host.abandon_confirm_title": "Quitter la mission ?",
|
||||||
|
"exercise_host.abandon_confirm_message": "Tu pourras la recommencer plus tard. Les étoiles de cette mission ne seront pas gagnées.",
|
||||||
|
"exercise_host.abandon_confirm_yes": "Oui, quitter",
|
||||||
|
"exercise_host.abandon_confirm_no": "Non, continuer",
|
||||||
|
"world_map.change_profile_button": "Changer de profil",
|
||||||
"feedback_panel.correct_title": "Bravo !",
|
"feedback_panel.correct_title": "Bravo !",
|
||||||
"feedback_panel.incorrect_title": "Pas tout à fait",
|
"feedback_panel.incorrect_title": "Pas tout à fait",
|
||||||
"feedback_panel.hint_label": "Indice :",
|
"feedback_panel.hint_label": "Indice :",
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ var _pending_outcome := ""
|
|||||||
@onready var _exercise_container: Control = %ExerciseContainer
|
@onready var _exercise_container: Control = %ExerciseContainer
|
||||||
@onready var _overlay_container: Control = %OverlayContainer
|
@onready var _overlay_container: Control = %OverlayContainer
|
||||||
@onready var _progress_label: Label = %ProgressLabel
|
@onready var _progress_label: Label = %ProgressLabel
|
||||||
|
@onready var _abandon_button: Button = %AbandonButton
|
||||||
|
@onready var _abandon_confirm_dialog: ConfirmationDialog = %AbandonConfirmDialog
|
||||||
|
|
||||||
|
|
||||||
## Accesseurs reserves aux tests d'integration (scenes/exercises/
|
## Accesseurs reserves aux tests d'integration (scenes/exercises/
|
||||||
@@ -50,6 +52,14 @@ func get_outcomes() -> Array[String]:
|
|||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
_abandon_button.text = UIText.get_text("exercise_host.abandon_button")
|
||||||
|
_abandon_button.pressed.connect(_on_abandon_pressed)
|
||||||
|
_abandon_confirm_dialog.title = UIText.get_text("exercise_host.abandon_confirm_title")
|
||||||
|
_abandon_confirm_dialog.dialog_text = UIText.get_text("exercise_host.abandon_confirm_message")
|
||||||
|
_abandon_confirm_dialog.ok_button_text = UIText.get_text("exercise_host.abandon_confirm_yes")
|
||||||
|
_abandon_confirm_dialog.cancel_button_text = UIText.get_text("exercise_host.abandon_confirm_no")
|
||||||
|
_abandon_confirm_dialog.confirmed.connect(_on_abandon_confirmed)
|
||||||
|
|
||||||
_mission = ExerciseEngine.get_mission(GameManager.pending_mission_id)
|
_mission = ExerciseEngine.get_mission(GameManager.pending_mission_id)
|
||||||
_rule = ExerciseEngine.get_rule(_mission["rule_id"])
|
_rule = ExerciseEngine.get_rule(_mission["rule_id"])
|
||||||
_skill_id = _rule.get("skill", "")
|
_skill_id = _rule.get("skill", "")
|
||||||
@@ -57,6 +67,20 @@ func _ready() -> void:
|
|||||||
_show_rule_panel()
|
_show_rule_panel()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_abandon_pressed() -> void:
|
||||||
|
_abandon_confirm_dialog.popup_centered()
|
||||||
|
|
||||||
|
|
||||||
|
## Quitter une mission ne rapporte ni etoile ni objet et n'est jamais compte
|
||||||
|
## comme un echec. Les tentatives deja faites restent enregistrees (ce sont de
|
||||||
|
## vraies observations d'apprentissage) et sont sauvegardees avant de partir.
|
||||||
|
func _on_abandon_confirmed() -> void:
|
||||||
|
ProgressManager.save_now()
|
||||||
|
GameManager.pending_mission_id = ""
|
||||||
|
GameManager.last_outcomes = []
|
||||||
|
GameManager.goto(GameManager.SCENE_WORLD_MAP)
|
||||||
|
|
||||||
|
|
||||||
func _show_rule_panel() -> void:
|
func _show_rule_panel() -> void:
|
||||||
var rule_panel: Control = preload("res://scenes/ui/rule_panel.tscn").instantiate()
|
var rule_panel: Control = preload("res://scenes/ui/rule_panel.tscn").instantiate()
|
||||||
_overlay_container.add_child(rule_panel)
|
_overlay_container.add_child(rule_panel)
|
||||||
|
|||||||
@@ -11,27 +11,12 @@ grow_horizontal = 2
|
|||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("1")
|
script = ExtResource("1")
|
||||||
|
|
||||||
[node name="HeaderBar" type="MarginContainer" parent="."]
|
|
||||||
layout_mode = 1
|
|
||||||
anchor_right = 1.0
|
|
||||||
offset_bottom = 40.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
theme_override_constants/margin_left = 16
|
|
||||||
theme_override_constants/margin_top = 8
|
|
||||||
theme_override_constants/margin_right = 16
|
|
||||||
theme_override_constants/margin_bottom = 8
|
|
||||||
|
|
||||||
[node name="ProgressLabel" type="Label" parent="HeaderBar"]
|
|
||||||
unique_name_in_owner = true
|
|
||||||
layout_mode = 2
|
|
||||||
horizontal_alignment = 2
|
|
||||||
|
|
||||||
[node name="ExerciseContainer" type="Control" parent="."]
|
[node name="ExerciseContainer" type="Control" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
offset_top = 40.0
|
offset_top = 48.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
|
||||||
@@ -44,3 +29,32 @@ anchor_bottom = 1.0
|
|||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
|
|
||||||
|
[node name="HeaderBar" type="MarginContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchor_right = 1.0
|
||||||
|
offset_bottom = 48.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
theme_override_constants/margin_left = 16
|
||||||
|
theme_override_constants/margin_top = 8
|
||||||
|
theme_override_constants/margin_right = 16
|
||||||
|
theme_override_constants/margin_bottom = 8
|
||||||
|
|
||||||
|
[node name="HBox" type="HBoxContainer" parent="HeaderBar"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="AbandonButton" type="Button" parent="HeaderBar/HBox"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Spacer" type="Control" parent="HeaderBar/HBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="ProgressLabel" type="Label" parent="HeaderBar/HBox"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
horizontal_alignment = 2
|
||||||
|
|
||||||
|
[node name="AbandonConfirmDialog" type="ConfirmationDialog" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ var _viewed_level := "CE1"
|
|||||||
@onready var _level_toggle_button: Button = %LevelToggleButton
|
@onready var _level_toggle_button: Button = %LevelToggleButton
|
||||||
@onready var _total_stars_label: Label = %TotalStarsLabel
|
@onready var _total_stars_label: Label = %TotalStarsLabel
|
||||||
@onready var _collection_button: Button = %CollectionButton
|
@onready var _collection_button: Button = %CollectionButton
|
||||||
|
@onready var _profile_button: Button = %ProfileButton
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
@@ -24,6 +25,8 @@ func _ready() -> void:
|
|||||||
_level_toggle_button.pressed.connect(_on_level_toggle_pressed)
|
_level_toggle_button.pressed.connect(_on_level_toggle_pressed)
|
||||||
_collection_button.text = UIText.get_text("world_map.collection_button")
|
_collection_button.text = UIText.get_text("world_map.collection_button")
|
||||||
_collection_button.pressed.connect(_on_collection_pressed)
|
_collection_button.pressed.connect(_on_collection_pressed)
|
||||||
|
_profile_button.text = UIText.get_text("world_map.change_profile_button")
|
||||||
|
_profile_button.pressed.connect(_on_change_profile_pressed)
|
||||||
_refresh()
|
_refresh()
|
||||||
|
|
||||||
|
|
||||||
@@ -49,6 +52,13 @@ func _populate_missions() -> void:
|
|||||||
_map_area.add_child(_build_marker(mission))
|
_map_area.add_child(_build_marker(mission))
|
||||||
|
|
||||||
|
|
||||||
|
## Revient au choix du profil sans rien perdre : la progression est ecrite
|
||||||
|
## avant de quitter la carte (le profil se rechargera a la prochaine selection).
|
||||||
|
func _on_change_profile_pressed() -> void:
|
||||||
|
ProgressManager.save_now()
|
||||||
|
GameManager.goto(GameManager.SCENE_PROFILE_SELECT)
|
||||||
|
|
||||||
|
|
||||||
func _on_collection_pressed() -> void:
|
func _on_collection_pressed() -> void:
|
||||||
GameManager.goto(GameManager.SCENE_COLLECTION)
|
GameManager.goto(GameManager.SCENE_COLLECTION)
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ unique_name_in_owner = true
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
custom_minimum_size = Vector2(0, 48)
|
custom_minimum_size = Vector2(0, 48)
|
||||||
|
|
||||||
|
[node name="ProfileButton" type="Button" parent="VBox"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
custom_minimum_size = Vector2(0, 48)
|
||||||
|
|
||||||
[node name="Guide" type="Control" parent="VBox" instance=ExtResource("2")]
|
[node name="Guide" type="Control" parent="VBox" instance=ExtResource("2")]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
extends GutTest
|
||||||
|
## Quitter une mission en cours : confirmation demandee, aucune etoile ni
|
||||||
|
## aucun objet, jamais compte comme un echec. Le changement de scene n'est
|
||||||
|
## pas observe ici (voir point 14 de docs/specs/decisions.md).
|
||||||
|
|
||||||
|
var _profile_id: String = ""
|
||||||
|
|
||||||
|
|
||||||
|
func before_each() -> void:
|
||||||
|
_profile_id = ProfileManager.create_profile("Test", "CE1")
|
||||||
|
ProfileManager.select_profile(_profile_id)
|
||||||
|
GameManager.pending_mission_id = "mission_01_pre_des_mots"
|
||||||
|
|
||||||
|
|
||||||
|
func after_each() -> void:
|
||||||
|
ProfileManager.delete_profile(_profile_id)
|
||||||
|
GameManager.pending_mission_id = ""
|
||||||
|
GameManager.last_outcomes = []
|
||||||
|
|
||||||
|
|
||||||
|
func _open_host() -> Control:
|
||||||
|
var host: Control = load("res://scenes/exercises/exercise_host.tscn").instantiate()
|
||||||
|
add_child_autofree(host)
|
||||||
|
await wait_process_frames(1)
|
||||||
|
return host
|
||||||
|
|
||||||
|
|
||||||
|
func test_abandon_asks_for_confirmation_before_leaving() -> void:
|
||||||
|
var host: Control = await _open_host()
|
||||||
|
|
||||||
|
var dialog: ConfirmationDialog = host.get_node("%AbandonConfirmDialog")
|
||||||
|
assert_false(dialog.visible)
|
||||||
|
assert_eq((host.get_node("%AbandonButton") as Button).text, "Quitter la mission")
|
||||||
|
|
||||||
|
host.get_node("%AbandonButton").pressed.emit()
|
||||||
|
await wait_process_frames(1)
|
||||||
|
|
||||||
|
assert_true(dialog.visible, "la confirmation doit s'afficher avant de quitter")
|
||||||
|
assert_eq(GameManager.pending_mission_id, "mission_01_pre_des_mots", "pas encore parti")
|
||||||
|
|
||||||
|
|
||||||
|
func test_confirmed_abandon_gives_no_stars_and_clears_the_mission() -> void:
|
||||||
|
var host: Control = await _open_host()
|
||||||
|
|
||||||
|
host.get_node("%AbandonConfirmDialog").confirmed.emit()
|
||||||
|
|
||||||
|
assert_eq(GameManager.pending_mission_id, "")
|
||||||
|
assert_eq(ProgressManager.stars(), 0)
|
||||||
|
assert_eq(ProgressManager.mission_best_stars("mission_01_pre_des_mots"), 0)
|
||||||
|
assert_eq(ProgressManager.owned_items(), [])
|
||||||
@@ -43,3 +43,12 @@ func test_ce2_profile_sees_ce2_missions_and_can_review_ce1() -> void:
|
|||||||
toggle.pressed.emit()
|
toggle.pressed.emit()
|
||||||
await wait_process_frames(1)
|
await wait_process_frames(1)
|
||||||
assert_eq(map.get_node("%MapArea").get_child_count(), 12)
|
assert_eq(map.get_node("%MapArea").get_child_count(), 12)
|
||||||
|
|
||||||
|
|
||||||
|
func test_map_offers_a_way_back_to_the_profile_selection() -> void:
|
||||||
|
var map := _open_map_for("CE1")
|
||||||
|
await wait_process_frames(1)
|
||||||
|
|
||||||
|
var button: Button = map.get_node("%ProfileButton")
|
||||||
|
assert_true(button.visible)
|
||||||
|
assert_eq(button.text, UIText.get_text("world_map.change_profile_button"))
|
||||||
|
|||||||
Reference in New Issue
Block a user