(prop :FlxActionDigital continueAction) (prop actionManager (new FlxActionManager)) (defNew [] (set continueAction (new FlxActionDigital "Continue" onContinue)) // TODO allow configuring continue keys -- any key, specifically mapped keys, etc. (continueAction.addKey SPACE JUST_PRESSED) (continueAction.addMouse LEFT JUST_PRESSED) (actionManager.addAction continueAction) (FlxG.inputs.add actionManager) (set actionManager.resetOnStateSwitch NONE)) (method :Void showScene [:Scene scene :Appearance appearance :Continuation cc] // TODO on the first appearance, give a super (for some scenes but probably not others... hm....) (FlxG.switchState (cast scene SceneFlxState)) (cc)) (var STAGE_LEFT_X 150) (var STAGE_RIGHT_X (- 1280 150)) (var ACTOR_Y 500) (var ACTOR_WIDTH 300) (method :Void showCharacter [:Character character :Appearance appearance :Continuation cc] // TODO on the first appearance, show name and description (maybe? also probably not for all?) // TODO flip sprite if facing left, and also allow for manually defined flipped frames so text doesn't mirror (character.actor.setGraphicSize ACTOR_WIDTH) (set character.actor.x (- (case character.stagePosition (Left STAGE_LEFT_X) (Right STAGE_RIGHT_X)) (/ character.actor.width 2))) (set character.actor.y ACTOR_Y) (FlxG.state.add character.actor) (cc)) (prop &mut :Null nextCC) (method onContinue [:FlxActionDigital continueAction] (whenLet [cc nextCC] (set nextCC null) (cc))) (method :Void waitForInputOrDelay [:Float delaySeconds :Continuation cc] // TODO allow user to choose between automatic delays and continue checks (if true //{ (set nextCC cc) // TODO show an indicator that input is needed //} ) ) (var DIALOG_X 300) (var DIALOG_WIDTH (- 1280 ACTOR_WIDTH ACTOR_WIDTH)) (var DIALOG_Y 500) (var DIALOG_HEIGHT (- 720 DIALOG_Y)) // TODO these could be customizable to the Actor (var DIALOG_BOX_COLOR FlxColor.BLACK) (var DIALOG_COLOR FlxColor.WHITE) (var DIALOG_SIZE 24) (var &mut :FlxSprite dialogBox) (var &mut :FlxText dialogText) (var &mut :FlxText speakerNameText) (method showDialog [:String speakerName :SpeechType type :String wryly :String text :Continuation cc] // TODO handle text messages, wrylies, off-screen, from-phone, etc. via (case type) // TODO attribute on-screen dialogue to the character's stageposition // Make a dialog box (unless dialogBox (set dialogBox (new FlxSprite DIALOG_X DIALOG_Y)) (dialogBox.makeGraphic DIALOG_WIDTH DIALOG_HEIGHT DIALOG_BOX_COLOR) (FlxG.state.add dialogBox)) (dialogBox.revive) // show the dialog (unless dialogText // TODO use FlxTypeText to reveal dialog gradually (set dialogText (new FlxText DIALOG_X DIALOG_Y DIALOG_WIDTH "" DIALOG_SIZE)) (FlxG.state.add dialogText)) (set dialogText.text text) // show the speaker name (unless speakerNameText (set speakerNameText (new FlxText DIALOG_X DIALOG_Y DIALOG_WIDTH "" DIALOG_SIZE)) (FlxG.state.add speakerNameText)) (if speakerName { (set speakerNameText.text "${speakerName}:") (speakerNameText.revive) (set dialogText.y (+ DIALOG_Y speakerNameText.height)) } (set dialogText.y DIALOG_Y)) (dialogText.revive) // wait for input // TODO customize the delay to the dialog length or voice-over length (waitForInputOrDelay 5 ->{ (dialogText.kill) (speakerNameText.kill) (dialogBox.kill) (cc) })) (method :Void playSound [:FlxSound sound :Float volumeMod :Continuation cc] // TODO preserve its original volume (set sound.volume volumeMod) (set sound.onComplete cc) (sound.play))