From ce3b154483ddae82437b777247398d8c06f1c375 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 1 Nov 2021 11:19:40 -0400 Subject: [PATCH] add actor name to FlxHollywoo dialog box --- .../src/hollywoo_flixel/FlxDirector.kiss | 30 ++++++++++++++----- projects/hollywoo/src/hollywoo/Director.hx | 2 +- projects/hollywoo/src/hollywoo/Movie.kiss | 4 +-- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss index 8914b72d..e6e98c6b 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss @@ -61,9 +61,10 @@ (var DIALOG_SIZE 24) (var &mut :FlxSprite dialogBox) -(var &mut :FlxText dialog) +(var &mut :FlxText dialogText) +(var &mut :FlxText speakerNameText) -(method showDialog [:SpeechType type :String wryly :String text :Continuation cc] +(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 @@ -73,17 +74,30 @@ (FlxG.state.add dialogBox)) (dialogBox.revive) // show the dialog - (unless dialog - (set dialog (new FlxText DIALOG_X DIALOG_Y DIALOG_WIDTH "" DIALOG_SIZE)) - (FlxG.state.add dialog)) - (set dialog.text text) - (dialog.revive) + (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 ->{ - (dialog.kill) + (dialogText.kill) + (speakerNameText.kill) (dialogBox.kill) (cc) })) diff --git a/projects/hollywoo/src/hollywoo/Director.hx b/projects/hollywoo/src/hollywoo/Director.hx index 02aff59b..84bc1f91 100644 --- a/projects/hollywoo/src/hollywoo/Director.hx +++ b/projects/hollywoo/src/hollywoo/Director.hx @@ -13,5 +13,5 @@ interface Director { function showScene(scene:Scene, appearance:Appearance, cc:Continuation):Void; function showCharacter(character:Character, appearance:Appearance, cc:Continuation):Void; function waitForInputOrDelay(delaySeconds:Float, cc:Continuation):Void; - function showDialog(type:SpeechType, wryly:String, dialog:String, cc:Continuation):Void; + function showDialog(speakerName:String, type:SpeechType, wryly:String, dialog:String, cc:Continuation):Void; } diff --git a/projects/hollywoo/src/hollywoo/Movie.kiss b/projects/hollywoo/src/hollywoo/Movie.kiss index 00175f3c..9a5a819d 100644 --- a/projects/hollywoo/src/hollywoo/Movie.kiss +++ b/projects/hollywoo/src/hollywoo/Movie.kiss @@ -76,9 +76,9 @@ // TODO moveCharacterAndFollow remove them, add them to another scene, set that the scene (method normalSpeech [actorName wryly text cc] - (director.showDialog (OnScreen (dictGet .characters (_currentScene) actorName)) wryly text cc)) + (director.showDialog actorName (OnScreen (dictGet .characters (_currentScene) actorName)) wryly text cc)) (method onPhoneSpeech [actorName wryly text cc] - (director.showDialog (ifLet [charOnScreen (dictGet .characters (_currentScene) actorName)] + (director.showDialog actorName (ifLet [charOnScreen (dictGet .characters (_currentScene) actorName)] (OnScreen charOnScreen) (FromPhone (dictGet actors actorName))) wryly text cc)) \ No newline at end of file