1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-09 00:04:42 +00:00
Funkin/source/StoryMenuState.hx

446 lines
11 KiB
Haxe
Raw Normal View History

2020-10-30 23:47:19 +00:00
package;
2021-03-22 14:09:46 +00:00
#if discord_rpc
2021-02-26 12:27:32 +00:00
import Discord.DiscordClient;
#end
2020-10-30 23:47:19 +00:00
import flixel.FlxSprite;
2021-02-12 06:20:20 +00:00
import flixel.addons.transition.FlxTransitionableState;
2020-10-30 23:47:19 +00:00
import flixel.graphics.frames.FlxAtlasFrames;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.group.FlxGroup;
2020-11-07 02:17:27 +00:00
import flixel.math.FlxMath;
2020-10-30 23:47:19 +00:00
import flixel.text.FlxText;
2020-11-01 01:11:14 +00:00
import flixel.tweens.FlxTween;
2020-12-27 10:57:45 +00:00
import flixel.util.FlxColor;
2020-11-01 01:11:14 +00:00
import flixel.util.FlxTimer;
import lime.net.curl.CURLCode;
2020-10-30 23:47:19 +00:00
using StringTools;
class StoryMenuState extends MusicBeatState
{
var scoreText:FlxText;
2020-12-11 09:15:24 +00:00
var weekData:Array<Dynamic> = [
2021-01-20 10:31:43 +00:00
['Tutorial'],
2020-12-11 09:15:24 +00:00
['Bopeebo', 'Fresh', 'Dadbattle'],
2021-02-25 01:22:37 +00:00
['Spookeez', 'South', "Monster"],
2020-12-27 10:37:04 +00:00
['Pico', 'Philly', "Blammed"],
2021-01-20 10:31:43 +00:00
['Satin-Panties', "High", "Milf"],
2021-02-02 07:20:14 +00:00
['Cocoa', 'Eggnog', 'Winter-Horrorland'],
2021-04-09 20:37:54 +00:00
['Senpai', 'Roses', 'Thorns'],
['Ugh', 'Guns', 'Stress']
2020-12-11 09:15:24 +00:00
];
2020-11-01 01:11:14 +00:00
var curDifficulty:Int = 1;
2020-10-30 23:47:19 +00:00
2021-04-09 20:37:54 +00:00
public static var weekUnlocked:Array<Bool> = [true, true, true, true, true, true, true, true];
2020-11-01 01:11:14 +00:00
2020-12-11 09:15:24 +00:00
var weekCharacters:Array<Dynamic> = [
['dad', 'bf', 'gf'],
['dad', 'bf', 'gf'],
['spooky', 'bf', 'gf'],
2020-12-27 10:37:04 +00:00
['pico', 'bf', 'gf'],
2021-01-20 10:31:43 +00:00
['mom', 'bf', 'gf'],
2021-02-02 07:20:14 +00:00
['parents-christmas', 'bf', 'gf'],
2021-04-09 20:37:54 +00:00
['senpai', 'bf', 'gf'],
['tankman', 'bf', 'gf']
2020-12-11 09:15:24 +00:00
];
2021-02-02 07:20:14 +00:00
var weekNames:Array<String> = [
"",
"Daddy Dearest",
"Spooky Month",
"PICO",
"MOMMY MUST MURDER",
"RED SNOW",
2021-04-09 20:37:54 +00:00
"hating simulator ft. moawling",
2021-04-09 23:17:14 +00:00
"TANKMAN"
2021-02-02 07:20:14 +00:00
];
var txtWeekTitle:FlxText;
2020-10-30 23:47:19 +00:00
var curWeek:Int = 0;
var txtTracklist:FlxText;
var grpWeekText:FlxTypedGroup<MenuItem>;
2020-11-01 01:11:14 +00:00
var grpWeekCharacters:FlxTypedGroup<MenuCharacter>;
2020-10-30 23:47:19 +00:00
var grpLocks:FlxTypedGroup<FlxSprite>;
var difficultySelectors:FlxGroup;
2020-11-01 01:11:14 +00:00
var sprDifficulty:FlxSprite;
var leftArrow:FlxSprite;
var rightArrow:FlxSprite;
2020-10-30 23:47:19 +00:00
override function create()
{
2021-02-12 06:20:20 +00:00
transIn = FlxTransitionableState.defaultTransIn;
transOut = FlxTransitionableState.defaultTransOut;
2020-11-07 02:17:27 +00:00
if (FlxG.sound.music != null)
{
if (!FlxG.sound.music.playing)
2021-02-08 21:34:48 +00:00
FlxG.sound.playMusic(Paths.music('freakyMenu'));
2020-11-07 02:17:27 +00:00
}
2020-11-01 19:16:22 +00:00
2020-11-01 01:11:14 +00:00
persistentUpdate = persistentDraw = true;
2020-10-30 23:47:19 +00:00
scoreText = new FlxText(10, 10, 0, "SCORE: 49324858", 36);
scoreText.setFormat("VCR OSD Mono", 32);
2021-02-02 07:20:14 +00:00
txtWeekTitle = new FlxText(FlxG.width * 0.7, 10, 0, "", 32);
txtWeekTitle.setFormat("VCR OSD Mono", 32, FlxColor.WHITE, RIGHT);
txtWeekTitle.alpha = 0.7;
2020-10-30 23:47:19 +00:00
var rankText:FlxText = new FlxText(0, 10);
rankText.text = 'RANK: GREAT';
rankText.setFormat(Paths.font("vcr.ttf"), 32);
2020-10-30 23:47:19 +00:00
rankText.size = scoreText.size;
rankText.screenCenter(X);
2021-02-08 21:34:48 +00:00
var ui_tex = Paths.getSparrowAtlas('campaign_menu_UI_assets');
2020-10-30 23:47:19 +00:00
var yellowBG:FlxSprite = new FlxSprite(0, 56).makeGraphic(FlxG.width, 400, 0xFFF9CF51);
grpWeekText = new FlxTypedGroup<MenuItem>();
add(grpWeekText);
2020-12-27 10:57:45 +00:00
var blackBarThingie:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, 56, FlxColor.BLACK);
add(blackBarThingie);
2020-11-01 01:11:14 +00:00
grpWeekCharacters = new FlxTypedGroup<MenuCharacter>();
2020-10-30 23:47:19 +00:00
grpLocks = new FlxTypedGroup<FlxSprite>();
add(grpLocks);
2020-11-07 20:52:21 +00:00
trace("Line 70");
2021-04-09 20:37:54 +00:00
2021-03-22 14:09:46 +00:00
#if discord_rpc
2021-02-26 12:27:32 +00:00
// Updating Discord Rich Presence
DiscordClient.changePresence("In the Menus", null);
2021-02-26 12:27:32 +00:00
#end
2020-11-07 20:52:21 +00:00
2020-10-30 23:47:19 +00:00
for (i in 0...weekData.length)
{
2020-11-07 02:17:27 +00:00
var weekThing:MenuItem = new MenuItem(0, yellowBG.y + yellowBG.height + 10, i);
2020-10-30 23:47:19 +00:00
weekThing.y += ((weekThing.height + 20) * i);
weekThing.targetY = i;
grpWeekText.add(weekThing);
weekThing.screenCenter(X);
weekThing.antialiasing = true;
// weekThing.updateHitbox();
2020-11-07 02:17:27 +00:00
// Needs an offset thingie
2020-10-30 23:47:19 +00:00
if (!weekUnlocked[i])
{
var lock:FlxSprite = new FlxSprite(weekThing.width + 10 + weekThing.x);
lock.frames = ui_tex;
lock.animation.addByPrefix('lock', 'lock');
lock.animation.play('lock');
lock.ID = i;
lock.antialiasing = true;
grpLocks.add(lock);
}
}
2020-11-07 20:52:21 +00:00
trace("Line 96");
2020-11-01 01:11:14 +00:00
for (char in 0...3)
{
var weekCharacterThing:MenuCharacter = new MenuCharacter((FlxG.width * 0.25) * (1 + char) - 150, weekCharacters[curWeek][char]);
weekCharacterThing.y += 70;
weekCharacterThing.antialiasing = true;
switch (weekCharacterThing.character)
{
case 'dad':
weekCharacterThing.setGraphicSize(Std.int(weekCharacterThing.width * 0.5));
weekCharacterThing.updateHitbox();
case 'bf':
weekCharacterThing.setGraphicSize(Std.int(weekCharacterThing.width * 0.9));
weekCharacterThing.updateHitbox();
2020-11-01 19:16:22 +00:00
weekCharacterThing.x -= 80;
2020-11-01 01:11:14 +00:00
case 'gf':
weekCharacterThing.setGraphicSize(Std.int(weekCharacterThing.width * 0.5));
weekCharacterThing.updateHitbox();
2020-12-11 09:15:24 +00:00
case 'pico':
2020-12-11 13:49:06 +00:00
weekCharacterThing.flipX = true;
2021-01-20 11:14:38 +00:00
case 'parents-christmas':
weekCharacterThing.setGraphicSize(Std.int(weekCharacterThing.width * 0.9));
weekCharacterThing.updateHitbox();
2020-11-01 01:11:14 +00:00
}
grpWeekCharacters.add(weekCharacterThing);
}
2020-10-30 23:47:19 +00:00
difficultySelectors = new FlxGroup();
add(difficultySelectors);
2020-11-07 20:52:21 +00:00
trace("Line 124");
2020-11-07 02:17:27 +00:00
leftArrow = new FlxSprite(grpWeekText.members[0].x + grpWeekText.members[0].width + 10, grpWeekText.members[0].y + 10);
2020-10-30 23:47:19 +00:00
leftArrow.frames = ui_tex;
leftArrow.animation.addByPrefix('idle', "arrow left");
2020-11-01 01:11:14 +00:00
leftArrow.animation.addByPrefix('press', "arrow push left");
2020-10-30 23:47:19 +00:00
leftArrow.animation.play('idle');
difficultySelectors.add(leftArrow);
2020-11-01 01:11:14 +00:00
sprDifficulty = new FlxSprite(leftArrow.x + 130, leftArrow.y);
2020-10-30 23:47:19 +00:00
sprDifficulty.frames = ui_tex;
sprDifficulty.animation.addByPrefix('easy', 'EASY');
sprDifficulty.animation.addByPrefix('normal', 'NORMAL');
sprDifficulty.animation.addByPrefix('hard', 'HARD');
sprDifficulty.animation.play('easy');
2020-11-01 01:11:14 +00:00
changeDifficulty();
2020-10-30 23:47:19 +00:00
difficultySelectors.add(sprDifficulty);
2020-11-01 01:11:14 +00:00
rightArrow = new FlxSprite(sprDifficulty.x + sprDifficulty.width + 50, leftArrow.y);
2020-10-30 23:47:19 +00:00
rightArrow.frames = ui_tex;
rightArrow.animation.addByPrefix('idle', 'arrow right');
2020-11-01 01:11:14 +00:00
rightArrow.animation.addByPrefix('press', "arrow push right", 24, false);
2020-10-30 23:47:19 +00:00
rightArrow.animation.play('idle');
difficultySelectors.add(rightArrow);
2020-11-07 20:52:21 +00:00
trace("Line 150");
2020-10-30 23:47:19 +00:00
add(yellowBG);
2020-11-01 01:11:14 +00:00
add(grpWeekCharacters);
2020-10-30 23:47:19 +00:00
txtTracklist = new FlxText(FlxG.width * 0.05, yellowBG.x + yellowBG.height + 100, 0, "Tracks", 32);
txtTracklist.alignment = CENTER;
txtTracklist.font = rankText.font;
txtTracklist.color = 0xFFe55777;
add(txtTracklist);
2020-11-01 19:16:22 +00:00
// add(rankText);
2020-11-07 02:17:27 +00:00
add(scoreText);
2021-02-02 07:20:14 +00:00
add(txtWeekTitle);
2020-10-30 23:47:19 +00:00
updateText();
2020-11-07 20:52:21 +00:00
trace("Line 165");
2020-10-30 23:47:19 +00:00
super.create();
}
override function update(elapsed:Float)
{
// scoreText.setFormat('VCR OSD Mono', 32);
lerpScore = CoolUtil.coolLerp(lerpScore, intendedScore, 0.5);
2020-11-07 02:17:27 +00:00
scoreText.text = "WEEK SCORE:" + Math.round(lerpScore);
2021-02-02 07:20:14 +00:00
txtWeekTitle.text = weekNames[curWeek].toUpperCase();
txtWeekTitle.x = FlxG.width - (txtWeekTitle.width + 10);
2020-10-30 23:47:19 +00:00
// FlxG.watch.addQuick('font', scoreText.font);
difficultySelectors.visible = weekUnlocked[curWeek];
grpLocks.forEach(function(lock:FlxSprite)
{
lock.y = grpWeekText.members[lock.ID].y;
});
2020-11-01 01:11:14 +00:00
if (!movedBack)
{
if (!selectedWeek)
{
2021-03-14 02:11:56 +00:00
if (controls.UI_UP_P)
2020-11-01 01:11:14 +00:00
{
changeWeek(-1);
}
2021-03-14 02:11:56 +00:00
if (controls.UI_DOWN_P)
2020-11-01 01:11:14 +00:00
{
changeWeek(1);
}
2021-03-14 02:11:56 +00:00
if (controls.UI_RIGHT)
2020-11-01 01:11:14 +00:00
rightArrow.animation.play('press')
else
rightArrow.animation.play('idle');
2021-03-14 02:11:56 +00:00
if (controls.UI_LEFT)
2020-11-01 01:11:14 +00:00
leftArrow.animation.play('press');
else
leftArrow.animation.play('idle');
2021-03-14 02:11:56 +00:00
if (controls.UI_RIGHT_P)
2020-11-01 01:11:14 +00:00
changeDifficulty(1);
2021-03-14 02:11:56 +00:00
if (controls.UI_LEFT_P)
2020-11-01 01:11:14 +00:00
changeDifficulty(-1);
}
if (controls.ACCEPT)
{
selectWeek();
}
}
if (controls.BACK && !movedBack && !selectedWeek)
{
2021-02-08 21:34:48 +00:00
FlxG.sound.play(Paths.sound('cancelMenu'));
2020-11-01 01:11:14 +00:00
movedBack = true;
FlxG.switchState(new MainMenuState());
}
2020-10-30 23:47:19 +00:00
super.update(elapsed);
}
2020-11-01 01:11:14 +00:00
var movedBack:Bool = false;
var selectedWeek:Bool = false;
2020-11-26 19:14:35 +00:00
var stopspamming:Bool = false;
2020-12-11 09:15:24 +00:00
2020-11-01 01:11:14 +00:00
function selectWeek()
{
if (weekUnlocked[curWeek])
{
2020-12-11 09:15:24 +00:00
if (stopspamming == false)
{
2021-02-08 21:34:48 +00:00
FlxG.sound.play(Paths.sound('confirmMenu'));
2020-11-01 01:11:14 +00:00
2021-03-02 03:35:27 +00:00
grpWeekText.members[curWeek].startFlashing();
grpWeekCharacters.members[1].animation.play('bfConfirm');
stopspamming = true;
}
2020-11-01 01:11:14 +00:00
PlayState.storyPlaylist = weekData[curWeek];
PlayState.isStoryMode = true;
selectedWeek = true;
var diffic = "";
switch (curDifficulty)
{
case 0:
diffic = '-easy';
case 2:
diffic = '-hard';
}
PlayState.storyDifficulty = curDifficulty;
PlayState.SONG = Song.loadFromJson(PlayState.storyPlaylist[0].toLowerCase() + diffic, PlayState.storyPlaylist[0].toLowerCase());
2020-11-07 02:17:27 +00:00
PlayState.storyWeek = curWeek;
PlayState.campaignScore = 0;
2020-11-01 01:11:14 +00:00
new FlxTimer().start(1, function(tmr:FlxTimer)
{
LoadingState.loadAndSwitchState(new PlayState(), true);
2020-11-01 01:11:14 +00:00
});
}
}
function changeDifficulty(change:Int = 0):Void
{
curDifficulty += change;
if (curDifficulty < 0)
curDifficulty = 2;
if (curDifficulty > 2)
curDifficulty = 0;
sprDifficulty.offset.x = 0;
switch (curDifficulty)
{
case 0:
sprDifficulty.animation.play('easy');
sprDifficulty.offset.x = 20;
case 1:
sprDifficulty.animation.play('normal');
sprDifficulty.offset.x = 70;
case 2:
sprDifficulty.animation.play('hard');
sprDifficulty.offset.x = 20;
}
sprDifficulty.alpha = 0;
2020-11-01 19:16:22 +00:00
// USING THESE WEIRD VALUES SO THAT IT DOESNT FLOAT UP
sprDifficulty.y = leftArrow.y - 15;
2020-11-06 10:56:45 +00:00
intendedScore = Highscore.getWeekScore(curWeek, curDifficulty);
2020-11-07 20:52:21 +00:00
2020-11-01 19:16:22 +00:00
FlxTween.tween(sprDifficulty, {y: leftArrow.y + 15, alpha: 1}, 0.07);
2020-11-01 01:11:14 +00:00
}
var lerpScore:Float = 0;
2020-11-07 02:17:27 +00:00
var intendedScore:Int = 0;
2020-10-30 23:47:19 +00:00
function changeWeek(change:Int = 0):Void
{
curWeek += change;
if (curWeek >= weekData.length)
curWeek = 0;
if (curWeek < 0)
curWeek = weekData.length - 1;
var bullShit:Int = 0;
for (item in grpWeekText.members)
{
item.targetY = bullShit - curWeek;
2020-11-07 02:17:27 +00:00
if (item.targetY == Std.int(0) && weekUnlocked[curWeek])
item.alpha = 1;
else
item.alpha = 0.6;
2020-10-30 23:47:19 +00:00
bullShit++;
}
2021-02-08 21:34:48 +00:00
FlxG.sound.play(Paths.sound('scrollMenu'));
2020-11-01 01:11:14 +00:00
2020-10-30 23:47:19 +00:00
updateText();
}
function updateText()
{
2020-11-01 01:11:14 +00:00
grpWeekCharacters.members[0].animation.play(weekCharacters[curWeek][0]);
grpWeekCharacters.members[1].animation.play(weekCharacters[curWeek][1]);
grpWeekCharacters.members[2].animation.play(weekCharacters[curWeek][2]);
2020-10-30 23:47:19 +00:00
txtTracklist.text = "Tracks\n";
2021-01-20 11:14:38 +00:00
switch (grpWeekCharacters.members[0].animation.curAnim.name)
{
case 'parents-christmas':
2021-02-02 07:20:14 +00:00
grpWeekCharacters.members[0].offset.set(200, 200);
grpWeekCharacters.members[0].setGraphicSize(Std.int(grpWeekCharacters.members[0].width * 0.99));
case 'senpai':
grpWeekCharacters.members[0].offset.set(130, 0);
grpWeekCharacters.members[0].setGraphicSize(Std.int(grpWeekCharacters.members[0].width * 1.4));
case 'mom':
grpWeekCharacters.members[0].offset.set(100, 200);
grpWeekCharacters.members[0].setGraphicSize(Std.int(grpWeekCharacters.members[0].width * 1));
case 'dad':
grpWeekCharacters.members[0].offset.set(120, 200);
grpWeekCharacters.members[0].setGraphicSize(Std.int(grpWeekCharacters.members[0].width * 1));
2021-04-09 20:37:54 +00:00
case 'tankman':
grpWeekCharacters.members[0].offset.set(60, -20);
grpWeekCharacters.members[0].setGraphicSize(Std.int(grpWeekCharacters.members[0].width * 1));
2021-01-20 11:53:20 +00:00
2021-01-20 11:14:38 +00:00
default:
2021-02-02 07:20:14 +00:00
grpWeekCharacters.members[0].offset.set(100, 100);
2021-01-20 11:53:20 +00:00
grpWeekCharacters.members[0].setGraphicSize(Std.int(grpWeekCharacters.members[0].width * 1));
// grpWeekCharacters.members[0].updateHitbox();
2021-01-20 11:14:38 +00:00
}
2020-10-30 23:47:19 +00:00
var stringThing:Array<String> = weekData[curWeek];
for (i in stringThing)
{
txtTracklist.text += "\n" + i;
}
txtTracklist.text = txtTracklist.text.toUpperCase();
txtTracklist.screenCenter(X);
txtTracklist.x -= FlxG.width * 0.35;
2020-12-11 09:15:24 +00:00
2020-11-07 02:17:27 +00:00
intendedScore = Highscore.getWeekScore(curWeek, curDifficulty);
2020-10-30 23:47:19 +00:00
}
}