2020-10-03 06:50:15 +00:00
|
|
|
package;
|
|
|
|
|
|
|
|
import flixel.FlxGame;
|
2021-02-16 06:53:25 +00:00
|
|
|
import flixel.FlxState;
|
2023-08-28 19:03:29 +00:00
|
|
|
import funkin.util.logging.CrashHandler;
|
2023-11-07 09:04:22 +00:00
|
|
|
import funkin.ui.debug.MemoryCounter;
|
2023-10-17 04:38:28 +00:00
|
|
|
import funkin.save.Save;
|
2022-09-07 23:07:08 +00:00
|
|
|
import haxe.ui.Toolkit;
|
2020-10-04 06:42:58 +00:00
|
|
|
import openfl.display.FPS;
|
2020-10-03 06:50:15 +00:00
|
|
|
import openfl.display.Sprite;
|
2021-02-16 06:53:25 +00:00
|
|
|
import openfl.events.Event;
|
2023-08-28 19:03:29 +00:00
|
|
|
import openfl.Lib;
|
2021-03-05 00:36:56 +00:00
|
|
|
import openfl.media.Video;
|
2023-10-21 05:04:50 +00:00
|
|
|
import funkin.util.CLIUtil;
|
2021-03-05 00:36:56 +00:00
|
|
|
import openfl.net.NetStream;
|
2020-10-03 06:50:15 +00:00
|
|
|
|
|
|
|
class Main extends Sprite
|
|
|
|
{
|
2023-01-23 03:25:45 +00:00
|
|
|
var gameWidth:Int = 1280; // Width of the game in pixels (might be less / more in actual pixels depending on your zoom).
|
|
|
|
var gameHeight:Int = 720; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom).
|
|
|
|
var initialState:Class<FlxState> = funkin.InitState; // The FlxState the game starts with.
|
|
|
|
var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions.
|
|
|
|
#if web
|
|
|
|
var framerate:Int = 60; // How many frames per second the game should run at.
|
|
|
|
#else
|
|
|
|
// TODO: This should probably be in the options menu?
|
|
|
|
var framerate:Int = 144; // How many frames per second the game should run at.
|
|
|
|
#end
|
|
|
|
var skipSplash:Bool = true; // Whether to skip the flixel splash screen that appears in release mode.
|
|
|
|
var startFullscreen:Bool = false; // Whether to start the game in fullscreen on desktop targets
|
|
|
|
|
|
|
|
// You can pretty much ignore everything from here on - your code should go in your states.
|
|
|
|
|
|
|
|
public static function main():Void
|
|
|
|
{
|
|
|
|
Lib.current.addChild(new Main());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function new()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
|
|
|
|
// TODO: Replace this with loadEnabledMods().
|
|
|
|
funkin.modding.PolymodHandler.loadAllMods();
|
|
|
|
|
|
|
|
if (stage != null)
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
addEventListener(Event.ADDED_TO_STAGE, init);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function init(?event:Event):Void
|
|
|
|
{
|
|
|
|
if (hasEventListener(Event.ADDED_TO_STAGE))
|
|
|
|
{
|
|
|
|
removeEventListener(Event.ADDED_TO_STAGE, init);
|
|
|
|
}
|
|
|
|
|
|
|
|
setupGame();
|
|
|
|
}
|
|
|
|
|
|
|
|
var video:Video;
|
|
|
|
var netStream:NetStream;
|
|
|
|
var overlay:Sprite;
|
|
|
|
|
|
|
|
public static var fpsCounter:FPS;
|
|
|
|
public static var memoryCounter:MemoryCounter;
|
|
|
|
|
|
|
|
function setupGame():Void
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The `zoom` argument of FlxGame was removed in the dev branch of Flixel,
|
|
|
|
* since it was considered confusing and unintuitive.
|
|
|
|
* If you want to change how the game scales when you resize the window,
|
|
|
|
* you can use `FlxG.scaleMode`.
|
|
|
|
* -Eric
|
|
|
|
*/
|
|
|
|
|
2023-08-28 19:03:29 +00:00
|
|
|
CrashHandler.initialize();
|
|
|
|
|
|
|
|
CrashHandler.queryStatus();
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
initHaxeUI();
|
|
|
|
|
|
|
|
fpsCounter = new FPS(10, 3, 0xFFFFFF);
|
2023-10-17 04:38:28 +00:00
|
|
|
// addChild(fpsCounter); // Handled by Preferences.init
|
2023-01-23 03:25:45 +00:00
|
|
|
#if !html5
|
|
|
|
memoryCounter = new MemoryCounter(10, 13, 0xFFFFFF);
|
2023-10-17 04:38:28 +00:00
|
|
|
// addChild(memoryCounter);
|
2023-01-23 03:25:45 +00:00
|
|
|
#end
|
2023-10-17 04:38:28 +00:00
|
|
|
|
|
|
|
// George recommends binding the save before FlxGame is created.
|
|
|
|
Save.load();
|
|
|
|
|
|
|
|
addChild(new FlxGame(gameWidth, gameHeight, initialState, framerate, framerate, skipSplash, startFullscreen));
|
|
|
|
|
|
|
|
#if hxcpp_debug_server
|
|
|
|
trace('hxcpp_debug_server is enabled! You can now connect to the game with a debugger.');
|
2023-01-23 03:25:45 +00:00
|
|
|
#end
|
|
|
|
}
|
|
|
|
|
|
|
|
function initHaxeUI():Void
|
|
|
|
{
|
|
|
|
// Calling this before any HaxeUI components get used is important:
|
|
|
|
// - It initializes the theme styles.
|
|
|
|
// - It scans the class path and registers any HaxeUI components.
|
|
|
|
Toolkit.init();
|
|
|
|
Toolkit.theme = 'dark'; // don't be cringe
|
2023-08-01 17:07:16 +00:00
|
|
|
Toolkit.autoScale = false;
|
2023-10-31 18:43:01 +00:00
|
|
|
funkin.input.Cursor.registerHaxeUICursors();
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
2020-10-03 06:50:15 +00:00
|
|
|
}
|