2020-10-31 02:30:35 -04:00
|
|
|
package;
|
|
|
|
|
|
|
|
import flixel.FlxG;
|
|
|
|
import flixel.FlxSprite;
|
2021-02-01 01:50:30 -05:00
|
|
|
import flixel.addons.text.FlxTypeText;
|
2020-10-31 02:30:35 -04:00
|
|
|
import flixel.graphics.frames.FlxAtlasFrames;
|
|
|
|
import flixel.group.FlxSpriteGroup;
|
|
|
|
import flixel.input.FlxKeyManager;
|
2021-02-01 01:50:30 -05:00
|
|
|
import flixel.text.FlxText;
|
|
|
|
import flixel.util.FlxTimer;
|
|
|
|
|
|
|
|
using StringTools;
|
2020-10-31 02:30:35 -04:00
|
|
|
|
|
|
|
class DialogueBox extends FlxSpriteGroup
|
|
|
|
{
|
|
|
|
var box:FlxSprite;
|
|
|
|
|
2021-02-01 01:50:30 -05:00
|
|
|
var curCharacter:String = '';
|
|
|
|
|
2020-10-31 02:30:35 -04:00
|
|
|
var dialogue:Alphabet;
|
|
|
|
var dialogueList:Array<String> = [];
|
|
|
|
|
2021-02-01 01:50:30 -05:00
|
|
|
// SECOND DIALOGUE FOR THE PIXEL SHIT INSTEAD???
|
|
|
|
var swagDialogue:FlxTypeText;
|
|
|
|
|
|
|
|
var dropText:FlxText;
|
|
|
|
|
2020-10-31 02:30:35 -04:00
|
|
|
public var finishThing:Void->Void;
|
|
|
|
|
2021-02-01 01:50:30 -05:00
|
|
|
var portraitLeft:FlxSprite;
|
|
|
|
var portraitRight:FlxSprite;
|
|
|
|
|
2021-02-01 05:52:10 -05:00
|
|
|
var handSelect:FlxSprite;
|
2021-02-02 00:48:22 -05:00
|
|
|
var bgFade:FlxSprite;
|
2021-02-01 05:52:10 -05:00
|
|
|
|
2020-10-31 02:30:35 -04:00
|
|
|
public function new(talkingRight:Bool = true, ?dialogueList:Array<String>)
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
|
2021-02-02 00:48:22 -05:00
|
|
|
FlxG.sound.playMusic('assets/music/Lunchbox' + TitleState.soundExt, 0);
|
|
|
|
FlxG.sound.music.fadeIn(1, 0, 0.8);
|
|
|
|
|
|
|
|
bgFade = new FlxSprite(-200, -200).makeGraphic(Std.int(FlxG.width * 1.3), Std.int(FlxG.height * 1.3), 0xFFB3DFd8);
|
2021-02-01 01:50:30 -05:00
|
|
|
bgFade.scrollFactor.set();
|
|
|
|
bgFade.alpha = 0;
|
|
|
|
add(bgFade);
|
|
|
|
|
|
|
|
new FlxTimer().start(0.83, function(tmr:FlxTimer)
|
|
|
|
{
|
|
|
|
bgFade.alpha += (1 / 5) * 0.7;
|
|
|
|
if (bgFade.alpha > 0.7)
|
|
|
|
bgFade.alpha = 0.7;
|
|
|
|
}, 5);
|
|
|
|
|
|
|
|
portraitLeft = new FlxSprite(-20, 40);
|
|
|
|
portraitLeft.frames = FlxAtlasFrames.fromSparrow('assets/images/weeb/senpaiPortrait.png', 'assets/images/weeb/senpaiPortrait.xml');
|
|
|
|
portraitLeft.animation.addByPrefix('enter', 'Senpai Portrait Enter', 24, false);
|
|
|
|
portraitLeft.setGraphicSize(Std.int(portraitLeft.width * PlayState.daPixelZoom * 0.9));
|
|
|
|
portraitLeft.updateHitbox();
|
|
|
|
portraitLeft.scrollFactor.set();
|
|
|
|
add(portraitLeft);
|
|
|
|
portraitLeft.visible = false;
|
|
|
|
|
|
|
|
portraitRight = new FlxSprite(0, 40);
|
|
|
|
portraitRight.frames = FlxAtlasFrames.fromSparrow('assets/images/weeb/bfPortrait.png', 'assets/images/weeb/bfPortrait.xml');
|
|
|
|
portraitRight.animation.addByPrefix('enter', 'Boyfriend portrait enter', 24, false);
|
|
|
|
portraitRight.setGraphicSize(Std.int(portraitRight.width * PlayState.daPixelZoom * 0.9));
|
|
|
|
portraitRight.updateHitbox();
|
|
|
|
portraitRight.scrollFactor.set();
|
|
|
|
add(portraitRight);
|
|
|
|
portraitRight.visible = false;
|
|
|
|
|
|
|
|
box = new FlxSprite(-20, 45);
|
|
|
|
box.frames = FlxAtlasFrames.fromSparrow('assets/images/weeb/pixelUI/dialogueBox-pixel.png', 'assets/images/weeb/pixelUI/dialogueBox-pixel.xml');
|
|
|
|
box.animation.addByPrefix('normalOpen', 'Text Box Appear', 24, false);
|
|
|
|
box.animation.addByIndices('normal', 'Text Box Appear', [4], "", 24);
|
2020-10-31 02:30:35 -04:00
|
|
|
box.animation.play('normalOpen');
|
2021-02-01 01:50:30 -05:00
|
|
|
box.setGraphicSize(Std.int(box.width * PlayState.daPixelZoom * 0.9));
|
|
|
|
box.updateHitbox();
|
2020-10-31 02:30:35 -04:00
|
|
|
add(box);
|
|
|
|
|
2021-02-01 05:52:10 -05:00
|
|
|
handSelect = new FlxSprite(FlxG.width * 0.9, FlxG.height * 0.9).loadGraphic('assets/images/weeb/pixelUI/hand_textbox.png');
|
|
|
|
add(handSelect);
|
|
|
|
|
2021-02-01 01:50:30 -05:00
|
|
|
box.screenCenter(X);
|
|
|
|
portraitLeft.screenCenter(X);
|
|
|
|
|
2020-10-31 02:30:35 -04:00
|
|
|
if (!talkingRight)
|
|
|
|
{
|
|
|
|
box.flipX = true;
|
|
|
|
}
|
|
|
|
|
2021-02-01 01:50:30 -05:00
|
|
|
dropText = new FlxText(242, 502, Std.int(FlxG.width * 0.6), "", 32);
|
|
|
|
dropText.font = 'Pixel Arial 11 Bold';
|
|
|
|
dropText.color = 0xFFD89494;
|
|
|
|
add(dropText);
|
|
|
|
|
|
|
|
swagDialogue = new FlxTypeText(240, 500, Std.int(FlxG.width * 0.6), "", 32);
|
|
|
|
swagDialogue.font = 'Pixel Arial 11 Bold';
|
|
|
|
swagDialogue.color = 0xFF3F2021;
|
|
|
|
swagDialogue.sounds = [FlxG.sound.load('assets/sounds/pixelText' + TitleState.soundExt, 0.6)];
|
|
|
|
add(swagDialogue);
|
|
|
|
|
2020-10-31 02:30:35 -04:00
|
|
|
dialogue = new Alphabet(0, 80, "", false, true);
|
|
|
|
// dialogue.x = 90;
|
2021-02-01 01:50:30 -05:00
|
|
|
// add(dialogue);
|
2020-10-31 02:30:35 -04:00
|
|
|
|
|
|
|
this.dialogueList = dialogueList;
|
|
|
|
}
|
|
|
|
|
|
|
|
var dialogueOpened:Bool = false;
|
|
|
|
var dialogueStarted:Bool = false;
|
|
|
|
|
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
2021-02-01 01:50:30 -05:00
|
|
|
dropText.text = swagDialogue.text;
|
|
|
|
|
2020-10-31 02:30:35 -04:00
|
|
|
if (box.animation.curAnim != null)
|
|
|
|
{
|
|
|
|
if (box.animation.curAnim.name == 'normalOpen' && box.animation.curAnim.finished)
|
|
|
|
{
|
|
|
|
box.animation.play('normal');
|
|
|
|
dialogueOpened = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dialogueOpened && !dialogueStarted)
|
|
|
|
{
|
|
|
|
startDialogue();
|
|
|
|
dialogueStarted = true;
|
|
|
|
}
|
|
|
|
|
2021-02-02 02:35:35 -05:00
|
|
|
if (FlxG.keys.justPressed.ANY)
|
2020-10-31 02:30:35 -04:00
|
|
|
{
|
|
|
|
remove(dialogue);
|
|
|
|
|
2021-02-02 00:48:22 -05:00
|
|
|
FlxG.sound.play('assets/sounds/clickText' + TitleState.soundExt, 0.8);
|
|
|
|
|
2020-10-31 02:30:35 -04:00
|
|
|
if (dialogueList[1] == null)
|
|
|
|
{
|
2021-02-02 00:48:22 -05:00
|
|
|
if (!isEnding)
|
|
|
|
{
|
|
|
|
isEnding = true;
|
|
|
|
FlxG.sound.music.fadeOut(2.2, 0);
|
|
|
|
|
|
|
|
new FlxTimer().start(0.2, function(tmr:FlxTimer)
|
|
|
|
{
|
|
|
|
box.alpha -= 1 / 5;
|
|
|
|
bgFade.alpha -= 1 / 5 * 0.7;
|
|
|
|
portraitLeft.visible = false;
|
|
|
|
portraitRight.visible = false;
|
|
|
|
swagDialogue.alpha -= 1 / 5;
|
|
|
|
dropText.alpha = swagDialogue.alpha;
|
|
|
|
}, 5);
|
|
|
|
|
|
|
|
new FlxTimer().start(1.2, function(tmr:FlxTimer)
|
|
|
|
{
|
|
|
|
finishThing();
|
|
|
|
kill();
|
|
|
|
});
|
|
|
|
}
|
2020-10-31 02:30:35 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dialogueList.remove(dialogueList[0]);
|
|
|
|
startDialogue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
super.update(elapsed);
|
|
|
|
}
|
|
|
|
|
2021-02-02 00:48:22 -05:00
|
|
|
var isEnding:Bool = false;
|
|
|
|
|
2020-10-31 02:30:35 -04:00
|
|
|
function startDialogue():Void
|
|
|
|
{
|
2021-02-01 01:50:30 -05:00
|
|
|
cleanDialog();
|
|
|
|
|
|
|
|
// var theDialog:Alphabet = new Alphabet(0, 70, dialogueList[0], false, true);
|
|
|
|
// dialogue = theDialog;
|
|
|
|
// add(theDialog);
|
|
|
|
|
|
|
|
// swagDialogue.text = ;
|
|
|
|
swagDialogue.resetText(dialogueList[0]);
|
2021-02-02 00:48:22 -05:00
|
|
|
swagDialogue.start(0.04, true);
|
2021-02-01 01:50:30 -05:00
|
|
|
|
|
|
|
switch (curCharacter)
|
|
|
|
{
|
|
|
|
case 'dad':
|
|
|
|
portraitRight.visible = false;
|
|
|
|
if (!portraitLeft.visible)
|
|
|
|
{
|
|
|
|
portraitLeft.visible = true;
|
|
|
|
portraitLeft.animation.play('enter');
|
|
|
|
}
|
|
|
|
case 'bf':
|
|
|
|
portraitLeft.visible = false;
|
|
|
|
if (!portraitRight.visible)
|
|
|
|
{
|
|
|
|
portraitRight.visible = true;
|
|
|
|
portraitRight.animation.play('enter');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function cleanDialog():Void
|
|
|
|
{
|
|
|
|
var splitName:Array<String> = dialogueList[0].split(":");
|
|
|
|
curCharacter = splitName[1];
|
|
|
|
dialogueList[0] = dialogueList[0].substr(splitName[1].length + 2).trim();
|
2020-10-31 02:30:35 -04:00
|
|
|
}
|
|
|
|
}
|