Expand description
Dialogue scripts (.dlg files): scenes of portraits, speech, narration,
reply choices and music changes. parse_dlg turns a file into scenes,
check_scene and check_duplicates validate them against the
game’s SceneRules, and print_scene writes a scene back out.
Every line that shows text has a LineId. Lines in an @if block
play only while a character is there (Present).
A game adds directives of its own (a place behind the talk, a cut to a
map) with a Directive type: the parser hands it every @name it
doesn’t know, and a scene keeps the steps it makes in order.
As a format (ADR-0007), Dlg reads a file’s scenes
(DialogueFile), and scripts_from_parsed checks them.
The format, for a game that adds no directive:
@scene gate_talk
@caption The east gate, dusk
@left mentor neutral
@right scout happy
mentor: Is the road clear?
scout[sad] (quietly, out of breath): Not since noon.
Riders came over the hill.
> Rain begins to fall.
@delivery low, keeping out of sight
mentor: Then we go by the river.
@delivery clear
@music storm
@choice
* earnest: Then we wait.
mentor: Agreed.
* wry: Then we get wet.
@endchoice
@if scout
scout: I'll keep watch.
@else
> Nobody keeps watch.
@endif
@endStructs§
- Character
Id - String id of a named character, e.g.
"guard_captain". Serialised as the bare string, so files name a character as"guard_captain". - Choice
Option - One reply the player can pick:
* <tone>: <text>, then its reaction. - Dialogue
File - The scenes of one
.dlgfile as written, each with where it is: what the.dlgformat (Dlg) reads.scripts_from_parsedchecks them against the game’s rules, once its characters, names and music are loaded. - Dialogue
Limits - How much text a game’s dialogue box and reply menu hold: the limits the
checks keep a script to, counted in cells (
text_width). - Dialogue
Table - Every scene of every dialogue file, by id. Build it with
DialogueTable::neworDefault(ADR-0039). - Dlg
- The
.dlgformat (dlg,.dlg) of a game whose own directives areD: a file’s scenes, with every syntax and structure errorparse_dlgfinds. The checks that need the game’s rules arescripts_from_parsed’s. - Line
- One line that shows text, as
Scene::lineslists it. - LineId
- The id of one dialogue line:
<scene id>_<8 hex>, with_2,_3… on repeats of the same speaker and text in one scene. Unique across every dialogue file. Empty on a step built by hand untilScene::assign_line_idsruns (the parser runs it). - Lines
- Where the steps of one list of steps (a scene’s, a reaction’s, one part
of an
@ifblock) are in the file. - NoTokens
- The tokens of a game that fills in nothing but names. Play its scenes
with
Named(orPlainif its text has no name tokens). - Parsed
- What
Directive::parseread from one line. - Parsed
Scene - A scene as written in a file, with the source lines the checks point at.
- Part
Lines - Where one part of a block is: an option of a
@choice, or one of the two parts of an@ifblock. - Scene
- One scene:
@scene <id>…@end. - Scripts
- Every scene of every dialogue file, with where each was written: what checks that need more of the game’s data run on once that is loaded.
- Scripts
Check scripts_from_parsedone scene at a time, for a game that must hand control back to its platform between them (a handheld’s update callback, which its OS ends when it runs too long):Self::new, thenSelf::check_nextas many times asSelf::uncheckedsays, thenSelf::finish. The scripts and the errors are the same.
Enums§
- Music
Line - What a
@musicline asks for. - NoDirective
- The directives of a game that adds none: there are no such steps.
- Present
- Who is there when a scene plays.
- Side
- A side of the dialogue screen, where one portrait stands.
- Step
- One step of a scene, in script order.
Dis the game’s own directives.
Constants§
- NARRATION_
SPEAKER - What stands for the speaker in a narration line’s hash and listing.
- REPLY_
SPEAKER - What stands for the speaker in a reply’s hash and listing.
Traits§
- Directive
- A step a game adds to the format:
@<name> <args>, for a name the engine’s own directives don’t use. The parser reads it withDirective::parse, a scene keeps it in order asStep::Directive, and the game plays it. - Scene
Rules - What
check_scenechecks a scene against: the game’s limits, tokens and names, and whatever it knows of its characters, portraits and music. A check the game has nothing for passes. - Tokens
- The
{tokens}a game fills in itself, besides the names table’s ({n:<id>},Names): a player-named hero’s name, say.
Functions§
- bad_id
- What an id that isn’t one (
is_id) is told. - caption_
key - The key a language pack translates the caption
textof scenesceneby:caption.<scene id>_<8 hex>, hashed like a line id. The same caption twice in a scene has one key. - char_
problem - What is wrong with character
cin dialogue text, if anything: text holds any character but a control character. Whether the font draws it is checked once the game’s text and its atlas load (crate::font::undrawn), not here. - check_
duplicates - One error for each scene whose id an earlier scene (in any file) already has.
- check_
scene - Checks one scene against
rules, replaying it to know who is on screen at each line. - is_id
- Whether
sis a valid scene, character or expression id: lowercase ASCII letters, digits and_, not empty. - line_
hash - The hash part of a line id: the low 32 bits of FNV-1a 64 over
speaker, a newline andtext, as 8 lowercase hex digits. - lines_
at_ longest - Lines
texttakes in a boxwidthcells wide (word_wrap, a wide character ofwidthstwo cells) once every token is filled in as its longest: each token is written out as that manyWs, with the tokens and names counted as inlongest_width. A token is so a Latin run that is never broken, the worst case (a typed name of that length). A line that fits the box here fits it with any player’s name. - longest_
width - Cells
textcan take once every token is filled in, at most (text_width, a wide character ofwidthstwo cells): the game’stokensat their longest (Tokens::longest) and every name token aslongest_name(the longest name in the table, so a rename can’t push the line over its limit). Unknown tokens, and name tokens without a table, count as written. - parse_
dlg - Parses dialogue
source(errors attributed tofile) into its scenes, in file order, and every syntax error found. A scene with errors in it is still returned (without the broken lines), so later checks can run. A directive the engine doesn’t know is read by the game’sD. - print_
scene - Writes
scenein.dlgformat (one line per step, reactions indented under their option, an@ifblock’s lines as far in as its@if), ending with@endand a newline. Parsing the result givessceneback. - scene_
of - The id of the scene the line with id
idis in, orNoneifiddoesn’t end like a line id (_<8 hex>, then_<n>on a repeat). - scripts_
from_ files - Like
scripts_from_sources, for files given as(file name, source)where aNonesource is a file that isn’t valid UTF-8 (an error). - scripts_
from_ parsed - Validates scenes already parsed (
files, from the.dlgformatDlg, in file order) asscripts_from_sourcesdoes: each scene withcheck_sceneand the game’s ownSceneRules::scene_problems, then the scene ids across files. - scripts_
from_ sources - Parses and validates dialogue files given as
(file name, source)pairs, each scene withcheck_sceneand the game’s ownSceneRules::scene_problems, then the scene ids across files. Reports every problem, ordered by file and line. - token_
problems - What is wrong with the
{...}oftext, in order: each must be one of the game’stokensor a name token with an id innames(any valid id without a table), and every{must close. The rule for a script and for every language pack’s dialogue text.