diff --git a/assets/data/dialogue/boxes/default.xml b/assets/data/dialogue/boxes/default.xml index ed6409cd..90e63022 100644 --- a/assets/data/dialogue/boxes/default.xml +++ b/assets/data/dialogue/boxes/default.xml @@ -1,6 +1,13 @@ - + + + + diff --git a/buildnumber.txt b/buildnumber.txt index 9006f06e..5a8694e0 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -2122 \ No newline at end of file +2129 \ No newline at end of file diff --git a/source/funkin/cutscenes/DialogueCutscene.hx b/source/funkin/cutscenes/DialogueCutscene.hx index 36d904a5..e551bdab 100644 --- a/source/funkin/cutscenes/DialogueCutscene.hx +++ b/source/funkin/cutscenes/DialogueCutscene.hx @@ -56,7 +56,7 @@ class DialogueCutscene extends Cutscene { // Add dialogue box dialogueBox = new DialogueBox(dialogueData.getAtt("box").getDefault("default")); add(dialogueBox); - + add(dialogueBox.text); next(); @@ -84,7 +84,7 @@ class DialogueCutscene extends Cutscene { if (charMap[curLine.char] != null) dialogueBox.popupChar(charMap[curLine.char]); - dialogueBox.playBubbleAnim(curLine.bubble); + dialogueBox.playBubbleAnim(curLine.bubble, curLine.text, curLine.speed); } public override function destroy() { diff --git a/source/funkin/cutscenes/dialogue/DialogueBox.hx b/source/funkin/cutscenes/dialogue/DialogueBox.hx index 8cb57169..c27314e0 100644 --- a/source/funkin/cutscenes/dialogue/DialogueBox.hx +++ b/source/funkin/cutscenes/dialogue/DialogueBox.hx @@ -1,5 +1,7 @@ package funkin.cutscenes.dialogue; +import flixel.addons.text.FlxTypeText; +import flixel.text.FlxText; import openfl.utils.Assets; import flixel.FlxG; import flixel.math.FlxPoint; @@ -12,6 +14,8 @@ class DialogueBox extends FunkinSprite { public var textTypeSFX:String = Paths.sound('dialogue/text'); public var nextSFX:String = Paths.sound('dialogue/next'); + public var text:FlxTypeText; + public function new(name:String) { super(); try { @@ -42,6 +46,18 @@ class DialogueBox extends FunkinSprite { if (dialogueBoxData.has.x) x += Std.parseFloat(dialogueBoxData.att.x).getDefault(0); if (dialogueBoxData.has.y) y += Std.parseFloat(dialogueBoxData.att.y).getDefault(0); visible = false; + + var textNode = dialogueBoxData.node.text; + if (textNode == null) + throw "The dialog box XML requires one text element."; + text = new FlxTypeText( + textNode.has.x ? Std.parseFloat(textNode.att.x).getDefault(0) : 0, + FlxG.height - (textNode.has.y ? Std.parseFloat(textNode.att.y).getDefault(0) : 0), + textNode.has.width ? Std.parseInt(textNode.att.width).getDefault(FlxG.width) : FlxG.width, ""); + text.color = textNode.getAtt("color").getColorFromDynamic().getDefault(0xFF000000); + text.size = Std.parseInt(textNode.att.size).getDefault(20); + text.font = Paths.font('${textNode.getAtt("font").getDefault("vcr")}.ttf'); + text.antialiasing = textNode.getAtt("antialiasing").getDefault("false") == "true"; } catch(e) { active = false; Logs.trace('Couldn\'t load dialogue box "$name": ${e.toString()}', ERROR); @@ -58,21 +74,35 @@ class DialogueBox extends FunkinSprite { char.show((FlxG.width / 2) + pos.x, FlxG.height - pos.y); } - public function playBubbleAnim(bubble:String) { + private var __nextText:String; + private var __speed:Float; + public function playBubbleAnim(bubble:String, text:String, speed:Float = 0.02) { + this.__nextText = text; + this.__speed = speed; + this.text.resetText(text); FlxG.sound.play(nextSFX); if (hasAnimation('$bubble-open')) playAnim('$bubble-open', true); - else + else { playAnim(bubble); + setText(__nextText, __speed); + } visible = true; } + public function setText(text:String, speed:Float = 0.02) { + this.text.delay = speed; + this.text.start(speed, true); + } + public override function update(elapsed:Float) { super.update(elapsed); if (isAnimFinished()) { var animName = getAnimName(); - if (animName.endsWith("-open")) + if (animName.endsWith("-open")) { playAnim(animName.substr(0, animName.length - 5)); + setText(__nextText, __speed); + } } }