Add voice track support to Hollywoo
This commit is contained in:
@@ -9,17 +9,19 @@ enum Appearance {
|
||||
|
||||
typedef Continuation = Void -> Void;
|
||||
|
||||
interface Director<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song, Prop> {
|
||||
var movie(default, default):Movie<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song, Prop>;
|
||||
interface Director<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song, Prop, VoiceTrack> {
|
||||
var movie(default, default):Movie<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song, Prop, VoiceTrack>;
|
||||
function showScene(scene:Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor, Prop>, appearance:Appearance, cc:Continuation):Void;
|
||||
function showCharacter(character:Character<StagePosition, StageFacing, Actor>, appearance:Appearance, cc:Continuation):Void;
|
||||
function hideCharacter(character:Character<StagePosition, StageFacing, Actor>, cc:Continuation):Void;
|
||||
function playSound(sound:Sound, volumeMod:Float, waitForEnd:Bool, cc:Continuation):Void;
|
||||
function playSong(song:Song, volumeMod:Float, loop:Bool, waitForEnd:Bool, cc:Continuation):Void;
|
||||
function playVoiceTrack(track:VoiceTrack, volumeMod:Float, start:Float, end:Float, cc:Continuation):Void;
|
||||
function stopSong():Void;
|
||||
function startWaitForInput(cc:Continuation):Void;
|
||||
function stopWaitForInput():Void;
|
||||
function showDialog(speakerName:String, type:SpeechType<StagePosition, StageFacing, Actor>, wryly:String, dialog:String, cc:Continuation):Void;
|
||||
function hideDialog():Void;
|
||||
function showPropOnScreen(prop:Prop, position:ScreenPosition, cc:Continuation):Void;
|
||||
// TODO showPropOnStage
|
||||
function hideProp(prop:Prop, cc:Continuation):Void;
|
||||
|
@@ -7,6 +7,8 @@ import kiss.Prelude;
|
||||
import kiss.FuzzyMap;
|
||||
import hollywoo.Scene;
|
||||
import hollywoo.Director;
|
||||
import haxe.Json;
|
||||
import uuid.Uuid;
|
||||
|
||||
enum DelayHandling {
|
||||
Auto;
|
||||
@@ -14,11 +16,17 @@ enum DelayHandling {
|
||||
Manual;
|
||||
}
|
||||
|
||||
typedef VoiceLine = {
|
||||
trackKey:String,
|
||||
start:Float,
|
||||
end:Float
|
||||
};
|
||||
|
||||
/**
|
||||
* Model/controller of a Hollywoo film, and main execution script
|
||||
*/
|
||||
@:build(kiss.Kiss.build())
|
||||
class Movie<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song, Prop> extends AsyncEmbeddedScript {
|
||||
class Movie<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song, Prop, VoiceTrack> extends AsyncEmbeddedScript {
|
||||
// TODO for some reason this wasn't working when declared in Movie.kiss:
|
||||
// Mutable representation of frames in time:
|
||||
var scenes:FuzzyMap<Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor, Prop>> = new FuzzyMap<Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor, Prop>>();
|
||||
|
@@ -7,6 +7,8 @@
|
||||
(prop :FuzzyMap<Sound> sounds (new FuzzyMap<Sound>))
|
||||
(prop :FuzzyMap<Song> songs (new FuzzyMap<Song>))
|
||||
(prop :FuzzyMap<Prop> props (new FuzzyMap<Prop>))
|
||||
(prop :Map<String,VoiceTrack> voiceTracks (new Map))
|
||||
(prop :FuzzyMap<VoiceLine> voiceLines (new FuzzyMap<VoiceLine>))
|
||||
|
||||
(prop &mut :DelayHandling delayHandling AutoWithSkip)
|
||||
|
||||
@@ -32,16 +34,30 @@
|
||||
(method _currentScene [] (dictGet scenes sceneKey))
|
||||
|
||||
(prop &mut :Map<String,String> intercutMap)
|
||||
(method showDialog [actorName dialogType wryly text cc]
|
||||
(method :Void showDialog [actorName dialogType wryly text cc]
|
||||
(when intercutMap
|
||||
(whenLet [sceneForActor (dictGet intercutMap actorName)]
|
||||
(setScene sceneForActor ->{})))
|
||||
(director.showDialog actorName dialogType wryly text cc))
|
||||
|
||||
(let [cc ->:Void {(director.hideDialog) (cc)}]
|
||||
(director.showDialog actorName dialogType wryly text cc)
|
||||
(when (< 0 (count voiceTracks))
|
||||
(case (try (dictGet voiceLines "$actorName $text") (catch [e] (print e) null))
|
||||
((objectWith trackKey start end)
|
||||
(director.playVoiceTrack (dictGet voiceTracks trackKey) 1 start end cc))
|
||||
(otherwise)))))
|
||||
|
||||
(method newVoiceTrack [actorName :VoiceTrack track :String lineJson]
|
||||
(let [trackKey (Uuid.v4)
|
||||
:haxe.DynamicAccess<Dynamic> lines (Json.parse lineJson)]
|
||||
(dictSet voiceTracks trackKey track)
|
||||
(doFor =>key line (lines.keyValueIterator)
|
||||
(dictSet voiceLines "$actorName $key" (objectWith [start line.start end line.end] trackKey)))))
|
||||
|
||||
(defNew
|
||||
[
|
||||
// "View" in the Model-View-Controller architecture:
|
||||
&prop :Director<Set,StagePosition,StageFacing,ScreenPosition,Actor,Sound,Song,Prop> director
|
||||
&prop :Director<Set,StagePosition,StageFacing,ScreenPosition,Actor,Sound,Song,Prop,VoiceTrack> director
|
||||
]
|
||||
|
||||
(set director.movie this)
|
||||
|
Reference in New Issue
Block a user