more cutscene fixes

This commit is contained in:
⍚~Nex
2025-01-23 00:43:49 +01:00
parent 4ae7e045b1
commit 97a3a30aa9
4 changed files with 45 additions and 25 deletions
+8 -6
View File
@@ -859,8 +859,9 @@ class PlayState extends MusicBeatState
* @param cutsceneScriptPath Optional: Custom script path.
* @param callback Callback called after the cutscene ended. If equals to `null`, `startCountdown` will be called.
* @param checkSeen Bool that by default is false, if true and `seenCutscene` is also true, it won't play the cutscene but directly call `callback` (PS: `seenCutscene` becomes true if the cutscene gets played and `checkSeen` was true)
* @param canSkipTransIn Bool that by default is true makes the in transition skip on certain types of cutscenes like dialogues.
*/
public function startCutscene(prefix:String = "", ?cutsceneScriptPath:String, ?callback:Void->Void, checkSeen:Bool = false) {
public function startCutscene(prefix:String = "", ?cutsceneScriptPath:String, ?callback:Void->Void, checkSeen:Bool = false, canSkipTransIn:Bool = true) {
if (callback == null) callback = startCountdown;
if ((checkSeen && seenCutscene) || !playCutscenes) {
callback();
@@ -885,15 +886,15 @@ class PlayState extends MusicBeatState
if (cutsceneScriptPath != null && Assets.exists(cutsceneScriptPath)) {
openSubState(new ScriptedCutscene(cutsceneScriptPath, toCall));
} else if (Assets.exists(dialogue)) {
MusicBeatState.skipTransIn = true;
if (canSkipTransIn) MusicBeatState.skipTransIn = true;
openSubState(new DialogueCutscene(dialogue, toCall));
} else if (Assets.exists(videoCutsceneAlt)) {
MusicBeatState.skipTransIn = true;
if (canSkipTransIn) MusicBeatState.skipTransIn = true;
persistentUpdate = false;
openSubState(new VideoCutscene(videoCutsceneAlt, toCall));
persistentDraw = false;
} else if (Assets.exists(videoCutscene)) {
MusicBeatState.skipTransIn = true;
if (canSkipTransIn) MusicBeatState.skipTransIn = true;
persistentUpdate = false;
openSubState(new VideoCutscene(videoCutscene, toCall));
persistentDraw = false;
@@ -1525,8 +1526,7 @@ class PlayState extends MusicBeatState
#end
}
startCutscene("end-", endCutscene, nextSong);
resetSongInfos();
startCutscene("end-", endCutscene, nextSong, false, false);
}
private static inline function getSongChanges():Array<HighscoreChange> {
@@ -1542,6 +1542,8 @@ class PlayState extends MusicBeatState
* Immediately switches to the next song, or goes back to the Story/Freeplay menu.
*/
public function nextSong() {
resetSongInfos();
if (isStoryMode)
{
campaignScore += songScore;
+4 -1
View File
@@ -25,8 +25,11 @@ class Cutscene extends MusicBeatSubstate {
super();
canOpenCustomTransition = true;
__callback = callback;
__pausable = allowPause;
__callback = function() {
canOpenCustomTransition = false;
callback();
};
pauseItems = Flags.DEFAULT_CUTSCENE_PAUSE_ITEMS;
skippable = canSkip;
@@ -50,7 +50,7 @@ class DialogueCutscene extends ScriptedCutscene {
}
public override function onErrorScriptLoading() {
Logs.trace('Could not find script for dialogue cutscene at "${scriptPath}"', WARNING, YELLOW);
//Logs.trace('Could not find script for dialogue cutscene at "${scriptPath}"', WARNING, YELLOW); // Too many warnings honestly, stawp - Nex
}
var parentDisabler:FunkinParentDisabler;
@@ -62,26 +62,26 @@ class DialogueCutscene extends ScriptedCutscene {
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;
if (event.cancelled) return;
dialogueData = event.dialogueData;
// Add characters
for(char in dialogueData.nodes.char) {
for (char in dialogueData.nodes.char) {
if (!char.has.name) continue;
if (charMap.exists(char.att.name))
Logs.trace('2 dialogue characters share the same name (${char.att.name}, ${char.att.name}). The old character has been replaced.');
var leChar:DialogueCharacter = new DialogueCharacter(char.att.name, char.getAtt('position').getDefault('default'));
if(char.has.defaultAnim) leChar.defaultAnim = char.att.defaultAnim;
if (char.has.defaultAnim) leChar.defaultAnim = char.att.defaultAnim;
add(charMap[char.att.name] = leChar);
}
var useDef:Bool = false;
if(dialogueData.has.forceBoxDefaultTxtSound && dialogueData.att.forceBoxDefaultTxtSound == "true")
if (dialogueData.has.forceBoxDefaultTxtSound && dialogueData.att.forceBoxDefaultTxtSound == "true")
useDef = true;
// Add lines
for(node in dialogueData.nodes.line) {
for (node in dialogueData.nodes.line) {
var formats = XMLUtil.getTextFormats(XMLUtil.fixSpacingInNode(node));
var volume:Null<Float> = 0.8;
var line:DialogueLine = {
@@ -99,8 +99,8 @@ class DialogueCutscene extends ScriptedCutscene {
textSound: null
};
if(node.has.textSound) line.textSound = FlxG.sound.load(Paths.sound(node.att.textSound));
else if(!useDef) {
if (node.has.textSound) line.textSound = FlxG.sound.load(Paths.sound(node.att.textSound));
else if (!useDef) {
var char:DialogueCharacter = charMap[line.char];
if(char != null && char.charData != null && char.charData.has.textSound)
line.textSound = FlxG.sound.load(Paths.sound(char.charData.att.textSound));
@@ -188,16 +188,16 @@ class DialogueCutscene extends ScriptedCutscene {
public override function close() {
var event = new CancellableEvent();
for(c in charMap) c.dialogueCharScript.call("close", [event]);
dialogueBox.dialogueBoxScript.call("close", [event]);
for (c in charMap) c.dialogueCharScript.call("close", [event]);
if (dialogueBox != null) dialogueBox.dialogueBoxScript.call("close", [event]);
dialogueScript.call("close", [event]);
if(event.cancelled) return;
if (event.cancelled) return;
super.close();
}
public override function destroy() {
if(curMusic != null && !curMusic.persist) curMusic.destroy();
if (curMusic != null && !curMusic.persist) curMusic.destroy();
super.destroy();
cutscene = null;