harvest/game/scripts/dialogue_speaker.gd
Forrest 1d92f49d96 Talking-head dialogue: DialogueDirector, DialogueBox, conversations and speakers
Conversations saved in game/resources/dialogue/ play once at their night and
phase in a paper box with talking heads; example: the morning of day 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 21:33:54 -04:00

51 lines
2.3 KiB
GDScript

class_name DialogueSpeaker
extends Resource
## Someone who talks in a conversation (Conversation, shown by DialogueBox): their name, their
## picture (the talking head, standing behind the box's top edge), the side of the box they stand
## on, and how their name and words look. Save one per character (game/resources/dialogue/
## speakers/) and use it in every line they say; a line (DialogueLine) can change the look of its
## own words, and its text takes BBCode ([i]...[/i], [color=red], ...).
enum HeadSide { LEFT, RIGHT }
## Where the words sit on the paper: on the speaker's side (as their name is), or set.
enum Align { SIDE, LEFT, CENTER, RIGHT }
@export var display_name := ""
## The talking head (a picture with a transparent background), scaled to portrait_height.
@export var portrait: Texture2D
## Optional mouth flaps: shown in turn with portrait while the words are being written.
@export var talk_frames: Array[Texture2D] = []
## Placeholder art while there's no portrait: one of Sketch.ICONS ("portrait" is the scarecrow,
## "thief" an alien, "breaker" a robot, "crow", "ufo").
@export var icon := ""
@export var side: HeadSide = HeadSide.LEFT
@export_group("Portrait")
@export_range(60.0, 800.0, 1.0, "suffix:px") var portrait_height := 360.0
## Nudges the head from its place (+x right, +y down).
@export var portrait_offset := Vector2.ZERO
## Mirrors the picture (to face the other way).
@export var flip := false
@export_group("Name")
@export var name_color := Sketch.PAPER_INK
@export_range(8, 120) var name_size := 50
@export_group("Words")
## Empty: the handwritten font of the morning sign (Sketch.font()).
@export var font: Font
@export var text_color := Sketch.PAPER_INK
@export_range(8, 120) var font_size := 36
@export var italic := false
@export var bold := false
@export var align: Align = Align.SIDE
## How fast the words are written; 0 shows each line at once.
@export_range(0.0, 200.0, 1.0, "suffix:letters/s") var letters_per_second := 45.0
@export_group("Voice")
## A short blip played as the words are written (none: silent).
@export var voice: AudioStream
@export_range(0.25, 4.0, 0.01) var voice_pitch := 1.0
@export_range(-40.0, 12.0, 0.5, "suffix:dB") var voice_volume_db := -10.0
## A blip every this many letters.
@export_range(1, 10) var voice_every := 2