From d7c4b8d4444a0f8c97f993c1762e755e02bce1af Mon Sep 17 00:00:00 2001
From: crowplexus <45212377+crowplexus@users.noreply.github.com>
Date: Thu, 9 Jan 2025 11:18:05 -0400
Subject: [PATCH] enable hgih DPI awareness
---
Project.xml | 2 +-
source/Main.hx | 76 +++++++++++++++++++-------------------------------
2 files changed, 30 insertions(+), 48 deletions(-)
diff --git a/Project.xml b/Project.xml
index 62791bded88..5fa2072745c 100644
--- a/Project.xml
+++ b/Project.xml
@@ -40,7 +40,7 @@
-
+
diff --git a/source/Main.hx b/source/Main.hx
index 5489e78332e..9b6057a8e7c 100644
--- a/source/Main.hx
+++ b/source/Main.hx
@@ -4,7 +4,7 @@ package;
import android.content.Context;
#end
-import debug.FPSCounter;
+import backend.FPSCounter;
import flixel.graphics.FlxGraphic;
import flixel.FlxGame;
@@ -35,20 +35,32 @@ import haxe.io.Path;
import backend.Highscore;
-#if linux
+// NATIVE API STUFF, YOU CAN IGNORE THIS AND SCROLL //
+#if (linux && !debug)
@:cppInclude('./external/gamemode_client.h')
+@:cppFileCode('#define GAMEMODE_AUTO')
+#end
+#if windows
+@:buildXml('
+
+
+
+
+')
@:cppFileCode('
- #define GAMEMODE_AUTO
+#include
+#include
+#pragma comment(lib, "Shell32.lib")
+extern "C" HRESULT WINAPI SetCurrentProcessExplicitAppUserModelID(PCWSTR AppID);
')
#end
-
+// // // // // // // // //
class Main extends Sprite
{
var game = {
width: 1280, // WINDOW width
height: 720, // WINDOW height
initialState: TitleState, // initial game state
- zoom: -1.0, // game state bounds
framerate: 60, // default framerate
skipSplash: true, // if the default flixel splash screen should be skipped
startFullscreen: false // if the game should start at fullscreen mode
@@ -67,49 +79,22 @@ class Main extends Sprite
{
super();
+ #if windows
+ // DPI Scaling fix for windows
+ // this shouldn't be needed for other systems
+ // Credit to YoshiCrafter29 for finding this function
+ untyped __cpp__("SetProcessDPIAware();");
+ #end
+
// Credits to MAJigsaw77 (he's the og author for this code)
#if android
Sys.setCwd(Path.addTrailingSlash(Context.getExternalFilesDir()));
#elseif ios
Sys.setCwd(lime.system.System.applicationStorageDirectory);
#end
-
- if (stage != null)
- {
- init();
- }
- else
- {
- addEventListener(Event.ADDED_TO_STAGE, init);
- }
#if VIDEOS_ALLOWED
hxvlc.util.Handle.init(#if (hxvlc >= "1.8.0") ['--no-lua'] #end);
#end
- }
-
- private function init(?E:Event):Void
- {
- if (hasEventListener(Event.ADDED_TO_STAGE))
- {
- removeEventListener(Event.ADDED_TO_STAGE, init);
- }
-
- setupGame();
- }
-
- private function setupGame():Void
- {
- var stageWidth:Int = Lib.current.stage.stageWidth;
- var stageHeight:Int = Lib.current.stage.stageHeight;
-
- if (game.zoom == -1.0)
- {
- var ratioX:Float = stageWidth / game.width;
- var ratioY:Float = stageHeight / game.height;
- game.zoom = Math.min(ratioX, ratioY);
- game.width = Math.ceil(stageWidth / game.zoom);
- game.height = Math.ceil(stageHeight / game.zoom);
- }
#if LUA_ALLOWED
Mods.pushGlobalMods();
@@ -117,14 +102,13 @@ class Main extends Sprite
Mods.loadTopMod();
FlxG.save.bind('funkin', CoolUtil.getSavePath());
-
Highscore.load();
#if LUA_ALLOWED Lua.set_callbacks_function(cpp.Callable.fromStaticFunction(psychlua.CallbackHandler.call)); #end
Controls.instance = new Controls();
ClientPrefs.loadDefaultKeys();
#if ACHIEVEMENTS_ALLOWED Achievements.load(); #end
- addChild(new FlxGame(game.width, game.height, game.initialState, #if (flixel < "5.0.0") game.zoom, #end game.framerate, game.framerate, game.skipSplash, game.startFullscreen));
+ addChild(new FlxGame(game.width, game.height, game.initialState, game.framerate, game.framerate, game.skipSplash, game.startFullscreen));
#if !mobile
fpsVar = new FPSCounter(10, 3, 0xFFFFFF);
@@ -206,14 +190,12 @@ class Main extends Sprite
}
errMsg += "\nUncaught Error: " + e.error;
- /*
- * remove if you're modding and want the crash log message to contain the link
- * please remember to actually modify the link for the github page to report the issues to.
- */
- //
+ // remove if you're modding and want the crash log message to contain the link
+ // please remember to actually modify the link for the github page to report the issues to.
#if officialBuild
- errMsg += "\nPlease report this error to the GitHub page: https://github.com/ShadowMario/FNF-PsychEngine\n\n> Crash Handler written by: sqirra-rng";
+ errMsg += "\nPlease report this error to the GitHub page: https://github.com/ShadowMario/FNF-PsychEngine";
#end
+ errMsg += "\n\n> Crash Handler written by: sqirra-rng";
if (!FileSystem.exists("./crash/"))
FileSystem.createDirectory("./crash/");