Files
aventuriers-des-mots/scenes/exercises/sentence_correction.gd
T
Denis Defolie 97a065879c Visual overhaul: theme, illustrations, redesigned screens (0.3.0)
Phase "habillage" of the post-0.1.0 plan. Rendering was reviewed on real
screenshots (new tools/screenshot.gd, `make screenshot`), which also
caught and fixed map markers overlapping and truncated titles.

- Global Godot theme (Atkinson Hyperlegible font, cream/green/gold
  palette, raised buttons, rounded cards, thick keyboard focus).
- Original vector art: forest/marsh backdrops, Plume the owl, stars,
  exercise-type icons, correct/try-again icons, 10 collection items.
- Redesigned world map (markers as cards with icon, title and stars,
  responsive layout), profile screens, mission intro, exercise host,
  rule/feedback panels, reward screen and collection grid.
- Motion helper (pop-in, fade) honouring an animations setting.
- Settings: animations flag; base window 1152x648 with canvas_items.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-11 22:36:43 +02:00

63 lines
2.3 KiB
GDScript

extends Control
## Exercice de correction de phrase : toucher le mot fautif puis le corriger
## (interaction decidee dans docs/specs/decisions.md, point 3). Scene
## autonome : emet la reponse par signal, ne touche ni a la sauvegarde ni a
## la progression.
signal answer_submitted(selected_indices: Array, corrections: Dictionary)
var _correction_edits: Dictionary = {}
@onready var _instruction_label: Label = %InstructionLabel
@onready var _tokens_box: HFlowContainer = %TokensBox
@onready var _corrections_box: VBoxContainer = %CorrectionsBox
@onready var _validate_button: Button = %ValidateButton
func _ready() -> void:
_validate_button.text = UIText.get_text("exercise_host.validate_button")
_validate_button.pressed.connect(_on_validate_pressed)
func load_exercise(exercise: Dictionary) -> void:
_instruction_label.text = exercise["instruction"]
for child in _tokens_box.get_children():
child.queue_free()
for child in _corrections_box.get_children():
child.queue_free()
_correction_edits.clear()
var tokens: Array = exercise["tokens"]
for i in tokens.size():
var button := Button.new()
button.text = tokens[i]["text"]
button.toggle_mode = true
button.theme_type_variation = &"SecondaryButton"
button.custom_minimum_size = Vector2(0, 60)
button.add_theme_font_size_override("font_size", 30)
button.toggled.connect(_on_token_toggled.bind(i))
_tokens_box.add_child(button)
func _on_token_toggled(pressed: bool, index: int) -> void:
if pressed:
if not _correction_edits.has(index):
var edit := LineEdit.new()
edit.placeholder_text = UIText.get_text("sentence_correction.correction_placeholder")
_corrections_box.add_child(edit)
_correction_edits[index] = edit
elif _correction_edits.has(index):
var edit: LineEdit = _correction_edits[index]
edit.queue_free()
_correction_edits.erase(index)
func _on_validate_pressed() -> void:
var selected_indices: Array = []
var corrections: Dictionary = {}
for index: int in _correction_edits.keys():
selected_indices.append(index)
corrections[index] = (_correction_edits[index] as LineEdit).text.strip_edges()
answer_submitted.emit(selected_indices, corrections)