CR: BG3-Chatbox fuer Dialoge + Doc-Updates (TYRVEIL.md, WELT.md)
- dialogue_choices zu dialogue_box umgebaut: Panel am unteren Bildrand zeigt jede Dialog-Zeile mit Sprechernamen lesbar an, Antwortauswahl integriert; Sprechblasen bleiben als Ambiente (CHANGEREQUESTS_DONE.md) - DialogueSystem spiegelt jede Zeile in die Box, Anzeigenamen aus neuer speakers-Map der Dialog-Dateien (Fallback: grossgeschriebene ID) - Einmal-Effekt-Grundlage: GameState.completed_dialogues (gespeichert, Save/Load-fest), DialogueSystem wendet Options-Effekte nur beim ersten Durchlauf an - Doc-Updates des Users eingecheckt: TYRVEIL.md (Protagonisten-Akte), WELT.md (Buch-Kanon), ueberarbeitete STORY/CHARACTERS/SPEC, CHANGEREQUESTS-Workflow Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
9fd103e9ce
commit
0f4ab3d3eb
14 changed files with 624 additions and 200 deletions
102
scripts/ui/dialogue_box.gd
Normal file
102
scripts/ui/dialogue_box.gd
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
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)
|
||||
|
||||
@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 (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 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)
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
extends CanvasLayer
|
||||
## Fokus-navigierbare Antwortauswahl für Dialoge (Phase 2a).
|
||||
##
|
||||
## Baut zur Laufzeit Buttons für die Antwortoptionen eines Dialog-Knotens
|
||||
## auf, unten mittig im Bild. Navigation über Pfeiltasten/D-Pad/linken
|
||||
## Stick, Aktivierung über confirm (Enter/Ⓐ/✕) — nach demselben Muster wie
|
||||
## im Hauptmenü: Events, die auch Godots ui_accept matchen, verarbeitet der
|
||||
## fokussierte Button selbst, nur die restlichen (Controller) lösen manuell
|
||||
## aus. choose() liefert den Index der gewählten Option als Coroutine.
|
||||
|
||||
signal option_chosen(index: int)
|
||||
|
||||
@onready var _options_box: VBoxContainer = $Root/OptionsBox
|
||||
|
||||
|
||||
## Startet unsichtbar; sichtbar wird die Auswahl nur über choose().
|
||||
func _ready() -> void:
|
||||
visible = false
|
||||
|
||||
|
||||
## Zeigt die Optionen 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
|
||||
|
||||
|
||||
## Aktiviert mit confirm den fokussierten Options-Button (nur solange die
|
||||
## Auswahl sichtbar ist); Fokus-Verlust wird auf die erste Option repariert.
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if not visible:
|
||||
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:
|
||||
for child in _options_box.get_children():
|
||||
_options_box.remove_child(child)
|
||||
child.queue_free()
|
||||
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(620, 44)
|
||||
button.pressed.connect(_on_option_pressed.bind(i))
|
||||
_options_box.add_child(button)
|
||||
if first_button == null:
|
||||
first_button = button
|
||||
visible = true
|
||||
if first_button != null:
|
||||
first_button.grab_focus.call_deferred()
|
||||
|
||||
|
||||
## Schließt die Auswahl und meldet den gewählten Index.
|
||||
func _on_option_pressed(index: int) -> void:
|
||||
visible = false
|
||||
option_chosen.emit(index)
|
||||
Loading…
Add table
Add a link
Reference in a new issue