2022-03-08 03:13:53 -05:00
|
|
|
package funkin;
|
2021-09-07 17:09:34 -04:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
import funkin.play.stage.StageData.StageDataParser;
|
2021-09-07 17:09:34 -04:00
|
|
|
import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond;
|
|
|
|
import flixel.addons.transition.FlxTransitionableState;
|
|
|
|
import flixel.addons.transition.TransitionData;
|
|
|
|
import flixel.graphics.FlxGraphic;
|
|
|
|
import flixel.math.FlxPoint;
|
|
|
|
import flixel.math.FlxRect;
|
2023-01-06 03:21:54 -05:00
|
|
|
import flixel.system.debug.log.LogStyle;
|
2021-09-07 17:09:34 -04:00
|
|
|
import flixel.util.FlxColor;
|
2022-04-18 19:46:39 -04:00
|
|
|
import funkin.modding.module.ModuleHandler;
|
2022-03-25 17:56:47 -04:00
|
|
|
import funkin.play.PlayState;
|
2022-04-18 20:39:41 -04:00
|
|
|
import funkin.play.character.CharacterData.CharacterDataParser;
|
2023-01-22 19:55:30 -05:00
|
|
|
import funkin.play.event.SongEvent.SongEventParser;
|
2022-09-13 01:09:30 -04:00
|
|
|
import funkin.play.song.SongData.SongDataParser;
|
2022-03-08 03:13:53 -05:00
|
|
|
import funkin.ui.PreferencesMenu;
|
2023-01-02 17:40:53 -05:00
|
|
|
import funkin.util.WindowUtil;
|
2023-01-06 03:21:54 -05:00
|
|
|
import funkin.util.macro.MacroUtil;
|
2022-03-25 17:56:47 -04:00
|
|
|
import openfl.display.BitmapData;
|
2021-09-07 17:09:34 -04:00
|
|
|
#if discord_rpc
|
|
|
|
import Discord.DiscordClient;
|
|
|
|
#end
|
|
|
|
|
2022-02-23 16:49:54 -05:00
|
|
|
/**
|
|
|
|
* Initializes the game state using custom defines.
|
|
|
|
* Only used in Debug builds.
|
|
|
|
*/
|
2021-09-07 17:09:34 -04:00
|
|
|
class InitState extends FlxTransitionableState
|
|
|
|
{
|
2023-01-22 19:55:30 -05:00
|
|
|
override public function create():Void
|
|
|
|
{
|
|
|
|
trace('This is a debug build, loading InitState...');
|
|
|
|
#if android
|
|
|
|
FlxG.android.preventDefaultKeys = [flixel.input.android.FlxAndroidKey.BACK];
|
|
|
|
#end
|
|
|
|
#if newgrounds
|
|
|
|
NGio.init();
|
|
|
|
#end
|
|
|
|
#if discord_rpc
|
|
|
|
DiscordClient.initialize();
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
Application.current.onExit.add(function(exitCode) {
|
2023-01-22 19:55:30 -05:00
|
|
|
DiscordClient.shutdown();
|
|
|
|
});
|
|
|
|
#end
|
|
|
|
|
|
|
|
// ==== flixel shit ==== //
|
|
|
|
|
|
|
|
// 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!
|
2023-01-22 22:25:45 -05:00
|
|
|
FlxG.debugger.addButton(LEFT, new BitmapData(200, 200), function() {
|
2023-01-22 19:55:30 -05:00
|
|
|
FlxG.debugger.visible = false;
|
|
|
|
});
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
FlxG.debugger.addButton(CENTER, new BitmapData(20, 20, true, 0xFFCC2233), function() {
|
2023-01-22 20:03:08 -05:00
|
|
|
if (FlxG.vcr.paused)
|
|
|
|
{
|
|
|
|
FlxG.vcr.resume();
|
|
|
|
|
|
|
|
for (snd in FlxG.sound.list)
|
2023-01-22 22:25:45 -05:00
|
|
|
{
|
2023-01-22 20:03:08 -05:00
|
|
|
snd.resume();
|
2023-01-22 22:25:45 -05:00
|
|
|
}
|
2023-01-22 20:03:08 -05:00
|
|
|
|
|
|
|
FlxG.sound.music.resume();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FlxG.vcr.pause();
|
|
|
|
|
|
|
|
for (snd in FlxG.sound.list)
|
2023-01-22 22:25:45 -05:00
|
|
|
{
|
2023-01-22 20:03:08 -05:00
|
|
|
snd.pause();
|
2023-01-22 22:25:45 -05:00
|
|
|
}
|
2023-01-22 20:03:08 -05:00
|
|
|
|
|
|
|
FlxG.sound.music.pause();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-05-22 20:55:53 -04:00
|
|
|
#if FLX_DEBUG
|
2023-01-22 22:25:45 -05:00
|
|
|
FlxG.debugger.addButton(CENTER, new BitmapData(20, 20, true, 0xFF2222CC), function() {
|
2023-01-22 20:03:08 -05:00
|
|
|
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;
|
|
|
|
});
|
2023-05-22 20:55:53 -04:00
|
|
|
#end
|
2023-01-22 20:03:08 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
FlxG.sound.muteKeys = [ZERO];
|
|
|
|
FlxG.game.focusLostFramerate = 60;
|
|
|
|
|
|
|
|
// FlxG.stage.window.borderless = true;
|
|
|
|
// FlxG.stage.window.mouseLock = true;
|
|
|
|
|
|
|
|
var diamond:FlxGraphic = FlxGraphic.fromClass(GraphicTransTileDiamond);
|
|
|
|
diamond.persist = true;
|
|
|
|
diamond.destroyOnNoUse = false;
|
|
|
|
|
|
|
|
FlxTransitionableState.defaultTransIn = new TransitionData(FADE, FlxColor.BLACK, 1, new FlxPoint(0, -1), {asset: diamond, width: 32, height: 32},
|
|
|
|
new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4));
|
|
|
|
FlxTransitionableState.defaultTransOut = new TransitionData(FADE, FlxColor.BLACK, 0.7, new FlxPoint(0, 1), {asset: diamond, width: 32, height: 32},
|
|
|
|
new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4));
|
|
|
|
|
|
|
|
// ===== save shit ===== //
|
|
|
|
|
|
|
|
FlxG.save.bind('funkin', 'ninjamuffin99');
|
|
|
|
|
|
|
|
// https://github.com/HaxeFlixel/flixel/pull/2396
|
|
|
|
// IF/WHEN MY PR GOES THRU AND IT GETS INTO MAIN FLIXEL, DELETE THIS CHUNKOF CODE, AND THEN UNCOMMENT THE LINE BELOW
|
|
|
|
// FlxG.sound.loadSavedPrefs();
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
if (FlxG.save.data.volume != null) FlxG.sound.volume = FlxG.save.data.volume;
|
|
|
|
if (FlxG.save.data.mute != null) FlxG.sound.muted = FlxG.save.data.mute;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Make errors and warnings less annoying.
|
|
|
|
LogStyle.ERROR.openConsole = false;
|
|
|
|
LogStyle.ERROR.errorSound = null;
|
|
|
|
LogStyle.WARNING.openConsole = false;
|
|
|
|
LogStyle.WARNING.errorSound = null;
|
|
|
|
|
|
|
|
// FlxG.save.close();
|
|
|
|
// FlxG.sound.loadSavedPrefs();
|
|
|
|
WindowUtil.initWindowEvents();
|
|
|
|
WindowUtil.disableCrashHandler();
|
|
|
|
|
|
|
|
PreferencesMenu.initPrefs();
|
|
|
|
PlayerSettings.init();
|
|
|
|
Highscore.load();
|
|
|
|
|
|
|
|
if (FlxG.save.data.weekUnlocked != null)
|
|
|
|
{
|
|
|
|
// FIX LATER!!!
|
|
|
|
// WEEK UNLOCK PROGRESSION!!
|
|
|
|
// StoryMenuState.weekUnlocked = FlxG.save.data.weekUnlocked;
|
|
|
|
|
2023-06-01 15:59:56 -04:00
|
|
|
// if (StoryMenuState.weekUnlocked.length < 4) StoryMenuState.weekUnlocked.insert(0, true);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// QUICK PATCH OOPS!
|
2023-06-01 15:59:56 -04:00
|
|
|
// if (!StoryMenuState.weekUnlocked[0]) StoryMenuState.weekUnlocked[0] = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
if (FlxG.save.data.seenVideo != null) VideoState.seenVideo = FlxG.save.data.seenVideo;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// ===== fuck outta here ===== //
|
|
|
|
|
|
|
|
// FlxTransitionableState.skipNextTransOut = true;
|
|
|
|
FlxTransitionableState.skipNextTransIn = true;
|
|
|
|
|
|
|
|
// TODO: Register custom event callbacks here
|
|
|
|
|
2023-05-17 16:42:58 -04:00
|
|
|
funkin.data.level.LevelRegistry.instance.loadEntries();
|
2023-01-22 19:55:30 -05:00
|
|
|
SongEventParser.loadEventCache();
|
|
|
|
SongDataParser.loadSongCache();
|
|
|
|
StageDataParser.loadStageCache();
|
|
|
|
CharacterDataParser.loadCharacterCache();
|
|
|
|
ModuleHandler.buildModuleCallbacks();
|
|
|
|
ModuleHandler.loadModuleCache();
|
|
|
|
|
|
|
|
FlxG.debugger.toggleKeys = [F2];
|
|
|
|
|
|
|
|
ModuleHandler.callOnCreate();
|
|
|
|
|
|
|
|
#if song
|
2023-01-22 22:25:45 -05:00
|
|
|
var song:String = getSong();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
var weeks:Array<Array<String>> = [
|
2023-01-22 19:55:30 -05:00
|
|
|
['bopeebo', 'fresh', 'dadbattle'],
|
|
|
|
['spookeez', 'south', 'monster'],
|
|
|
|
['spooky', 'spooky', 'monster'],
|
|
|
|
['pico', 'philly', 'blammed'],
|
|
|
|
['satin-panties', 'high', 'milf'],
|
|
|
|
['cocoa', 'eggnog', 'winter-horrorland'],
|
|
|
|
['senpai', 'roses', 'thorns'],
|
|
|
|
['ugh', 'guns', 'stress']
|
|
|
|
];
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
var week:Int = 0;
|
2023-01-22 19:55:30 -05:00
|
|
|
for (i in 0...weeks.length)
|
|
|
|
{
|
|
|
|
if (weeks[i].contains(song))
|
|
|
|
{
|
|
|
|
week = i + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
if (week == 0) throw 'Invalid -D song=$song';
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
startSong(week, song, false);
|
|
|
|
#elseif week
|
2023-01-22 22:25:45 -05:00
|
|
|
var week:Int = getWeek();
|
|
|
|
|
|
|
|
var songs:Array<String> = [
|
|
|
|
'bopeebo',
|
|
|
|
'spookeez',
|
|
|
|
'spooky',
|
|
|
|
'pico',
|
|
|
|
'satin-panties',
|
|
|
|
'cocoa',
|
|
|
|
'senpai',
|
|
|
|
'ugh'
|
2023-01-22 19:55:30 -05:00
|
|
|
];
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
if (week <= 0 || week >= songs.length) throw 'invalid -D week=' + week;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
startSong(week, songs[week - 1], true);
|
|
|
|
#elseif FREEPLAY
|
|
|
|
FlxG.switchState(new FreeplayState());
|
|
|
|
#elseif ANIMATE
|
2023-02-21 20:58:15 -05:00
|
|
|
FlxG.switchState(new funkin.ui.animDebugShit.FlxAnimateTest());
|
2023-01-22 19:55:30 -05:00
|
|
|
#elseif CHARTING
|
|
|
|
FlxG.switchState(new ChartingState());
|
|
|
|
#elseif STAGEBUILD
|
|
|
|
FlxG.switchState(new StageBuilderState());
|
|
|
|
#elseif FIGHT
|
|
|
|
FlxG.switchState(new PicoFight());
|
|
|
|
#elseif ANIMDEBUG
|
|
|
|
FlxG.switchState(new funkin.ui.animDebugShit.DebugBoundingState());
|
|
|
|
#elseif LATENCY
|
|
|
|
FlxG.switchState(new LatencyState());
|
|
|
|
#elseif NETTEST
|
|
|
|
FlxG.switchState(new netTest.NetTest());
|
|
|
|
#else
|
|
|
|
FlxG.sound.cache(Paths.music('freakyMenu'));
|
|
|
|
FlxG.switchState(new TitleState());
|
|
|
|
#end
|
|
|
|
}
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
function startSong(week, song, isStoryMode):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
var dif:Int = getDif();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
PlayState.currentSong = SongLoad.loadFromJson(song, song);
|
|
|
|
PlayState.currentSong_NEW = SongDataParser.fetchSong(song);
|
|
|
|
PlayState.isStoryMode = isStoryMode;
|
|
|
|
PlayState.storyDifficulty = dif;
|
|
|
|
PlayState.storyDifficulty_NEW = switch (dif)
|
|
|
|
{
|
|
|
|
case 0: 'easy';
|
|
|
|
case 1: 'normal';
|
|
|
|
case 2: 'hard';
|
|
|
|
default: 'normal';
|
|
|
|
};
|
|
|
|
SongLoad.curDiff = PlayState.storyDifficulty_NEW;
|
|
|
|
PlayState.storyWeek = week;
|
|
|
|
LoadingState.loadAndSwitchState(new PlayState());
|
|
|
|
}
|
2022-02-09 20:24:33 -05:00
|
|
|
}
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
function getWeek():Int
|
|
|
|
return Std.parseInt(MacroUtil.getDefine('week'));
|
2022-02-11 14:21:42 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
function getSong():String
|
|
|
|
return MacroUtil.getDefine('song');
|
2022-02-11 14:21:42 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
function getDif():Int
|
|
|
|
return Std.parseInt(MacroUtil.getDefine('dif', '1'));
|