dialogues rewrites & more week 6 porting WIP

This commit is contained in:
⍚~Nex
2024-02-17 04:03:11 +01:00
parent ae721ed4e4
commit 778de6bbc6
15 changed files with 173 additions and 72 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
<!DOCTYPE codename-engine-dialogue-box>
<dialoguebox scale="0.9" y="75">
<dialoguebox y="75">
<!--
Node containing all text settings
-->
+21
View File
@@ -0,0 +1,21 @@
<!DOCTYPE codename-engine-dialogue-box>
<dialoguebox sprite="pixel/dialogueBox" antialiasing="false" graphicSizex="1344" x="20" y="-215" textSound="pixel/pixelText" nextSound="pixel/clickText">
<!--
Node containing all text settings
-->
<text x="242" y="218" width="768" color="#3f2021" size="32" antialiasing="false" borderSize="2" borderStyle="shadow" borderColor="#D89494" />
<!--
All positions for characters
-->
<charpos name="left" x="-500" y="184" />
<charpos name="middle" x="0" y="184" />
<charpos name="right" x="500" y="184" flipBubble="true" />
<!--
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)
-->
<anim name="normal" anim="Text Box Appear instance 10004" fps="24" loop="true"/>
<anim name="normal-open" anim="Text Box Appear instance 10" fps="24" />
</dialoguebox>
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<TextureAtlas imagePath="dialogueBox.png">
<!-- Created with Adobe Animate version 20.0.0.17400 -->
<!-- http://www.adobe.com/products/animate.html -->
<SubTexture name="Text Box Appear instance 10000" x="0" y="0" width="249" height="144"/>
<SubTexture name="Text Box Appear instance 10001" x="259" y="0" width="249" height="144"/>
<SubTexture name="Text Box Appear instance 10002" x="0" y="154" width="249" height="144"/>
<SubTexture name="Text Box Appear instance 10003" x="259" y="154" width="249" height="144"/>
<SubTexture name="Text Box Appear instance 10004" x="259" y="154" width="249" height="144"/>
</TextureAtlas>
+17
View File
@@ -0,0 +1,17 @@
<!DOCTYPE codename-engine-dialogue>
<dialogue box="senpai">
<!-- All characters -->
<char name="dad" char="dad" position="left" />
<char name="boyfriend" char="boyfriend" position="right" />
<!-- Lines -->
<line char="dad">
Not bad for an ugly worm.
</line>
<line char="dad">
But this time I'll rip your nuts off right after your girlfriend finishes gargling mine.
</line>
<line char="boyfriend">
Bop beep be be skdoo bep
</line>
</dialogue>
+1 -5
View File
@@ -1,4 +1,3 @@
static var roses_shouldPlayOnThorns = false;
var self = this;
__script__.setParent(PlayState.instance);
@@ -36,10 +35,7 @@ function create() {
FlxG.camera.followLerp = 0;
FlxTween.tween(camGame.scroll, {x: -366, y: 192}, 3, {
ease: FlxEase.cubeInOut,
onComplete: (_) -> {
roses_shouldPlayOnThorns = true;
self.close();
}
onComplete: (_) -> {self.close();}
});
}
});
+17
View File
@@ -0,0 +1,17 @@
<!DOCTYPE codename-engine-dialogue>
<dialogue box="senpai">
<!-- All characters -->
<char name="dad" char="dad" position="left" />
<char name="boyfriend" char="boyfriend" position="right" />
<!-- Lines -->
<line char="dad">
Ah, a new fair maiden has come in search of true love!
</line>
<line char="dad">
A serenade between gentlemen shall decide where her beautiful heart shall reside.
</line>
<line char="boyfriend">
Beep bo bop
</line>
</dialogue>
+22
View File
@@ -0,0 +1,22 @@
<!DOCTYPE codename-engine-dialogue>
<dialogue box="senpai">
<!-- All characters -->
<char name="dad" char="dad" position="left" />
<!-- Lines -->
<line char="dad">
Direct contact with real humans, after being trapped in here for so long...
</line>
<line char="dad">
and HER of all people.
</line>
<line char="dad">
I'll make her father pay for what he's done to me and all the others,,,,
</line>
<line char="dad">
I'll beat you and make you take my place.
</line>
<line char="dad">
You don't mind your bodies being borrowed right? It's only fair...
</line>
</dialogue>
+1 -9
View File
@@ -1,6 +1,5 @@
import flixel.addons.util.FlxSimplex;
static var roses_shouldPlayOnThorns = false;
var self = this;
__script__.setParent(PlayState.instance);
@@ -9,13 +8,6 @@ var senpaiEvil:FlxSprite;
var dfx = 0;
var dfy = 0;
function create() {
// Cutscene stuff
if(!roses_shouldPlayOnThorns) {
disableScript();
self.close();
return;
}
roses_shouldPlayOnThorns = false;
camHUD.visible = false;
var red:FlxSprite = new FlxSprite().makeSolid(FlxG.width + 100, FlxG.height + 100, 0xFFff1b31);
@@ -64,7 +56,7 @@ function create() {
white.destroy();
camHUD.visible = true;
self.close();
self.startDialogue("songs/" + PlayState.instance.SONG.meta.name.toLowerCase() + "/creepyDialogue.xml", self.close);
}
});
Binary file not shown.
Binary file not shown.
Binary file not shown.
+40 -14
View File
@@ -61,16 +61,14 @@ class XMLUtil {
}
/**
* Creates a new sprite based on a XML node.
* Overrides a sprite based on a XML node.
*/
public static function createSpriteFromXML(node:Access, parentFolder:String = "", defaultAnimType:XMLAnimType = BEAT, ?cl:Class<FunkinSprite>):FunkinSprite {
public static function loadSpriteFromXML(spr:FunkinSprite, node:Access, parentFolder:String = "", defaultAnimType:XMLAnimType = BEAT):FunkinSprite {
if (parentFolder == null) parentFolder = "";
var spr:FunkinSprite = cl != null ? Type.createInstance(cl, []) : new FunkinSprite();
spr.name = node.getAtt("name");
spr.antialiasing = true;
spr.loadSprite(Paths.image('$parentFolder${node.getAtt("sprite")}', null, true));
spr.loadSprite(Paths.image('$parentFolder${node.getAtt("sprite").getDefault(spr.name)}', null, true));
spr.spriteAnimType = defaultAnimType;
if (node.has.type) {
@@ -88,15 +86,14 @@ class XMLUtil {
if (node.has.scroll) {
var scroll:Null<Float> = Std.parseFloat(node.att.scroll);
if (scroll.isNotNull()) spr.scrollFactor.set(scroll, scroll);
} else {
if (node.has.scrollx) {
var scroll:Null<Float> = Std.parseFloat(node.att.scrollx);
if (scroll.isNotNull()) spr.scrollFactor.x = scroll;
}
if (node.has.scrolly) {
var scroll:Null<Float> = Std.parseFloat(node.att.scrolly);
if (scroll.isNotNull()) spr.scrollFactor.y = scroll;
}
}
if (node.has.scrollx) {
var scroll:Null<Float> = Std.parseFloat(node.att.scrollx);
if (scroll.isNotNull()) spr.scrollFactor.x = scroll;
}
if (node.has.scrolly) {
var scroll:Null<Float> = Std.parseFloat(node.att.scrolly);
if (scroll.isNotNull()) spr.scrollFactor.y = scroll;
}
if (node.has.skewx) {
var skew:Null<Float> = Std.parseFloat(node.att.skewx);
@@ -107,6 +104,14 @@ class XMLUtil {
if (skew.isNotNull()) spr.skew.y = skew;
}
if (node.has.antialiasing) spr.antialiasing = node.att.antialiasing == "true";
if (node.has.width) {
var width:Null<Float> = Std.parseFloat(node.att.width);
if (width.isNotNull()) spr.width = width;
}
if (node.has.height) {
var height:Null<Float> = Std.parseFloat(node.att.height);
if (height.isNotNull()) spr.height = height;
}
if (node.has.scale) {
var scale:Null<Float> = Std.parseFloat(node.att.scale);
if (scale.isNotNull()) spr.scale.set(scale, scale);
@@ -119,6 +124,18 @@ class XMLUtil {
var scale:Null<Float> = Std.parseFloat(node.att.scaley);
if (scale.isNotNull()) spr.scale.y = scale;
}
if (node.has.graphicSize) {
var graphicSize:Null<Int> = Std.parseInt(node.att.graphicSize);
if (graphicSize.isNotNull()) spr.setGraphicSize(graphicSize, graphicSize);
}
if (node.has.graphicSizex) {
var graphicSizex:Null<Int> = Std.parseInt(node.att.graphicSizex);
if (graphicSizex.isNotNull()) spr.setGraphicSize(graphicSizex);
}
if (node.has.graphicSizey) {
var graphicSizey:Null<Int> = Std.parseInt(node.att.graphicSizey);
if (graphicSizey.isNotNull()) spr.setGraphicSize(0, graphicSizey);
}
if (node.has.updateHitbox && node.att.updateHitbox == "true") spr.updateHitbox();
if(node.has.zoomfactor)
@@ -156,6 +173,15 @@ class XMLUtil {
return spr;
}
/**
* Creates a new sprite based on a XML node.
*/
public static inline function createSpriteFromXML(node:Access, parentFolder:String = "", defaultAnimType:XMLAnimType = BEAT, ?cl:Class<FunkinSprite>, ?args:Array<Dynamic>):FunkinSprite {
if(cl == null) cl = FunkinSprite;
if(args == null) args = [];
return loadSpriteFromXML(Type.createInstance(cl, args), node, parentFolder, defaultAnimType);
}
public static function extractAnimFromXML(anim:Access, animType:XMLAnimType = NONE, loop:Bool = false):AnimData {
var animData:AnimData = {
name: null,
+25 -28
View File
@@ -801,7 +801,7 @@ class PlayState extends MusicBeatState
*/
public function startCutscene(prefix:String = "", ?cutsceneScriptPath:String, ?callback:Void->Void, checkSeen:Bool = false) {
if (callback == null) callback = startCountdown;
if (checkSeen && seenCutscene) {
if ((checkSeen && seenCutscene) || !playCutscenes) {
callback();
return;
}
@@ -809,34 +809,31 @@ class PlayState extends MusicBeatState
if (cutsceneScriptPath == null)
cutsceneScriptPath = Paths.script('songs/${SONG.meta.name.toLowerCase()}/${prefix}cutscene');
if (playCutscenes) {
inCutscene = true;
var videoCutscene = Paths.video('${PlayState.SONG.meta.name.toLowerCase()}-${prefix}cutscene');
var videoCutsceneAlt = Paths.file('songs/${PlayState.SONG.meta.name.toLowerCase()}/${prefix}cutscene.mp4');
var dialogue = Paths.file('songs/${PlayState.SONG.meta.name.toLowerCase()}/${prefix}dialogue.xml');
persistentUpdate = true;
var toCall:Void->Void = function() {
if(checkSeen) seenCutscene = true;
callback();
}
inCutscene = true;
var videoCutscene = Paths.video('${PlayState.SONG.meta.name.toLowerCase()}-${prefix}cutscene');
var videoCutsceneAlt = Paths.file('songs/${PlayState.SONG.meta.name.toLowerCase()}/${prefix}cutscene.mp4');
var dialogue = Paths.file('songs/${PlayState.SONG.meta.name.toLowerCase()}/${prefix}dialogue.xml');
persistentUpdate = true;
var toCall:Void->Void = function() {
if(checkSeen) seenCutscene = true;
callback();
}
if (cutsceneScriptPath != null && Assets.exists(cutsceneScriptPath)) {
openSubState(new ScriptedCutscene(cutsceneScriptPath, toCall));
} else if (Assets.exists(dialogue)) {
MusicBeatState.skipTransIn = true;
openSubState(new DialogueCutscene(dialogue, toCall));
} else if (Assets.exists(videoCutsceneAlt)) {
MusicBeatState.skipTransIn = true;
persistentUpdate = false;
openSubState(new VideoCutscene(videoCutsceneAlt, toCall));
persistentDraw = false;
} else if (Assets.exists(videoCutscene)) {
MusicBeatState.skipTransIn = true;
persistentUpdate = false;
openSubState(new VideoCutscene(videoCutscene, toCall));
persistentDraw = false;
} else
callback();
if (cutsceneScriptPath != null && Assets.exists(cutsceneScriptPath)) {
openSubState(new ScriptedCutscene(cutsceneScriptPath, toCall));
} else if (Assets.exists(dialogue)) {
MusicBeatState.skipTransIn = true;
openSubState(new DialogueCutscene(dialogue, toCall));
} else if (Assets.exists(videoCutsceneAlt)) {
MusicBeatState.skipTransIn = true;
persistentUpdate = false;
openSubState(new VideoCutscene(videoCutsceneAlt, toCall));
persistentDraw = false;
} else if (Assets.exists(videoCutscene)) {
MusicBeatState.skipTransIn = true;
persistentUpdate = false;
openSubState(new VideoCutscene(videoCutscene, toCall));
persistentDraw = false;
} else
callback();
}
@@ -18,13 +18,16 @@ class DialogueBox extends FunkinSprite {
super();
try {
dialogueBoxData = new Access(Xml.parse(Assets.getText(Paths.xml('dialogue/boxes/$name'))).firstElement());
if(!dialogueBoxData.has.sprite) dialogueBoxData.x.set("sprite", name);
XMLUtil.loadSpriteFromXML(this, dialogueBoxData, "dialogue/boxes/", NONE);
visible = false;
loadSprite(Paths.image('dialogue/boxes/${dialogueBoxData.getAtt('sprite').getDefault(name)}'));
var preX:Float = x;
screenCenter(X); x += preX;
y += FlxG.height - height;
for(anim in dialogueBoxData.nodes.anim) {
if (!anim.has.name) continue;
XMLUtil.addXMLAnimation(this, anim);
}
if(dialogueBoxData.has.textSound) textTypeSFX = Paths.sound(dialogueBoxData.att.textSound);
if(dialogueBoxData.has.nextSound) nextSFX = Paths.sound(dialogueBoxData.att.nextSound);
for(pos in dialogueBoxData.nodes.charpos) {
if (!pos.has.name) continue;
@@ -35,16 +38,6 @@ 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;
if (dialogueBoxData.has.x) x += Std.parseFloat(dialogueBoxData.att.x).getDefault(0);
if (dialogueBoxData.has.y) y += Std.parseFloat(dialogueBoxData.att.y).getDefault(0);
visible = false;
var textNode = dialogueBoxData.node.text;
if (textNode == null)
throw "The dialog box XML requires one text element.";
@@ -57,6 +50,16 @@ class DialogueBox extends FunkinSprite {
text.font = Paths.font('${textNode.getAtt("font").getDefault("vcr.ttf")}');
text.antialiasing = textNode.getAtt("antialiasing").getDefault("false") == "true";
text.sounds = [FlxG.sound.load(textTypeSFX)];
if(textNode.has.borderStyle) {
text.borderStyle = switch(textNode.att.borderStyle.trim().toLowerCase()) {
case "none": NONE;
case "shadow": SHADOW;
case "outline_fast": OUTLINE_FAST;
default: OUTLINE;
}
text.borderSize = Std.parseFloat(textNode.getAtt("borderSize")).getDefault(1);
text.borderColor = textNode.getAtt("borderColor").getColorFromDynamic().getDefault(0xFFFFFFFF);
}
} catch(e) {
active = false;
Logs.trace('Couldn\'t load dialogue box "$name": ${e.toString()}', ERROR);