diff --git a/assets/data/dialogue/boxes/default.xml b/assets/data/dialogue/boxes/default.xml index e6fd2f4d..ed6409cd 100644 --- a/assets/data/dialogue/boxes/default.xml +++ b/assets/data/dialogue/boxes/default.xml @@ -1,17 +1,17 @@ - + - - - + + + - + - - + + \ No newline at end of file diff --git a/assets/data/dialogue/characters/boyfriend.xml b/assets/data/dialogue/characters/boyfriend.xml index c5774f46..50eaae21 100644 --- a/assets/data/dialogue/characters/boyfriend.xml +++ b/assets/data/dialogue/characters/boyfriend.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/assets/data/dialogue/characters/dad.xml b/assets/data/dialogue/characters/dad.xml index c5774f46..fa9aa006 100644 --- a/assets/data/dialogue/characters/dad.xml +++ b/assets/data/dialogue/characters/dad.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/assets/data/dialogue/characters/niko.xml b/assets/data/dialogue/characters/niko.xml index c5774f46..87ae6587 100644 --- a/assets/data/dialogue/characters/niko.xml +++ b/assets/data/dialogue/characters/niko.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/buildnumber.txt b/buildnumber.txt index 6adc804a..9006f06e 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -2112 \ No newline at end of file +2122 \ No newline at end of file diff --git a/source/funkin/cutscenes/DialogueCutscene.hx b/source/funkin/cutscenes/DialogueCutscene.hx index 64d0fdb1..36d904a5 100644 --- a/source/funkin/cutscenes/DialogueCutscene.hx +++ b/source/funkin/cutscenes/DialogueCutscene.hx @@ -18,13 +18,14 @@ class DialogueCutscene extends Cutscene { public var dialogueBox:DialogueBox; public var nextSFX:FlxSound; + public var dialogueCamera:FlxCamera; public function new(dialoguePath:String, callback:Void->Void) { super(callback); this.dialoguePath = dialoguePath; - camera = new FlxCamera(); - camera.bgColor = 0; - FlxG.cameras.add(camera, false); + camera = dialogueCamera = new FlxCamera(); + dialogueCamera.bgColor = 0; + FlxG.cameras.add(dialogueCamera, false); } public override function create() { @@ -56,6 +57,8 @@ class DialogueCutscene extends Cutscene { dialogueBox = new DialogueBox(dialogueData.getAtt("box").getDefault("default")); add(dialogueBox); + + next(); } catch(e) { Logs.trace('Error while loading dialogue at ${dialoguePath}', ERROR); @@ -75,11 +78,9 @@ class DialogueCutscene extends Cutscene { return; } - for(c in charMap) { - if (c.visible) { - // TODO: remove character smoothly - } - } + for(k=>c in charMap) + if (k != curLine.char) + c.hide(); if (charMap[curLine.char] != null) dialogueBox.popupChar(charMap[curLine.char]); @@ -88,7 +89,7 @@ class DialogueCutscene extends Cutscene { public override function destroy() { super.destroy(); - FlxG.cameras.remove(camera); + FlxG.cameras.remove(dialogueCamera); } } diff --git a/source/funkin/cutscenes/dialogue/DialogueBox.hx b/source/funkin/cutscenes/dialogue/DialogueBox.hx index 5f608ed2..8cb57169 100644 --- a/source/funkin/cutscenes/dialogue/DialogueBox.hx +++ b/source/funkin/cutscenes/dialogue/DialogueBox.hx @@ -9,6 +9,9 @@ class DialogueBox extends FunkinSprite { public var dialogueBoxData:Access; public var positions:Map = []; + public var textTypeSFX:String = Paths.sound('dialogue/text'); + public var nextSFX:String = Paths.sound('dialogue/next'); + public function new(name:String) { super(); try { @@ -30,6 +33,9 @@ class DialogueBox extends FunkinSprite { }; } + if (dialogueBoxData.has.textSound) textTypeSFX = Paths.sound(dialogueBoxData.att.textSound); + if (dialogueBoxData.has.nextSound) nextSFX = Paths.sound(dialogueBoxData.att.nextSound); + antialiasing = dialogueBoxData.getAtt("antialiasing").getDefault("true") == "true"; screenCenter(X); y = FlxG.height - height; @@ -40,6 +46,8 @@ class DialogueBox extends FunkinSprite { active = false; Logs.trace('Couldn\'t load dialogue box "$name": ${e.toString()}', ERROR); } + FlxG.sound.cache(nextSFX); + FlxG.sound.cache(textTypeSFX); } public function popupChar(char:DialogueCharacter) { @@ -47,15 +55,11 @@ class DialogueBox extends FunkinSprite { var pos = positions[char.positionName]; if (pos == null) return; - if (!char.visible) { - char.alpha = 0; - char.visible = true; - char.setPosition(pos.x, pos.y + 100); - char.show(pos.y); - } + char.show((FlxG.width / 2) + pos.x, FlxG.height - pos.y); } public function playBubbleAnim(bubble:String) { + FlxG.sound.play(nextSFX); if (hasAnimation('$bubble-open')) playAnim('$bubble-open', true); else @@ -63,6 +67,15 @@ class DialogueBox extends FunkinSprite { visible = 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)); + } + } + public override function destroy() { super.destroy(); positions = null; diff --git a/source/funkin/cutscenes/dialogue/DialogueCharacter.hx b/source/funkin/cutscenes/dialogue/DialogueCharacter.hx index e9c32c23..3f1c4920 100644 --- a/source/funkin/cutscenes/dialogue/DialogueCharacter.hx +++ b/source/funkin/cutscenes/dialogue/DialogueCharacter.hx @@ -8,6 +8,7 @@ import haxe.xml.Access; class DialogueCharacter extends FunkinSprite { public var charData:Access; public var curTween:FlxTween; + public var curTweenContext:DialogueCharTweenContext = NONE; public var positionName:String; public function new(name:String, position:String) { @@ -17,10 +18,11 @@ class DialogueCharacter extends FunkinSprite { charData = new Access(Xml.parse(Assets.getText(Paths.xml('dialogue/characters/$name'))).firstElement()); loadSprite(Paths.image('dialogue/characters/${charData.getAtt('sprite').getDefault(name)}')); antialiasing = charData.getAtt('antialiasing').getDefault('true') == 'true'; + scale.scale(charData.has.scale ? Std.parseFloat(charData.att.scale).getDefault(1) : 1); + updateHitbox(); offset.set( charData.has.x ? Std.parseFloat(charData.att.x).getDefault(0) : 0, - charData.has.y ? Std.parseFloat(charData.att.y).getDefault(0) : 0); - scale.scale(charData.has.scale ? Std.parseFloat(charData.att.scale).getDefault(1) : 1); + (charData.has.y ? Std.parseFloat(charData.att.y).getDefault(0) : 0) + this.height); for(anim in charData.nodes.anim) XMLUtil.addXMLAnimation(this, anim, true); } catch(e) { @@ -29,10 +31,31 @@ class DialogueCharacter extends FunkinSprite { visible = false; } - public function show(y:Float) { - if (curTween != null) - curTween.cancel(); + public function show(x:Float, y:Float) { + if (curTweenContext != (curTweenContext = POPIN)) { + setPosition(x, y + 100); + if (curTween != null) + curTween.cancel(); - curTween = FlxTween.tween(this, {alpha: 1, y: y}, 0.5, {ease: FlxEase.cubeOut}); + alpha = 0; + visible = true; + + curTween = FlxTween.tween(this, {alpha: 1, y: y}, 0.2, {ease: FlxEase.quintOut}); + } } + + public function hide() { + if (curTweenContext != (curTweenContext = POPOUT)) { + if (curTween != null) + curTween.cancel(); + + curTween = FlxTween.tween(this, {alpha: 0, y: y + 100}, 0.2, {ease: FlxEase.quintIn}); + } + } +} + +enum abstract DialogueCharTweenContext(Int) { + var NONE = -1; + var POPIN = 0; + var POPOUT = 1; } \ No newline at end of file