From 038116f0057d3a0c40e52fa97b3ab276597cc6b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=8D=9A=7ENex?=
<87421482+NexIsDumb@users.noreply.github.com>
Date: Sun, 25 Feb 2024 04:37:06 +0100
Subject: [PATCH] dialogues stuff & porting WIP 8
---
assets/data/dialogue/boxes/hating-simulator.hx | 8 +++++---
assets/songs/test/dialogue.xml | 2 +-
assets/songs/thorns/cutscene.hx | 17 +++--------------
.../funkin/game/cutscenes/DialogueCutscene.hx | 13 ++++++++++---
.../game/cutscenes/dialogue/DialogueBox.hx | 8 +++++++-
5 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/assets/data/dialogue/boxes/hating-simulator.hx b/assets/data/dialogue/boxes/hating-simulator.hx
index 24aa06fd..791bc411 100644
--- a/assets/data/dialogue/boxes/hating-simulator.hx
+++ b/assets/data/dialogue/boxes/hating-simulator.hx
@@ -49,9 +49,11 @@ function close(event) {
var time:Float = 0;
function update(elapsed:Float) {
- hand.x = 1060 + Math.sin((time += elapsed) * Math.PI * 2) * 12;
- hand.x -= hand.x % hand.scale.x;
- hand.y -= hand.y % hand.scale.y;
+ if(hand.visible = dialogueEnded) {
+ hand.x = 1060 + Math.sin((time += elapsed) * Math.PI * 2) * 12;
+ hand.x -= hand.x % hand.scale.x;
+ hand.y -= hand.y % hand.scale.y;
+ }
}
function postPlayBubbleAnim() {
diff --git a/assets/songs/test/dialogue.xml b/assets/songs/test/dialogue.xml
index eb51dd98..697f8043 100644
--- a/assets/songs/test/dialogue.xml
+++ b/assets/songs/test/dialogue.xml
@@ -7,7 +7,7 @@
-
+
yo its me your enemy! how are you
diff --git a/assets/songs/thorns/cutscene.hx b/assets/songs/thorns/cutscene.hx
index 9d0be5b8..13ceed85 100644
--- a/assets/songs/thorns/cutscene.hx
+++ b/assets/songs/thorns/cutscene.hx
@@ -28,12 +28,6 @@ function create() {
dfy = senpaiEvil.y;
add(senpaiEvil);
- var white:FlxSprite = new FlxSprite().makeSolid(FlxG.width + 100, FlxG.height + 100, FlxColor.WHITE);
- white.screenCenter();
- white.scrollFactor.set();
- white.alpha = 0;
- add(white);
-
new FlxTimer().start(3.2, function(deadTime:FlxTimer)
{
FlxG.camera.fade(FlxColor.WHITE, 1.6, false, function() {
@@ -42,25 +36,20 @@ function create() {
remove(red, true);
red.destroy();
- white.alpha = 1;
+ FlxG.camera._fxFadeAlpha = 1;
});
});
scream = FlxG.sound.play(Paths.sound('cutscenes/weeb/Senpai_Dies'), 1, false, null, true, function()
{
new FlxTimer().start(0.2, function(swagTimer:FlxTimer) {
- white.alpha -= 0.15;
+ FlxG.camera._fxFadeAlpha -= 0.15;
- if(white.alpha > 0) swagTimer.reset();
+ if(FlxG.camera._fxFadeAlpha > 0) swagTimer.reset();
else {
- remove(white, true);
- white.destroy();
-
camHUD.visible = true;
self.startDialogue("songs/" + PlayState.instance.SONG.meta.name.toLowerCase() + "/creepyDialogue.xml", self.close);
}
});
-
- FlxG.camera.fade(FlxColor.WHITE, 0.0001, true);
});
}
diff --git a/source/funkin/game/cutscenes/DialogueCutscene.hx b/source/funkin/game/cutscenes/DialogueCutscene.hx
index 7daa78e6..518c0a05 100644
--- a/source/funkin/game/cutscenes/DialogueCutscene.hx
+++ b/source/funkin/game/cutscenes/DialogueCutscene.hx
@@ -63,6 +63,7 @@ class DialogueCutscene extends Cutscene {
// Add lines
for(node in dialogueData.nodes.line) {
+ var volume:Null = 0.8;
var line:DialogueLine = {
text: XMLUtil.fixXMLText(node.innerHTML),
char: node.getAtt('char').getDefault('boyfriend'),
@@ -70,7 +71,8 @@ class DialogueCutscene extends Cutscene {
callback: node.getAtt('callback'),
changeDefAnim: node.getAtt('changeDefAnim'),
speed: node.has.speed ? Std.parseFloat(node.att.speed).getDefault(0.05) : 0.05,
- changeMusic: node.has.changeMusic ? FlxG.sound.load(Paths.music(node.getAtt('changeMusic')), 0.8, true) : null,
+ musicVolume: node.has.musicVolume ? (volume = Std.parseFloat(node.att.speed).getDefault(0.8)) : null,
+ changeMusic: node.has.changeMusic ? FlxG.sound.load(Paths.music(node.getAtt('changeMusic')), volume, true) : null,
playSound: node.has.playSound ? FlxG.sound.load(Paths.sound(node.getAtt('playSound'))) : null,
nextSound: node.has.nextSound ? FlxG.sound.load(Paths.music(node.getAtt('nextSound'))) : null,
textSound: null
@@ -100,7 +102,11 @@ class DialogueCutscene extends Cutscene {
public override function update(elapsed:Float) {
super.update(elapsed);
- if(controls.ACCEPT) next();
+ if(controls.ACCEPT) {
+ @:privateAccess
+ if(dialogueBox.dialogueEnded) next();
+ else dialogueBox.text.skip();
+ }
}
public var canProceed:Bool = true;
@@ -138,7 +144,7 @@ class DialogueCutscene extends Cutscene {
curMusic = curLine.changeMusic;
curMusic.play();
curMusic.fadeIn(1, 0, curMusic.volume);
- }
+ } else if(curLine.musicVolume != null && curMusic != null) curMusic.volume = curLine.musicVolume;
}
public override function close() {
@@ -165,6 +171,7 @@ typedef DialogueLine = {
var bubble:String;
var callback:String;
var speed:Float;
+ var musicVolume:Null;
var changeMusic:FlxSound;
var playSound:FlxSound;
var nextSound:FlxSound;
diff --git a/source/funkin/game/cutscenes/dialogue/DialogueBox.hx b/source/funkin/game/cutscenes/dialogue/DialogueBox.hx
index d5614b36..28f3b090 100644
--- a/source/funkin/game/cutscenes/dialogue/DialogueBox.hx
+++ b/source/funkin/game/cutscenes/dialogue/DialogueBox.hx
@@ -13,6 +13,7 @@ import haxe.xml.Access;
class DialogueBox extends FunkinSprite {
public var dialogueBoxData:Access;
public var positions:Map = [];
+ public var dialogueEnded:Bool = false; // Using text._typing is also fair but it doesnt check for eventual opening anims! - Nex
public var nextSFX:String = Paths.sound('dialogue/next');
public var defaultTextTypeSFX:Array;
@@ -127,8 +128,12 @@ class DialogueBox extends FunkinSprite {
if(event.customSFX != null) event.customSFX.play();
else if(event.allowDefault) FlxG.sound.play(nextSFX);
- var idk:Void->Void = () -> if(text != null && text.trim().length > 0) setText(event.text, event.speed, event.customTypeSFX);
+ var idk:Void->Void = () -> {
+ if(text != null && text.trim().length > 0) setText(event.text, event.speed, event.customTypeSFX);
+ else dialogueEnded = true;
+ }
+ dialogueEnded = false;
this.text.resetText('');
var anim:String = event.bubble + event.suffix;
if(hasAnimation(anim)) playAnim(anim, true);
@@ -152,6 +157,7 @@ class DialogueBox extends FunkinSprite {
this.text.sounds = event.customTypeSFX != null ? event.customTypeSFX : defaultTextTypeSFX;
this.text.delay = event.speed;
this.text.start(event.speed, true);
+ this.text.completeCallback = () -> dialogueEnded = true;
}
public override function destroy() {