A cool cabin
This commit is contained in:
15
src/hollywoo/Director.hx
Normal file
15
src/hollywoo/Director.hx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package hollywoo;
|
||||||
|
|
||||||
|
import hollywoo.Stage;
|
||||||
|
|
||||||
|
enum Appearance {
|
||||||
|
FirstAppearance;
|
||||||
|
ReAppearance; // Could count the number of appearances with an int, but I don't see any reason that would be important
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef Continuation = Void -> Void;
|
||||||
|
|
||||||
|
interface Director<Set, StagePosition, StageFacing, ScreenPosition, Actor> {
|
||||||
|
function showSet(set:Set, appearance:Appearance, cc:Continuation):Void;
|
||||||
|
function showCharacter(character:Character<StagePosition, StageFacing, Actor>, appearance:Appearance, cc:Continuation):Void;
|
||||||
|
}
|
1
src/hollywoo/HollywooDSL.kiss
Normal file
1
src/hollywoo/HollywooDSL.kiss
Normal file
@@ -0,0 +1 @@
|
|||||||
|
(defNew [director] (super director))
|
@@ -2,6 +2,12 @@ package hollywoo;
|
|||||||
|
|
||||||
import kiss.Kiss;
|
import kiss.Kiss;
|
||||||
import kiss.Prelude;
|
import kiss.Prelude;
|
||||||
|
import hollywoo.text.TextDirector;
|
||||||
|
import hollywoo.text.TextStage;
|
||||||
|
import kiss.EmbeddedScript;
|
||||||
|
|
||||||
|
@:build(kiss.EmbeddedScript.build("HollywooDSL.kiss", "examples/pure-hollywoo/basic.hollywoo"))
|
||||||
|
class BasicHollywoo extends TextStage {}
|
||||||
|
|
||||||
@:build(kiss.Kiss.build())
|
@:build(kiss.Kiss.build())
|
||||||
class Main {}
|
class Main {}
|
||||||
|
@@ -1 +1,4 @@
|
|||||||
(print "Hello world!")
|
(defMacro runTextExample [exampleClass]
|
||||||
|
`(.run (new ,exampleClass (new TextDirector))))
|
||||||
|
|
||||||
|
(runTextExample BasicHollywoo)
|
43
src/hollywoo/Stage.hx
Normal file
43
src/hollywoo/Stage.hx
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package hollywoo;
|
||||||
|
|
||||||
|
import kiss.EmbeddedScript;
|
||||||
|
|
||||||
|
enum SceneTime {
|
||||||
|
Morning;
|
||||||
|
Day;
|
||||||
|
Evening;
|
||||||
|
Night;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ScenePerspective {
|
||||||
|
Interior;
|
||||||
|
Exterior;
|
||||||
|
Mixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef Character<StagePosition, StageFacing, Actor> = {
|
||||||
|
stagePosition:StagePosition,
|
||||||
|
stageFacing:StageFacing,
|
||||||
|
actor:Actor
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor> = {
|
||||||
|
set:Set,
|
||||||
|
characters:Map<String, Character<StagePosition, StageFacing, Actor>>,
|
||||||
|
time:SceneTime,
|
||||||
|
perspective:ScenePerspective
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model of a Hollywoo film
|
||||||
|
*/
|
||||||
|
@:build(kiss.Kiss.build())
|
||||||
|
class Stage<Set, StagePosition, StageFacing, ScreenPosition, Actor> extends kiss.EmbeddedScript {
|
||||||
|
// Mostly immutable, reusable resources:
|
||||||
|
var sets:Map<String, Set> = [];
|
||||||
|
var actors:Map<String, Actor> = [];
|
||||||
|
|
||||||
|
|
||||||
|
// Mutable representation of frames in time:
|
||||||
|
var scenes:Map<String, Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor>> = [];
|
||||||
|
}
|
2
src/hollywoo/Stage.kiss
Normal file
2
src/hollywoo/Stage.kiss
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
// "View" in the Model-View-Controller architecture:
|
||||||
|
(defNew [&prop :Director<Set,StagePosition,StageFacing,ScreenPosition,Actor> director] (super))
|
@@ -1,4 +1,4 @@
|
|||||||
|||Title: The First Hollywoo Script
|
|||Title: The First Fountain->Hollywoo Script
|
||||||
Credit: written by
|
Credit: written by
|
||||||
Author: Nat Quayle Nelson (she/her)
|
Author: Nat Quayle Nelson (she/her)
|
||||||
Contact: natquaylenelson@gmail.com
|
Contact: natquaylenelson@gmail.com
|
1
src/hollywoo/examples/pure-hollywoo/basic.hollywoo
Normal file
1
src/hollywoo/examples/pure-hollywoo/basic.hollywoo
Normal file
@@ -0,0 +1 @@
|
|||||||
|
(director.showSet (object name "Cabin" description "A cool cabin") FirstAppearance ->:Void {})
|
30
src/hollywoo/text/TextDirector.hx
Normal file
30
src/hollywoo/text/TextDirector.hx
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package hollywoo.text;
|
||||||
|
|
||||||
|
import hollywoo.text.TextStage;
|
||||||
|
import hollywoo.Director;
|
||||||
|
|
||||||
|
class TextDirector implements Director<TextSet, TextStagePosition, TextStageFacing, TextScreenPosition, TextActor> {
|
||||||
|
public function new() {}
|
||||||
|
|
||||||
|
public function showSet(set:TextSet, appearance:Appearance, cc:Continuation) {
|
||||||
|
switch (appearance) {
|
||||||
|
case FirstAppearance:
|
||||||
|
Sys.println('-- ${set.name} --');
|
||||||
|
Sys.println(set.description);
|
||||||
|
case ReAppearance:
|
||||||
|
Sys.println('-- back at the ${set.name}');
|
||||||
|
}
|
||||||
|
cc();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showCharacter(character:TextCharacter, appearance:Appearance, cc:Continuation) {
|
||||||
|
switch ([appearance, character.stagePosition]) {
|
||||||
|
case [_, OffStage]:
|
||||||
|
case [FirstAppearance, OnStage]:
|
||||||
|
Sys.println('A ${character.actor.description} is onstage. This is ${character.actor.name}');
|
||||||
|
case [ReAppearance, OnStage]:
|
||||||
|
Sys.println('${character.actor.name} is here');
|
||||||
|
}
|
||||||
|
cc();
|
||||||
|
}
|
||||||
|
}
|
26
src/hollywoo/text/TextStage.hx
Normal file
26
src/hollywoo/text/TextStage.hx
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package hollywoo.text;
|
||||||
|
|
||||||
|
import hollywoo.Stage;
|
||||||
|
|
||||||
|
typedef TextSet = {
|
||||||
|
name:String,
|
||||||
|
description:String
|
||||||
|
}
|
||||||
|
|
||||||
|
enum TextStagePosition {
|
||||||
|
OnStage;
|
||||||
|
OffStage;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef TextStageFacing = String;
|
||||||
|
|
||||||
|
typedef TextScreenPosition = Int; // number of line breaks to precede a SUPER
|
||||||
|
|
||||||
|
typedef TextCharacter = Character<TextStagePosition, TextStageFacing, TextActor>;
|
||||||
|
|
||||||
|
typedef TextActor = {
|
||||||
|
name:String,
|
||||||
|
description:String
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef TextStage = Stage<TextSet, TextStagePosition, TextStageFacing, TextScreenPosition, TextActor>;
|
Reference in New Issue
Block a user