diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.hx b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.hx index c4e7b17e..3e4d5958 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.hx +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.hx @@ -16,10 +16,11 @@ import hollywoo_flixel.FlxMovie; import flixel.util.FlxColor; import flixel.text.FlxText; import flixel.system.FlxSound; +import flixel.FlxCamera; import flixel.util.FlxTimer; import haxe.Constraints; import kiss_flixel.SpriteTools; import haxe.ds.Option; @:build(kiss.Kiss.build()) -class FlxDirector implements Director {} +class FlxDirector implements Director {} diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss index 1412b3df..1b7da634 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss @@ -1,6 +1,6 @@ (prop :FlxActionDigital continueAction) (prop actionManager (new FlxActionManager)) -(prop &mut :Movie movie) +(prop &mut :Movie movie) (defAlias &ident flxMovie (cast movie FlxMovie)) (loadFrom "hollywoo-flixel" "src/hollywoo_flixel/Aliases.kiss") @@ -22,7 +22,7 @@ (spriteLayers.push g) (FlxG.state.add g)))) -(method :Void showSet [:FlxSprite setSprite :SceneTime time :ScenePerspective perspective :Appearance appearance :Continuation cc] +(method :Void showSet [:FlxSprite setSprite :SceneTime time :ScenePerspective perspective :Appearance appearance :FlxCamera camera :Continuation cc] (case appearance (FirstAppearance (setSprite.setGraphicSize FlxG.width) @@ -31,10 +31,17 @@ (setSprite.updateHitbox) (setSprite.screenCenter)) (otherwise)) + (FlxG.cameras.remove flxMovie.uiCamera false) + (FlxG.cameras.remove flxMovie.screenCamera false) + (FlxG.cameras.add camera) + (FlxG.cameras.add flxMovie.screenCamera) + (FlxG.cameras.add flxMovie.uiCamera) + (set setSprite.cameras [camera]) (FlxG.state.add setSprite) (cc)) -(method :Void hideSet [:FlxSprite set :Continuation cc] +(method :Void hideSet [:FlxSprite set :FlxCamera camera :Continuation cc] + (FlxG.cameras.remove camera false) (FlxG.state.remove set) (cc)) @@ -42,9 +49,10 @@ (method :Option autoZConfig [] (Some (object zPerLayer flxMovie.STAGE_BEHIND_DY frontLayer 0))) -(method :Void showCharacter [:Character character :Appearance appearance :Continuation cc] +(method :Void showCharacter [:Character character :Appearance appearance :FlxCamera camera :Continuation cc] // TODO on the first appearance, show name and description (maybe? also probably not for all?) // TODO also allow for manually defined flipped frames so text on clothing doesn't mirror + (set character.actor.cameras [camera]) (set character.actor.flipX ?!(= character.stageFacing character.actor.defaultFacing)) // All actors same width, display centered on x (character.actor.setGraphicSize flxMovie.ACTOR_WIDTH) @@ -62,7 +70,7 @@ (FlxG.state.add character.actor) (cc)) -(method :Void hideCharacter [:Character character :Continuation cc] +(method :Void hideCharacter [:Character character :FlxCamera camera :Continuation cc] (FlxG.state.remove character.actor) (cc)) @@ -136,11 +144,13 @@ (set dialogBox (new FlxSprite flxMovie.DIALOG_X flxMovie.DIALOG_Y)) (dialogBox.makeGraphic flxMovie.DIALOG_WIDTH flxMovie.DIALOG_HEIGHT DIALOG_BOX_COLOR)) + (set dialogBox.cameras [flxMovie.uiCamera]) (FlxG.state.add dialogBox) (dialogBox.revive) // show the dialog (unless dialogText (set dialogText (new FlxText flxMovie.DIALOG_X flxMovie.DIALOG_Y flxMovie.DIALOG_WIDTH "" DIALOG_SIZE))) + (set dialogText.cameras [flxMovie.uiCamera]) (FlxG.state.add dialogText) (set dialogText.text text) // TODO actually page through the dialog instead of sizing it down? @@ -152,6 +162,7 @@ // show the speaker name (unless speakerNameText (set speakerNameText (new FlxText flxMovie.DIALOG_X flxMovie.DIALOG_Y 0 "" DIALOG_SIZE))) + (set speakerNameText.cameras [flxMovie.uiCamera]) (FlxG.state.add speakerNameText) (if speakerName { @@ -278,6 +289,7 @@ (cc)) (method :Void showPropOnScreen [:FlxSprite prop :FlxScreenPosition position :Continuation cc] + (set prop.cameras [flxMovie.screenCamera]) // TODO give the prop reveal some time to land (add a delay to the cc) (ifLet [(FullControl layer rpos) position] (smartShowPropOnScreen prop layer rpos cc) diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxMovie.hx b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxMovie.hx index 490cabbf..f8881fd2 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxMovie.hx +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxMovie.hx @@ -3,6 +3,7 @@ package hollywoo_flixel; import flixel.FlxState; import flixel.FlxSprite; import flixel.system.FlxSound; +import flixel.FlxCamera; import hollywoo.Director; import hollywoo.Movie; import hollywoo_flixel.ActorFlxSprite; @@ -39,7 +40,7 @@ enum FlxScreenPosition { /** * Model/controller of a Hollywoo-Flixel film, and main execution script */ -class FlxMovie extends Movie { +class FlxMovie extends Movie { // Think of HollywooFlixelDSL.kiss as the corresponding Kiss file for this class! public function new(director:FlxDirector, ?voiceLinesAssetPath:String) { @@ -50,6 +51,8 @@ class FlxMovie extends Movie, ScreenPosition, Actor, Sound, Song, Prop, VoiceTrack> { - var movie(default, default):Movie; +interface Director, ScreenPosition, Actor, Sound, Song, Prop, VoiceTrack, Camera> { + var movie(default, default):Movie; function autoZConfig():Option; - function showSet(set:Set, time:SceneTime, perspective:ScenePerspective, appearance:Appearance, cc:Continuation):Void; - function hideSet(set:Set, cc:Continuation):Void; - function showCharacter(character:Character, appearance:Appearance, cc:Continuation):Void; - function hideCharacter(character:Character, cc:Continuation):Void; + function showSet(set:Set, time:SceneTime, perspective:ScenePerspective, appearance:Appearance, camera:Camera, cc:Continuation):Void; + function hideSet(set:Set, camera: Camera, cc:Continuation):Void; + function showCharacter(character:Character, appearance:Appearance, camera:Camera, cc:Continuation):Void; + function hideCharacter(character:Character, camera:Camera, cc:Continuation):Void; function playSound(sound:Sound, volumeMod:Float, waitForEnd:Bool, cc:Continuation):Void; function stopSound(sound:Sound):Void; function playSong(song:Song, volumeMod:Float, loop:Bool, waitForEnd:Bool, cc:Continuation):Void; diff --git a/projects/hollywoo/src/hollywoo/Movie.hx b/projects/hollywoo/src/hollywoo/Movie.hx index a0b5683b..ab397cc1 100644 --- a/projects/hollywoo/src/hollywoo/Movie.hx +++ b/projects/hollywoo/src/hollywoo/Movie.hx @@ -42,4 +42,4 @@ enum CreditsLine { * Model/controller of a Hollywoo film, and main execution script */ @:build(kiss.Kiss.build()) -class Movie, ScreenPosition, Actor, Sound, Song, Prop, VoiceTrack> extends AsyncEmbeddedScript {} +class Movie, ScreenPosition, Actor, Sound, Song, Prop, VoiceTrack, Camera> extends AsyncEmbeddedScript {} diff --git a/projects/hollywoo/src/hollywoo/Movie.kiss b/projects/hollywoo/src/hollywoo/Movie.kiss index ee88e7ca..befd0217 100644 --- a/projects/hollywoo/src/hollywoo/Movie.kiss +++ b/projects/hollywoo/src/hollywoo/Movie.kiss @@ -18,7 +18,7 @@ (prop &mut :DelayHandling delayHandling AutoWithSkip) // Mutable representation of frames in time: - (prop :FuzzyMap> scenes (new FuzzyMap>)) + (prop :FuzzyMap> scenes (new FuzzyMap>)) (prop :FuzzyMap shownScenes (new FuzzyMap)) (prop :FuzzyMap shownCharacters (new FuzzyMap)) @@ -105,13 +105,13 @@ (if sceneKey // hide current scene background (let [currentScene (dictGet scenes sceneKey)] - (director.hideSet currentScene.set + (director.hideSet currentScene.set currentScene.camera (makeCC // hide current scene characters (_ccForEach currentScene.characters ->[:Character c :Continuation cc] - (director.hideCharacter c cc) + (director.hideCharacter c currentScene.camera cc) (makeCC // hide current scene props, etc. (_ccForEach @@ -121,15 +121,15 @@ cc)))))) (cc))) - (method _showScene [:Scene scene :Appearance appearance :Continuation cc] + (method _showScene [:Scene scene :Appearance appearance :Camera camera :Continuation cc] // Show current scene background - (director.showSet scene.set scene.time scene.perspective appearance + (director.showSet scene.set scene.time scene.perspective appearance camera (makeCC // Show current scene characters (_ccForEach (object iterator ->(scene.characters.keys)) ->[:String key :Continuation cc] - (director.showCharacter (dictGet scene.characters key) (appearanceFlag shownCharacters key) cc) + (director.showCharacter (dictGet scene.characters key) (appearanceFlag shownCharacters key) camera cc) (makeCC // hide current scene props, etc. (_ccForEach @@ -141,7 +141,7 @@ (defNew [ // "View" in the Model-View-Controller architecture: - &prop :Director director + &prop :Director director &opt :String voiceLinesJson &opt :String positionsJson ] @@ -219,7 +219,7 @@ (assert isLoading) (dictSet sets name set)) -(hollywooMethod newSceneFromSet true [name :String setKey :SceneTime time :ScenePerspective perspective] +(hollywooMethod newSceneFromSet true [name :String setKey :SceneTime time :ScenePerspective perspective :Camera camera] (assert isLoading) (dictSet scenes name (objectWith [ @@ -229,6 +229,8 @@ (new FuzzyMap>) propsOnScreen (new FuzzyMap>) + camera + camera ] time perspective))) @@ -240,6 +242,7 @@ (_showScene (dictGet scenes name) (appearanceFlag shownScenes name) + .camera (dictGet scenes name) cc)))) @@ -305,12 +308,13 @@ (director.showCharacter character (appearanceFlag shownCharacters actorName) + .camera (_currentScene) cc))))) (hollywooMethod removeCharacter false [actorName :Continuation cc] (let [c (dictGet .characters (_currentScene) actorName)] (.remove .characters (_currentScene) actorName) - (director.hideCharacter c cc))) + (director.hideCharacter c .camera (_currentScene) cc))) // INSTANTLY move a character: (hollywooMethod moveCharacter false [actorName :Dynamic newPosition :StageFacing newFacing :Continuation cc] diff --git a/projects/hollywoo/src/hollywoo/Scene.hx b/projects/hollywoo/src/hollywoo/Scene.hx index 89ab499f..3e8b2959 100644 --- a/projects/hollywoo/src/hollywoo/Scene.hx +++ b/projects/hollywoo/src/hollywoo/Scene.hx @@ -38,11 +38,12 @@ typedef ScreenProp = { prop:Prop }; -typedef Scene, ScreenPosition, Actor, Prop> = { +typedef Scene, ScreenPosition, Actor, Prop, Camera> = { set:Set, characters:FuzzyMap>, propsOnScreen:FuzzyMap>, // TODO props on stage time:SceneTime, - perspective:ScenePerspective + perspective:ScenePerspective, + camera:Camera };