make Movie the controller for handling state outside of director logic

This commit is contained in:
2021-10-27 15:23:17 -04:00
parent e24e85ea35
commit 02b39bf2a8
3 changed files with 47 additions and 3 deletions

View File

@@ -13,4 +13,5 @@ interface Director<Set, StagePosition, StageFacing, ScreenPosition, Actor> {
function showScene(scene:Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor>, appearance:Appearance, cc:Continuation):Void;
function showCharacter(character:Character<StagePosition, StageFacing, Actor>, appearance:Appearance, cc:Continuation):Void;
function waitForInputOrDelay(delaySeconds:Float, cc:Continuation):Void;
function showDialog(character:Character<StagePosition, StageFacing, Actor>, dialog:String, cc:Continuation):Void;
}

View File

@@ -1,6 +1,8 @@
package hollywoo;
import kiss.AsyncEmbeddedScript;
import kiss.Prelude;
import hollywoo.Scene;
/**
* Model/controller of a Hollywoo film, and main execution script

View File

@@ -1,6 +1,47 @@
// Mostly immutable, reusable resources:
(prop :Map<String,Set> sets (new Map))
(prop :Map<String,Actor> actors (new Map))
// "View" in the Model-View-Controller architecture:
(defNew [&prop :Director<Set,StagePosition,StageFacing,ScreenPosition,Actor> director] (super))
// TODO for some reason this won't work when declared in Kiss syntax:
// Mutable representation of frames in time:
// var scenes:Map<String, Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor>> = [];
(prop :Map<String,Bool> shownScenes (new Map))
(defNew
[
// "View" in the Model-View-Controller architecture:
&prop :Director<Set,StagePosition,StageFacing,ScreenPosition,Actor> director
]
(super))
(method newSet [name :Set set :Continuation cc]
(dictSet sets name set)
(cc))
(method newSceneFromSet [name :String setKey :SceneTime time :ScenePerspective perspective :Continuation cc]
(dictSet scenes name (objectWith
[
set
(dictGet sets setKey)
characters
(new Map)
]
time
perspective))
(cc))
(method newScene [name :Scene<Set,StagePosition,StageFacing,ScreenPosition,Actor> scene :Continuation cc]
(dictSet scenes name scene)
(cc))
(method setScene [name :Continuation cc]
(director.showScene
(dictGet scenes name)
(if (dictGet shownScenes name)
ReAppearance
{
(dictSet shownScenes name true)
FirstAppearance
})
cc))