2020-10-21 18:05:27 +00:00
|
|
|
package;
|
2021-04-08 00:19:49 +00:00
|
|
|
|
2020-11-07 02:17:27 +00:00
|
|
|
import flash.text.TextField;
|
2021-08-22 00:45:03 +00:00
|
|
|
import flixel.FlxCamera;
|
|
|
|
import flixel.FlxGame;
|
2020-10-21 18:05:27 +00:00
|
|
|
import flixel.FlxSprite;
|
2021-06-08 01:14:50 +00:00
|
|
|
import flixel.FlxState;
|
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;
|
2021-08-21 23:53:08 +00:00
|
|
|
import flixel.input.touch.FlxTouch;
|
2021-08-24 19:28:04 +00:00
|
|
|
import flixel.math.FlxAngle;
|
2020-11-07 02:17:27 +00:00
|
|
|
import flixel.math.FlxMath;
|
2021-08-24 19:28:04 +00:00
|
|
|
import flixel.math.FlxPoint;
|
2020-10-21 18:05:27 +00:00
|
|
|
import flixel.text.FlxText;
|
2021-03-02 05:46:28 +00:00
|
|
|
import flixel.tweens.FlxTween;
|
2020-11-07 02:17:27 +00:00
|
|
|
import flixel.util.FlxColor;
|
2021-10-21 21:40:53 +00:00
|
|
|
import flixel.util.FlxTimer;
|
2021-10-21 19:05:32 +00:00
|
|
|
import freeplayStuff.DJBoyfriend;
|
2021-10-21 21:40:53 +00:00
|
|
|
import freeplayStuff.SongMenuItem;
|
2021-08-10 06:40:47 +00:00
|
|
|
import lime.app.Future;
|
2020-11-07 02:17:27 +00:00
|
|
|
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
|
|
|
|
2021-04-22 02:17:00 +00:00
|
|
|
// var selector:FlxText;
|
2020-10-21 18:05:27 +00:00
|
|
|
var curSelected:Int = 0;
|
2020-11-07 02:17:27 +00:00
|
|
|
var curDifficulty:Int = 1;
|
|
|
|
|
|
|
|
var scoreText:FlxText;
|
|
|
|
var diffText:FlxText;
|
2021-04-14 02:02:21 +00:00
|
|
|
var lerpScore:Float = 0;
|
2020-11-07 02:17:27 +00:00
|
|
|
var intendedScore:Int = 0;
|
2020-10-21 18:05:27 +00:00
|
|
|
|
2021-04-10 15:21:04 +00:00
|
|
|
var coolColors:Array<Int> = [
|
|
|
|
0xff9271fd,
|
|
|
|
0xff9271fd,
|
|
|
|
0xff223344,
|
|
|
|
0xFF941653,
|
|
|
|
0xFFfc96d7,
|
|
|
|
0xFFa0d1ff,
|
|
|
|
0xffff78bf,
|
|
|
|
0xfff6b604
|
|
|
|
];
|
2021-03-02 05:46:28 +00:00
|
|
|
|
2020-11-01 19:16:22 +00:00
|
|
|
private var grpSongs:FlxTypedGroup<Alphabet>;
|
2021-10-21 21:40:53 +00:00
|
|
|
private var grpCapsules:FlxTypedGroup<SongMenuItem>;
|
2020-11-25 03:53:48 +00:00
|
|
|
private var curPlaying:Bool = false;
|
2020-11-01 19:16:22 +00:00
|
|
|
|
2021-03-02 04:58:19 +00:00
|
|
|
private var iconArray:Array<HealthIcon> = [];
|
2021-04-08 21:29:31 +00:00
|
|
|
var scoreBG:FlxSprite;
|
2021-03-02 04:58:19 +00:00
|
|
|
|
2020-10-21 18:05:27 +00:00
|
|
|
override function create()
|
|
|
|
{
|
2021-05-06 10:54:57 +00:00
|
|
|
#if discord_rpc
|
|
|
|
// Updating Discord Rich Presence
|
|
|
|
DiscordClient.changePresence("In the Menus", null);
|
|
|
|
#end
|
|
|
|
|
|
|
|
var isDebug:Bool = false;
|
|
|
|
|
|
|
|
#if debug
|
|
|
|
isDebug = true;
|
|
|
|
addSong('Test', 1, 'bf-pixel');
|
|
|
|
#end
|
|
|
|
|
2021-02-25 01:52:59 +00:00
|
|
|
var initSonglist = CoolUtil.coolTextFile(Paths.txt('freeplaySonglist'));
|
|
|
|
|
|
|
|
for (i in 0...initSonglist.length)
|
|
|
|
{
|
2021-03-01 23:59:51 +00:00
|
|
|
songs.push(new SongMetadata(initSonglist[i], 1, 'gf'));
|
2021-02-25 01:52:59 +00:00
|
|
|
}
|
2021-01-15 04:33:12 +00:00
|
|
|
|
2021-03-05 00:36:56 +00:00
|
|
|
if (FlxG.sound.music != null)
|
|
|
|
{
|
|
|
|
if (!FlxG.sound.music.playing)
|
|
|
|
FlxG.sound.playMusic(Paths.music('freakyMenu'));
|
|
|
|
}
|
2020-11-01 19:16:22 +00:00
|
|
|
|
2021-03-01 23:59:51 +00:00
|
|
|
if (StoryMenuState.weekUnlocked[2] || isDebug)
|
|
|
|
addWeek(['Bopeebo', 'Fresh', 'Dadbattle'], 1, ['dad']);
|
|
|
|
|
2020-12-04 17:36:28 +00:00
|
|
|
if (StoryMenuState.weekUnlocked[2] || isDebug)
|
2021-03-13 18:43:11 +00:00
|
|
|
addWeek(['Spookeez', 'South', 'Monster'], 2, ['spooky', 'spooky', 'monster']);
|
2020-11-01 19:16:22 +00:00
|
|
|
|
2020-12-11 11:45:00 +00:00
|
|
|
if (StoryMenuState.weekUnlocked[3] || isDebug)
|
2021-03-01 21:46:08 +00:00
|
|
|
addWeek(['Pico', 'Philly', 'Blammed'], 3, ['pico']);
|
2020-12-11 11:45:00 +00:00
|
|
|
|
2020-12-27 10:37:04 +00:00
|
|
|
if (StoryMenuState.weekUnlocked[4] || isDebug)
|
2021-03-01 21:46:08 +00:00
|
|
|
addWeek(['Satin-Panties', 'High', 'Milf'], 4, ['mom']);
|
2020-12-27 10:37:04 +00:00
|
|
|
|
2021-01-17 09:16:02 +00:00
|
|
|
if (StoryMenuState.weekUnlocked[5] || isDebug)
|
2021-03-01 21:46:08 +00:00
|
|
|
addWeek(['Cocoa', 'Eggnog', 'Winter-Horrorland'], 5, ['parents-christmas', 'parents-christmas', 'monster-christmas']);
|
2021-01-17 09:16:02 +00:00
|
|
|
|
2021-01-25 03:42:51 +00:00
|
|
|
if (StoryMenuState.weekUnlocked[6] || isDebug)
|
2021-03-01 21:46:08 +00:00
|
|
|
addWeek(['Senpai', 'Roses', 'Thorns'], 6, ['senpai', 'senpai', 'spirit']);
|
2021-01-25 03:42:51 +00:00
|
|
|
|
2021-03-04 08:00:48 +00:00
|
|
|
if (StoryMenuState.weekUnlocked[7] || isDebug)
|
|
|
|
addWeek(['Ugh', 'Guns', 'Stress'], 7, ['tankman']);
|
|
|
|
|
2021-09-22 20:04:34 +00:00
|
|
|
addWeek(["Darnell", "lit-up", "2hot"], 8, ['darnell']);
|
2021-09-23 01:09:28 +00:00
|
|
|
addWeek(["bro"], 1, ['gf']);
|
2021-09-06 18:50:04 +00:00
|
|
|
|
2020-10-21 18:05:27 +00:00
|
|
|
// LOAD MUSIC
|
|
|
|
|
|
|
|
// LOAD CHARACTERS
|
|
|
|
|
2021-08-22 00:45:03 +00:00
|
|
|
trace(FlxG.width);
|
|
|
|
trace(FlxG.camera.zoom);
|
|
|
|
trace(FlxG.camera.initialZoom);
|
|
|
|
trace(FlxCamera.defaultZoom);
|
|
|
|
trace(FlxG.initialZoom);
|
2020-10-25 20:51:06 +00:00
|
|
|
|
2020-11-01 19:16:22 +00:00
|
|
|
grpSongs = new FlxTypedGroup<Alphabet>();
|
|
|
|
add(grpSongs);
|
|
|
|
|
2021-10-21 21:40:53 +00:00
|
|
|
grpCapsules = new FlxTypedGroup<SongMenuItem>();
|
|
|
|
add(grpCapsules);
|
|
|
|
|
2020-10-21 18:05:27 +00:00
|
|
|
for (i in 0...songs.length)
|
|
|
|
{
|
2021-10-21 21:40:53 +00:00
|
|
|
var funnyMenu:SongMenuItem = new SongMenuItem(FlxG.width, (i * 150) + 160, songs[i].songName);
|
|
|
|
funnyMenu.targetPos.x = funnyMenu.x;
|
|
|
|
funnyMenu.ID = i;
|
|
|
|
|
|
|
|
new FlxTimer().start((0.06 * i) + 0.8, function(lerpTmr)
|
|
|
|
{
|
|
|
|
funnyMenu.doLerp = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
grpCapsules.add(funnyMenu);
|
|
|
|
|
2021-02-25 01:52:59 +00:00
|
|
|
var songText:Alphabet = new Alphabet(0, (70 * i) + 30, songs[i].songName, true, false);
|
2021-10-21 21:40:53 +00:00
|
|
|
songText.x += 100;
|
2020-11-01 19:16:22 +00:00
|
|
|
songText.isMenuItem = true;
|
|
|
|
songText.targetY = i;
|
2021-10-21 21:40:53 +00:00
|
|
|
|
|
|
|
// grpSongs.add(songText);
|
2021-03-01 23:59:51 +00:00
|
|
|
|
|
|
|
var icon:HealthIcon = new HealthIcon(songs[i].songCharacter);
|
|
|
|
icon.sprTracker = songText;
|
2021-03-02 04:58:19 +00:00
|
|
|
|
|
|
|
// using a FlxGroup is too much fuss!
|
|
|
|
iconArray.push(icon);
|
2021-10-21 21:40:53 +00:00
|
|
|
// add(icon);
|
2021-03-01 23:59:51 +00:00
|
|
|
|
2020-11-01 19:16:22 +00:00
|
|
|
// 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;
|
|
|
|
|
2021-04-22 02:17:00 +00:00
|
|
|
scoreBG = new FlxSprite(scoreText.x - 6, 0).makeGraphic(1, 66, 0x99000000);
|
2021-04-08 21:29:31 +00:00
|
|
|
scoreBG.antialiasing = false;
|
2020-11-07 02:17:27 +00:00
|
|
|
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-10-21 19:05:32 +00:00
|
|
|
var dj:DJBoyfriend = new DJBoyfriend(0, -100);
|
|
|
|
add(dj);
|
|
|
|
|
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);
|
2021-04-22 02:17:00 +00:00
|
|
|
// selector = new FlxText();
|
2020-10-30 23:47:19 +00:00
|
|
|
|
2021-04-22 02:17:00 +00:00
|
|
|
// selector.size = 40;
|
|
|
|
// 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-03-01 21:46:08 +00:00
|
|
|
public function addSong(songName:String, weekNum:Int, songCharacter:String)
|
2021-02-25 01:52:59 +00:00
|
|
|
{
|
2021-03-01 21:46:08 +00:00
|
|
|
songs.push(new SongMetadata(songName, weekNum, songCharacter));
|
2021-02-25 01:52:59 +00:00
|
|
|
}
|
|
|
|
|
2021-03-01 21:46:08 +00:00
|
|
|
public function addWeek(songs:Array<String>, weekNum:Int, ?songCharacters:Array<String>)
|
2021-02-25 01:52:59 +00:00
|
|
|
{
|
2021-03-01 21:46:08 +00:00
|
|
|
if (songCharacters == null)
|
|
|
|
songCharacters = ['bf'];
|
|
|
|
|
|
|
|
var num:Int = 0;
|
2021-02-25 01:52:59 +00:00
|
|
|
for (song in songs)
|
|
|
|
{
|
2021-03-01 21:46:08 +00:00
|
|
|
addSong(song, weekNum, songCharacters[num]);
|
|
|
|
|
|
|
|
if (songCharacters.length != 1)
|
|
|
|
num++;
|
2021-02-25 01:52:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-21 23:53:08 +00:00
|
|
|
var touchY:Float = 0;
|
2021-08-22 20:54:22 +00:00
|
|
|
var touchX:Float = 0;
|
|
|
|
var dxTouch:Float = 0;
|
2021-08-21 23:53:08 +00:00
|
|
|
var dyTouch:Float = 0;
|
|
|
|
var velTouch:Float = 0;
|
|
|
|
|
|
|
|
var veloctiyLoopShit:Float = 0;
|
2021-08-22 00:45:03 +00:00
|
|
|
var touchTimer:Float = 0;
|
2021-08-21 23:53:08 +00:00
|
|
|
|
2021-08-24 19:28:04 +00:00
|
|
|
var initTouchPos:FlxPoint = new FlxPoint();
|
|
|
|
|
2020-10-21 18:05:27 +00:00
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
2021-08-22 00:45:03 +00:00
|
|
|
super.update(elapsed);
|
|
|
|
|
|
|
|
if (FlxG.sound.music != null)
|
|
|
|
{
|
|
|
|
if (FlxG.sound.music.volume < 0.7)
|
|
|
|
{
|
|
|
|
FlxG.sound.music.volume += 0.5 * FlxG.elapsed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lerpScore = CoolUtil.coolLerp(lerpScore, intendedScore, 0.4);
|
|
|
|
|
|
|
|
scoreText.text = "PERSONAL BEST:" + Math.round(lerpScore);
|
|
|
|
|
|
|
|
positionHighscore();
|
|
|
|
|
|
|
|
var upP = controls.UI_UP_P;
|
|
|
|
var downP = controls.UI_DOWN_P;
|
|
|
|
var accepted = controls.ACCEPT;
|
|
|
|
|
2021-08-21 23:53:08 +00:00
|
|
|
if (FlxG.onMobile)
|
|
|
|
{
|
2021-08-24 19:28:04 +00:00
|
|
|
for (touch in FlxG.touches.list)
|
|
|
|
{
|
|
|
|
if (touch.justPressed)
|
|
|
|
{
|
|
|
|
initTouchPos.set(touch.screenX, touch.screenY);
|
|
|
|
}
|
|
|
|
if (touch.pressed)
|
|
|
|
{
|
|
|
|
var dx = initTouchPos.x - touch.screenX;
|
|
|
|
var dy = initTouchPos.y - touch.screenY;
|
|
|
|
|
|
|
|
var angle = Math.atan2(dy, dx);
|
|
|
|
var length = Math.sqrt(dx * dx + dy * dy);
|
|
|
|
|
|
|
|
FlxG.watch.addQuick("LENGTH", length);
|
|
|
|
FlxG.watch.addQuick("ANGLE", Math.round(FlxAngle.asDegrees(angle)));
|
|
|
|
trace("ANGLE", Math.round(FlxAngle.asDegrees(angle)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* switch (inputID)
|
|
|
|
{
|
|
|
|
case FlxObject.UP:
|
|
|
|
return
|
|
|
|
case FlxObject.DOWN:
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2021-08-21 23:53:08 +00:00
|
|
|
if (FlxG.touches.getFirst() != null)
|
|
|
|
{
|
2021-08-22 00:45:03 +00:00
|
|
|
if (touchTimer >= 1.5)
|
|
|
|
accepted = true;
|
|
|
|
|
|
|
|
touchTimer += FlxG.elapsed;
|
2021-08-21 23:53:08 +00:00
|
|
|
var touch:FlxTouch = FlxG.touches.getFirst();
|
|
|
|
|
|
|
|
velTouch = Math.abs((touch.screenY - dyTouch)) / 50;
|
|
|
|
|
|
|
|
dyTouch = touch.screenY - touchY;
|
2021-08-22 20:54:22 +00:00
|
|
|
dxTouch = touch.screenX - touchX;
|
2021-08-21 23:53:08 +00:00
|
|
|
|
|
|
|
if (touch.justPressed)
|
|
|
|
{
|
|
|
|
touchY = touch.screenY;
|
|
|
|
dyTouch = 0;
|
|
|
|
velTouch = 0;
|
2021-08-22 20:54:22 +00:00
|
|
|
|
|
|
|
touchX = touch.screenX;
|
|
|
|
dxTouch = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Math.abs(dxTouch) >= 100)
|
|
|
|
{
|
|
|
|
touchX = touch.screenX;
|
|
|
|
if (dxTouch != 0)
|
|
|
|
dxTouch < 0 ? changeDiff(1) : changeDiff(-1);
|
2021-08-21 23:53:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Math.abs(dyTouch) >= 100)
|
|
|
|
{
|
|
|
|
touchY = touch.screenY;
|
|
|
|
|
|
|
|
if (dyTouch != 0)
|
|
|
|
dyTouch < 0 ? changeSelection(1) : changeSelection(-1);
|
|
|
|
// changeSelection(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-08-22 00:45:03 +00:00
|
|
|
touchTimer = 0;
|
|
|
|
|
2021-08-22 20:54:22 +00:00
|
|
|
/* if (velTouch >= 0)
|
|
|
|
{
|
|
|
|
trace(velTouch);
|
|
|
|
velTouch -= FlxG.elapsed;
|
2021-08-21 23:53:08 +00:00
|
|
|
|
2021-08-22 20:54:22 +00:00
|
|
|
veloctiyLoopShit += velTouch;
|
2021-08-21 23:53:08 +00:00
|
|
|
|
2021-08-22 20:54:22 +00:00
|
|
|
trace("VEL LOOP: " + veloctiyLoopShit);
|
2021-08-21 23:53:08 +00:00
|
|
|
|
2021-08-22 20:54:22 +00:00
|
|
|
if (veloctiyLoopShit >= 30)
|
|
|
|
{
|
|
|
|
veloctiyLoopShit = 0;
|
|
|
|
changeSelection(1);
|
|
|
|
}
|
2021-08-21 23:53:08 +00:00
|
|
|
|
2021-08-22 20:54:22 +00:00
|
|
|
// trace(velTouch);
|
|
|
|
}*/
|
2021-08-21 23:53:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-17 05:20:00 +00:00
|
|
|
#if mobile
|
|
|
|
for (touch in FlxG.touches.list)
|
|
|
|
{
|
|
|
|
if (touch.justPressed)
|
|
|
|
{
|
2021-08-21 23:53:08 +00:00
|
|
|
// accepted = true;
|
2021-08-17 05:20:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#end
|
|
|
|
|
2020-10-30 23:47:19 +00:00
|
|
|
if (upP)
|
2020-11-01 19:16:22 +00:00
|
|
|
changeSelection(-1);
|
2020-10-30 23:47:19 +00:00
|
|
|
if (downP)
|
2020-11-01 19:16:22 +00:00
|
|
|
changeSelection(1);
|
2020-10-21 18:05:27 +00:00
|
|
|
|
2021-04-08 00:19:49 +00:00
|
|
|
if (FlxG.mouse.wheel != 0)
|
|
|
|
changeSelection(-Math.round(FlxG.mouse.wheel / 4));
|
|
|
|
|
2021-03-14 02:11:56 +00:00
|
|
|
if (controls.UI_LEFT_P)
|
2020-11-07 02:17:27 +00:00
|
|
|
changeDiff(-1);
|
2021-03-14 02:11:56 +00:00
|
|
|
if (controls.UI_RIGHT_P)
|
2020-11-07 02:17:27 +00:00
|
|
|
changeDiff(1);
|
|
|
|
|
2020-11-01 19:16:22 +00:00
|
|
|
if (controls.BACK)
|
|
|
|
{
|
2021-04-15 14:19:02 +00:00
|
|
|
FlxG.sound.play(Paths.sound('cancelMenu'));
|
2020-11-01 19:16:22 +00:00
|
|
|
FlxG.switchState(new MainMenuState());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (accepted)
|
|
|
|
{
|
2021-09-10 14:07:55 +00:00
|
|
|
// if (Assets.exists())
|
|
|
|
|
2021-02-25 01:52:59 +00:00
|
|
|
var poop:String = Highscore.formatSong(songs[curSelected].songName.toLowerCase(), curDifficulty);
|
2021-09-10 14:07:55 +00:00
|
|
|
|
2021-09-21 19:39:30 +00:00
|
|
|
// does not work properly, always just accidentally sets it to normal anyways!
|
|
|
|
/* if (!Assets.exists(Paths.json(songs[curSelected].songName + '/' + poop)))
|
|
|
|
{
|
|
|
|
// defaults to normal if HARD / EASY doesn't exist
|
|
|
|
// does not account if NORMAL doesn't exist!
|
|
|
|
FlxG.log.warn("CURRENT DIFFICULTY IS NOT CHARTED, DEFAULTING TO NORMAL!");
|
|
|
|
poop = Highscore.formatSong(songs[curSelected].songName.toLowerCase(), 1);
|
|
|
|
curDifficulty = 1;
|
|
|
|
}*/
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-08 01:14:50 +00:00
|
|
|
override function switchTo(nextState:FlxState):Bool
|
|
|
|
{
|
|
|
|
clearDaCache(songs[curSelected].songName);
|
|
|
|
return super.switchTo(nextState);
|
|
|
|
}
|
|
|
|
|
2020-11-07 02:17:27 +00:00
|
|
|
function changeDiff(change:Int = 0)
|
|
|
|
{
|
2021-08-24 19:28:04 +00:00
|
|
|
touchTimer = 0;
|
|
|
|
|
2020-11-07 02:17:27 +00:00
|
|
|
curDifficulty += change;
|
|
|
|
|
|
|
|
if (curDifficulty < 0)
|
|
|
|
curDifficulty = 2;
|
|
|
|
if (curDifficulty > 2)
|
|
|
|
curDifficulty = 0;
|
|
|
|
|
2021-02-25 01:52:59 +00:00
|
|
|
intendedScore = Highscore.getScore(songs[curSelected].songName, curDifficulty);
|
2020-11-07 02:17:27 +00:00
|
|
|
|
2021-03-02 05:46:28 +00:00
|
|
|
PlayState.storyDifficulty = curDifficulty;
|
|
|
|
|
|
|
|
diffText.text = "< " + CoolUtil.difficultyString() + " >";
|
2021-04-08 21:29:31 +00:00
|
|
|
positionHighscore();
|
2020-11-01 19:16:22 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 01:14:50 +00:00
|
|
|
// Clears the cache of songs, frees up memory, they'll have to be loaded in later tho
|
|
|
|
function clearDaCache(actualSongTho:String)
|
|
|
|
{
|
|
|
|
for (song in songs)
|
|
|
|
{
|
|
|
|
if (song.songName != actualSongTho)
|
|
|
|
{
|
|
|
|
trace('trying to remove: ' + song.songName);
|
2021-08-10 06:40:47 +00:00
|
|
|
// openfl.Assets.cache.clear(Paths.inst(song.songName));
|
2021-06-08 01:14:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-01 19:16:22 +00:00
|
|
|
function changeSelection(change:Int = 0)
|
|
|
|
{
|
2020-11-07 02:17:27 +00:00
|
|
|
NGio.logEvent('Fresh');
|
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
|
2021-02-10 20:18:14 +00:00
|
|
|
#if PRELOAD_ALL
|
2021-08-21 23:53:08 +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;
|
|
|
|
|
2021-03-02 04:58:19 +00:00
|
|
|
for (i in 0...iconArray.length)
|
|
|
|
{
|
|
|
|
iconArray[i].alpha = 0.6;
|
|
|
|
}
|
|
|
|
|
|
|
|
iconArray[curSelected].alpha = 1;
|
|
|
|
|
2021-10-21 21:40:53 +00:00
|
|
|
for (index => capsule in grpCapsules.members)
|
2020-10-21 23:33:43 +00:00
|
|
|
{
|
2021-10-21 21:40:53 +00:00
|
|
|
capsule.selected = false;
|
2020-11-01 19:16:22 +00:00
|
|
|
|
2021-10-21 21:40:53 +00:00
|
|
|
capsule.targetPos.y = ((index - curSelected) * 150) + 160;
|
|
|
|
capsule.targetPos.x = 270 + (60 * (Math.sin(index - curSelected)));
|
2020-11-01 19:16:22 +00:00
|
|
|
}
|
2021-10-21 21:40:53 +00:00
|
|
|
|
|
|
|
grpCapsules.members[curSelected].selected = true;
|
2020-10-21 18:05:27 +00:00
|
|
|
}
|
2021-04-08 21:29:31 +00:00
|
|
|
|
|
|
|
function positionHighscore()
|
|
|
|
{
|
|
|
|
scoreText.x = FlxG.width - scoreText.width - 6;
|
|
|
|
scoreBG.scale.x = FlxG.width - scoreText.x + 6;
|
|
|
|
scoreBG.x = FlxG.width - scoreBG.scale.x / 2;
|
|
|
|
|
|
|
|
diffText.x = Std.int(scoreBG.x + scoreBG.width / 2);
|
|
|
|
diffText.x -= (diffText.width / 2);
|
|
|
|
}
|
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;
|
2021-03-01 21:46:08 +00:00
|
|
|
public var songCharacter:String = "";
|
2021-02-25 01:52:59 +00:00
|
|
|
|
2021-03-01 21:46:08 +00:00
|
|
|
public function new(song:String, week:Int, songCharacter:String)
|
2021-02-25 01:52:59 +00:00
|
|
|
{
|
|
|
|
this.songName = song;
|
|
|
|
this.week = week;
|
2021-03-01 21:46:08 +00:00
|
|
|
this.songCharacter = songCharacter;
|
2021-02-25 01:52:59 +00:00
|
|
|
}
|
|
|
|
}
|