dialogues stuff & porting WIP 3

couldn't do too much for tonight
This commit is contained in:
⍚~Nex
2024-02-18 03:51:38 +01:00
parent 4583716274
commit c4dc5b71d1
6 changed files with 23 additions and 21 deletions
+2 -2
View File
@@ -16,6 +16,6 @@
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" />
<anim name="normal" anim="Text Box Appear instance 10004" fps="24" loop="true" />
<anim name="normal-firstOpen" anim="Text Box Appear instance 10" fps="24" />
</dialoguebox>
@@ -0,0 +1,4 @@
<!DOCTYPE codename-engine-dialogue-character>
<character sprite="pixel/boyfriend" x="570" y="-599" graphicSizex="1334" antialiasing="false" >
<anim name="show" anim="Boyfriend portrait enter instance 10" fps="24" />
</character>
+2 -2
View File
@@ -2,7 +2,7 @@
<dialogue box="senpai">
<!-- All characters -->
<char name="senpai" char="senpai" position="left" />
<char name="boyfriend" char="boyfriend" position="right" />
<char name="pixelBf" char="pixelBf" position="right" />
<!-- Lines -->
<line char="senpai">
@@ -11,7 +11,7 @@
<line char="senpai">
But this time I'll rip your nuts off right after your girlfriend finishes gargling mine.
</line>
<line char="boyfriend">
<line char="pixelBf">
Bop beep be be skdoo bep
</line>
</dialogue>
+2 -2
View File
@@ -2,7 +2,7 @@
<dialogue box="senpai">
<!-- All characters -->
<char name="senpai" char="senpai" position="left" />
<char name="boyfriend" char="boyfriend" position="right" />
<char name="pixelBf" char="pixelBf" position="right" />
<!-- Lines -->
<line char="senpai">
@@ -11,7 +11,7 @@
<line char="senpai">
A serenade between gentlemen shall decide where her beautiful heart shall reside.
</line>
<line char="boyfriend">
<line char="pixelBf">
Beep bo bop
</line>
</dialogue>
@@ -8,6 +8,7 @@ import haxe.xml.Access;
class DialogueBox extends FunkinSprite {
public var dialogueBoxData:Access;
public var positions:Map<String, CharPosDef> = [];
public var everPlayedAny:Bool = false;
public var textTypeSFX:String = Paths.sound('dialogue/text');
public var nextSFX:String = Paths.sound('dialogue/next');
@@ -29,6 +30,13 @@ class DialogueBox extends FunkinSprite {
if(dialogueBoxData.has.textSound) textTypeSFX = Paths.sound(dialogueBoxData.att.textSound);
if(dialogueBoxData.has.nextSound) nextSFX = Paths.sound(dialogueBoxData.att.nextSound);
animation.finishCallback = (name:String) -> {
if(name.endsWith("-open") || name.endsWith("-firstOpen")) {
playAnim(name.substr(0, name.length - 5));
setText(__nextText, __speed);
}
}
for(pos in dialogueBoxData.nodes.charpos) {
if (!pos.has.name) continue;
positions[pos.att.name] = {
@@ -48,7 +56,6 @@ class DialogueBox extends FunkinSprite {
text.color = textNode.getAtt("color").getColorFromDynamic().getDefault(0xFF000000);
text.size = Std.parseInt(textNode.att.size).getDefault(20);
text.font = Paths.font('${textNode.getAtt("font").getDefault("vcr.ttf")}');
text.delay = Std.parseFloat(textNode.getAtt("delay")).getDefault(0.05);
text.antialiasing = textNode.getAtt("antialiasing").getDefault("false") == "true";
text.sounds = [FlxG.sound.load(textTypeSFX)];
if(textNode.has.borderStyle) {
@@ -84,13 +91,14 @@ class DialogueBox extends FunkinSprite {
this.__speed = speed;
this.text.resetText(text);
FlxG.sound.play(nextSFX);
if (hasAnimation('$bubble-open'))
playAnim('$bubble-open', true);
if(hasAnimation('$bubble-open')) playAnim('$bubble-open', true);
else if(hasAnimation('$bubble-firstOpen') && !everPlayedAny) playAnim('$bubble-firstOpen', true);
else {
playAnim(bubble);
setText(__nextText, __speed);
}
visible = true;
everPlayedAny = true;
}
public function setText(text:String, speed:Float = 0.02) {
@@ -98,17 +106,6 @@ class DialogueBox extends FunkinSprite {
this.text.start(speed, 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));
setText(__nextText, __speed);
}
}
}
public override function destroy() {
super.destroy();
positions = null;
@@ -39,9 +39,11 @@ class DialogueCharacter extends FunkinSprite {
public function show(x:Float, y:Float) {
if (curAnimContext == (curAnimContext = POPIN)) return;
visible = true;
if (hasAnimation('show')) {
playAnim('show', true);
setPosition(x, y);
alpha = 1;
} else {
setPosition(x, y + 100);
if(curTween != null) curTween.cancel();
@@ -49,7 +51,6 @@ class DialogueCharacter extends FunkinSprite {
alpha = 0;
curTween = FlxTween.tween(this, {alpha: 1, y: y}, 0.2, {ease: FlxEase.quintOut});
}
visible = true;
}
public function hide() {