2022-03-08 08:13:53 +00:00
|
|
|
package funkin;
|
2021-09-07 21:09:34 +00:00
|
|
|
|
|
|
|
import flixel.addons.transition.FlxTransitionableState;
|
2023-06-16 21:37:56 +00:00
|
|
|
import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond;
|
2021-09-07 21:09:34 +00:00
|
|
|
import flixel.addons.transition.TransitionData;
|
2024-09-19 14:03:16 +00:00
|
|
|
import flixel.FlxSprite;
|
|
|
|
import flixel.FlxState;
|
2021-09-07 21:09:34 +00:00
|
|
|
import flixel.graphics.FlxGraphic;
|
|
|
|
import flixel.math.FlxPoint;
|
|
|
|
import flixel.math.FlxRect;
|
2023-01-06 08:21:54 +00:00
|
|
|
import flixel.system.debug.log.LogStyle;
|
2021-09-07 21:09:34 +00:00
|
|
|
import flixel.util.FlxColor;
|
2024-03-23 19:34:37 +00:00
|
|
|
import funkin.data.dialogue.conversation.ConversationRegistry;
|
|
|
|
import funkin.data.dialogue.dialoguebox.DialogueBoxRegistry;
|
|
|
|
import funkin.data.dialogue.speaker.SpeakerRegistry;
|
|
|
|
import funkin.data.freeplay.album.AlbumRegistry;
|
2024-09-19 14:03:16 +00:00
|
|
|
import funkin.data.freeplay.player.PlayerRegistry;
|
|
|
|
import funkin.data.freeplay.style.FreeplayStyleRegistry;
|
|
|
|
import funkin.data.notestyle.NoteStyleRegistry;
|
2023-09-08 21:46:44 +00:00
|
|
|
import funkin.data.song.SongRegistry;
|
2024-09-19 14:03:16 +00:00
|
|
|
import funkin.data.event.SongEventRegistry;
|
|
|
|
import funkin.data.stage.StageRegistry;
|
|
|
|
import funkin.data.story.level.LevelRegistry;
|
|
|
|
import funkin.modding.module.ModuleHandler;
|
2023-07-14 00:26:56 +00:00
|
|
|
import funkin.play.character.CharacterData.CharacterDataParser;
|
2024-05-31 14:55:42 +00:00
|
|
|
import funkin.play.notes.notekind.NoteKindManager;
|
2024-09-19 14:03:16 +00:00
|
|
|
import funkin.play.PlayStatePlaylist;
|
|
|
|
import funkin.ui.debug.charting.ChartEditorState;
|
2023-08-08 19:41:25 +00:00
|
|
|
import funkin.ui.title.TitleState;
|
2024-09-19 14:03:16 +00:00
|
|
|
import funkin.ui.transition.LoadingState;
|
2023-10-21 05:04:50 +00:00
|
|
|
import funkin.util.CLIUtil;
|
|
|
|
import funkin.util.CLIUtil.CLIParams;
|
2024-09-19 14:03:16 +00:00
|
|
|
import funkin.util.macro.MacroUtil;
|
2024-03-14 01:47:15 +00:00
|
|
|
import funkin.util.TimerUtil;
|
2024-03-05 01:47:23 +00:00
|
|
|
import funkin.util.TrackerUtil;
|
2024-09-19 14:03:16 +00:00
|
|
|
import funkin.util.WindowUtil;
|
|
|
|
import openfl.display.BitmapData;
|
2024-08-26 22:01:36 +00:00
|
|
|
#if FEATURE_DISCORD_RPC
|
2024-09-19 14:03:16 +00:00
|
|
|
import funkin.api.discord.DiscordClient;
|
2021-09-07 21:09:34 +00:00
|
|
|
#end
|
|
|
|
|
2022-02-23 21:49:54 +00:00
|
|
|
/**
|
2023-11-07 09:04:22 +00:00
|
|
|
* A core class which performs initialization of the game.
|
2023-06-27 00:39:47 +00:00
|
|
|
* The initialization state has several functions:
|
|
|
|
* - Calls code to set up the game, including loading saves and parsing game data.
|
|
|
|
* - Chooses whether to start via debug or via launching normally.
|
2023-09-05 02:18:45 +00:00
|
|
|
*
|
|
|
|
* It should not contain any sprites or rendering.
|
2022-02-23 21:49:54 +00:00
|
|
|
*/
|
2023-09-05 02:18:45 +00:00
|
|
|
class InitState extends FlxState
|
2021-09-07 21:09:34 +00:00
|
|
|
{
|
2023-06-27 00:39:47 +00:00
|
|
|
/**
|
|
|
|
* Perform a bunch of game setup, then immediately transition to the title screen.
|
|
|
|
*/
|
|
|
|
public override function create():Void
|
|
|
|
{
|
2024-02-16 02:34:24 +00:00
|
|
|
// Setup a bunch of important Flixel stuff.
|
2023-06-27 00:39:47 +00:00
|
|
|
setupShit();
|
|
|
|
|
2023-10-17 04:38:28 +00:00
|
|
|
// Load player options from save data.
|
2024-02-16 02:34:24 +00:00
|
|
|
// Flixel has already loaded the save data, so we can just use it.
|
2023-10-17 04:38:28 +00:00
|
|
|
Preferences.init();
|
2024-02-16 02:34:24 +00:00
|
|
|
|
2023-10-17 04:38:28 +00:00
|
|
|
// Load controls from save data.
|
|
|
|
PlayerSettings.init();
|
2023-06-27 00:39:47 +00:00
|
|
|
|
|
|
|
startGame();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup a bunch of important Flixel stuff.
|
|
|
|
*/
|
2024-03-05 01:47:23 +00:00
|
|
|
function setupShit():Void
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
2023-06-25 16:36:00 +00:00
|
|
|
//
|
2023-06-27 00:39:47 +00:00
|
|
|
// GAME SETUP
|
2023-06-25 16:36:00 +00:00
|
|
|
//
|
2023-06-27 00:39:47 +00:00
|
|
|
|
|
|
|
// Setup window events (like callbacks for onWindowClose)
|
2024-04-30 04:40:42 +00:00
|
|
|
// and fullscreen keybind setup
|
2023-06-27 00:39:47 +00:00
|
|
|
WindowUtil.initWindowEvents();
|
|
|
|
// Disable the thing on Windows where it tries to send a bug report to Microsoft because why do they care?
|
|
|
|
WindowUtil.disableCrashHandler();
|
|
|
|
|
2023-06-25 16:36:00 +00:00
|
|
|
// This ain't a pixel art game! (most of the time)
|
|
|
|
FlxSprite.defaultAntialiasing = true;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
// Disable default keybinds for volume (we manually control volume in MusicBeatState with custom binds)
|
|
|
|
FlxG.sound.volumeUpKeys = [];
|
|
|
|
FlxG.sound.volumeDownKeys = [];
|
|
|
|
FlxG.sound.muteKeys = [];
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
// Set the game to a lower frame rate while it is in the background.
|
|
|
|
FlxG.game.focusLostFramerate = 30;
|
|
|
|
|
2024-03-12 21:57:52 +00:00
|
|
|
setupFlixelDebug();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
//
|
|
|
|
// FLIXEL TRANSITIONS
|
|
|
|
//
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
// Diamond Transition
|
2023-01-23 00:55:30 +00:00
|
|
|
var diamond:FlxGraphic = FlxGraphic.fromClass(GraphicTransTileDiamond);
|
|
|
|
diamond.persist = true;
|
|
|
|
diamond.destroyOnNoUse = false;
|
|
|
|
|
2023-06-28 01:29:58 +00:00
|
|
|
// NOTE: tileData is ignored if TransitionData.type is FADE instead of TILES.
|
|
|
|
var tileData:TransitionTileData = {asset: diamond, width: 32, height: 32};
|
|
|
|
|
2023-07-04 20:38:10 +00:00
|
|
|
FlxTransitionableState.defaultTransIn = new TransitionData(FADE, FlxColor.BLACK, 1, new FlxPoint(0, -1), tileData,
|
2023-06-28 01:29:58 +00:00
|
|
|
new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4));
|
2023-07-04 20:38:10 +00:00
|
|
|
FlxTransitionableState.defaultTransOut = new TransitionData(FADE, FlxColor.BLACK, 0.7, new FlxPoint(0, 1), tileData,
|
2023-06-28 01:29:58 +00:00
|
|
|
new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4));
|
2023-06-27 00:39:47 +00:00
|
|
|
// Don't play transition in when entering the title state.
|
|
|
|
FlxTransitionableState.skipNextTransIn = true;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
//
|
|
|
|
// NEWGROUNDS API SETUP
|
|
|
|
//
|
|
|
|
#if newgrounds
|
|
|
|
NGio.init();
|
|
|
|
#end
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
//
|
|
|
|
// DISCORD API SETUP
|
|
|
|
//
|
2024-08-26 22:01:36 +00:00
|
|
|
#if FEATURE_DISCORD_RPC
|
2024-09-19 14:03:16 +00:00
|
|
|
DiscordClient.instance.init();
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-09-19 14:03:16 +00:00
|
|
|
lime.app.Application.current.onExit.add(function(exitCode) {
|
|
|
|
DiscordClient.instance.shutdown();
|
2023-06-27 00:39:47 +00:00
|
|
|
});
|
|
|
|
#end
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
//
|
|
|
|
// ANDROID SETUP
|
|
|
|
//
|
|
|
|
#if android
|
|
|
|
FlxG.android.preventDefaultKeys = [flixel.input.android.FlxAndroidKey.BACK];
|
|
|
|
#end
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-01-04 00:53:17 +00:00
|
|
|
//
|
|
|
|
// FLIXEL PLUGINS
|
|
|
|
//
|
2024-02-16 02:34:24 +00:00
|
|
|
// Plugins provide a useful interface for globally active Flixel objects,
|
|
|
|
// that receive update events regardless of the current state.
|
2024-02-22 06:47:35 +00:00
|
|
|
// TODO: Move scripted Module behavior to a Flixel plugin.
|
2024-08-26 22:01:36 +00:00
|
|
|
#if FEATURE_DEBUG_FUNCTIONS
|
2024-02-28 05:19:08 +00:00
|
|
|
funkin.util.plugins.MemoryGCPlugin.initialize();
|
|
|
|
#end
|
2024-09-25 12:39:57 +00:00
|
|
|
#if FEATURE_SCREENSHOTS
|
|
|
|
funkin.util.plugins.ScreenshotPlugin.initialize();
|
|
|
|
#end
|
2024-01-04 00:53:17 +00:00
|
|
|
funkin.util.plugins.EvacuateDebugPlugin.initialize();
|
2024-02-22 06:47:35 +00:00
|
|
|
funkin.util.plugins.ForceCrashPlugin.initialize();
|
2024-01-04 00:53:17 +00:00
|
|
|
funkin.util.plugins.ReloadAssetsDebugPlugin.initialize();
|
2024-02-16 19:42:28 +00:00
|
|
|
funkin.util.plugins.VolumePlugin.initialize();
|
2024-01-04 00:53:17 +00:00
|
|
|
funkin.util.plugins.WatchPlugin.initialize();
|
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
//
|
|
|
|
// GAME DATA PARSING
|
|
|
|
//
|
2023-07-14 00:26:56 +00:00
|
|
|
|
2024-02-07 23:45:13 +00:00
|
|
|
// NOTE: Registries must be imported and not referenced with fully qualified names,
|
2023-07-14 00:26:56 +00:00
|
|
|
// to ensure build macros work properly.
|
2024-02-07 23:45:13 +00:00
|
|
|
trace('Parsing game data...');
|
2024-03-14 01:47:15 +00:00
|
|
|
var perfStart:Float = TimerUtil.start();
|
2024-02-07 23:45:13 +00:00
|
|
|
SongEventRegistry.loadEventCache(); // SongEventRegistry is structured differently so it's not a BaseRegistry.
|
2023-09-08 21:46:44 +00:00
|
|
|
SongRegistry.instance.loadEntries();
|
2023-07-14 00:26:56 +00:00
|
|
|
LevelRegistry.instance.loadEntries();
|
|
|
|
NoteStyleRegistry.instance.loadEntries();
|
2024-06-18 21:56:24 +00:00
|
|
|
PlayerRegistry.instance.loadEntries();
|
2024-02-07 14:21:44 +00:00
|
|
|
ConversationRegistry.instance.loadEntries();
|
|
|
|
DialogueBoxRegistry.instance.loadEntries();
|
|
|
|
SpeakerRegistry.instance.loadEntries();
|
2024-08-29 23:55:24 +00:00
|
|
|
FreeplayStyleRegistry.instance.loadEntries();
|
2024-03-20 18:37:24 +00:00
|
|
|
AlbumRegistry.instance.loadEntries();
|
2024-01-16 21:49:15 +00:00
|
|
|
StageRegistry.instance.loadEntries();
|
2024-02-07 23:45:13 +00:00
|
|
|
|
2024-03-17 02:20:22 +00:00
|
|
|
// TODO: CharacterDataParser doesn't use json2object, so it's way slower than the other parsers and more prone to syntax errors.
|
|
|
|
// Move it to use a BaseRegistry.
|
|
|
|
CharacterDataParser.loadCharacterCache();
|
2024-01-16 21:49:15 +00:00
|
|
|
|
2024-05-31 14:55:42 +00:00
|
|
|
NoteKindManager.loadScripts();
|
2024-05-31 12:02:28 +00:00
|
|
|
|
2023-07-14 00:26:56 +00:00
|
|
|
ModuleHandler.buildModuleCallbacks();
|
|
|
|
ModuleHandler.loadModuleCache();
|
|
|
|
ModuleHandler.callOnCreate();
|
2024-02-07 14:21:44 +00:00
|
|
|
|
2024-03-14 01:47:15 +00:00
|
|
|
trace('Parsing game data took: ${TimerUtil.ms(perfStart)}');
|
2023-06-27 00:39:47 +00:00
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
/**
|
|
|
|
* Start the game.
|
|
|
|
*
|
|
|
|
* By default, moves to the `TitleState`.
|
|
|
|
* But based on compile defines, the game can start immediately on a specific song,
|
|
|
|
* or immediately in a specific debug menu.
|
|
|
|
*/
|
|
|
|
function startGame():Void
|
|
|
|
{
|
2024-03-17 02:20:22 +00:00
|
|
|
#if SONG
|
|
|
|
// -DSONG=bopeebo
|
2023-06-27 00:39:47 +00:00
|
|
|
startSong(defineSong(), defineDifficulty());
|
2024-03-17 02:20:22 +00:00
|
|
|
#elseif LEVEL
|
|
|
|
// -DLEVEL=week1 -DDIFFICULTY=hard
|
2023-06-27 00:39:47 +00:00
|
|
|
startLevel(defineLevel(), defineDifficulty());
|
2024-03-17 02:20:22 +00:00
|
|
|
#elseif FREEPLAY
|
|
|
|
// -DFREEPLAY
|
2024-02-06 00:46:11 +00:00
|
|
|
FlxG.switchState(() -> new funkin.ui.freeplay.FreeplayState());
|
2024-03-17 02:20:22 +00:00
|
|
|
#elseif DIALOGUE
|
|
|
|
// -DDIALOGUE
|
2024-02-10 07:38:23 +00:00
|
|
|
FlxG.switchState(() -> new funkin.ui.debug.dialogue.ConversationDebugState());
|
2024-03-17 02:20:22 +00:00
|
|
|
#elseif ANIMATE
|
|
|
|
// -DANIMATE
|
2024-02-06 00:46:11 +00:00
|
|
|
FlxG.switchState(() -> new funkin.ui.debug.anim.FlxAnimateTest());
|
2024-03-17 02:20:22 +00:00
|
|
|
#elseif WAVEFORM
|
|
|
|
// -DWAVEFORM
|
2024-02-10 04:13:40 +00:00
|
|
|
FlxG.switchState(() -> new funkin.ui.debug.WaveformTestState());
|
2024-03-17 02:20:22 +00:00
|
|
|
#elseif CHARTING
|
|
|
|
// -DCHARTING
|
2024-02-06 00:46:11 +00:00
|
|
|
FlxG.switchState(() -> new funkin.ui.debug.charting.ChartEditorState());
|
2024-03-17 02:20:22 +00:00
|
|
|
#elseif STAGEBUILD
|
|
|
|
// -DSTAGEBUILD
|
2024-02-06 00:46:11 +00:00
|
|
|
FlxG.switchState(() -> new funkin.ui.debug.stage.StageBuilderState());
|
2024-05-18 00:26:34 +00:00
|
|
|
#elseif RESULTS
|
|
|
|
// -DRESULTS
|
|
|
|
FlxG.switchState(() -> new funkin.play.ResultState(
|
|
|
|
{
|
2023-09-24 04:53:53 +00:00
|
|
|
storyMode: true,
|
2024-05-31 05:42:41 +00:00
|
|
|
title: "Cum Song Erect by Kawai Sprite",
|
2024-05-30 09:25:51 +00:00
|
|
|
songId: "cum",
|
2024-07-04 02:50:39 +00:00
|
|
|
characterId: "pico-playable",
|
2024-05-31 05:42:41 +00:00
|
|
|
difficultyId: "nightmare",
|
2024-05-18 00:26:34 +00:00
|
|
|
isNewHighscore: true,
|
|
|
|
scoreData:
|
|
|
|
{
|
|
|
|
score: 1_234_567,
|
|
|
|
tallies:
|
|
|
|
{
|
|
|
|
sick: 130,
|
2024-06-05 04:40:14 +00:00
|
|
|
good: 60,
|
2024-05-18 00:26:34 +00:00
|
|
|
bad: 69,
|
|
|
|
shit: 69,
|
|
|
|
missed: 69,
|
|
|
|
combo: 69,
|
|
|
|
maxCombo: 69,
|
|
|
|
totalNotesHit: 140,
|
2024-07-07 08:10:37 +00:00
|
|
|
totalNotes: 190
|
2024-05-18 00:26:34 +00:00
|
|
|
}
|
2024-07-10 21:25:52 +00:00
|
|
|
// 2400 total notes = 7% = LOSS
|
|
|
|
// 240 total notes = 79% = GOOD
|
|
|
|
// 230 total notes = 82% = GREAT
|
|
|
|
// 210 total notes = 91% = EXCELLENT
|
|
|
|
// 190 total notes = PERFECT
|
2024-05-18 00:26:34 +00:00
|
|
|
},
|
|
|
|
}));
|
2024-03-17 02:20:22 +00:00
|
|
|
#elseif ANIMDEBUG
|
|
|
|
// -DANIMDEBUG
|
2024-02-06 00:46:11 +00:00
|
|
|
FlxG.switchState(() -> new funkin.ui.debug.anim.DebugBoundingState());
|
2024-03-17 02:20:22 +00:00
|
|
|
#elseif LATENCY
|
|
|
|
// -DLATENCY
|
2024-02-06 00:46:11 +00:00
|
|
|
FlxG.switchState(() -> new funkin.LatencyState());
|
2023-06-27 00:39:47 +00:00
|
|
|
#else
|
|
|
|
startGameNormally();
|
|
|
|
#end
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
/**
|
|
|
|
* Start the game by moving to the title state and play the game as normal.
|
|
|
|
*/
|
|
|
|
function startGameNormally():Void
|
|
|
|
{
|
2023-10-21 05:04:50 +00:00
|
|
|
var params:CLIParams = CLIUtil.processArgs();
|
|
|
|
trace('Command line args: ${params}');
|
|
|
|
|
|
|
|
if (params.chart.shouldLoadChart)
|
|
|
|
{
|
2024-02-06 00:46:11 +00:00
|
|
|
FlxG.switchState(() -> new ChartEditorState(
|
2023-10-21 05:04:50 +00:00
|
|
|
{
|
|
|
|
fnfcTargetPath: params.chart.chartPath,
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FlxG.sound.cache(Paths.music('freakyMenu/freakyMenu'));
|
2024-02-06 00:46:11 +00:00
|
|
|
FlxG.switchState(() -> new TitleState());
|
2023-10-21 05:04:50 +00:00
|
|
|
}
|
2023-06-27 00:39:47 +00:00
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
/**
|
|
|
|
* Start the game by directly loading into a specific song.
|
|
|
|
* @param songId
|
|
|
|
* @param difficultyId
|
|
|
|
*/
|
|
|
|
function startSong(songId:String, difficultyId:String = 'normal'):Void
|
|
|
|
{
|
2023-09-08 21:46:44 +00:00
|
|
|
var songData:funkin.play.song.Song = funkin.data.song.SongRegistry.instance.fetchEntry(songId);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
if (songData == null)
|
|
|
|
{
|
|
|
|
startGameNormally();
|
|
|
|
return;
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-04-08 22:39:51 +00:00
|
|
|
// TODO: Rework loading behavior so we don't have to do this.
|
|
|
|
switch (songId)
|
|
|
|
{
|
|
|
|
case 'tutorial' | 'bopeebo' | 'fresh' | 'dadbattle':
|
|
|
|
Paths.setCurrentLevel('week1');
|
|
|
|
PlayStatePlaylist.campaignId = 'week1';
|
|
|
|
case 'spookeez' | 'south' | 'monster':
|
|
|
|
Paths.setCurrentLevel('week2');
|
|
|
|
PlayStatePlaylist.campaignId = 'week2';
|
|
|
|
case 'pico' | 'philly-nice' | 'blammed':
|
|
|
|
Paths.setCurrentLevel('week3');
|
|
|
|
PlayStatePlaylist.campaignId = 'week3';
|
|
|
|
case 'high' | 'satin-panties' | 'milf':
|
|
|
|
Paths.setCurrentLevel('week4');
|
|
|
|
PlayStatePlaylist.campaignId = 'week4';
|
|
|
|
case 'cocoa' | 'eggnog' | 'winter-horrorland':
|
|
|
|
Paths.setCurrentLevel('week5');
|
|
|
|
PlayStatePlaylist.campaignId = 'week5';
|
|
|
|
case 'senpai' | 'roses' | 'thorns':
|
|
|
|
Paths.setCurrentLevel('week6');
|
|
|
|
PlayStatePlaylist.campaignId = 'week6';
|
|
|
|
case 'ugh' | 'guns' | 'stress':
|
|
|
|
Paths.setCurrentLevel('week7');
|
|
|
|
PlayStatePlaylist.campaignId = 'week7';
|
|
|
|
case 'darnell' | 'lit-up' | '2hot' | 'blazin':
|
|
|
|
Paths.setCurrentLevel('weekend1');
|
|
|
|
PlayStatePlaylist.campaignId = 'weekend1';
|
|
|
|
}
|
|
|
|
|
2024-02-17 04:48:43 +00:00
|
|
|
LoadingState.loadPlayState(
|
2023-06-27 00:39:47 +00:00
|
|
|
{
|
|
|
|
targetSong: songData,
|
|
|
|
targetDifficulty: difficultyId,
|
2024-02-17 04:48:43 +00:00
|
|
|
});
|
2023-06-27 00:39:47 +00:00
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
/**
|
|
|
|
* Start the game by directly loading into a specific story mode level.
|
|
|
|
* @param levelId
|
|
|
|
* @param difficultyId
|
|
|
|
*/
|
|
|
|
function startLevel(levelId:String, difficultyId:String = 'normal'):Void
|
|
|
|
{
|
2024-03-23 19:34:37 +00:00
|
|
|
var currentLevel:funkin.ui.story.Level = funkin.data.story.level.LevelRegistry.instance.fetchEntry(levelId);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
if (currentLevel == null)
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
2023-06-27 00:39:47 +00:00
|
|
|
startGameNormally();
|
|
|
|
return;
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
|
|
|
|
2024-04-08 22:39:51 +00:00
|
|
|
// TODO: Rework loading behavior so we don't have to do this.
|
|
|
|
Paths.setCurrentLevel(levelId);
|
|
|
|
PlayStatePlaylist.campaignId = levelId;
|
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
PlayStatePlaylist.playlistSongIds = currentLevel.getSongs();
|
|
|
|
PlayStatePlaylist.isStoryMode = true;
|
|
|
|
PlayStatePlaylist.campaignScore = 0;
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
var targetSongId:String = PlayStatePlaylist.playlistSongIds.shift();
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-09-08 21:46:44 +00:00
|
|
|
var targetSong:funkin.play.song.Song = SongRegistry.instance.fetchEntry(targetSongId);
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-02-17 04:48:43 +00:00
|
|
|
LoadingState.loadPlayState(
|
2023-06-27 00:39:47 +00:00
|
|
|
{
|
|
|
|
targetSong: targetSong,
|
|
|
|
targetDifficulty: difficultyId,
|
2024-02-17 04:48:43 +00:00
|
|
|
});
|
2023-06-27 00:39:47 +00:00
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2024-03-12 21:57:52 +00:00
|
|
|
function setupFlixelDebug():Void
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// FLIXEL DEBUG SETUP
|
|
|
|
//
|
2024-08-26 22:01:36 +00:00
|
|
|
#if FEATURE_DEBUG_FUNCTIONS
|
|
|
|
trace('Initializing Flixel debugger...');
|
|
|
|
|
|
|
|
#if !debug
|
|
|
|
// Make errors less annoying on release builds.
|
2024-03-12 21:57:52 +00:00
|
|
|
LogStyle.ERROR.openConsole = false;
|
|
|
|
LogStyle.ERROR.errorSound = null;
|
2024-08-26 22:01:36 +00:00
|
|
|
#end
|
|
|
|
|
|
|
|
// Make errors and warnings less annoying.
|
2024-03-12 21:57:52 +00:00
|
|
|
LogStyle.WARNING.openConsole = false;
|
|
|
|
LogStyle.WARNING.errorSound = null;
|
|
|
|
|
|
|
|
// Disable using ~ to open the console (we use that for the Editor menu)
|
|
|
|
FlxG.debugger.toggleKeys = [F2];
|
|
|
|
TrackerUtil.initTrackers();
|
|
|
|
// Adds an additional Close Debugger button.
|
|
|
|
// This big obnoxious white button is for MOBILE, so that you can press it
|
|
|
|
// easily with your finger when debug bullshit pops up during testing lol!
|
|
|
|
FlxG.debugger.addButton(LEFT, new BitmapData(200, 200), function() {
|
|
|
|
FlxG.debugger.visible = false;
|
|
|
|
|
|
|
|
// Make errors and warnings less annoying.
|
|
|
|
// Forcing this always since I have never been happy to have the debugger to pop up
|
|
|
|
LogStyle.ERROR.openConsole = false;
|
|
|
|
LogStyle.ERROR.errorSound = null;
|
|
|
|
LogStyle.WARNING.openConsole = false;
|
|
|
|
LogStyle.WARNING.errorSound = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Adds a red button to the debugger.
|
|
|
|
// This pauses the game AND the music! This ensures the Conductor stops.
|
|
|
|
FlxG.debugger.addButton(CENTER, new BitmapData(20, 20, true, 0xFFCC2233), function() {
|
|
|
|
if (FlxG.vcr.paused)
|
|
|
|
{
|
|
|
|
FlxG.vcr.resume();
|
|
|
|
|
|
|
|
for (snd in FlxG.sound.list)
|
|
|
|
{
|
|
|
|
snd.resume();
|
|
|
|
}
|
|
|
|
|
|
|
|
FlxG.sound.music.resume();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FlxG.vcr.pause();
|
|
|
|
|
|
|
|
for (snd in FlxG.sound.list)
|
|
|
|
{
|
|
|
|
snd.pause();
|
|
|
|
}
|
|
|
|
|
|
|
|
FlxG.sound.music.pause();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Adds a blue button to the debugger.
|
|
|
|
// This skips forward in the song.
|
|
|
|
FlxG.debugger.addButton(CENTER, new BitmapData(20, 20, true, 0xFF2222CC), function() {
|
|
|
|
FlxG.game.debugger.vcr.onStep();
|
|
|
|
|
|
|
|
for (snd in FlxG.sound.list)
|
|
|
|
{
|
|
|
|
snd.pause();
|
|
|
|
snd.time += FlxG.elapsed * 1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
FlxG.sound.music.pause();
|
|
|
|
FlxG.sound.music.time += FlxG.elapsed * 1000;
|
|
|
|
});
|
|
|
|
#end
|
|
|
|
}
|
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
function defineSong():String
|
|
|
|
{
|
|
|
|
return MacroUtil.getDefine('SONG');
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
function defineLevel():String
|
2023-01-23 00:55:30 +00:00
|
|
|
{
|
2023-06-27 00:39:47 +00:00
|
|
|
return MacroUtil.getDefine('LEVEL');
|
|
|
|
}
|
2023-01-23 00:55:30 +00:00
|
|
|
|
2023-06-27 00:39:47 +00:00
|
|
|
function defineDifficulty():String
|
|
|
|
{
|
|
|
|
return MacroUtil.getDefine('DIFFICULTY');
|
2023-01-23 00:55:30 +00:00
|
|
|
}
|
2022-02-10 01:24:33 +00:00
|
|
|
}
|