@@ -26,7 +26,7 @@ import crowplexus.iris.Iris;
2626import psychlua .HScript .HScriptInfos ;
2727#end
2828
29- #if linux
29+ #if ( linux || mac)
3030import lime .graphics .Image ;
3131#end
3232
@@ -54,6 +54,7 @@ import backend.Highscore;
5454@:cppInclude (' ./external/gamemode_client.h' )
5555@:cppFileCode (' #define GAMEMODE_AUTO' )
5656#end
57+
5758#if windows
5859@:buildXml ('
5960<target id="haxe">
@@ -71,7 +72,7 @@ extern "C" HRESULT WINAPI SetCurrentProcessExplicitAppUserModelID(PCWSTR AppID);
7172// // // // // // // // //
7273class Main extends Sprite
7374{
74- var game = {
75+ public static final game = {
7576 width : 1280 , // WINDOW width
7677 height : 720 , // WINDOW height
7778 initialState : states. FirstCheckState , // initial game state
@@ -99,18 +100,8 @@ class Main extends Sprite
99100 public function new ()
100101 {
101102 super ();
102- #if windows
103- // DPI Scaling fix for windows
104- // this shouldn't be needed for other systems
105- // Credit to YoshiCrafter29 for finding this function
106- untyped __cpp__ (" SetProcessDPIAware();" );
107-
108- var display = lime.system. System .getDisplay (0 );
109- if (display != null ) {
110- var dpiScale : Float = display .dpi / 96 ;
111- Application .current .window .width = Std .int (game .width * dpiScale );
112- Application .current .window .height = Std .int (game .height * dpiScale );
113- }
103+ #if (cpp && windows)
104+ backend.window. Native .fixScaling ();
114105 #end
115106
116107 // Credits to MAJigsaw77 (he's the og author for this code)
@@ -222,7 +213,7 @@ class Main extends Sprite
222213 }
223214 #end
224215
225- #if linux
216+ #if ( linux || mac) // fix the app icon not showing up on the Linux Panel / Mac Dock
226217 var icon = Image .fromFile (" icon.png" );
227218 Lib .current .stage .window .setIcon (icon );
228219 #end
@@ -247,6 +238,10 @@ class Main extends Sprite
247238 DiscordClient .prepare ();
248239 #end
249240
241+ FlxG .fixedTimestep = false ;
242+ FlxG .game .focusLostFramerate = 60 ;
243+ FlxG .keys .preventDefaultKeys = [TAB ];
244+
250245 Lib .current .loaderInfo .addEventListener (NativeProcessExitEvent .EXIT , onClosing ); // help-
251246
252247 // try { // WHY THE HELL IS THIS CRASHING???????????????????
@@ -475,8 +470,7 @@ class Main extends Sprite
475470 } else {
476471 Application .current .window .alert (" The game encountered a critical error and will now restart." , " Game Bricked" );
477472 trace (" The game was bricked. Restarting..." );
478- var mainInstance = new Main ();
479- var mainGame = mainInstance .game ;
473+ var mainGame = Main .game ;
480474 var initialState = Type .getClass (mainGame .initialState );
481475 var restartProcess = new Process (" Mixtape.exe" , [" GameJoltBug" , " restart" ]);
482476 FlxG .switchState (new states. ExitState ());
@@ -487,8 +481,7 @@ class Main extends Sprite
487481 case " APDisconnectSubstate" :
488482 Application .current .window .alert (" The game encountered a critical error and will now restart." , " AP Disconnect Error" );
489483 trace (" AP Disconnect Error. Restarting..." );
490- var mainInstance = new Main ();
491- var mainGame = mainInstance .game ;
484+ var mainGame = Main .game ;
492485 var initialState = Type .getClass (mainGame .initialState );
493486 var restartProcess = new Process (" Mixtape.exe" , [" APDisconnectError" , " restart" ]);
494487 // FlxG.switchState(new states.ExitState());
@@ -507,8 +500,7 @@ class Main extends Sprite
507500 }
508501
509502 if (! handled ) {
510- var mainInstance = new Main ();
511- var mainGame = mainInstance .game ;
503+ var mainGame = Main .game ;
512504 FlxG .switchState (Type .createInstance (states. TitleState , []));
513505 trace (" Unhandled state: " + (Type .getClassName (Type .getClass (FlxG .state ))));
514506 trace (" Restarting Game..." );
0 commit comments