2023-11-07 09:04:22 +00:00
|
|
|
package funkin.ui.freeplay;
|
2021-04-08 00:19:49 +00:00
|
|
|
|
2023-10-11 03:32:01 +00:00
|
|
|
import flixel.addons.transition.FlxTransitionableState;
|
|
|
|
import flixel.addons.ui.FlxInputText;
|
2021-08-22 00:45:03 +00:00
|
|
|
import flixel.FlxCamera;
|
2020-10-21 18:05:27 +00:00
|
|
|
import flixel.FlxSprite;
|
2021-10-22 03:08:48 +00:00
|
|
|
import flixel.group.FlxGroup;
|
2023-10-11 03:32:01 +00:00
|
|
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
2024-03-12 03:42:32 +00:00
|
|
|
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
|
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;
|
|
|
|
import flixel.math.FlxPoint;
|
2023-10-11 03:32:01 +00:00
|
|
|
import flixel.system.debug.watch.Tracker.TrackerProfile;
|
2020-10-21 18:05:27 +00:00
|
|
|
import flixel.text.FlxText;
|
2021-10-22 03:08:48 +00:00
|
|
|
import flixel.tweens.FlxEase;
|
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-22 03:08:48 +00:00
|
|
|
import flixel.util.FlxSpriteUtil;
|
2021-10-21 21:40:53 +00:00
|
|
|
import flixel.util.FlxTimer;
|
2024-03-12 03:42:32 +00:00
|
|
|
import funkin.audio.FunkinSound;
|
2024-03-23 19:34:37 +00:00
|
|
|
import funkin.data.story.level.LevelRegistry;
|
2023-10-11 03:32:01 +00:00
|
|
|
import funkin.data.song.SongRegistry;
|
2024-03-12 03:42:32 +00:00
|
|
|
import funkin.graphics.FunkinCamera;
|
|
|
|
import funkin.graphics.FunkinSprite;
|
2023-11-07 09:04:22 +00:00
|
|
|
import funkin.graphics.shaders.AngleMask;
|
|
|
|
import funkin.graphics.shaders.HSVShader;
|
|
|
|
import funkin.graphics.shaders.PureColor;
|
|
|
|
import funkin.graphics.shaders.StrokeShader;
|
2024-01-11 05:30:00 +00:00
|
|
|
import funkin.input.Controls;
|
2023-10-11 03:32:01 +00:00
|
|
|
import funkin.play.PlayStatePlaylist;
|
|
|
|
import funkin.play.song.Song;
|
|
|
|
import funkin.save.Save;
|
|
|
|
import funkin.save.Save.SaveScoreData;
|
2024-01-11 05:30:00 +00:00
|
|
|
import funkin.ui.AtlasText;
|
|
|
|
import funkin.ui.mainmenu.MainMenuState;
|
2023-11-07 09:04:22 +00:00
|
|
|
import funkin.ui.MusicBeatSubState;
|
|
|
|
import funkin.ui.transition.LoadingState;
|
|
|
|
import funkin.ui.transition.StickerSubState;
|
|
|
|
import funkin.util.MathUtil;
|
2022-03-24 03:27:48 +00:00
|
|
|
import lime.utils.Assets;
|
2020-10-21 18:05:27 +00:00
|
|
|
|
2024-02-05 18:35:30 +00:00
|
|
|
/**
|
|
|
|
* Parameters used to initialize the FreeplayState.
|
|
|
|
*/
|
|
|
|
typedef FreeplayStateParams =
|
|
|
|
{
|
2024-02-06 02:35:58 +00:00
|
|
|
?character:String,
|
2024-02-05 18:35:30 +00:00
|
|
|
};
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
/**
|
|
|
|
* The state for the freeplay menu, allowing the player to select any song to play.
|
|
|
|
*/
|
2023-06-01 22:52:58 +00:00
|
|
|
class FreeplayState extends MusicBeatSubState
|
2020-10-21 18:05:27 +00:00
|
|
|
{
|
2024-02-10 04:13:40 +00:00
|
|
|
//
|
|
|
|
// Params
|
|
|
|
//
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The current character for this FreeplayState.
|
|
|
|
* You can't change this without transitioning to a new FreeplayState.
|
|
|
|
*/
|
2024-02-06 02:35:58 +00:00
|
|
|
final currentCharacter:String;
|
|
|
|
|
2024-02-09 19:58:57 +00:00
|
|
|
/**
|
|
|
|
* For the audio preview, the duration of the fade-in effect.
|
|
|
|
*/
|
|
|
|
public static final FADE_IN_DURATION:Float = 0.5;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For the audio preview, the duration of the fade-out effect.
|
|
|
|
*/
|
|
|
|
public static final FADE_OUT_DURATION:Float = 0.25;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For the audio preview, the volume at which the fade-in starts.
|
|
|
|
*/
|
|
|
|
public static final FADE_IN_START_VOLUME:Float = 0.25;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For the audio preview, the volume at which the fade-in ends.
|
|
|
|
*/
|
|
|
|
public static final FADE_IN_END_VOLUME:Float = 1.0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For the audio preview, the volume at which the fade-out starts.
|
|
|
|
*/
|
|
|
|
public static final FADE_OUT_END_VOLUME:Float = 0.0;
|
|
|
|
|
2023-10-12 07:20:21 +00:00
|
|
|
var songs:Array<Null<FreeplaySongData>> = [];
|
|
|
|
|
|
|
|
var diffIdsCurrent:Array<String> = [];
|
|
|
|
var diffIdsTotal:Array<String> = [];
|
2020-10-21 18:05:27 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
var curSelected:Int = 0;
|
2023-10-12 07:20:21 +00:00
|
|
|
var currentDifficulty:String = Constants.DEFAULT_DIFFICULTY;
|
2020-11-07 02:17:27 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
var fp:FreeplayScore;
|
2024-01-11 05:30:00 +00:00
|
|
|
var txtCompletion:AtlasText;
|
2023-01-23 00:55:30 +00:00
|
|
|
var lerpCompletion:Float = 0;
|
|
|
|
var intendedCompletion:Float = 0;
|
|
|
|
var lerpScore:Float = 0;
|
|
|
|
var intendedScore:Int = 0;
|
2020-10-21 18:05:27 +00:00
|
|
|
|
2023-10-12 07:20:21 +00:00
|
|
|
var grpDifficulties:FlxTypedSpriteGroup<DifficultySprite>;
|
2021-12-07 22:41:18 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
var coolColors:Array<Int> = [
|
2024-03-20 18:37:24 +00:00
|
|
|
0xFF9271FD,
|
|
|
|
0xFF9271FD,
|
|
|
|
0xFF223344,
|
2023-01-23 00:55:30 +00:00
|
|
|
0xFF941653,
|
2024-03-20 18:37:24 +00:00
|
|
|
0xFFFC96D7,
|
|
|
|
0xFFA0D1FF,
|
|
|
|
0xFFFF78BF,
|
|
|
|
0xFFF6B604
|
2023-01-23 00:55:30 +00:00
|
|
|
];
|
2021-03-02 05:46:28 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
var grpSongs:FlxTypedGroup<Alphabet>;
|
|
|
|
var grpCapsules:FlxTypedGroup<SongMenuItem>;
|
2023-09-29 00:29:19 +00:00
|
|
|
var curCapsule:SongMenuItem;
|
2023-01-23 03:25:45 +00:00
|
|
|
var curPlaying:Bool = false;
|
2020-11-01 19:16:22 +00:00
|
|
|
|
2024-02-06 02:35:58 +00:00
|
|
|
var displayedVariations:Array<String>;
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
var dj:DJBoyfriend;
|
2022-11-15 07:23:44 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var ostName:FlxText;
|
|
|
|
var albumRoll:AlbumRoll;
|
|
|
|
|
2023-11-07 23:53:50 +00:00
|
|
|
var letterSort:LetterSort;
|
2024-03-20 18:37:24 +00:00
|
|
|
var exitMovers:ExitMoverData = new Map();
|
2022-09-26 22:22:45 +00:00
|
|
|
|
2023-04-06 05:39:27 +00:00
|
|
|
var stickerSubState:StickerSubState;
|
|
|
|
|
2024-04-02 01:59:53 +00:00
|
|
|
public static var rememberedDifficulty:Null<String> = Constants.DEFAULT_DIFFICULTY;
|
2024-04-03 05:40:08 +00:00
|
|
|
public static var rememberedSongId:Null<String> = 'tutorial';
|
2023-10-12 07:20:21 +00:00
|
|
|
|
2024-02-06 02:35:58 +00:00
|
|
|
public function new(?params:FreeplayStateParams, ?stickers:StickerSubState)
|
2023-04-06 05:39:27 +00:00
|
|
|
{
|
2024-02-05 18:35:30 +00:00
|
|
|
currentCharacter = params?.character ?? Constants.DEFAULT_CHARACTER;
|
|
|
|
|
2023-04-06 05:39:27 +00:00
|
|
|
if (stickers != null)
|
|
|
|
{
|
|
|
|
stickerSubState = stickers;
|
|
|
|
}
|
|
|
|
|
2024-03-29 02:33:50 +00:00
|
|
|
super(FlxColor.TRANSPARENT);
|
2023-04-06 05:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
override function create():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
2023-04-06 05:39:27 +00:00
|
|
|
super.create();
|
|
|
|
|
2024-05-03 03:02:47 +00:00
|
|
|
FlxG.state.persistentUpdate = false;
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
FlxTransitionableState.skipNextTransIn = true;
|
2021-10-22 03:08:48 +00:00
|
|
|
|
2023-04-06 05:39:27 +00:00
|
|
|
if (stickerSubState != null)
|
|
|
|
{
|
|
|
|
this.persistentUpdate = true;
|
|
|
|
this.persistentDraw = true;
|
|
|
|
|
|
|
|
openSubState(stickerSubState);
|
|
|
|
stickerSubState.degenStickers();
|
|
|
|
}
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
#if discord_rpc
|
|
|
|
// Updating Discord Rich Presence
|
2024-03-16 04:55:57 +00:00
|
|
|
DiscordClient.changePresence('In the Menus', null);
|
2023-01-23 00:55:30 +00:00
|
|
|
#end
|
2021-05-06 10:54:57 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
var isDebug:Bool = false;
|
2021-05-06 10:54:57 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
#if debug
|
|
|
|
isDebug = true;
|
|
|
|
#end
|
2021-05-06 10:54:57 +00:00
|
|
|
|
2024-03-16 04:55:57 +00:00
|
|
|
FunkinSound.playMusic('freakyMenu',
|
|
|
|
{
|
|
|
|
overrideExisting: true,
|
|
|
|
restartTrack: false
|
|
|
|
});
|
2020-11-01 19:16:22 +00:00
|
|
|
|
2023-10-11 03:32:01 +00:00
|
|
|
// Add a null entry that represents the RANDOM option
|
|
|
|
songs.push(null);
|
2021-03-01 23:59:51 +00:00
|
|
|
|
2024-02-06 02:35:58 +00:00
|
|
|
// TODO: This makes custom variations disappear from Freeplay. Figure out a better solution later.
|
|
|
|
// Default character (BF) shows default and Erect variations. Pico shows only Pico variations.
|
2024-03-16 04:55:57 +00:00
|
|
|
displayedVariations = (currentCharacter == 'bf') ? [Constants.DEFAULT_VARIATION, 'erect'] : [currentCharacter];
|
2024-02-06 02:35:58 +00:00
|
|
|
|
2023-09-29 00:29:19 +00:00
|
|
|
// programmatically adds the songs via LevelRegistry and SongRegistry
|
2024-05-02 01:51:33 +00:00
|
|
|
for (levelId in LevelRegistry.instance.listSortedLevelIds())
|
2023-09-29 00:29:19 +00:00
|
|
|
{
|
2023-10-12 07:20:21 +00:00
|
|
|
for (songId in LevelRegistry.instance.parseEntryData(levelId).songs)
|
2023-09-29 00:29:19 +00:00
|
|
|
{
|
2023-10-12 07:20:21 +00:00
|
|
|
var song:Song = SongRegistry.instance.fetchEntry(songId);
|
|
|
|
|
2024-02-06 02:35:58 +00:00
|
|
|
// Only display songs which actually have available charts for the current character.
|
2024-04-04 01:57:29 +00:00
|
|
|
var availableDifficultiesForSong:Array<String> = song.listDifficulties(displayedVariations, false);
|
2024-02-06 02:35:58 +00:00
|
|
|
if (availableDifficultiesForSong.length == 0) continue;
|
2023-10-12 07:20:21 +00:00
|
|
|
|
2024-02-06 02:35:58 +00:00
|
|
|
songs.push(new FreeplaySongData(levelId, songId, song, displayedVariations));
|
|
|
|
for (difficulty in availableDifficultiesForSong)
|
2023-10-12 07:20:21 +00:00
|
|
|
{
|
|
|
|
diffIdsTotal.pushUnique(difficulty);
|
|
|
|
}
|
2023-09-29 00:29:19 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-06 18:50:04 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
// LOAD MUSIC
|
2020-10-21 18:05:27 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
// LOAD CHARACTERS
|
2020-10-21 18:05:27 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
trace(FlxG.width);
|
|
|
|
trace(FlxG.camera.zoom);
|
|
|
|
trace(FlxG.camera.initialZoom);
|
|
|
|
trace(FlxCamera.defaultZoom);
|
2020-10-25 20:51:06 +00:00
|
|
|
|
2024-03-13 01:34:50 +00:00
|
|
|
var pinkBack:FunkinSprite = FunkinSprite.create('freeplay/pinkBack');
|
2024-03-20 18:37:24 +00:00
|
|
|
pinkBack.color = 0xFFFFD4E9; // sets it to pink!
|
2023-01-23 00:55:30 +00:00
|
|
|
pinkBack.x -= pinkBack.width;
|
2021-10-22 03:08:48 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
FlxTween.tween(pinkBack, {x: 0}, 0.6, {ease: FlxEase.quartOut});
|
|
|
|
add(pinkBack);
|
2021-10-22 03:08:48 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var orangeBackShit:FunkinSprite = new FunkinSprite(84, 440).makeSolidColor(Std.int(pinkBack.width), 75, 0xFFFEDA00);
|
2023-01-23 00:55:30 +00:00
|
|
|
add(orangeBackShit);
|
2021-10-22 03:08:48 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var alsoOrangeLOL:FunkinSprite = new FunkinSprite(0, orangeBackShit.y).makeSolidColor(100, Std.int(orangeBackShit.height), 0xFFFFD400);
|
2023-01-23 00:55:30 +00:00
|
|
|
add(alsoOrangeLOL);
|
2021-10-22 03:08:48 +00:00
|
|
|
|
2023-03-16 04:17:52 +00:00
|
|
|
exitMovers.set([pinkBack, orangeBackShit, alsoOrangeLOL],
|
|
|
|
{
|
|
|
|
x: -pinkBack.width,
|
|
|
|
y: pinkBack.y,
|
|
|
|
speed: 0.4,
|
|
|
|
wait: 0
|
|
|
|
});
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
FlxSpriteUtil.alphaMaskFlxSprite(orangeBackShit, pinkBack, orangeBackShit);
|
|
|
|
orangeBackShit.visible = false;
|
|
|
|
alsoOrangeLOL.visible = false;
|
2021-10-22 03:08:48 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
var grpTxtScrolls:FlxGroup = new FlxGroup();
|
|
|
|
add(grpTxtScrolls);
|
|
|
|
grpTxtScrolls.visible = false;
|
2021-10-22 03:08:48 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
FlxG.debugger.addTrackerProfile(new TrackerProfile(BGScrollingText, ['x', 'y', 'speed', 'size']));
|
2023-08-28 18:52:03 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var moreWays:BGScrollingText = new BGScrollingText(0, 160, 'HOT BLOODED IN MORE WAYS THAN ONE', FlxG.width, true, 43);
|
|
|
|
moreWays.funnyColor = 0xFFFFF383;
|
2023-08-28 18:52:03 +00:00
|
|
|
moreWays.speed = 6.8;
|
2023-01-23 00:55:30 +00:00
|
|
|
grpTxtScrolls.add(moreWays);
|
2021-10-22 03:08:48 +00:00
|
|
|
|
2023-03-16 04:17:52 +00:00
|
|
|
exitMovers.set([moreWays],
|
2023-03-16 01:05:15 +00:00
|
|
|
{
|
2023-03-16 05:03:45 +00:00
|
|
|
x: FlxG.width * 2,
|
|
|
|
speed: 0.4,
|
2023-03-16 01:05:15 +00:00
|
|
|
});
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var funnyScroll:BGScrollingText = new BGScrollingText(0, 220, 'BOYFRIEND', FlxG.width / 2, false, 60);
|
|
|
|
funnyScroll.funnyColor = 0xFFFF9963;
|
2023-08-28 18:52:03 +00:00
|
|
|
funnyScroll.speed = -3.8;
|
2023-01-23 00:55:30 +00:00
|
|
|
grpTxtScrolls.add(funnyScroll);
|
2021-10-22 03:08:48 +00:00
|
|
|
|
2023-03-16 04:17:52 +00:00
|
|
|
exitMovers.set([funnyScroll],
|
2023-03-16 01:05:15 +00:00
|
|
|
{
|
2023-03-16 05:03:45 +00:00
|
|
|
x: -funnyScroll.width * 2,
|
2023-03-16 01:05:15 +00:00
|
|
|
y: funnyScroll.y,
|
2023-03-16 05:03:45 +00:00
|
|
|
speed: 0.4,
|
2023-03-16 01:05:15 +00:00
|
|
|
wait: 0
|
|
|
|
});
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var txtNuts:BGScrollingText = new BGScrollingText(0, 285, 'PROTECT YO NUTS', FlxG.width / 2, true, 43);
|
2023-08-28 18:52:03 +00:00
|
|
|
txtNuts.speed = 3.5;
|
2023-01-23 00:55:30 +00:00
|
|
|
grpTxtScrolls.add(txtNuts);
|
2023-03-16 04:17:52 +00:00
|
|
|
exitMovers.set([txtNuts],
|
2023-03-16 01:05:15 +00:00
|
|
|
{
|
2023-03-16 05:03:45 +00:00
|
|
|
x: FlxG.width * 2,
|
|
|
|
speed: 0.4,
|
2023-03-16 01:05:15 +00:00
|
|
|
});
|
2021-10-22 03:08:48 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var funnyScroll2:BGScrollingText = new BGScrollingText(0, 335, 'BOYFRIEND', FlxG.width / 2, false, 60);
|
|
|
|
funnyScroll2.funnyColor = 0xFFFF9963;
|
2023-08-28 18:52:03 +00:00
|
|
|
funnyScroll2.speed = -3.8;
|
2023-01-23 00:55:30 +00:00
|
|
|
grpTxtScrolls.add(funnyScroll2);
|
2021-10-22 03:08:48 +00:00
|
|
|
|
2023-03-16 04:17:52 +00:00
|
|
|
exitMovers.set([funnyScroll2],
|
2023-03-16 01:05:15 +00:00
|
|
|
{
|
2023-03-16 05:03:45 +00:00
|
|
|
x: -funnyScroll2.width * 2,
|
|
|
|
speed: 0.5,
|
2023-03-16 01:05:15 +00:00
|
|
|
});
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var moreWays2:BGScrollingText = new BGScrollingText(0, 397, 'HOT BLOODED IN MORE WAYS THAN ONE', FlxG.width, true, 43);
|
|
|
|
moreWays2.funnyColor = 0xFFFFF383;
|
2023-08-28 18:52:03 +00:00
|
|
|
moreWays2.speed = 6.8;
|
2023-01-23 00:55:30 +00:00
|
|
|
grpTxtScrolls.add(moreWays2);
|
|
|
|
|
2023-03-16 04:17:52 +00:00
|
|
|
exitMovers.set([moreWays2],
|
2023-03-16 01:05:15 +00:00
|
|
|
{
|
2023-03-16 05:03:45 +00:00
|
|
|
x: FlxG.width * 2,
|
|
|
|
speed: 0.4
|
2023-03-16 01:05:15 +00:00
|
|
|
});
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var funnyScroll3:BGScrollingText = new BGScrollingText(0, orangeBackShit.y + 10, 'BOYFRIEND', FlxG.width / 2, 60);
|
|
|
|
funnyScroll3.funnyColor = 0xFFFEA400;
|
2023-08-28 18:52:03 +00:00
|
|
|
funnyScroll3.speed = -3.8;
|
2023-01-23 00:55:30 +00:00
|
|
|
grpTxtScrolls.add(funnyScroll3);
|
|
|
|
|
2023-03-16 04:17:52 +00:00
|
|
|
exitMovers.set([funnyScroll3],
|
2023-03-16 01:05:15 +00:00
|
|
|
{
|
2023-03-16 05:03:45 +00:00
|
|
|
x: -funnyScroll3.width * 2,
|
|
|
|
speed: 0.3
|
2023-03-16 01:05:15 +00:00
|
|
|
});
|
|
|
|
|
2023-08-29 02:01:25 +00:00
|
|
|
dj = new DJBoyfriend(640, 366);
|
2023-03-16 04:17:52 +00:00
|
|
|
exitMovers.set([dj],
|
2023-03-16 01:05:15 +00:00
|
|
|
{
|
|
|
|
x: -dj.width * 1.6,
|
2023-03-16 05:03:45 +00:00
|
|
|
speed: 0.5
|
2023-03-16 01:05:15 +00:00
|
|
|
});
|
2024-03-20 18:37:24 +00:00
|
|
|
|
2024-02-06 02:35:58 +00:00
|
|
|
// TODO: Replace this.
|
2024-03-20 18:37:24 +00:00
|
|
|
if (currentCharacter == 'pico') dj.visible = false;
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
add(dj);
|
|
|
|
|
|
|
|
var bgDad:FlxSprite = new FlxSprite(pinkBack.width * 0.75, 0).loadGraphic(Paths.image('freeplay/freeplayBGdad'));
|
|
|
|
bgDad.setGraphicSize(0, FlxG.height);
|
|
|
|
bgDad.updateHitbox();
|
|
|
|
bgDad.shader = new AngleMask();
|
|
|
|
bgDad.visible = false;
|
|
|
|
|
|
|
|
var blackOverlayBullshitLOLXD:FlxSprite = new FlxSprite(FlxG.width).makeGraphic(Std.int(bgDad.width), Std.int(bgDad.height), FlxColor.BLACK);
|
|
|
|
add(blackOverlayBullshitLOLXD); // used to mask the text lol!
|
|
|
|
|
2023-03-16 04:17:52 +00:00
|
|
|
exitMovers.set([blackOverlayBullshitLOLXD, bgDad],
|
2023-03-16 01:05:15 +00:00
|
|
|
{
|
|
|
|
x: FlxG.width * 1.5,
|
2023-03-16 04:17:52 +00:00
|
|
|
speed: 0.4,
|
2023-03-16 01:05:15 +00:00
|
|
|
wait: 0
|
|
|
|
});
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
add(bgDad);
|
2024-04-30 05:38:00 +00:00
|
|
|
FlxTween.tween(blackOverlayBullshitLOLXD, {x: pinkBack.width * 0.75}, 0.7, {ease: FlxEase.quintOut});
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
blackOverlayBullshitLOLXD.shader = bgDad.shader;
|
|
|
|
|
|
|
|
grpSongs = new FlxTypedGroup<Alphabet>();
|
|
|
|
add(grpSongs);
|
|
|
|
|
|
|
|
grpCapsules = new FlxTypedGroup<SongMenuItem>();
|
|
|
|
add(grpCapsules);
|
|
|
|
|
2023-10-12 07:20:21 +00:00
|
|
|
grpDifficulties = new FlxTypedSpriteGroup<DifficultySprite>(-300, 80);
|
2023-01-23 00:55:30 +00:00
|
|
|
add(grpDifficulties);
|
|
|
|
|
2023-03-16 04:17:52 +00:00
|
|
|
exitMovers.set([grpDifficulties],
|
|
|
|
{
|
|
|
|
x: -300,
|
|
|
|
speed: 0.25,
|
|
|
|
wait: 0
|
|
|
|
});
|
|
|
|
|
2023-10-12 07:20:21 +00:00
|
|
|
for (diffId in diffIdsTotal)
|
|
|
|
{
|
|
|
|
var diffSprite:DifficultySprite = new DifficultySprite(diffId);
|
|
|
|
diffSprite.difficultyId = diffId;
|
|
|
|
grpDifficulties.add(diffSprite);
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-03-16 01:05:15 +00:00
|
|
|
grpDifficulties.group.forEach(function(spr) {
|
2023-01-23 00:55:30 +00:00
|
|
|
spr.visible = false;
|
|
|
|
});
|
|
|
|
|
2023-10-12 07:20:21 +00:00
|
|
|
for (diffSprite in grpDifficulties.group.members)
|
|
|
|
{
|
|
|
|
if (diffSprite == null) continue;
|
|
|
|
if (diffSprite.difficultyId == currentDifficulty) diffSprite.visible = true;
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
albumRoll = new AlbumRoll();
|
2024-03-28 05:46:50 +00:00
|
|
|
albumRoll.albumId = null;
|
2024-03-20 18:37:24 +00:00
|
|
|
add(albumRoll);
|
2023-08-09 23:34:19 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
albumRoll.applyExitMovers(exitMovers);
|
2023-08-09 23:34:19 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
var overhangStuff:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, 64, FlxColor.BLACK);
|
|
|
|
overhangStuff.y -= overhangStuff.height;
|
|
|
|
add(overhangStuff);
|
|
|
|
FlxTween.tween(overhangStuff, {y: 0}, 0.3, {ease: FlxEase.quartOut});
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var fnfFreeplay:FlxText = new FlxText(8, 8, 0, 'FREEPLAY', 48);
|
|
|
|
fnfFreeplay.font = 'VCR OSD Mono';
|
2023-01-23 00:55:30 +00:00
|
|
|
fnfFreeplay.visible = false;
|
2023-03-16 01:05:15 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
ostName = new FlxText(8, 8, FlxG.width - 8 - 8, 'OFFICIAL OST', 48);
|
|
|
|
ostName.font = 'VCR OSD Mono';
|
2024-01-11 05:30:00 +00:00
|
|
|
ostName.alignment = RIGHT;
|
|
|
|
ostName.visible = false;
|
|
|
|
|
2024-01-11 05:52:42 +00:00
|
|
|
exitMovers.set([overhangStuff, fnfFreeplay, ostName],
|
2023-03-16 01:05:15 +00:00
|
|
|
{
|
2023-03-16 04:17:52 +00:00
|
|
|
y: -overhangStuff.height,
|
2023-03-16 01:05:15 +00:00
|
|
|
x: 0,
|
|
|
|
speed: 0.2,
|
|
|
|
wait: 0
|
|
|
|
});
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var sillyStroke:StrokeShader = new StrokeShader(0xFFFFFFFF, 2, 2);
|
2023-01-23 00:55:30 +00:00
|
|
|
fnfFreeplay.shader = sillyStroke;
|
2024-04-30 07:22:30 +00:00
|
|
|
ostName.shader = sillyStroke;
|
2023-01-23 00:55:30 +00:00
|
|
|
add(fnfFreeplay);
|
2024-01-11 05:52:42 +00:00
|
|
|
add(ostName);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-01-11 05:30:00 +00:00
|
|
|
var fnfHighscoreSpr:FlxSprite = new FlxSprite(860, 70);
|
2023-01-23 00:55:30 +00:00
|
|
|
fnfHighscoreSpr.frames = Paths.getSparrowAtlas('freeplay/highscore');
|
2024-03-20 18:37:24 +00:00
|
|
|
fnfHighscoreSpr.animation.addByPrefix('highscore', 'highscore small instance 1', 24, false);
|
2023-01-23 00:55:30 +00:00
|
|
|
fnfHighscoreSpr.visible = false;
|
|
|
|
fnfHighscoreSpr.setGraphicSize(0, Std.int(fnfHighscoreSpr.height * 1));
|
|
|
|
fnfHighscoreSpr.updateHitbox();
|
|
|
|
add(fnfHighscoreSpr);
|
|
|
|
|
2023-03-16 01:05:15 +00:00
|
|
|
new FlxTimer().start(FlxG.random.float(12, 50), function(tmr) {
|
2024-03-20 18:37:24 +00:00
|
|
|
fnfHighscoreSpr.animation.play('highscore');
|
2023-01-23 00:55:30 +00:00
|
|
|
tmr.time = FlxG.random.float(20, 60);
|
|
|
|
}, 0);
|
|
|
|
|
2024-04-03 08:52:12 +00:00
|
|
|
fp = new FreeplayScore(460, 60, 7, 100);
|
2023-01-23 00:55:30 +00:00
|
|
|
fp.visible = false;
|
|
|
|
add(fp);
|
|
|
|
|
2024-01-11 05:30:00 +00:00
|
|
|
var clearBoxSprite:FlxSprite = new FlxSprite(1165, 65).loadGraphic(Paths.image('freeplay/clearBox'));
|
2024-04-30 05:33:29 +00:00
|
|
|
clearBoxSprite.visible = false;
|
2024-01-11 05:30:00 +00:00
|
|
|
add(clearBoxSprite);
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
txtCompletion = new AtlasText(1185, 87, '69', AtlasFont.FREEPLAY_CLEAR);
|
2023-01-23 00:55:30 +00:00
|
|
|
txtCompletion.visible = false;
|
|
|
|
add(txtCompletion);
|
|
|
|
|
2023-11-07 23:53:50 +00:00
|
|
|
letterSort = new LetterSort(400, 75);
|
2023-08-09 20:15:34 +00:00
|
|
|
add(letterSort);
|
|
|
|
letterSort.visible = false;
|
|
|
|
|
|
|
|
exitMovers.set([letterSort],
|
|
|
|
{
|
|
|
|
y: -100,
|
|
|
|
speed: 0.3
|
|
|
|
});
|
|
|
|
|
|
|
|
letterSort.changeSelectionCallback = (str) -> {
|
|
|
|
switch (str)
|
|
|
|
{
|
2024-03-20 18:37:24 +00:00
|
|
|
case 'fav':
|
2023-08-09 20:15:34 +00:00
|
|
|
generateSongList({filterType: FAVORITE}, true);
|
2024-03-20 18:37:24 +00:00
|
|
|
case 'ALL':
|
2023-08-09 23:34:19 +00:00
|
|
|
generateSongList(null, true);
|
2023-08-09 20:15:34 +00:00
|
|
|
default:
|
|
|
|
generateSongList({filterType: REGEXP, filterData: str}, true);
|
|
|
|
}
|
2024-04-29 07:49:28 +00:00
|
|
|
|
|
|
|
// We want to land on the first song of the group, rather than random song when changing letter sorts
|
|
|
|
// that is, only if there's more than one song in the group!
|
|
|
|
if (grpCapsules.members.length > 0)
|
|
|
|
{
|
|
|
|
curSelected = 1;
|
|
|
|
changeSelection();
|
|
|
|
}
|
2023-08-09 20:15:34 +00:00
|
|
|
};
|
|
|
|
|
2024-04-30 05:33:29 +00:00
|
|
|
exitMovers.set([fp, txtCompletion, fnfHighscoreSpr, txtCompletion, clearBoxSprite],
|
2023-03-16 04:17:52 +00:00
|
|
|
{
|
|
|
|
x: FlxG.width,
|
|
|
|
speed: 0.3
|
|
|
|
});
|
|
|
|
|
2024-04-24 23:45:17 +00:00
|
|
|
var diffSelLeft:DifficultySelector = new DifficultySelector(20, grpDifficulties.y - 10, false, controls);
|
|
|
|
var diffSelRight:DifficultySelector = new DifficultySelector(325, grpDifficulties.y - 10, true, controls);
|
|
|
|
diffSelLeft.visible = false;
|
|
|
|
diffSelRight.visible = false;
|
|
|
|
add(diffSelLeft);
|
|
|
|
add(diffSelRight);
|
|
|
|
|
|
|
|
// be careful not to "add()" things in here unless it's to a group that's already added to the state
|
|
|
|
// otherwise it won't be properly attatched to funnyCamera (relavent code should be at the bottom of create())
|
2023-03-16 01:05:15 +00:00
|
|
|
dj.onIntroDone.add(function() {
|
2023-08-09 23:34:19 +00:00
|
|
|
// when boyfriend hits dat shiii
|
2023-09-20 03:27:07 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
albumRoll.playIntro();
|
2023-08-09 23:34:19 +00:00
|
|
|
|
2024-04-05 05:24:03 +00:00
|
|
|
new FlxTimer().start(0.75, function(_) {
|
2024-04-05 23:47:33 +00:00
|
|
|
// albumRoll.showTitle();
|
2024-04-05 05:24:03 +00:00
|
|
|
});
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
FlxTween.tween(grpDifficulties, {x: 90}, 0.6, {ease: FlxEase.quartOut});
|
|
|
|
|
2024-04-24 23:45:17 +00:00
|
|
|
diffSelLeft.visible = true;
|
|
|
|
diffSelRight.visible = true;
|
2023-08-09 20:15:34 +00:00
|
|
|
letterSort.visible = true;
|
|
|
|
|
2023-03-16 04:17:52 +00:00
|
|
|
exitMovers.set([diffSelLeft, diffSelRight],
|
|
|
|
{
|
|
|
|
x: -diffSelLeft.width * 2,
|
|
|
|
speed: 0.26
|
|
|
|
});
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-03-16 01:05:15 +00:00
|
|
|
new FlxTimer().start(1 / 24, function(handShit) {
|
2023-01-23 00:55:30 +00:00
|
|
|
fnfHighscoreSpr.visible = true;
|
|
|
|
fnfFreeplay.visible = true;
|
2024-01-11 05:52:42 +00:00
|
|
|
ostName.visible = true;
|
2023-01-23 00:55:30 +00:00
|
|
|
fp.visible = true;
|
|
|
|
fp.updateScore(0);
|
|
|
|
|
2024-04-30 05:33:29 +00:00
|
|
|
clearBoxSprite.visible = true;
|
2023-01-23 00:55:30 +00:00
|
|
|
txtCompletion.visible = true;
|
|
|
|
intendedCompletion = 0;
|
|
|
|
|
2023-03-16 01:05:15 +00:00
|
|
|
new FlxTimer().start(1.5 / 24, function(bold) {
|
2023-01-23 00:55:30 +00:00
|
|
|
sillyStroke.width = 0;
|
|
|
|
sillyStroke.height = 0;
|
2023-09-20 03:27:07 +00:00
|
|
|
changeSelection();
|
2023-01-23 00:55:30 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
pinkBack.color = 0xFFFFD863;
|
2023-01-23 00:55:30 +00:00
|
|
|
bgDad.visible = true;
|
|
|
|
orangeBackShit.visible = true;
|
|
|
|
alsoOrangeLOL.visible = true;
|
|
|
|
grpTxtScrolls.visible = true;
|
|
|
|
});
|
|
|
|
|
2023-08-09 06:47:22 +00:00
|
|
|
generateSongList(null, false);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-04-24 23:45:17 +00:00
|
|
|
// dedicated camera for the state so we don't need to fuk around with camera scrolls from the mainmenu / elsewhere
|
2024-04-10 18:45:07 +00:00
|
|
|
var funnyCam:FunkinCamera = new FunkinCamera('freeplayFunny', 0, 0, FlxG.width, FlxG.height);
|
2023-01-23 00:55:30 +00:00
|
|
|
funnyCam.bgColor = FlxColor.TRANSPARENT;
|
2024-04-24 23:45:17 +00:00
|
|
|
FlxG.cameras.add(funnyCam, false);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-03-16 01:05:15 +00:00
|
|
|
forEach(function(bs) {
|
2023-01-23 00:55:30 +00:00
|
|
|
bs.cameras = [funnyCam];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-04-01 22:34:26 +00:00
|
|
|
var currentFilter:SongFilter = null;
|
|
|
|
var currentFilteredSongs:Array<FreeplaySongData> = [];
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
/**
|
|
|
|
* Given the current filter, rebuild the current song list.
|
|
|
|
*
|
|
|
|
* @param filterStuff A filter to apply to the song list (regex, startswith, all, favorite)
|
2024-04-17 02:12:07 +00:00
|
|
|
* @param force Whether the capsules should "jump" back in or not using their animation
|
2024-04-01 22:34:26 +00:00
|
|
|
* @param onlyIfChanged Only apply the filter if the song list has changed
|
2024-03-20 18:37:24 +00:00
|
|
|
*/
|
2024-04-01 22:34:26 +00:00
|
|
|
public function generateSongList(filterStuff:Null<SongFilter>, force:Bool = false, onlyIfChanged:Bool = true):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
2023-06-09 22:25:21 +00:00
|
|
|
var tempSongs:Array<FreeplaySongData> = songs;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-04-30 18:36:57 +00:00
|
|
|
// Remember just the difficulty because it's important for song sorting.
|
|
|
|
if (rememberedDifficulty != null)
|
|
|
|
{
|
|
|
|
currentDifficulty = rememberedDifficulty;
|
|
|
|
}
|
|
|
|
|
2024-04-17 02:12:07 +00:00
|
|
|
if (filterStuff != null) tempSongs = sortSongs(tempSongs, filterStuff);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-04-01 22:34:26 +00:00
|
|
|
// Filter further by current selected difficulty.
|
|
|
|
if (currentDifficulty != null)
|
|
|
|
{
|
|
|
|
tempSongs = tempSongs.filter(song -> {
|
|
|
|
if (song == null) return true; // Random
|
|
|
|
return song.songDifficulties.contains(currentDifficulty);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (onlyIfChanged)
|
|
|
|
{
|
|
|
|
// == performs equality by reference
|
|
|
|
if (tempSongs.isEqualUnordered(currentFilteredSongs)) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only now do we know that the filter is actually changing.
|
|
|
|
|
2024-04-30 18:36:57 +00:00
|
|
|
// If curSelected is 0, the result will be null and fall back to the rememberedSongId.
|
2024-04-03 05:40:08 +00:00
|
|
|
rememberedSongId = grpCapsules.members[curSelected]?.songData?.songId ?? rememberedSongId;
|
2024-04-01 22:34:26 +00:00
|
|
|
|
|
|
|
for (cap in grpCapsules.members)
|
|
|
|
{
|
|
|
|
cap.kill();
|
|
|
|
}
|
|
|
|
|
|
|
|
currentFilter = filterStuff;
|
|
|
|
|
|
|
|
currentFilteredSongs = tempSongs;
|
|
|
|
curSelected = 0;
|
|
|
|
|
2023-08-28 18:52:03 +00:00
|
|
|
var hsvShader:HSVShader = new HSVShader();
|
|
|
|
|
2023-08-09 06:47:22 +00:00
|
|
|
var randomCapsule:SongMenuItem = grpCapsules.recycle(SongMenuItem);
|
2023-10-17 00:12:40 +00:00
|
|
|
randomCapsule.init(FlxG.width, 0, null);
|
2023-08-06 20:24:34 +00:00
|
|
|
randomCapsule.onConfirm = function() {
|
2023-10-17 04:38:28 +00:00
|
|
|
capsuleOnConfirmRandom(randomCapsule);
|
2023-08-06 20:24:34 +00:00
|
|
|
};
|
|
|
|
randomCapsule.y = randomCapsule.intendedY(0) + 10;
|
|
|
|
randomCapsule.targetPos.x = randomCapsule.x;
|
|
|
|
randomCapsule.alpha = 0.5;
|
|
|
|
randomCapsule.songText.visible = false;
|
|
|
|
randomCapsule.favIcon.visible = false;
|
|
|
|
randomCapsule.initJumpIn(0, force);
|
2023-08-28 18:52:03 +00:00
|
|
|
randomCapsule.hsvShader = hsvShader;
|
2023-08-06 20:24:34 +00:00
|
|
|
grpCapsules.add(randomCapsule);
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
for (i in 0...tempSongs.length)
|
|
|
|
{
|
2023-10-11 03:32:01 +00:00
|
|
|
if (tempSongs[i] == null) continue;
|
|
|
|
|
2023-08-09 06:47:22 +00:00
|
|
|
var funnyMenu:SongMenuItem = grpCapsules.recycle(SongMenuItem);
|
2023-10-11 03:32:01 +00:00
|
|
|
|
2023-10-17 00:12:40 +00:00
|
|
|
funnyMenu.init(FlxG.width, 0, tempSongs[i]);
|
2023-09-29 00:29:19 +00:00
|
|
|
funnyMenu.onConfirm = function() {
|
|
|
|
capsuleOnConfirmDefault(funnyMenu);
|
|
|
|
};
|
2023-08-04 21:10:27 +00:00
|
|
|
funnyMenu.y = funnyMenu.intendedY(i + 1) + 10;
|
2023-01-23 00:55:30 +00:00
|
|
|
funnyMenu.targetPos.x = funnyMenu.x;
|
|
|
|
funnyMenu.ID = i;
|
2023-09-19 23:10:30 +00:00
|
|
|
funnyMenu.capsule.alpha = 0.5;
|
2023-01-23 00:55:30 +00:00
|
|
|
funnyMenu.songText.visible = false;
|
|
|
|
funnyMenu.favIcon.visible = tempSongs[i].isFav;
|
2023-08-28 18:52:03 +00:00
|
|
|
funnyMenu.hsvShader = hsvShader;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-04-16 17:24:41 +00:00
|
|
|
funnyMenu.forcePosition();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
grpCapsules.add(funnyMenu);
|
|
|
|
}
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
FlxG.console.registerFunction('changeSelection', changeSelection);
|
2023-09-20 03:27:07 +00:00
|
|
|
|
2023-10-12 07:20:21 +00:00
|
|
|
rememberSelection();
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
changeSelection();
|
2024-04-30 18:36:57 +00:00
|
|
|
changeDiff(0, true);
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
|
|
|
|
2024-04-17 02:12:07 +00:00
|
|
|
/**
|
|
|
|
* Filters an array of songs based on a filter
|
|
|
|
* @param songsToFilter What data to use when filtering
|
|
|
|
* @param songFilter The filter to apply
|
|
|
|
* @return Array<FreeplaySongData>
|
|
|
|
*/
|
|
|
|
public function sortSongs(songsToFilter:Array<FreeplaySongData>, songFilter:SongFilter):Array<FreeplaySongData>
|
|
|
|
{
|
|
|
|
switch (songFilter.filterType)
|
|
|
|
{
|
|
|
|
case REGEXP:
|
|
|
|
// filterStuff.filterData has a string with the first letter of the sorting range, and the second one
|
|
|
|
// this creates a filter to return all the songs that start with a letter between those two
|
|
|
|
|
|
|
|
// if filterData looks like "A-C", the regex should look something like this: ^[A-C].*
|
|
|
|
// to get every song that starts between A and C
|
|
|
|
var filterRegexp:EReg = new EReg('^[' + songFilter.filterData + '].*', 'i');
|
|
|
|
songsToFilter = songsToFilter.filter(str -> {
|
|
|
|
if (str == null) return true; // Random
|
|
|
|
return filterRegexp.match(str.songName);
|
|
|
|
});
|
|
|
|
|
|
|
|
case STARTSWITH:
|
|
|
|
// extra note: this is essentially a "search"
|
|
|
|
|
|
|
|
songsToFilter = songsToFilter.filter(str -> {
|
|
|
|
if (str == null) return true; // Random
|
|
|
|
return str.songName.toLowerCase().startsWith(songFilter.filterData);
|
|
|
|
});
|
|
|
|
case ALL:
|
|
|
|
// no filter!
|
|
|
|
case FAVORITE:
|
|
|
|
songsToFilter = songsToFilter.filter(str -> {
|
|
|
|
if (str == null) return true; // Random
|
|
|
|
return str.isFav;
|
|
|
|
});
|
|
|
|
default:
|
|
|
|
// return all on default
|
|
|
|
}
|
|
|
|
return songsToFilter;
|
|
|
|
}
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
var touchY:Float = 0;
|
|
|
|
var touchX:Float = 0;
|
|
|
|
var dxTouch:Float = 0;
|
|
|
|
var dyTouch:Float = 0;
|
|
|
|
var velTouch:Float = 0;
|
|
|
|
|
|
|
|
var veloctiyLoopShit:Float = 0;
|
|
|
|
var touchTimer:Float = 0;
|
|
|
|
|
|
|
|
var initTouchPos:FlxPoint = new FlxPoint();
|
|
|
|
|
|
|
|
var spamTimer:Float = 0;
|
|
|
|
var spamming:Bool = false;
|
|
|
|
|
2023-10-17 04:38:28 +00:00
|
|
|
var busy:Bool = false; // Set to true once the user has pressed enter to select a song.
|
|
|
|
|
2024-03-12 03:42:32 +00:00
|
|
|
override function update(elapsed:Float):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
|
|
|
super.update(elapsed);
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.F)
|
|
|
|
{
|
2024-04-01 22:34:26 +00:00
|
|
|
var targetSong = grpCapsules.members[curSelected]?.songData;
|
|
|
|
if (targetSong != null)
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
2024-03-20 18:37:24 +00:00
|
|
|
var realShit:Int = curSelected;
|
2024-04-01 22:34:26 +00:00
|
|
|
targetSong.isFav = !targetSong.isFav;
|
|
|
|
if (targetSong.isFav)
|
2023-10-11 03:32:01 +00:00
|
|
|
{
|
|
|
|
FlxTween.tween(grpCapsules.members[realShit], {angle: 360}, 0.4,
|
|
|
|
{
|
|
|
|
ease: FlxEase.elasticOut,
|
|
|
|
onComplete: _ -> {
|
|
|
|
grpCapsules.members[realShit].favIcon.visible = true;
|
2024-03-20 18:37:24 +00:00
|
|
|
grpCapsules.members[realShit].favIcon.animation.play('fav');
|
2023-10-11 03:32:01 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
grpCapsules.members[realShit].favIcon.animation.play('fav', false, true);
|
|
|
|
new FlxTimer().start((1 / 24) * 14, _ -> {
|
|
|
|
grpCapsules.members[realShit].favIcon.visible = false;
|
2023-01-23 03:25:45 +00:00
|
|
|
});
|
2023-10-11 03:32:01 +00:00
|
|
|
new FlxTimer().start((1 / 24) * 24, _ -> {
|
|
|
|
FlxTween.tween(grpCapsules.members[realShit], {angle: 0}, 0.4, {ease: FlxEase.elasticOut});
|
|
|
|
});
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-07 09:04:22 +00:00
|
|
|
lerpScore = MathUtil.coolLerp(lerpScore, intendedScore, 0.2);
|
|
|
|
lerpCompletion = MathUtil.coolLerp(lerpCompletion, intendedCompletion, 0.9);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-01-11 05:30:00 +00:00
|
|
|
if (Math.isNaN(lerpScore))
|
|
|
|
{
|
|
|
|
lerpScore = intendedScore;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Math.isNaN(lerpCompletion))
|
|
|
|
{
|
|
|
|
lerpCompletion = intendedCompletion;
|
|
|
|
}
|
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
fp.updateScore(Std.int(lerpScore));
|
|
|
|
|
2024-01-11 05:30:00 +00:00
|
|
|
txtCompletion.text = '${Math.floor(lerpCompletion * 100)}';
|
|
|
|
|
|
|
|
// Right align the completion percentage
|
|
|
|
switch (txtCompletion.text.length)
|
|
|
|
{
|
|
|
|
case 3:
|
2024-04-30 05:33:29 +00:00
|
|
|
txtCompletion.offset.x = 10;
|
2024-01-11 05:30:00 +00:00
|
|
|
case 2:
|
2024-04-30 05:33:29 +00:00
|
|
|
txtCompletion.offset.x = 0;
|
2024-01-11 05:30:00 +00:00
|
|
|
case 1:
|
2024-04-30 05:33:29 +00:00
|
|
|
txtCompletion.offset.x = -24;
|
2024-01-11 05:30:00 +00:00
|
|
|
default:
|
2024-04-30 05:33:29 +00:00
|
|
|
txtCompletion.offset.x = 0;
|
2024-01-11 05:30:00 +00:00
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-10-17 04:38:28 +00:00
|
|
|
handleInputs(elapsed);
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleInputs(elapsed:Float):Void
|
|
|
|
{
|
|
|
|
if (busy) return;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-03-24 08:53:05 +00:00
|
|
|
var upP:Bool = controls.UI_UP_P && !FlxG.keys.pressed.CONTROL;
|
|
|
|
var downP:Bool = controls.UI_DOWN_P && !FlxG.keys.pressed.CONTROL;
|
|
|
|
var accepted:Bool = controls.ACCEPT && !FlxG.keys.pressed.CONTROL;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
if (FlxG.onMobile)
|
|
|
|
{
|
|
|
|
for (touch in FlxG.touches.list)
|
|
|
|
{
|
|
|
|
if (touch.justPressed)
|
|
|
|
{
|
|
|
|
initTouchPos.set(touch.screenX, touch.screenY);
|
|
|
|
}
|
|
|
|
if (touch.pressed)
|
|
|
|
{
|
2024-03-20 18:37:24 +00:00
|
|
|
var dx:Float = initTouchPos.x - touch.screenX;
|
|
|
|
var dy:Float = initTouchPos.y - touch.screenY;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var angle:Float = Math.atan2(dy, dx);
|
|
|
|
var length:Float = Math.sqrt(dx * dx + dy * dy);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
FlxG.watch.addQuick('LENGTH', length);
|
|
|
|
FlxG.watch.addQuick('ANGLE', Math.round(FlxAngle.asDegrees(angle)));
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FlxG.touches.getFirst() != null)
|
|
|
|
{
|
2023-01-23 03:25:45 +00:00
|
|
|
if (touchTimer >= 1.5) accepted = true;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
touchTimer += elapsed;
|
|
|
|
var touch:FlxTouch = FlxG.touches.getFirst();
|
|
|
|
|
|
|
|
velTouch = Math.abs((touch.screenY - dyTouch)) / 50;
|
|
|
|
|
|
|
|
dyTouch = touch.screenY - touchY;
|
|
|
|
dxTouch = touch.screenX - touchX;
|
|
|
|
|
|
|
|
if (touch.justPressed)
|
|
|
|
{
|
|
|
|
touchY = touch.screenY;
|
|
|
|
dyTouch = 0;
|
|
|
|
velTouch = 0;
|
|
|
|
|
|
|
|
touchX = touch.screenX;
|
|
|
|
dxTouch = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Math.abs(dxTouch) >= 100)
|
|
|
|
{
|
|
|
|
touchX = touch.screenX;
|
2023-01-23 03:25:45 +00:00
|
|
|
if (dxTouch != 0) dxTouch < 0 ? changeDiff(1) : changeDiff(-1);
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Math.abs(dyTouch) >= 100)
|
|
|
|
{
|
|
|
|
touchY = touch.screenY;
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
if (dyTouch != 0) dyTouch < 0 ? changeSelection(1) : changeSelection(-1);
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
touchTimer = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if mobile
|
|
|
|
for (touch in FlxG.touches.list)
|
|
|
|
{
|
|
|
|
if (touch.justPressed)
|
|
|
|
{
|
|
|
|
// accepted = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#end
|
|
|
|
|
2024-03-24 08:53:05 +00:00
|
|
|
if (!FlxG.keys.pressed.CONTROL && (controls.UI_UP || controls.UI_DOWN))
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
|
|
|
if (spamming)
|
|
|
|
{
|
|
|
|
if (spamTimer >= 0.07)
|
|
|
|
{
|
|
|
|
spamTimer = 0;
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
if (controls.UI_UP)
|
|
|
|
{
|
|
|
|
changeSelection(-1);
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
else
|
2024-03-20 18:37:24 +00:00
|
|
|
{
|
2023-01-23 00:55:30 +00:00
|
|
|
changeSelection(1);
|
2024-03-20 18:37:24 +00:00
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
|
|
|
}
|
2024-03-24 08:53:05 +00:00
|
|
|
else if (spamTimer >= 0.9)
|
|
|
|
{
|
|
|
|
spamming = true;
|
|
|
|
}
|
|
|
|
else if (spamTimer <= 0)
|
|
|
|
{
|
|
|
|
if (controls.UI_UP)
|
|
|
|
{
|
|
|
|
changeSelection(-1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
changeSelection(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
spamTimer += elapsed;
|
|
|
|
dj.resetAFKTimer();
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spamming = false;
|
|
|
|
spamTimer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FlxG.mouse.wheel != 0)
|
|
|
|
{
|
|
|
|
dj.resetAFKTimer();
|
|
|
|
changeSelection(-Math.round(FlxG.mouse.wheel / 4));
|
|
|
|
}
|
|
|
|
|
2024-03-24 08:53:05 +00:00
|
|
|
if (controls.UI_LEFT_P && !FlxG.keys.pressed.CONTROL)
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
|
|
|
dj.resetAFKTimer();
|
|
|
|
changeDiff(-1);
|
2024-04-01 22:34:26 +00:00
|
|
|
generateSongList(currentFilter, true);
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
2024-03-24 08:53:05 +00:00
|
|
|
if (controls.UI_RIGHT_P && !FlxG.keys.pressed.CONTROL)
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
|
|
|
dj.resetAFKTimer();
|
|
|
|
changeDiff(1);
|
2024-04-01 22:34:26 +00:00
|
|
|
generateSongList(currentFilter, true);
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
|
|
|
|
2024-05-03 01:23:55 +00:00
|
|
|
if (controls.BACK)
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
2023-03-17 02:02:56 +00:00
|
|
|
FlxTween.globalManager.clear();
|
|
|
|
FlxTimer.globalManager.clear();
|
|
|
|
dj.onIntroDone.removeAll();
|
|
|
|
|
2024-03-23 21:50:48 +00:00
|
|
|
FunkinSound.playOnce(Paths.sound('cancelMenu'));
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-03-16 01:05:15 +00:00
|
|
|
var longestTimer:Float = 0;
|
|
|
|
|
2023-03-16 04:17:52 +00:00
|
|
|
for (grpSpr in exitMovers.keys())
|
2023-03-16 01:05:15 +00:00
|
|
|
{
|
2023-03-16 04:17:52 +00:00
|
|
|
var moveData:MoveData = exitMovers.get(grpSpr);
|
|
|
|
|
|
|
|
for (spr in grpSpr)
|
|
|
|
{
|
2024-03-28 05:46:50 +00:00
|
|
|
if (spr == null) continue;
|
|
|
|
|
2023-03-16 04:17:52 +00:00
|
|
|
var funnyMoveShit:MoveData = moveData;
|
|
|
|
|
|
|
|
if (moveData.x == null) funnyMoveShit.x = spr.x;
|
|
|
|
if (moveData.y == null) funnyMoveShit.y = spr.y;
|
|
|
|
if (moveData.speed == null) funnyMoveShit.speed = 0.2;
|
|
|
|
if (moveData.wait == null) funnyMoveShit.wait = 0;
|
2023-03-16 01:05:15 +00:00
|
|
|
|
2023-03-16 04:17:52 +00:00
|
|
|
FlxTween.tween(spr, {x: funnyMoveShit.x, y: funnyMoveShit.y}, funnyMoveShit.speed, {ease: FlxEase.expoIn});
|
|
|
|
|
|
|
|
longestTimer = Math.max(longestTimer, funnyMoveShit.speed + funnyMoveShit.wait);
|
|
|
|
}
|
2023-03-16 01:05:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (caps in grpCapsules.members)
|
|
|
|
{
|
|
|
|
caps.doJumpIn = false;
|
|
|
|
caps.doLerp = false;
|
|
|
|
caps.doJumpOut = true;
|
|
|
|
}
|
|
|
|
|
2024-04-30 17:58:39 +00:00
|
|
|
if (Type.getClass(_parentState) == MainMenuState)
|
2023-03-16 04:55:25 +00:00
|
|
|
{
|
2024-04-30 17:58:39 +00:00
|
|
|
_parentState.persistentUpdate = false;
|
|
|
|
_parentState.persistentDraw = true;
|
2023-03-16 04:55:25 +00:00
|
|
|
}
|
|
|
|
|
2023-03-16 01:05:15 +00:00
|
|
|
new FlxTimer().start(longestTimer, (_) -> {
|
|
|
|
FlxTransitionableState.skipNextTransIn = true;
|
|
|
|
FlxTransitionableState.skipNextTransOut = true;
|
2024-04-30 17:58:39 +00:00
|
|
|
if (Type.getClass(_parentState) == MainMenuState)
|
2023-03-16 04:17:52 +00:00
|
|
|
{
|
2024-04-03 05:40:08 +00:00
|
|
|
FunkinSound.playMusic('freakyMenu',
|
|
|
|
{
|
|
|
|
overrideExisting: true,
|
|
|
|
restartTrack: false
|
|
|
|
});
|
2023-03-16 04:17:52 +00:00
|
|
|
close();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-02-06 02:35:58 +00:00
|
|
|
FlxG.switchState(() -> new MainMenuState());
|
2023-03-16 04:17:52 +00:00
|
|
|
}
|
2023-03-16 01:05:15 +00:00
|
|
|
});
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (accepted)
|
|
|
|
{
|
2023-08-06 20:24:34 +00:00
|
|
|
grpCapsules.members[curSelected].onConfirm();
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-16 02:09:01 +00:00
|
|
|
public override function destroy():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
2023-12-16 02:09:01 +00:00
|
|
|
super.destroy();
|
2024-04-03 05:01:58 +00:00
|
|
|
var daSong:Null<FreeplaySongData> = currentFilteredSongs[curSelected];
|
2023-10-11 03:32:01 +00:00
|
|
|
if (daSong != null)
|
|
|
|
{
|
|
|
|
clearDaCache(daSong.songName);
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
|
|
|
|
2024-04-30 18:36:57 +00:00
|
|
|
function changeDiff(change:Int = 0, force:Bool = false):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
|
|
|
touchTimer = 0;
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var currentDifficultyIndex:Int = diffIdsCurrent.indexOf(currentDifficulty);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-10-12 07:20:21 +00:00
|
|
|
if (currentDifficultyIndex == -1) currentDifficultyIndex = diffIdsCurrent.indexOf(Constants.DEFAULT_DIFFICULTY);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-10-12 07:20:21 +00:00
|
|
|
currentDifficultyIndex += change;
|
|
|
|
|
|
|
|
if (currentDifficultyIndex < 0) currentDifficultyIndex = diffIdsCurrent.length - 1;
|
|
|
|
if (currentDifficultyIndex >= diffIdsCurrent.length) currentDifficultyIndex = 0;
|
|
|
|
|
|
|
|
currentDifficulty = diffIdsCurrent[currentDifficultyIndex];
|
2023-10-03 23:14:46 +00:00
|
|
|
|
2024-04-01 22:34:26 +00:00
|
|
|
var daSong:Null<FreeplaySongData> = grpCapsules.members[curSelected].songData;
|
2023-10-11 03:32:01 +00:00
|
|
|
if (daSong != null)
|
|
|
|
{
|
2024-04-01 22:34:26 +00:00
|
|
|
var songScore:SaveScoreData = Save.instance.getSongScore(grpCapsules.members[curSelected].songData.songId, currentDifficulty);
|
2023-10-11 03:32:01 +00:00
|
|
|
intendedScore = songScore?.score ?? 0;
|
|
|
|
intendedCompletion = songScore?.accuracy ?? 0.0;
|
2023-10-12 07:20:21 +00:00
|
|
|
rememberedDifficulty = currentDifficulty;
|
2023-10-11 03:32:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
intendedScore = 0;
|
|
|
|
intendedCompletion = 0.0;
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-01-11 05:30:00 +00:00
|
|
|
if (intendedCompletion == Math.POSITIVE_INFINITY || intendedCompletion == Math.NEGATIVE_INFINITY || Math.isNaN(intendedCompletion))
|
|
|
|
{
|
|
|
|
intendedCompletion = 0;
|
|
|
|
}
|
|
|
|
|
2023-10-12 07:20:21 +00:00
|
|
|
grpDifficulties.group.forEach(function(diffSprite) {
|
|
|
|
diffSprite.visible = false;
|
2023-01-23 00:55:30 +00:00
|
|
|
});
|
|
|
|
|
2023-10-12 07:20:21 +00:00
|
|
|
for (diffSprite in grpDifficulties.group.members)
|
|
|
|
{
|
|
|
|
if (diffSprite == null) continue;
|
|
|
|
if (diffSprite.difficultyId == currentDifficulty)
|
|
|
|
{
|
|
|
|
if (change != 0)
|
|
|
|
{
|
|
|
|
diffSprite.visible = true;
|
|
|
|
diffSprite.offset.y += 5;
|
|
|
|
diffSprite.alpha = 0.5;
|
|
|
|
new FlxTimer().start(1 / 24, function(swag) {
|
|
|
|
diffSprite.alpha = 1;
|
|
|
|
diffSprite.updateHitbox();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
diffSprite.visible = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-01-11 05:30:00 +00:00
|
|
|
|
2024-04-30 18:36:57 +00:00
|
|
|
if (change != 0 || force)
|
2024-01-11 05:30:00 +00:00
|
|
|
{
|
|
|
|
// Update the song capsules to reflect the new difficulty info.
|
|
|
|
for (songCapsule in grpCapsules.members)
|
|
|
|
{
|
|
|
|
if (songCapsule == null) continue;
|
|
|
|
if (songCapsule.songData != null)
|
|
|
|
{
|
|
|
|
songCapsule.songData.currentDifficulty = currentDifficulty;
|
|
|
|
songCapsule.init(null, null, songCapsule.songData);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
songCapsule.init(null, null, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-23 22:22:15 +00:00
|
|
|
// Set the album graphic and play the animation if relevant.
|
2024-03-28 05:46:50 +00:00
|
|
|
var newAlbumId:String = daSong?.albumId;
|
2024-03-23 22:22:15 +00:00
|
|
|
if (albumRoll.albumId != newAlbumId)
|
|
|
|
{
|
|
|
|
albumRoll.albumId = newAlbumId;
|
2024-03-30 04:54:07 +00:00
|
|
|
albumRoll.skipIntro();
|
2024-03-23 22:22:15 +00:00
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Clears the cache of songs, frees up memory, they' ll have to be loaded in later tho function clearDaCache(actualSongTho:String)
|
2024-03-20 18:37:24 +00:00
|
|
|
function clearDaCache(actualSongTho:String):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
|
|
|
for (song in songs)
|
|
|
|
{
|
2023-10-17 04:38:28 +00:00
|
|
|
if (song == null) continue;
|
2023-01-23 00:55:30 +00:00
|
|
|
if (song.songName != actualSongTho)
|
|
|
|
{
|
|
|
|
trace('trying to remove: ' + song.songName);
|
|
|
|
// openfl.Assets.cache.clear(Paths.inst(song.songName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-17 00:12:40 +00:00
|
|
|
function capsuleOnConfirmRandom(randomCapsule:SongMenuItem):Void
|
2023-08-06 20:24:34 +00:00
|
|
|
{
|
2024-03-20 18:37:24 +00:00
|
|
|
trace('RANDOM SELECTED');
|
2023-08-06 20:24:34 +00:00
|
|
|
|
2023-10-17 04:38:28 +00:00
|
|
|
busy = true;
|
2023-11-07 23:53:50 +00:00
|
|
|
letterSort.inputEnabled = false;
|
2023-10-17 00:12:40 +00:00
|
|
|
|
|
|
|
var availableSongCapsules:Array<SongMenuItem> = grpCapsules.members.filter(function(cap:SongMenuItem) {
|
|
|
|
// Dead capsules are ones which were removed from the list when changing filters.
|
|
|
|
return cap.alive && cap.songData != null;
|
|
|
|
});
|
|
|
|
|
|
|
|
trace('Available songs: ${availableSongCapsules.map(function(cap) {
|
|
|
|
return cap.songData.songName;
|
|
|
|
})}');
|
|
|
|
|
2023-11-07 23:53:50 +00:00
|
|
|
if (availableSongCapsules.length == 0)
|
|
|
|
{
|
2024-03-20 18:37:24 +00:00
|
|
|
trace('No songs available!');
|
2023-11-07 23:53:50 +00:00
|
|
|
busy = false;
|
|
|
|
letterSort.inputEnabled = true;
|
2024-03-23 21:50:48 +00:00
|
|
|
FunkinSound.playOnce(Paths.sound('cancelMenu'));
|
2023-11-07 23:53:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-10-17 00:12:40 +00:00
|
|
|
var targetSong:SongMenuItem = FlxG.random.getObject(availableSongCapsules);
|
|
|
|
|
|
|
|
// Seeing if I can do an animation...
|
|
|
|
curSelected = grpCapsules.members.indexOf(targetSong);
|
|
|
|
changeSelection(0); // Trigger an update.
|
|
|
|
|
|
|
|
// Act like we hit Confirm on that song.
|
|
|
|
capsuleOnConfirmDefault(targetSong);
|
2023-10-17 04:38:28 +00:00
|
|
|
}
|
|
|
|
|
2023-09-29 00:29:19 +00:00
|
|
|
function capsuleOnConfirmDefault(cap:SongMenuItem):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
2023-10-17 04:38:28 +00:00
|
|
|
busy = true;
|
2023-11-07 23:53:50 +00:00
|
|
|
letterSort.inputEnabled = false;
|
2023-08-06 20:24:34 +00:00
|
|
|
|
|
|
|
PlayStatePlaylist.isStoryMode = false;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-11-02 03:20:47 +00:00
|
|
|
var targetSong:Song = SongRegistry.instance.fetchEntry(cap.songData.songId);
|
2023-11-29 01:52:45 +00:00
|
|
|
if (targetSong == null)
|
|
|
|
{
|
|
|
|
FlxG.log.warn('WARN: could not find song with id (${cap.songData.songId})');
|
|
|
|
return;
|
|
|
|
}
|
2023-10-12 07:20:21 +00:00
|
|
|
var targetDifficulty:String = currentDifficulty;
|
2024-02-06 02:35:58 +00:00
|
|
|
var targetVariation:String = targetSong.getFirstValidVariation(targetDifficulty);
|
2023-08-06 20:24:34 +00:00
|
|
|
|
2023-10-17 00:12:40 +00:00
|
|
|
PlayStatePlaylist.campaignId = cap.songData.levelId;
|
2023-08-06 20:24:34 +00:00
|
|
|
|
|
|
|
// Visual and audio effects.
|
2024-03-23 21:50:48 +00:00
|
|
|
FunkinSound.playOnce(Paths.sound('confirmMenu'));
|
2023-08-06 20:24:34 +00:00
|
|
|
dj.confirm();
|
|
|
|
|
|
|
|
new FlxTimer().start(1, function(tmr:FlxTimer) {
|
2023-10-17 00:12:40 +00:00
|
|
|
Paths.setCurrentLevel(cap.songData.levelId);
|
2024-02-17 04:48:43 +00:00
|
|
|
LoadingState.loadPlayState(
|
2023-08-06 20:24:34 +00:00
|
|
|
{
|
|
|
|
targetSong: targetSong,
|
|
|
|
targetDifficulty: targetDifficulty,
|
2024-02-06 02:35:58 +00:00
|
|
|
targetVariation: targetVariation,
|
2024-02-29 23:49:20 +00:00
|
|
|
practiceMode: false,
|
|
|
|
minimalMode: false,
|
2024-04-01 22:34:26 +00:00
|
|
|
|
|
|
|
#if (debug || FORCE_DEBUG_VERSION)
|
|
|
|
botPlayMode: FlxG.keys.pressed.SHIFT,
|
|
|
|
#else
|
|
|
|
botPlayMode: false,
|
|
|
|
#end
|
2024-03-06 03:27:07 +00:00
|
|
|
// TODO: Make these an option! It's currently only accessible via chart editor.
|
|
|
|
// startTimestamp: 0.0,
|
|
|
|
// playbackRate: 0.5,
|
|
|
|
// botPlayMode: true,
|
2024-02-17 04:48:43 +00:00
|
|
|
}, true);
|
2023-08-06 20:24:34 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-10-12 07:20:21 +00:00
|
|
|
function rememberSelection():Void
|
|
|
|
{
|
|
|
|
if (rememberedSongId != null)
|
|
|
|
{
|
2024-04-01 22:34:26 +00:00
|
|
|
curSelected = currentFilteredSongs.findIndex(function(song) {
|
2023-10-12 07:20:21 +00:00
|
|
|
if (song == null) return false;
|
|
|
|
return song.songId == rememberedSongId;
|
|
|
|
});
|
2024-04-01 22:34:26 +00:00
|
|
|
|
|
|
|
if (curSelected == -1) curSelected = 0;
|
2023-10-12 07:20:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rememberedDifficulty != null)
|
|
|
|
{
|
|
|
|
currentDifficulty = rememberedDifficulty;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-12 03:42:32 +00:00
|
|
|
function changeSelection(change:Int = 0):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
2024-03-23 21:50:48 +00:00
|
|
|
FunkinSound.playOnce(Paths.sound('scrollMenu'), 0.4);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var prevSelected:Int = curSelected;
|
2023-10-17 00:12:40 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
curSelected += change;
|
|
|
|
|
2023-08-09 07:03:58 +00:00
|
|
|
if (curSelected < 0) curSelected = grpCapsules.countLiving() - 1;
|
|
|
|
if (curSelected >= grpCapsules.countLiving()) curSelected = 0;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var daSongCapsule:SongMenuItem = grpCapsules.members[curSelected];
|
2023-10-17 00:12:40 +00:00
|
|
|
if (daSongCapsule.songData != null)
|
2023-08-09 07:03:58 +00:00
|
|
|
{
|
2024-03-04 21:37:42 +00:00
|
|
|
var songScore:SaveScoreData = Save.instance.getSongScore(daSongCapsule.songData.songId, currentDifficulty);
|
2023-10-11 03:32:01 +00:00
|
|
|
intendedScore = songScore?.score ?? 0;
|
|
|
|
intendedCompletion = songScore?.accuracy ?? 0.0;
|
2023-11-02 03:20:47 +00:00
|
|
|
diffIdsCurrent = daSongCapsule.songData.songDifficulties;
|
|
|
|
rememberedSongId = daSongCapsule.songData.songId;
|
2023-10-12 07:20:21 +00:00
|
|
|
changeDiff();
|
2023-08-09 07:03:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
intendedScore = 0;
|
2023-10-11 03:32:01 +00:00
|
|
|
intendedCompletion = 0.0;
|
2024-04-01 22:34:26 +00:00
|
|
|
diffIdsCurrent = diffIdsTotal;
|
2023-10-12 07:20:21 +00:00
|
|
|
rememberedSongId = null;
|
|
|
|
rememberedDifficulty = null;
|
2024-03-28 05:46:50 +00:00
|
|
|
albumRoll.albumId = null;
|
2023-08-09 07:03:58 +00:00
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
|
|
|
for (index => capsule in grpCapsules.members)
|
|
|
|
{
|
2023-08-04 19:59:17 +00:00
|
|
|
index += 1;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-09-20 03:27:07 +00:00
|
|
|
capsule.selected = index == curSelected + 1;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-08-04 21:10:27 +00:00
|
|
|
capsule.targetPos.y = capsule.intendedY(index - curSelected);
|
2023-01-23 00:55:30 +00:00
|
|
|
capsule.targetPos.x = 270 + (60 * (Math.sin(index - curSelected)));
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
if (index < curSelected) capsule.targetPos.y -= 100; // another 100 for good measure
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
|
|
|
|
2023-08-14 02:12:08 +00:00
|
|
|
if (grpCapsules.countLiving() > 0)
|
|
|
|
{
|
|
|
|
if (curSelected == 0)
|
|
|
|
{
|
2024-03-24 03:38:07 +00:00
|
|
|
FunkinSound.playMusic('freeplayRandom',
|
|
|
|
{
|
|
|
|
startingVolume: 0.0,
|
|
|
|
overrideExisting: true,
|
|
|
|
restartTrack: true
|
|
|
|
});
|
2023-08-14 02:12:08 +00:00
|
|
|
FlxG.sound.music.fadeIn(2, 0, 0.8);
|
|
|
|
}
|
2023-10-12 07:20:21 +00:00
|
|
|
else
|
|
|
|
{
|
2023-10-17 00:12:40 +00:00
|
|
|
// TODO: Stream the instrumental of the selected song?
|
2024-03-24 03:38:07 +00:00
|
|
|
var didReplace:Bool = FunkinSound.playMusic('freakyMenu',
|
|
|
|
{
|
|
|
|
startingVolume: 0.0,
|
|
|
|
overrideExisting: true,
|
|
|
|
restartTrack: false
|
|
|
|
});
|
|
|
|
if (didReplace)
|
2023-10-17 00:12:40 +00:00
|
|
|
{
|
2024-03-16 04:55:57 +00:00
|
|
|
FunkinSound.playMusic('freakyMenu',
|
|
|
|
{
|
|
|
|
startingVolume: 0.0,
|
|
|
|
overrideExisting: true,
|
|
|
|
restartTrack: false
|
|
|
|
});
|
2023-10-17 00:12:40 +00:00
|
|
|
FlxG.sound.music.fadeIn(2, 0, 0.8);
|
|
|
|
}
|
2023-10-12 07:20:21 +00:00
|
|
|
}
|
2023-08-14 02:12:08 +00:00
|
|
|
grpCapsules.members[curSelected].selected = true;
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
2024-03-29 02:33:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Build an instance of `FreeplayState` that is above the `MainMenuState`.
|
|
|
|
* @return The MainMenuState with the FreeplayState as a substate.
|
|
|
|
*/
|
|
|
|
public static function build(?params:FreeplayStateParams, ?stickers:StickerSubState):MusicBeatState
|
|
|
|
{
|
|
|
|
var result = new MainMenuState();
|
|
|
|
|
|
|
|
result.openSubState(new FreeplayState(params, stickers));
|
2024-05-01 19:22:20 +00:00
|
|
|
result.persistentUpdate = false;
|
|
|
|
result.persistentDraw = true;
|
2024-03-29 02:33:50 +00:00
|
|
|
return result;
|
|
|
|
}
|
2021-12-08 00:29:26 +00:00
|
|
|
}
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
/**
|
|
|
|
* The difficulty selector arrows to the left and right of the difficulty.
|
|
|
|
*/
|
2021-12-08 00:29:26 +00:00
|
|
|
class DifficultySelector extends FlxSprite
|
|
|
|
{
|
2023-01-23 00:55:30 +00:00
|
|
|
var controls:Controls;
|
|
|
|
var whiteShader:PureColor;
|
2021-12-08 00:29:26 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
public function new(x:Float, y:Float, flipped:Bool, controls:Controls)
|
|
|
|
{
|
|
|
|
super(x, y);
|
2021-12-08 00:29:26 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
this.controls = controls;
|
2021-12-08 00:29:26 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
frames = Paths.getSparrowAtlas('freeplay/freeplaySelector');
|
2024-03-20 18:37:24 +00:00
|
|
|
animation.addByPrefix('shine', 'arrow pointer loop', 24);
|
2023-01-23 00:55:30 +00:00
|
|
|
animation.play('shine');
|
2021-12-08 00:29:26 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
whiteShader = new PureColor(FlxColor.WHITE);
|
2021-12-08 03:34:01 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
shader = whiteShader;
|
2021-12-08 03:34:01 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
flipX = flipped;
|
|
|
|
}
|
2021-04-08 21:29:31 +00:00
|
|
|
|
2024-03-12 03:42:32 +00:00
|
|
|
override function update(elapsed:Float):Void
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
2024-03-24 08:53:05 +00:00
|
|
|
if (flipX && controls.UI_RIGHT_P && !FlxG.keys.pressed.CONTROL) moveShitDown();
|
|
|
|
if (!flipX && controls.UI_LEFT_P && !FlxG.keys.pressed.CONTROL) moveShitDown();
|
2021-12-08 00:29:26 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
super.update(elapsed);
|
|
|
|
}
|
2021-12-08 00:29:26 +00:00
|
|
|
|
2024-03-12 03:42:32 +00:00
|
|
|
function moveShitDown():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
|
|
|
offset.y -= 5;
|
2021-04-08 21:29:31 +00:00
|
|
|
|
2023-01-23 00:55:30 +00:00
|
|
|
whiteShader.colorSet = true;
|
2021-12-08 03:34:01 +00:00
|
|
|
|
2023-08-07 02:20:18 +00:00
|
|
|
scale.x = scale.y = 0.5;
|
|
|
|
|
2023-03-16 01:05:15 +00:00
|
|
|
new FlxTimer().start(2 / 24, function(tmr) {
|
2023-08-07 02:20:18 +00:00
|
|
|
scale.x = scale.y = 1;
|
2023-01-23 00:55:30 +00:00
|
|
|
whiteShader.colorSet = false;
|
|
|
|
updateHitbox();
|
|
|
|
});
|
|
|
|
}
|
2020-10-21 18:05:27 +00:00
|
|
|
}
|
2021-02-25 01:52:59 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
/**
|
|
|
|
* Structure for the current song filter.
|
|
|
|
*/
|
2022-09-28 06:50:53 +00:00
|
|
|
typedef SongFilter =
|
|
|
|
{
|
2023-01-23 00:55:30 +00:00
|
|
|
var filterType:FilterType;
|
|
|
|
var ?filterData:Dynamic;
|
2022-09-28 06:50:53 +00:00
|
|
|
}
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
/**
|
|
|
|
* Possible types to use for the song filter.
|
|
|
|
*/
|
2022-09-28 06:50:53 +00:00
|
|
|
enum abstract FilterType(String)
|
|
|
|
{
|
2024-03-20 18:37:24 +00:00
|
|
|
/**
|
|
|
|
* Filter to songs which start with a string
|
|
|
|
*/
|
|
|
|
public var STARTSWITH;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter to songs which match a regular expression
|
|
|
|
*/
|
|
|
|
public var REGEXP;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter to songs which are favorited
|
|
|
|
*/
|
|
|
|
public var FAVORITE;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter to all songs
|
|
|
|
*/
|
|
|
|
public var ALL;
|
2022-09-28 06:50:53 +00:00
|
|
|
}
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
/**
|
|
|
|
* Data about a specific song in the freeplay menu.
|
|
|
|
*/
|
2023-06-09 22:25:21 +00:00
|
|
|
class FreeplaySongData
|
2021-02-25 01:52:59 +00:00
|
|
|
{
|
2024-03-20 18:37:24 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the song has been favorited.
|
|
|
|
*/
|
2023-10-12 07:20:21 +00:00
|
|
|
public var isFav:Bool = false;
|
|
|
|
|
2024-01-11 05:30:00 +00:00
|
|
|
var song:Song;
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
public var levelId(default, null):String = '';
|
|
|
|
public var songId(default, null):String = '';
|
2024-01-11 05:30:00 +00:00
|
|
|
|
|
|
|
public var songDifficulties(default, null):Array<String> = [];
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
public var songName(default, null):String = '';
|
|
|
|
public var songCharacter(default, null):String = '';
|
2024-01-11 05:30:00 +00:00
|
|
|
public var songRating(default, null):Int = 0;
|
2024-03-28 05:46:50 +00:00
|
|
|
public var albumId(default, null):Null<String> = null;
|
2024-01-11 05:30:00 +00:00
|
|
|
|
|
|
|
public var currentDifficulty(default, set):String = Constants.DEFAULT_DIFFICULTY;
|
2024-02-06 02:35:58 +00:00
|
|
|
public var displayedVariations(default, null):Array<String> = [Constants.DEFAULT_VARIATION];
|
2024-01-11 05:30:00 +00:00
|
|
|
|
|
|
|
function set_currentDifficulty(value:String):String
|
|
|
|
{
|
|
|
|
if (currentDifficulty == value) return value;
|
|
|
|
|
|
|
|
currentDifficulty = value;
|
2024-02-06 02:35:58 +00:00
|
|
|
updateValues(displayedVariations);
|
2024-01-11 05:30:00 +00:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2024-02-06 02:35:58 +00:00
|
|
|
public function new(levelId:String, songId:String, song:Song, ?displayedVariations:Array<String>)
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
2023-06-09 22:25:21 +00:00
|
|
|
this.levelId = levelId;
|
2024-01-11 05:30:00 +00:00
|
|
|
this.songId = songId;
|
|
|
|
this.song = song;
|
2024-02-06 02:35:58 +00:00
|
|
|
if (displayedVariations != null) this.displayedVariations = displayedVariations;
|
2024-01-11 05:30:00 +00:00
|
|
|
|
2024-02-06 02:35:58 +00:00
|
|
|
updateValues(displayedVariations);
|
2024-01-11 05:30:00 +00:00
|
|
|
}
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
function updateValues(variations:Array<String>):Void
|
2024-01-11 05:30:00 +00:00
|
|
|
{
|
2024-04-04 01:57:29 +00:00
|
|
|
this.songDifficulties = song.listDifficulties(variations, false, false);
|
2024-01-11 05:30:00 +00:00
|
|
|
if (!this.songDifficulties.contains(currentDifficulty)) currentDifficulty = Constants.DEFAULT_DIFFICULTY;
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
var songDifficulty:SongDifficulty = song.getDifficulty(currentDifficulty, variations);
|
2024-01-11 05:30:00 +00:00
|
|
|
if (songDifficulty == null) return;
|
|
|
|
this.songName = songDifficulty.songName;
|
|
|
|
this.songCharacter = songDifficulty.characters.opponent;
|
|
|
|
this.songRating = songDifficulty.difficultyRating;
|
2024-03-28 05:46:50 +00:00
|
|
|
if (songDifficulty.album == null)
|
|
|
|
{
|
|
|
|
FlxG.log.warn('No album for: ${songDifficulty.songName}');
|
|
|
|
this.albumId = Constants.DEFAULT_ALBUM_ID;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.albumId = songDifficulty.album;
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
2021-02-25 01:52:59 +00:00
|
|
|
}
|
2023-03-16 01:05:15 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
/**
|
|
|
|
* The map storing information about the exit movers.
|
|
|
|
*/
|
|
|
|
typedef ExitMoverData = Map<Array<FlxSprite>, MoveData>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The data for an exit mover.
|
|
|
|
*/
|
2023-03-16 01:05:15 +00:00
|
|
|
typedef MoveData =
|
|
|
|
{
|
2023-03-16 04:17:52 +00:00
|
|
|
var ?x:Float;
|
|
|
|
var ?y:Float;
|
|
|
|
var ?speed:Float;
|
|
|
|
var ?wait:Float;
|
2023-03-16 01:05:15 +00:00
|
|
|
}
|
2023-10-12 07:20:21 +00:00
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
/**
|
|
|
|
* The sprite for the difficulty
|
|
|
|
*/
|
2023-10-12 07:20:21 +00:00
|
|
|
class DifficultySprite extends FlxSprite
|
|
|
|
{
|
2024-03-20 18:37:24 +00:00
|
|
|
/**
|
|
|
|
* The difficulty id which this sprite represents.
|
|
|
|
*/
|
2023-10-12 07:20:21 +00:00
|
|
|
public var difficultyId:String;
|
|
|
|
|
|
|
|
public function new(diffId:String)
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
|
|
|
|
difficultyId = diffId;
|
|
|
|
|
2023-11-20 16:12:50 +00:00
|
|
|
if (Assets.exists(Paths.file('images/freeplay/freeplay${diffId}.xml')))
|
|
|
|
{
|
|
|
|
this.frames = Paths.getSparrowAtlas('freeplay/freeplay${diffId}');
|
|
|
|
this.animation.addByPrefix('idle', 'idle0', 24, true);
|
|
|
|
if (Preferences.flashingLights) this.animation.play('idle');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.loadGraphic(Paths.image('freeplay/freeplay' + diffId));
|
|
|
|
}
|
2023-10-12 07:20:21 +00:00
|
|
|
}
|
|
|
|
}
|