Files
CodenameEngine/source/funkin/system/MainState.hx
T

50 lines
1.4 KiB
Haxe

package funkin.system;
import sys.FileSystem;
import funkin.mods.ModsFolder;
import funkin.menus.TitleState;
import funkin.menus.BetaWarningState;
import flixel.FlxState;
/**
* Simple state used for loading the game
*/
class MainState extends FlxState {
public static var initiated:Bool = false;
public static var betaWarningShown:Bool = false;
public override function create() {
super.create();
if (!initiated)
Main.loadGameSettings();
initiated = true;
Options.save();
FlxG.bitmap.reset();
FlxG.sound.destroy(true);
Paths.assetsTree.reset();
#if MOD_SUPPORT
if (ModsFolder.currentModFolder != null)
Paths.assetsTree.addLibrary(ModsFolder.loadModLib('${ModsFolder.modsPath}${ModsFolder.currentModFolder}'));
if (FileSystem.exists(ModsFolder.addonsPath) && FileSystem.isDirectory(ModsFolder.addonsPath))
for(addon in [for(dir in FileSystem.readDirectory(ModsFolder.addonsPath)) if (FileSystem.isDirectory('${ModsFolder.addonsPath}$dir')) dir])
Paths.assetsTree.addLibrary(ModsFolder.loadModLib('${ModsFolder.addonsPath}$addon'));
#end
Main.refreshAssets();
ModsFolder.onModSwitch.dispatch(ModsFolder.currentModFolder);
DiscordUtil.reloadJsonData();
TitleState.initialized = false;
if (betaWarningShown)
FlxG.switchState(new TitleState());
else {
FlxG.switchState(new BetaWarningState());
betaWarningShown = true;
}
}
}