From c4dc5b71d1fbb95cb0138c28fe877f336cb4afe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sun, 18 Feb 2024 03:51:38 +0100 Subject: [PATCH] dialogues stuff & porting WIP 3 couldn't do too much for tonight --- assets/data/dialogue/boxes/senpai.xml | 4 +-- assets/data/dialogue/characters/pixelBf.xml | 4 +++ assets/songs/roses/dialogue.xml | 4 +-- assets/songs/senpai/dialogue.xml | 4 +-- .../game/cutscenes/dialogue/DialogueBox.hx | 25 ++++++++----------- .../cutscenes/dialogue/DialogueCharacter.hx | 3 ++- 6 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 assets/data/dialogue/characters/pixelBf.xml diff --git a/assets/data/dialogue/boxes/senpai.xml b/assets/data/dialogue/boxes/senpai.xml index 643f860a..430dc9f2 100644 --- a/assets/data/dialogue/boxes/senpai.xml +++ b/assets/data/dialogue/boxes/senpai.xml @@ -16,6 +16,6 @@ All animations for the dialogue box For example, if you wanna add an "angry" animation, add an animation named "angry" (box idle), and "angry-open" (not needed, for box apparition) --> - - + + \ No newline at end of file diff --git a/assets/data/dialogue/characters/pixelBf.xml b/assets/data/dialogue/characters/pixelBf.xml new file mode 100644 index 00000000..5292d4de --- /dev/null +++ b/assets/data/dialogue/characters/pixelBf.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/assets/songs/roses/dialogue.xml b/assets/songs/roses/dialogue.xml index 4afba293..904cf803 100644 --- a/assets/songs/roses/dialogue.xml +++ b/assets/songs/roses/dialogue.xml @@ -2,7 +2,7 @@ - + @@ -11,7 +11,7 @@ But this time I'll rip your nuts off right after your girlfriend finishes gargling mine. - + Bop beep be be skdoo bep \ No newline at end of file diff --git a/assets/songs/senpai/dialogue.xml b/assets/songs/senpai/dialogue.xml index 0a8c62ed..5a0115c4 100644 --- a/assets/songs/senpai/dialogue.xml +++ b/assets/songs/senpai/dialogue.xml @@ -2,7 +2,7 @@ - + @@ -11,7 +11,7 @@ A serenade between gentlemen shall decide where her beautiful heart shall reside. - + Beep bo bop \ No newline at end of file diff --git a/source/funkin/game/cutscenes/dialogue/DialogueBox.hx b/source/funkin/game/cutscenes/dialogue/DialogueBox.hx index f61e65c1..4604b353 100644 --- a/source/funkin/game/cutscenes/dialogue/DialogueBox.hx +++ b/source/funkin/game/cutscenes/dialogue/DialogueBox.hx @@ -8,6 +8,7 @@ import haxe.xml.Access; class DialogueBox extends FunkinSprite { public var dialogueBoxData:Access; public var positions:Map = []; + public var everPlayedAny:Bool = false; public var textTypeSFX:String = Paths.sound('dialogue/text'); public var nextSFX:String = Paths.sound('dialogue/next'); @@ -29,6 +30,13 @@ class DialogueBox extends FunkinSprite { if(dialogueBoxData.has.textSound) textTypeSFX = Paths.sound(dialogueBoxData.att.textSound); if(dialogueBoxData.has.nextSound) nextSFX = Paths.sound(dialogueBoxData.att.nextSound); + animation.finishCallback = (name:String) -> { + if(name.endsWith("-open") || name.endsWith("-firstOpen")) { + playAnim(name.substr(0, name.length - 5)); + setText(__nextText, __speed); + } + } + for(pos in dialogueBoxData.nodes.charpos) { if (!pos.has.name) continue; positions[pos.att.name] = { @@ -48,7 +56,6 @@ class DialogueBox extends FunkinSprite { 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.delay = Std.parseFloat(textNode.getAtt("delay")).getDefault(0.05); text.antialiasing = textNode.getAtt("antialiasing").getDefault("false") == "true"; text.sounds = [FlxG.sound.load(textTypeSFX)]; if(textNode.has.borderStyle) { @@ -84,13 +91,14 @@ class DialogueBox extends FunkinSprite { this.__speed = speed; this.text.resetText(text); FlxG.sound.play(nextSFX); - if (hasAnimation('$bubble-open')) - playAnim('$bubble-open', true); + if(hasAnimation('$bubble-open')) playAnim('$bubble-open', true); + else if(hasAnimation('$bubble-firstOpen') && !everPlayedAny) playAnim('$bubble-firstOpen', true); else { playAnim(bubble); setText(__nextText, __speed); } visible = true; + everPlayedAny = true; } public function setText(text:String, speed:Float = 0.02) { @@ -98,17 +106,6 @@ class DialogueBox extends FunkinSprite { this.text.start(speed, true); } - public override function update(elapsed:Float) { - super.update(elapsed); - if (isAnimFinished()) { - var animName = getAnimName(); - if (animName.endsWith("-open")) { - playAnim(animName.substr(0, animName.length - 5)); - setText(__nextText, __speed); - } - } - } - public override function destroy() { super.destroy(); positions = null; diff --git a/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx b/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx index db089b9d..f3097d66 100644 --- a/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx +++ b/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx @@ -39,9 +39,11 @@ class DialogueCharacter extends FunkinSprite { public function show(x:Float, y:Float) { if (curAnimContext == (curAnimContext = POPIN)) return; + visible = true; if (hasAnimation('show')) { playAnim('show', true); setPosition(x, y); + alpha = 1; } else { setPosition(x, y + 100); if(curTween != null) curTween.cancel(); @@ -49,7 +51,6 @@ class DialogueCharacter extends FunkinSprite { alpha = 0; curTween = FlxTween.tween(this, {alpha: 1, y: y}, 0.2, {ease: FlxEase.quintOut}); } - visible = true; } public function hide() {