2020-10-21 18:05:27 +00:00
|
|
|
package;
|
|
|
|
|
2021-02-26 12:27:32 +00:00
|
|
|
#if !html
|
|
|
|
import Discord.DiscordClient;
|
|
|
|
#end
|
2020-11-07 02:17:27 +00:00
|
|
|
import flash.text.TextField;
|
2020-10-21 18:05:27 +00:00
|
|
|
import flixel.FlxG;
|
|
|
|
import flixel.FlxSprite;
|
2020-10-25 20:51:06 +00:00
|
|
|
import flixel.addons.display.FlxGridOverlay;
|
2020-11-01 19:16:22 +00:00
|
|
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
2020-11-07 02:17:27 +00:00
|
|
|
import flixel.math.FlxMath;
|
2020-10-21 18:05:27 +00:00
|
|
|
import flixel.text.FlxText;
|
2020-11-07 02:17:27 +00:00
|
|
|
import flixel.util.FlxColor;
|
|
|
|
import lime.utils.Assets;
|
2020-10-21 18:05:27 +00:00
|
|
|
|
2021-01-15 04:33:12 +00:00
|
|
|
using StringTools;
|
|
|
|
|
2020-10-21 18:05:27 +00:00
|
|
|
class FreeplayState extends MusicBeatState
|
|
|
|
{
|
2021-02-25 01:52:59 +00:00
|
|
|
var songs:Array<SongMetadata> = [];
|
2020-10-21 18:05:27 +00:00
|
|
|
|
|
|
|
var selector:FlxText;
|
|
|
|
var curSelected:Int = 0;
|
2020-11-07 02:17:27 +00:00
|
|
|
var curDifficulty:Int = 1;
|
|
|
|
|
|
|
|
var scoreText:FlxText;
|
|
|
|
var diffText:FlxText;
|
|
|
|
var lerpScore:Int = 0;
|
|
|
|
var intendedScore:Int = 0;
|
2020-10-21 18:05:27 +00:00
|
|
|
|
2020-11-01 19:16:22 +00:00
|
|
|
private var grpSongs:FlxTypedGroup<Alphabet>;
|
2020-11-25 03:53:48 +00:00
|
|
|
private var curPlaying:Bool = false;
|
2020-11-01 19:16:22 +00:00
|
|
|
|
2020-10-21 18:05:27 +00:00
|
|
|
override function create()
|
|
|
|
{
|
2021-02-25 01:52:59 +00:00
|
|
|
var initSonglist = CoolUtil.coolTextFile(Paths.txt('freeplaySonglist'));
|
|
|
|
|
|
|
|
for (i in 0...initSonglist.length)
|
|
|
|
{
|
|
|
|
songs.push(new SongMetadata(initSonglist[i], 1));
|
|
|
|
}
|
2021-01-15 04:33:12 +00:00
|
|
|
|
2020-11-25 03:53:48 +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-25 03:53:48 +00:00
|
|
|
}
|
|
|
|
*/
|
2020-11-01 19:16:22 +00:00
|
|
|
|
2021-02-26 12:27:32 +00:00
|
|
|
#if !html
|
|
|
|
// Updating Discord Rich Presence
|
|
|
|
DiscordClient.changePresence("In the menus.", null);
|
|
|
|
#end
|
|
|
|
|
2020-11-02 06:46:37 +00:00
|
|
|
var isDebug:Bool = false;
|
|
|
|
|
|
|
|
#if debug
|
|
|
|
isDebug = true;
|
|
|
|
#end
|
|
|
|
|
2020-12-04 17:36:28 +00:00
|
|
|
if (StoryMenuState.weekUnlocked[2] || isDebug)
|
2021-02-25 01:52:59 +00:00
|
|
|
addWeek(['Spookeez', 'South', 'Monster'], 2);
|
2020-11-01 19:16:22 +00:00
|
|
|
|
2020-12-11 11:45:00 +00:00
|
|
|
if (StoryMenuState.weekUnlocked[3] || isDebug)
|
2021-02-25 01:52:59 +00:00
|
|
|
addWeek(['Pico', 'Philly', 'Blammed'], 3);
|
2020-12-11 11:45:00 +00:00
|
|
|
|
2020-12-27 10:37:04 +00:00
|
|
|
if (StoryMenuState.weekUnlocked[4] || isDebug)
|
2021-02-25 01:52:59 +00:00
|
|
|
addWeek(['Satin-Panties', 'High', 'Milf'], 4);
|
2020-12-27 10:37:04 +00:00
|
|
|
|
2021-01-17 09:16:02 +00:00
|
|
|
if (StoryMenuState.weekUnlocked[5] || isDebug)
|
2021-02-25 01:52:59 +00:00
|
|
|
addWeek(['Cocoa', 'Eggnog', 'Winter-Horrorland'], 5);
|
2021-01-17 09:16:02 +00:00
|
|
|
|
2021-01-25 03:42:51 +00:00
|
|
|
if (StoryMenuState.weekUnlocked[6] || isDebug)
|
2021-02-25 01:52:59 +00:00
|
|
|
addWeek(['Senpai', 'Roses', 'Thorns'], 6);
|
2021-01-25 03:42:51 +00:00
|
|
|
|
2020-10-21 18:05:27 +00:00
|
|
|
// LOAD MUSIC
|
|
|
|
|
|
|
|
// LOAD CHARACTERS
|
|
|
|
|
2021-02-08 21:34:48 +00:00
|
|
|
var bg:FlxSprite = new FlxSprite().loadGraphic(Paths.image('menuBGBlue'));
|
2020-10-25 20:51:06 +00:00
|
|
|
add(bg);
|
|
|
|
|
2020-11-01 19:16:22 +00:00
|
|
|
grpSongs = new FlxTypedGroup<Alphabet>();
|
|
|
|
add(grpSongs);
|
|
|
|
|
2020-10-21 18:05:27 +00:00
|
|
|
for (i in 0...songs.length)
|
|
|
|
{
|
2021-02-25 01:52:59 +00:00
|
|
|
var songText:Alphabet = new Alphabet(0, (70 * i) + 30, songs[i].songName, true, false);
|
2020-11-01 19:16:22 +00:00
|
|
|
songText.isMenuItem = true;
|
|
|
|
songText.targetY = i;
|
|
|
|
grpSongs.add(songText);
|
|
|
|
// songText.x += 40;
|
2020-10-30 23:47:19 +00:00
|
|
|
// DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !!
|
|
|
|
// songText.screenCenter(X);
|
2020-10-21 18:05:27 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 02:17:27 +00:00
|
|
|
scoreText = new FlxText(FlxG.width * 0.7, 5, 0, "", 32);
|
|
|
|
// scoreText.autoSize = false;
|
2021-02-10 20:18:14 +00:00
|
|
|
scoreText.setFormat(Paths.font("vcr.ttf"), 32, FlxColor.WHITE, RIGHT);
|
2020-11-07 02:17:27 +00:00
|
|
|
// scoreText.alignment = RIGHT;
|
|
|
|
|
|
|
|
var scoreBG:FlxSprite = new FlxSprite(scoreText.x - 6, 0).makeGraphic(Std.int(FlxG.width * 0.35), 66, 0xFF000000);
|
|
|
|
scoreBG.alpha = 0.6;
|
|
|
|
add(scoreBG);
|
|
|
|
|
|
|
|
diffText = new FlxText(scoreText.x, scoreText.y + 36, 0, "", 24);
|
|
|
|
diffText.font = scoreText.font;
|
|
|
|
add(diffText);
|
|
|
|
|
|
|
|
add(scoreText);
|
|
|
|
|
2020-11-01 19:16:22 +00:00
|
|
|
changeSelection();
|
2020-11-07 02:17:27 +00:00
|
|
|
changeDiff();
|
2020-11-01 19:16:22 +00:00
|
|
|
|
2021-02-08 21:34:48 +00:00
|
|
|
// FlxG.sound.playMusic(Paths.music('title'), 0);
|
2020-11-01 19:16:22 +00:00
|
|
|
// FlxG.sound.music.fadeIn(2, 0, 0.8);
|
2020-10-21 18:05:27 +00:00
|
|
|
selector = new FlxText();
|
2020-10-30 23:47:19 +00:00
|
|
|
|
2020-10-25 20:51:06 +00:00
|
|
|
selector.size = 40;
|
2020-10-21 18:05:27 +00:00
|
|
|
selector.text = ">";
|
2020-11-01 19:16:22 +00:00
|
|
|
// add(selector);
|
2020-10-21 18:05:27 +00:00
|
|
|
|
2020-10-25 20:51:06 +00:00
|
|
|
var swag:Alphabet = new Alphabet(1, 0, "swag");
|
|
|
|
|
2020-11-07 02:17:27 +00:00
|
|
|
// JUST DOIN THIS SHIT FOR TESTING!!!
|
|
|
|
/*
|
|
|
|
var md:String = Markdown.markdownToHtml(Assets.getText('CHANGELOG.md'));
|
|
|
|
|
|
|
|
var texFel:TextField = new TextField();
|
|
|
|
texFel.width = FlxG.width;
|
|
|
|
texFel.height = FlxG.height;
|
|
|
|
// texFel.
|
|
|
|
texFel.htmlText = md;
|
|
|
|
|
|
|
|
FlxG.stage.addChild(texFel);
|
|
|
|
|
|
|
|
// scoreText.textField.htmlText = md;
|
|
|
|
|
|
|
|
trace(md);
|
|
|
|
*/
|
|
|
|
|
2020-10-21 18:05:27 +00:00
|
|
|
super.create();
|
|
|
|
}
|
|
|
|
|
2021-02-25 01:52:59 +00:00
|
|
|
public function addSong(songName:String, weekNum:Int)
|
|
|
|
{
|
|
|
|
songs.push(new SongMetadata(songName, weekNum));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addWeek(songs:Array<String>, weekNum:Int)
|
|
|
|
{
|
|
|
|
for (song in songs)
|
|
|
|
{
|
|
|
|
addSong(song, weekNum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-21 18:05:27 +00:00
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
2020-10-30 23:47:19 +00:00
|
|
|
super.update(elapsed);
|
2020-11-07 02:17:27 +00:00
|
|
|
|
2020-11-25 03:53:48 +00:00
|
|
|
if (FlxG.sound.music.volume < 0.7)
|
|
|
|
{
|
|
|
|
FlxG.sound.music.volume += 0.5 * FlxG.elapsed;
|
|
|
|
}
|
|
|
|
|
2020-11-07 02:17:27 +00:00
|
|
|
lerpScore = Math.floor(FlxMath.lerp(lerpScore, intendedScore, 0.4));
|
2020-11-10 18:08:18 +00:00
|
|
|
|
|
|
|
if (Math.abs(lerpScore - intendedScore) <= 10)
|
|
|
|
lerpScore = intendedScore;
|
|
|
|
|
2020-11-07 02:17:27 +00:00
|
|
|
scoreText.text = "PERSONAL BEST:" + lerpScore;
|
|
|
|
|
2020-10-30 23:47:19 +00:00
|
|
|
var upP = controls.UP_P;
|
|
|
|
var downP = controls.DOWN_P;
|
|
|
|
var accepted = controls.ACCEPT;
|
|
|
|
|
|
|
|
if (upP)
|
2020-10-21 18:05:27 +00:00
|
|
|
{
|
2020-11-01 19:16:22 +00:00
|
|
|
changeSelection(-1);
|
2020-10-21 18:05:27 +00:00
|
|
|
}
|
2020-10-30 23:47:19 +00:00
|
|
|
if (downP)
|
2020-10-21 18:05:27 +00:00
|
|
|
{
|
2020-11-01 19:16:22 +00:00
|
|
|
changeSelection(1);
|
2020-10-21 18:05:27 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 02:17:27 +00:00
|
|
|
if (controls.LEFT_P)
|
|
|
|
changeDiff(-1);
|
|
|
|
if (controls.RIGHT_P)
|
|
|
|
changeDiff(1);
|
|
|
|
|
2020-11-01 19:16:22 +00:00
|
|
|
if (controls.BACK)
|
|
|
|
{
|
|
|
|
FlxG.switchState(new MainMenuState());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (accepted)
|
|
|
|
{
|
2021-02-25 01:52:59 +00:00
|
|
|
var poop:String = Highscore.formatSong(songs[curSelected].songName.toLowerCase(), curDifficulty);
|
2020-11-25 03:53:48 +00:00
|
|
|
|
2020-11-07 02:17:27 +00:00
|
|
|
trace(poop);
|
|
|
|
|
2021-02-25 01:52:59 +00:00
|
|
|
PlayState.SONG = Song.loadFromJson(poop, songs[curSelected].songName.toLowerCase());
|
2020-11-01 19:16:22 +00:00
|
|
|
PlayState.isStoryMode = false;
|
2020-11-07 02:17:27 +00:00
|
|
|
PlayState.storyDifficulty = curDifficulty;
|
2021-02-25 01:22:37 +00:00
|
|
|
|
2021-02-25 01:52:59 +00:00
|
|
|
PlayState.storyWeek = songs[curSelected].week;
|
|
|
|
trace('CUR WEEK' + PlayState.storyWeek);
|
2021-02-09 18:07:05 +00:00
|
|
|
LoadingState.loadAndSwitchState(new PlayState());
|
2020-11-07 02:17:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeDiff(change:Int = 0)
|
|
|
|
{
|
|
|
|
curDifficulty += change;
|
|
|
|
|
|
|
|
if (curDifficulty < 0)
|
|
|
|
curDifficulty = 2;
|
|
|
|
if (curDifficulty > 2)
|
|
|
|
curDifficulty = 0;
|
|
|
|
|
2020-11-10 20:07:34 +00:00
|
|
|
#if !switch
|
2021-02-25 01:52:59 +00:00
|
|
|
intendedScore = Highscore.getScore(songs[curSelected].songName, curDifficulty);
|
2020-11-10 20:07:34 +00:00
|
|
|
#end
|
2020-11-07 02:17:27 +00:00
|
|
|
|
|
|
|
switch (curDifficulty)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
diffText.text = "EASY";
|
|
|
|
case 1:
|
|
|
|
diffText.text = 'NORMAL';
|
|
|
|
case 2:
|
|
|
|
diffText.text = "HARD";
|
2020-11-01 19:16:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeSelection(change:Int = 0)
|
|
|
|
{
|
2021-02-27 02:28:01 +00:00
|
|
|
#if !switch
|
|
|
|
NGio.logEvent('Fresh');
|
|
|
|
#end
|
2020-11-07 02:17:27 +00:00
|
|
|
|
2020-11-25 03:53:48 +00:00
|
|
|
// NGio.logEvent('Fresh');
|
2021-02-08 21:34:48 +00:00
|
|
|
FlxG.sound.play(Paths.sound('scrollMenu'), 0.4);
|
2020-11-25 03:53:48 +00:00
|
|
|
|
2020-11-01 19:16:22 +00:00
|
|
|
curSelected += change;
|
2020-10-26 23:06:42 +00:00
|
|
|
|
2020-10-21 18:05:27 +00:00
|
|
|
if (curSelected < 0)
|
|
|
|
curSelected = songs.length - 1;
|
|
|
|
if (curSelected >= songs.length)
|
|
|
|
curSelected = 0;
|
|
|
|
|
2020-11-01 19:16:22 +00:00
|
|
|
// selector.y = (70 * curSelected) + 30;
|
2020-10-21 18:05:27 +00:00
|
|
|
|
2020-11-10 20:07:34 +00:00
|
|
|
#if !switch
|
2021-02-25 01:52:59 +00:00
|
|
|
intendedScore = Highscore.getScore(songs[curSelected].songName, curDifficulty);
|
2020-11-07 02:17:27 +00:00
|
|
|
// lerpScore = 0;
|
2020-11-10 20:07:34 +00:00
|
|
|
#end
|
2020-11-07 02:17:27 +00:00
|
|
|
|
2021-02-10 20:18:14 +00:00
|
|
|
#if PRELOAD_ALL
|
2021-02-25 01:52:59 +00:00
|
|
|
FlxG.sound.playMusic(Paths.inst(songs[curSelected].songName), 0);
|
2021-02-10 20:18:14 +00:00
|
|
|
#end
|
2020-11-25 03:53:48 +00:00
|
|
|
|
2020-11-01 19:16:22 +00:00
|
|
|
var bullShit:Int = 0;
|
|
|
|
|
|
|
|
for (item in grpSongs.members)
|
2020-10-21 23:33:43 +00:00
|
|
|
{
|
2020-11-01 19:16:22 +00:00
|
|
|
item.targetY = bullShit - curSelected;
|
|
|
|
bullShit++;
|
2020-10-21 23:33:43 +00:00
|
|
|
|
2020-11-01 19:16:22 +00:00
|
|
|
item.alpha = 0.6;
|
|
|
|
// item.setGraphicSize(Std.int(item.width * 0.8));
|
|
|
|
|
|
|
|
if (item.targetY == 0)
|
2020-10-26 23:06:42 +00:00
|
|
|
{
|
2020-11-01 19:16:22 +00:00
|
|
|
item.alpha = 1;
|
|
|
|
// item.setGraphicSize(Std.int(item.width));
|
2020-10-26 23:06:42 +00:00
|
|
|
}
|
2020-11-01 19:16:22 +00:00
|
|
|
}
|
2020-10-21 18:05:27 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-25 01:52:59 +00:00
|
|
|
|
|
|
|
class SongMetadata
|
|
|
|
{
|
|
|
|
public var songName:String = "";
|
|
|
|
public var week:Int = 0;
|
|
|
|
|
|
|
|
public function new(song:String, week:Int)
|
|
|
|
{
|
|
|
|
this.songName = song;
|
|
|
|
this.week = week;
|
|
|
|
}
|
|
|
|
}
|