2022-03-08 08:13:53 +00:00
|
|
|
package funkin;
|
2020-10-31 06:30:35 +00:00
|
|
|
|
|
|
|
import flixel.FlxSprite;
|
2021-02-01 06:50:30 +00:00
|
|
|
import flixel.addons.text.FlxTypeText;
|
2020-10-31 06:30:35 +00:00
|
|
|
import flixel.group.FlxSpriteGroup;
|
2021-02-01 06:50:30 +00:00
|
|
|
import flixel.text.FlxText;
|
2021-02-02 09:54:36 +00:00
|
|
|
import flixel.util.FlxColor;
|
2021-02-01 06:50:30 +00:00
|
|
|
import flixel.util.FlxTimer;
|
2022-03-08 08:13:53 +00:00
|
|
|
import funkin.play.PlayState;
|
2021-02-01 06:50:30 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
/**
|
|
|
|
* Handles dialog boxes and text, like the ones in Week 6.
|
|
|
|
*/
|
2020-10-31 06:30:35 +00:00
|
|
|
class DialogueBox extends FlxSpriteGroup
|
|
|
|
{
|
2023-01-23 03:25:45 +00:00
|
|
|
var box:FlxSprite;
|
|
|
|
|
|
|
|
var curCharacter:String = '';
|
|
|
|
|
|
|
|
var dialogue:Alphabet;
|
|
|
|
var dialogueList:Array<String> = [];
|
|
|
|
|
|
|
|
// SECOND DIALOGUE FOR THE PIXEL SHIT INSTEAD???
|
|
|
|
var swagDialogue:FlxTypeText;
|
|
|
|
|
|
|
|
var dropText:FlxText;
|
|
|
|
|
|
|
|
public var finishThing:Void->Void;
|
|
|
|
|
|
|
|
var portraitLeft:FlxSprite;
|
|
|
|
var portraitRight:FlxSprite;
|
|
|
|
|
|
|
|
var handSelect:FlxSprite;
|
|
|
|
var bgFade:FlxSprite;
|
|
|
|
|
|
|
|
public function new(talkingRight:Bool = true, ?dialogueList:Array<String>)
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
|
2023-09-08 21:46:44 +00:00
|
|
|
switch (PlayState.instance.currentSong.id.toLowerCase())
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
|
|
|
case 'senpai':
|
|
|
|
FlxG.sound.playMusic(Paths.music('Lunchbox'), 0);
|
|
|
|
FlxG.sound.music.fadeIn(1, 0, 0.8);
|
|
|
|
case 'thorns':
|
|
|
|
FlxG.sound.playMusic(Paths.music('LunchboxScary'), 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);
|
|
|
|
bgFade.scrollFactor.set();
|
|
|
|
bgFade.alpha = 0;
|
|
|
|
add(bgFade);
|
|
|
|
|
2023-06-06 21:38:31 +00:00
|
|
|
new FlxTimer().start(0.83, function(tmr:FlxTimer) {
|
2023-01-23 03:25:45 +00:00
|
|
|
bgFade.alpha += (1 / 5) * 0.7;
|
|
|
|
if (bgFade.alpha > 0.7) bgFade.alpha = 0.7;
|
|
|
|
}, 5);
|
|
|
|
|
|
|
|
portraitLeft = new FlxSprite(-20, 40);
|
|
|
|
portraitLeft.frames = Paths.getSparrowAtlas('weeb/senpaiPortrait');
|
|
|
|
portraitLeft.animation.addByPrefix('enter', 'Senpai Portrait Enter', 24, false);
|
|
|
|
portraitLeft.setGraphicSize(Std.int(portraitLeft.width * Constants.PIXEL_ART_SCALE * 0.9));
|
|
|
|
portraitLeft.updateHitbox();
|
|
|
|
portraitLeft.scrollFactor.set();
|
|
|
|
add(portraitLeft);
|
|
|
|
portraitLeft.visible = false;
|
|
|
|
|
|
|
|
portraitRight = new FlxSprite(0, 40);
|
|
|
|
portraitRight.frames = Paths.getSparrowAtlas('weeb/bfPortrait');
|
|
|
|
portraitRight.animation.addByPrefix('enter', 'Boyfriend portrait enter', 24, false);
|
|
|
|
portraitRight.setGraphicSize(Std.int(portraitRight.width * Constants.PIXEL_ART_SCALE * 0.9));
|
|
|
|
portraitRight.updateHitbox();
|
|
|
|
portraitRight.scrollFactor.set();
|
|
|
|
add(portraitRight);
|
|
|
|
portraitRight.visible = false;
|
|
|
|
|
|
|
|
box = new FlxSprite(-20, 45);
|
|
|
|
|
|
|
|
var hasDialog:Bool = false;
|
2023-09-08 21:46:44 +00:00
|
|
|
switch (PlayState.instance.currentSong.id.toLowerCase())
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
|
|
|
case 'senpai':
|
|
|
|
hasDialog = true;
|
|
|
|
box.frames = Paths.getSparrowAtlas('weeb/pixelUI/dialogueBox-pixel');
|
|
|
|
box.animation.addByPrefix('normalOpen', 'Text Box Appear', 24, false);
|
|
|
|
box.animation.addByIndices('normal', 'Text Box Appear', [4], '', 24);
|
|
|
|
case 'roses':
|
|
|
|
hasDialog = true;
|
|
|
|
FlxG.sound.play(Paths.sound('ANGRY_TEXT_BOX'));
|
|
|
|
|
|
|
|
box.frames = Paths.getSparrowAtlas('weeb/pixelUI/dialogueBox-senpaiMad');
|
|
|
|
box.animation.addByPrefix('normalOpen', 'SENPAI ANGRY IMPACT SPEECH', 24, false);
|
|
|
|
box.animation.addByIndices('normal', 'SENPAI ANGRY IMPACT SPEECH', [4], '', 24);
|
|
|
|
|
|
|
|
case 'thorns':
|
|
|
|
hasDialog = true;
|
|
|
|
box.frames = Paths.getSparrowAtlas('weeb/pixelUI/dialogueBox-evil');
|
|
|
|
box.animation.addByPrefix('normalOpen', 'Spirit Textbox spawn', 24, false);
|
|
|
|
box.animation.addByIndices('normal', 'Spirit Textbox spawn', [11], '', 24);
|
|
|
|
|
|
|
|
var face:FlxSprite = new FlxSprite(320, 170).loadGraphic(Paths.image('weeb/spiritFaceForward'));
|
|
|
|
face.setGraphicSize(Std.int(face.width * 6));
|
|
|
|
add(face);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.dialogueList = dialogueList;
|
|
|
|
|
|
|
|
if (!hasDialog) return;
|
|
|
|
|
|
|
|
box.animation.play('normalOpen');
|
|
|
|
box.setGraphicSize(Std.int(box.width * Constants.PIXEL_ART_SCALE * 0.9));
|
|
|
|
box.updateHitbox();
|
|
|
|
add(box);
|
|
|
|
|
|
|
|
box.screenCenter(X);
|
|
|
|
portraitLeft.screenCenter(X);
|
|
|
|
|
|
|
|
handSelect = new FlxSprite(1042, 590).loadGraphic(Paths.image('weeb/pixelUI/hand_textbox'));
|
|
|
|
handSelect.setGraphicSize(Std.int(handSelect.width * Constants.PIXEL_ART_SCALE * 0.9));
|
|
|
|
handSelect.updateHitbox();
|
|
|
|
handSelect.visible = false;
|
|
|
|
add(handSelect);
|
|
|
|
|
|
|
|
if (!talkingRight)
|
|
|
|
{
|
|
|
|
// box.flipX = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
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(Paths.sound('pixelText'), 0.6)];
|
|
|
|
add(swagDialogue);
|
|
|
|
|
|
|
|
dialogue = new Alphabet(0, 80, '', false, true);
|
|
|
|
// dialogue.x = 90;
|
|
|
|
// add(dialogue);
|
|
|
|
}
|
|
|
|
|
|
|
|
var dialogueOpened:Bool = false;
|
|
|
|
var dialogueStarted:Bool = false;
|
|
|
|
var dialogueEnded:Bool = false;
|
|
|
|
|
|
|
|
override function update(elapsed:Float):Void
|
|
|
|
{
|
|
|
|
// HARD CODING CUZ IM STUPDI
|
2023-09-08 21:46:44 +00:00
|
|
|
if (PlayState.instance.currentSong.id.toLowerCase() == 'roses') portraitLeft.visible = false;
|
|
|
|
if (PlayState.instance.currentSong.id.toLowerCase() == 'thorns')
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
|
|
|
portraitLeft.color = FlxColor.BLACK;
|
|
|
|
swagDialogue.color = FlxColor.WHITE;
|
|
|
|
dropText.color = FlxColor.BLACK;
|
|
|
|
}
|
|
|
|
|
|
|
|
dropText.text = swagDialogue.text;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.ANY && dialogueEnded)
|
|
|
|
{
|
|
|
|
remove(dialogue);
|
|
|
|
|
|
|
|
FlxG.sound.play(Paths.sound('clickText'), 0.8);
|
|
|
|
|
|
|
|
if (dialogueList[1] == null && dialogueList[0] != null)
|
|
|
|
{
|
|
|
|
if (!isEnding)
|
|
|
|
{
|
|
|
|
isEnding = true;
|
|
|
|
|
2023-09-08 21:46:44 +00:00
|
|
|
if (PlayState.instance.currentSong.id.toLowerCase() == 'senpai'
|
|
|
|
|| PlayState.instance.currentSong.id.toLowerCase() == 'thorns') FlxG.sound.music.fadeOut(2.2, 0);
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-06-06 21:38:31 +00:00
|
|
|
new FlxTimer().start(0.2, function(tmr:FlxTimer) {
|
2023-01-23 03:25:45 +00:00
|
|
|
box.alpha -= 1 / 5;
|
|
|
|
bgFade.alpha -= 1 / 5 * 0.7;
|
|
|
|
portraitLeft.visible = false;
|
|
|
|
portraitRight.visible = false;
|
|
|
|
swagDialogue.alpha -= 1 / 5;
|
|
|
|
handSelect.alpha -= 1 / 5;
|
|
|
|
dropText.alpha = swagDialogue.alpha;
|
|
|
|
}, 5);
|
|
|
|
|
2023-06-06 21:38:31 +00:00
|
|
|
new FlxTimer().start(1.2, function(tmr:FlxTimer) {
|
2023-01-23 03:25:45 +00:00
|
|
|
finishThing();
|
|
|
|
kill();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dialogueList.remove(dialogueList[0]);
|
|
|
|
startDialogue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (FlxG.keys.justPressed.ANY && dialogueStarted) swagDialogue.skip();
|
|
|
|
|
|
|
|
super.update(elapsed);
|
|
|
|
}
|
|
|
|
|
|
|
|
var isEnding:Bool = false;
|
|
|
|
|
|
|
|
function startDialogue():Void
|
|
|
|
{
|
|
|
|
cleanDialog();
|
|
|
|
// var theDialog:Alphabet = new Alphabet(0, 70, dialogueList[0], false, true);
|
|
|
|
// dialogue = theDialog;
|
|
|
|
// add(theDialog);
|
|
|
|
|
|
|
|
// swagDialogue.text = ;
|
|
|
|
swagDialogue.resetText(dialogueList[0]);
|
|
|
|
swagDialogue.start(0.04);
|
2023-06-06 21:38:31 +00:00
|
|
|
swagDialogue.completeCallback = function() {
|
2023-01-23 03:25:45 +00:00
|
|
|
trace('dialogue finish');
|
|
|
|
handSelect.visible = true;
|
|
|
|
dialogueEnded = true;
|
|
|
|
};
|
|
|
|
handSelect.visible = false;
|
|
|
|
dialogueEnded = false;
|
|
|
|
|
|
|
|
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 06:30:35 +00:00
|
|
|
}
|