dialog history support

This commit is contained in:
2023-06-12 12:32:19 -06:00
parent b50ef1ef70
commit 74132ee232
3 changed files with 17 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ interface Director<Set:Cloneable<Set>, Actor, Sound, Song, Prop, VoiceTrack, Cam
function resume():Void;
function showPauseMenu(resume:Continuation):Void;
function showDialogHistory(history:Array<HistoryElement<Actor>>, resume:Continuation):Void;
function chooseString(prompt:String, choices:Array<String>, submit:String->Void):Void;
function enterString(prompt:String, submit:String->Void):Void;

View File

@@ -37,6 +37,14 @@ typedef VoiceLine = {
?alts:Array<VoiceLine>
};
enum HistoryElement<Actor> {
Sound(caption:String);
Dialog(speakerName:String, type:SpeechType<Actor>, wryly:String, text:String);
Super(text:String);
// Scene change? To provide a horizontal divider or something? But what constitutes a scene change? Intercut would add too many.
// I don't want to manually define scene changes though.
}
// (speakerName, character, wryly, args, text, cc) -> cleanup function
typedef CustomDialogTypeHandler<Actor> = (String, Character<Actor>, String, Array<Dynamic>, String, Continuation) -> (Void->Void);

View File

@@ -11,6 +11,8 @@
(var MAX_CAPTION_DURATION 3)
(prop &mut :Int captionId 0)
(prop :Array<HistoryElement<Actor>> dialogHistory [])
// Mostly immutable, reusable resources:
(prop :FuzzyMap<Set> sets (new FuzzyMap<Set>))
(prop :FuzzyMap<Actor> actors (new FuzzyMap<Actor>))
@@ -68,6 +70,7 @@
(when _hideCustomDialog
(_hideCustomDialog)
(set _hideCustomDialog null))
(dialogHistory.push (Dialog actorName dialogType wryly text))
(processIntercut actorName
(makeCC
(let [cc ->:Void {(director.hideDialog) (cc)}
@@ -294,6 +297,8 @@
(shortcutHandler.start))
(shortcutHandler.registerItem "{escape} Pause the movie"
->cc (director.showPauseMenu cc))
(shortcutHandler.registerItem "{tab} show dialog history"
->cc (director.showDialogHistory dialogHistory cc))
(#when debug
(shortcutHandler.registerItem "[d]efine [d]elay"
@@ -462,6 +467,8 @@
(set volumeMod (or volumeMod 1))
(assert (<= 0 volumeMod 1))
(localVar &mut :Null<Int> id null)
(whenLet [desc (dictGet soundDescriptions name)]
(dialogHistory.push (Sound desc)))
(when showCaptions
(whenLet [desc (dictGet soundDescriptions name)]
(set id captionId++)
@@ -599,6 +606,7 @@
(hollywooMethod superText true [text :Continuation cc]
(dialogHistory.push (Super text))
// Skip voice track handling:
(director.showDialog "" Super "" text cc))