FINISHED PORTING 10 gotta still finalize dialogues

98% completed dialogue system!
BUT ALL THE PORTING COMPLEDD
This commit is contained in:
⍚~Nex
2024-02-26 00:34:25 +01:00
parent e18e1a2c7a
commit abb953647e
10 changed files with 108 additions and 38 deletions
@@ -1,3 +1,4 @@
var loopedTimah:FlxTimer; // Hey! a man has fallen into the river in lego city! and if youre asking why this is here, you shall disappear! - Nex
var bgFade:FlxSprite;
var hand:FlxSprite;
@@ -8,7 +9,7 @@ function postCreate() {
bgFade.alpha = 0;
cutscene.insert(0, bgFade);
new FlxTimer().start(0.83, function(tmr:FlxTimer)
loopedTimah = new FlxTimer().start(0.83, function(tmr:FlxTimer)
{
bgFade.alpha += (1 / 5) * 0.7;
if (bgFade.alpha > 0.7)
@@ -26,14 +27,11 @@ function close(event) {
else event.cancelled = true;
cutscene.canProceed = false;
if(cutscene.curMusic != null) {
cutscene.curMusic.persist = true;
cutscene.curMusic.fadeOut(2.2, 0);
cutscene.curMusic.fadeTween.onComplete = (_) -> cutscene.curMusic.destroy();
}
cutscene.curMusic?.fadeOut(1, 0);
for(c in cutscene.charMap) c.visible = false;
new FlxTimer().start(0.2, function(tmr:FlxTimer)
loopedTimah.cancel();
loopedTimah = new FlxTimer().start(0.2, function(tmr:FlxTimer)
{
if (tmr.elapsedLoops <= 5) {
cutscene.dialogueBox.alpha -= 1 / 5;
@@ -1,4 +1,3 @@
// TO FINISH!!! - Nex
import flixel.tweens.FlxTweenType;
var aberration:CustomShader = null;
@@ -8,17 +7,37 @@ function postCreate() {
spirit.setGraphicSize(Std.int(spirit.width * 6));
if(Options.gameplayShaders) {
spirit.shader = aberration = new CustomShader('chromaticAberration');
FlxTween.num(-0.003, 0.003, 3, {ease: FlxEase.sineInOut, type: FlxTweenType.PINGPONG}, function(num) { aberration.redOff = [0, -num]; aberration.blueOff = [0, num]; });
FlxTween.num(-0.003, 0.003, 3, {ease: FlxEase.sineInOut, type: FlxTweenType.PINGPONG}, function(num) { if(aberration == null) return; aberration.redOff = [0, -num]; aberration.blueOff = [0, num]; });
}
//spirit.alpha = 0;
cutscene.add(spirit);
FlxG.camera._fxFadeAlpha = 0;
cutscene.dialogueCamera.bgColor = FlxColor.fromRGBFloat(1, 1, 1, 0.3);
}
var finished:Bool = false;
function close(event) {
if(finished) return;
else event.cancelled = true;
cutscene.canProceed = false;
cutscene.curMusic?.fadeOut(1, 0);
for(c in cutscene.charMap) c.visible = false;
spirit.destroy();
spirit.shader = aberration = null;
new FlxTimer().start(0.4, function(swagTimer:FlxTimer) {
cutscene.dialogueCamera.alpha -= 0.15;
if(cutscene.dialogueCamera.alpha > 0) swagTimer.reset();
else {
finished = true;
cutscene.close();
}
});
}
function popupChar(event) {
if(!active || event.char.positionName != "left") return;
event.char.color = FlxColor.BLACK;
var pos = positions["left"];
if (pos == null) return; // It shouldnt but whatever - Nex
//spirit.setPosition((FlxG.width / 2) + pos.x - event.char.offset.x, FlxG.height - pos.y - event.char.offset.y);
}
+1 -1
View File
@@ -1,5 +1,5 @@
<!DOCTYPE codename-engine-stage>
<stage zoom="1" name="school-evil" folder="stages/school/" startCamPosY="200" startCamPosX="300">
<stage zoom="1" name="school-evil" folder="stages/school/" startCamPosY="550" startCamPosX="600">
<sprite name="bg" x="400" y="200" sprite="animatedEvilSchool"
antialiasing="false" scale="6" scrollx="0.8" scrolly="0.9" type="loop"/>
</stage>
+8
View File
@@ -0,0 +1,8 @@
function next(first:Bool) {
if(first && canProceed) {
canProceed = false;
dialogueLines[0].playSound.play();
new FlxTimer().start(1, (_) -> this.next(true));
}
else if(this.lastLine == null) canProceed = true; // If its not null means the dialogue is not at the first one! - Nex
}
+2 -2
View File
@@ -41,10 +41,10 @@ function create() {
});
scream = FlxG.sound.play(Paths.sound('cutscenes/weeb/Senpai_Dies'), 1, false, null, true, function()
{
new FlxTimer().start(0.2, function(swagTimer:FlxTimer) {
new FlxTimer().start(0.4, function(swagTimer:FlxTimer) {
FlxG.camera._fxFadeAlpha -= 0.15;
if(FlxG.camera._fxFadeAlpha > 0) swagTimer.reset();
if(FlxG.camera._fxFadeAlpha > 0.3) swagTimer.reset();
else {
camHUD.visible = true;
self.startDialogue("songs/" + PlayState.instance.SONG.meta.name.toLowerCase() + "/creepyDialogue.xml", self.close);
@@ -0,0 +1,11 @@
package funkin.backend.scripting.events;
import haxe.xml.Access;
/**
* CANCEL this event to customize from 0 the xml structure part!
*/
final class DialogueStructureEvent extends CancellableEvent
{
public var dialogueData:Access;
}
+17 -12
View File
@@ -726,7 +726,7 @@ class PlayState extends MusicBeatState
scoreTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), "Score:0", 16);
missesTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), "Misses:0", 16);
accuracyTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), "Acc:-% (N/A)", 16);
accuracyTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), "Accuracy:-% (N/A)", 16);
accuracyTxt.addFormat(accFormat, 0, 1);
for(text in [scoreTxt, missesTxt, accuracyTxt]) {
@@ -736,6 +736,7 @@ class PlayState extends MusicBeatState
scoreTxt.alignment = RIGHT;
missesTxt.alignment = CENTER;
accuracyTxt.alignment = LEFT;
updateRatingStuff();
for(e in [healthBar, healthBarBG, iconP1, iconP2, scoreTxt, missesTxt, accuracyTxt])
e.cameras = [camHUD];
@@ -1191,17 +1192,7 @@ class PlayState extends MusicBeatState
iconP2.health = 1 - (healthBar.percent / 100);
}
@:dox(hide)
override public function update(elapsed:Float)
{
scripts.call("update", [elapsed]);
if (inCutscene) {
super.update(elapsed);
scripts.call("postUpdate", [elapsed]);
return;
}
function updateRatingStuff() {
scoreTxt.text = 'Score:$songScore';
missesTxt.text = '${comboBreaks ? "Combo Breaks" : "Misses"}:$misses';
@@ -1215,6 +1206,20 @@ class PlayState extends MusicBeatState
accuracyTxt._formatRanges[0].range.start = accuracyTxt.text.length - curRating.rating.length;
accuracyTxt._formatRanges[0].range.end = accuracyTxt.text.length;
}
}
@:dox(hide)
override public function update(elapsed:Float)
{
scripts.call("update", [elapsed]);
if (inCutscene) {
super.update(elapsed);
scripts.call("postUpdate", [elapsed]);
return;
}
updateRatingStuff();
if (controls.PAUSE && startedCountdown && canPause)
pauseGame();
@@ -1,10 +1,12 @@
package funkin.game.cutscenes;
import funkin.backend.scripting.events.CancellableEvent;
import funkin.backend.utils.FunkinParentDisabler;
import funkin.backend.scripting.events.*;
import funkin.backend.scripting.Script;
import flixel.sound.FlxSound;
import funkin.game.cutscenes.dialogue.*;
import haxe.xml.Access;
import haxe.io.Path;
/**
* Substate made for dialogue cutscenes. To use it in a scripted cutscene, call `startDialogue`.
@@ -24,7 +26,7 @@ class DialogueCutscene extends Cutscene {
public var curMusic:FlxSound = null;
public static var cutscene:DialogueCutscene;
//public var dialogueScript:Script;
public var dialogueScript:Script;
public function set_curLine(val:DialogueLine) {
lastLine = curLine;
@@ -37,14 +39,23 @@ class DialogueCutscene extends Cutscene {
camera = dialogueCamera = new FlxCamera();
dialogueCamera.bgColor = 0;
FlxG.cameras.add(dialogueCamera, false);
dialogueScript = Script.create(Paths.script(Path.withoutExtension(dialoguePath), null, dialoguePath.startsWith('assets')));
dialogueScript.setParent(cutscene = this);
dialogueScript.load();
}
var parentDisabler:FunkinParentDisabler;
public override function create() {
cutscene = this;
super.create();
add(parentDisabler = new FunkinParentDisabler());
try {
dialogueData = new Access(Xml.parse(Assets.getText(dialoguePath)).firstElement());
var event = EventManager.get(DialogueStructureEvent).recycle(dialogueData);
event.dialogueData = new Access(Xml.parse(Assets.getText(dialoguePath)).firstElement());
dialogueScript.call('structureLoaded', [event]);
if(event.cancelled) return;
dialogueData = event.dialogueData;
// Add characters
for(char in dialogueData.nodes.char) {
@@ -98,10 +109,18 @@ class DialogueCutscene extends Cutscene {
Logs.trace('Error while loading dialogue at ${dialoguePath}: ${e.toString()}', ERROR);
close();
}
dialogueScript.call("postCreate");
}
public override function beatHit(curBeat:Int) {
super.beatHit(curBeat);
dialogueScript.call("beatHit", [curBeat]);
}
public override function update(elapsed:Float) {
super.update(elapsed);
dialogueScript.call("update", [elapsed]);
if(controls.ACCEPT) {
@:privateAccess
if(dialogueBox.dialogueEnded) next();
@@ -109,8 +128,13 @@ class DialogueCutscene extends Cutscene {
}
}
/**
* Use this to cancel `next`!
*/
public var canProceed:Bool = true;
public function next(playFirst:Bool = false) {
dialogueScript.call("next", [playFirst]);
if(!canProceed) return;
if ((curLine = dialogueLines.shift()) == null) {
@@ -145,20 +169,25 @@ class DialogueCutscene extends Cutscene {
curMusic.play();
curMusic.fadeIn(1, 0, curMusic.volume);
} else if(curLine.musicVolume != null && curMusic != null) curMusic.volume = curLine.musicVolume;
dialogueScript.call("postNext", [playFirst]);
}
public override function close() {
var event = new CancellableEvent();
for(c in charMap) c.dialogueCharScript.call("close", [event]);
dialogueBox.dialogueBoxScript.call("close", [event]);
if(event.cancelled)
return;
dialogueScript.call("close", [event]);
if(event.cancelled) return;
super.close();
}
public override function destroy() {
if(curMusic != null && !curMusic.persist) curMusic.destroy();
dialogueScript.call("destroy");
dialogueScript.destroy();
super.destroy();
cutscene = null;
FlxG.cameras.remove(dialogueCamera);
@@ -36,7 +36,7 @@ class DialogueBox extends FunkinSprite {
if(event.cancelled) return; // No idea the pyscho that would do this but hey, it can happen - Nex
try {
event.dialogueBoxData = dialogueBoxData = new Access(Xml.parse(Assets.getText(Paths.xml(defPath + event.name))).firstElement());
event.dialogueBoxData = new Access(Xml.parse(Assets.getText(Paths.xml(defPath + event.name))).firstElement());
dialogueBoxScript.call('structureLoaded', [event]);
if(event.cancelled) return;
name = event.name;
@@ -32,7 +32,7 @@ class DialogueCharacter extends FunkinSprite {
if(event.cancelled) return;
try {
event.charData = charData = new Access(Xml.parse(Assets.getText(Paths.xml(defPath + event.name))).firstElement());
event.charData = new Access(Xml.parse(Assets.getText(Paths.xml(defPath + event.name))).firstElement());
dialogueCharScript.call('structureLoaded', [event]);
if(event.cancelled) return;
name = event.name;