- imogen_intro auf drei Entscheidungspunkte mit je drei Optionen (Klinge/Herz/neutral) verlaengert; neuer Mittelteil (Nachtwachen-Muster, Akt-1-konform ohne Wahrheit-1-Vorwegnahme); Violet/Rhiannon/Wren je eine dritte neutrale Option - Dialog-Abbruch ueber cancel (Esc/B/Kreis): bei offener Auswahl via Dialog-Box (ABORT_INDEX), waehrend Zeilen via DialogueSystem; Tyrveil sagt die abort_line aus der Dialog-Datei an; Abbruch vor der ersten Entscheidung laesst den Erst-Effekt bestehen, nach Effekten gilt der Dialog als gefuehrt (Anti-Farming); Esc gibt im Dialog nicht mehr die Maus frei - Konsistenzcheck aller Gespraeche gegen STORY/WELT/CHARACTERS/TYRVEIL: Violets Rotschwaenze auf die Roten korrigiert (Farbe vs. Schwanztyp, SPEC 6), Rest konsistent (CHANGEREQUESTS_DONE.md) - Headless verifiziert (34 Checks): drei Entscheidungen bei Imogen (-15/+3), dritte Option per Fokus-Navigation, beide Abbruch-Pfade samt Werte- und Flag-Semantik Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
109 lines
3.5 KiB
GDScript
109 lines
3.5 KiB
GDScript
extends CanvasLayer
|
|
## Dialog-Box am unteren Bildrand im Stil von Baldur's Gate 3
|
|
## (Change Request, siehe docs/CHANGEREQUESTS_DONE.md).
|
|
##
|
|
## Zeigt jede Dialog-Zeile gut lesbar mit Sprechernamen an und beherbergt
|
|
## die fokus-navigierbare Antwortauswahl; die Sprechblasen über den Köpfen
|
|
## bleiben als Ambiente bestehen. Navigation über Pfeiltasten/D-Pad/linken
|
|
## Stick, Aktivierung über confirm (Enter/Ⓐ/✕) nach dem Muster des
|
|
## Hauptmenü-Fixes: Events, die auch Godots ui_accept matchen, verarbeitet
|
|
## der fokussierte Button selbst, nur die übrigen (Controller) lösen
|
|
## manuell aus. choose() liefert den Index der gewählten Option als
|
|
## Coroutine.
|
|
|
|
signal option_chosen(index: int)
|
|
|
|
const ABORT_INDEX := -1
|
|
|
|
@onready var _speaker_label: Label = $Root/Panel/Margin/Content/SpeakerLabel
|
|
@onready var _line_label: Label = $Root/Panel/Margin/Content/LineLabel
|
|
@onready var _options_box: VBoxContainer = $Root/Panel/Margin/Content/OptionsBox
|
|
|
|
|
|
## Startet unsichtbar; sichtbar wird die Box über show_line().
|
|
func _ready() -> void:
|
|
visible = false
|
|
|
|
|
|
## Zeigt eine Dialog-Zeile mit Sprechernamen; eine noch offene
|
|
## Antwortauswahl wird dabei geleert.
|
|
func show_line(speaker_name: String, text: String) -> void:
|
|
_speaker_label.text = speaker_name
|
|
_line_label.text = text
|
|
_clear_options()
|
|
visible = true
|
|
|
|
|
|
## Zeigt die Antwortoptionen unterhalb der aktuellen Zeile an und liefert
|
|
## den Index der gewählten Option, sobald der Spieler bestätigt hat.
|
|
func choose(option_texts: Array) -> int:
|
|
_show_options(option_texts)
|
|
var index: int = await option_chosen
|
|
return index
|
|
|
|
|
|
## Blendet die Box am Dialogende aus.
|
|
func hide_box() -> void:
|
|
_clear_options()
|
|
visible = false
|
|
|
|
|
|
## Meldet, ob gerade eine Antwortauswahl offen ist (auch für Test-Sonden).
|
|
func has_open_options() -> bool:
|
|
return visible and _options_box.visible
|
|
|
|
|
|
## Aktiviert mit confirm den fokussierten Options-Button und meldet mit
|
|
## cancel den Dialog-Abbruch als ABORT_INDEX (nur solange eine Auswahl
|
|
## offen ist); Fokus-Verlust wird auf die erste Option repariert.
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if not has_open_options():
|
|
return
|
|
if event.is_action_pressed("cancel"):
|
|
_clear_options()
|
|
option_chosen.emit(ABORT_INDEX)
|
|
return
|
|
if not event.is_action_pressed("confirm"):
|
|
return
|
|
var focused := get_viewport().gui_get_focus_owner()
|
|
if focused == null or focused.get_parent() != _options_box:
|
|
if _options_box.get_child_count() > 0:
|
|
(_options_box.get_child(0) as Button).grab_focus()
|
|
return
|
|
if event.is_action("ui_accept"):
|
|
return
|
|
var button := focused as BaseButton
|
|
if button != null and not button.disabled:
|
|
button.pressed.emit()
|
|
|
|
|
|
## Baut die Options-Buttons neu auf und setzt den Fokus auf die erste
|
|
## Option.
|
|
func _show_options(option_texts: Array) -> void:
|
|
_clear_options()
|
|
var first_button: Button = null
|
|
for i in option_texts.size():
|
|
var button := Button.new()
|
|
button.text = str(option_texts[i])
|
|
button.custom_minimum_size = Vector2(0, 40)
|
|
button.pressed.connect(_on_option_pressed.bind(i))
|
|
_options_box.add_child(button)
|
|
if first_button == null:
|
|
first_button = button
|
|
_options_box.visible = true
|
|
if first_button != null:
|
|
first_button.grab_focus.call_deferred()
|
|
|
|
|
|
## Entfernt alle Options-Buttons und blendet die Options-Leiste aus.
|
|
func _clear_options() -> void:
|
|
for child in _options_box.get_children():
|
|
_options_box.remove_child(child)
|
|
child.queue_free()
|
|
_options_box.visible = false
|
|
|
|
|
|
## Schließt die Auswahl und meldet den gewählten Index.
|
|
func _on_option_pressed(index: int) -> void:
|
|
_clear_options()
|
|
option_chosen.emit(index)
|