From ac5c26423c9fe5d552af664c55997034cdbe79de Mon Sep 17 00:00:00 2001 From: Altertoriel Date: Sun, 22 Dec 2024 22:00:51 +0900 Subject: [PATCH 1/4] fix `FPSCounter` counting --- source/debug/FPSCounter.hx | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/source/debug/FPSCounter.hx b/source/debug/FPSCounter.hx index 297a81a0c1d..2fb43d7d7dd 100644 --- a/source/debug/FPSCounter.hx +++ b/source/debug/FPSCounter.hx @@ -10,19 +10,6 @@ class FPSCounter extends TextField { public var currentFPS(default, null):Float; - /* - inline function gay():Float - { - #if (cpp && windows) - return 0; - #elseif cpp - return cpp.vm.Gc.memInfo64(cpp.vm.Gc.MEM_INFO_USAGE); - #else - return cast(openfl.system.System.totalMemory, UInt); - #end - } - */ - /** The current memory usage (WARNING: this is NOT your total program memory usage, rather it shows the garbage collector memory) **/ @@ -56,17 +43,17 @@ class FPSCounter extends TextField var fpsMultiplier:Float = 1.0; var deltaTimeout:Float = 0.0; + public var timeoutDelay:Float = 1000; // Event Handlers override function __enterFrame(deltaTime:Float):Void { - if (deltaTimeout > 1000) { - deltaTimeout = 0.0; - return; - } - final now:Float = haxe.Timer.stamp() * 1000; times.push(now); while (times[0] < now - 1000 / fpsMultiplier) times.shift(); + if (deltaTimeout < timeoutDelay) { + deltaTimeout += deltaTime; + return; + } if (Std.isOfType(FlxG.state, PlayState) && !PlayState.instance.trollingMode) { try { fpsMultiplier = PlayState.instance.playbackRate; } @@ -78,7 +65,6 @@ class FPSCounter extends TextField currentFPS = Math.min(FlxG.drawFramerate, times.length) / fpsMultiplier; updateText(); - deltaTimeout += deltaTime; if (ClientPrefs.rainbowFPS) { @@ -97,6 +83,7 @@ class FPSCounter extends TextField if (currentFPS <= ClientPrefs.framerate / 4) textColor = 0xFFFF0000; } + deltaTimeout = 0.0; } public dynamic function updateText():Void { // so people can override it in hscript @@ -113,4 +100,4 @@ class FPSCounter extends TextField text += "\nSystem: " + '${System.platformLabel} ${System.platformVersion}'; } } -} +} \ No newline at end of file From 568749532c928080481132365d8e2b20b05de8b2 Mon Sep 17 00:00:00 2001 From: Altertoriel Date: Sun, 22 Dec 2024 22:04:19 +0900 Subject: [PATCH 2/4] `FPSCounter` updates more times per second now --- source/debug/FPSCounter.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/debug/FPSCounter.hx b/source/debug/FPSCounter.hx index 2fb43d7d7dd..672e9c5a11a 100644 --- a/source/debug/FPSCounter.hx +++ b/source/debug/FPSCounter.hx @@ -43,7 +43,7 @@ class FPSCounter extends TextField var fpsMultiplier:Float = 1.0; var deltaTimeout:Float = 0.0; - public var timeoutDelay:Float = 1000; + public var timeoutDelay:Float = 500; // Event Handlers override function __enterFrame(deltaTime:Float):Void { From f03dd310243bc58c7de7121be15c703f33c961c9 Mon Sep 17 00:00:00 2001 From: Altertoriel Date: Sun, 22 Dec 2024 22:12:18 +0900 Subject: [PATCH 3/4] Fix hxdiscord_rpc --- source/DiscordClient.hx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/DiscordClient.hx b/source/DiscordClient.hx index 80316915dc7..17b56b51c18 100644 --- a/source/DiscordClient.hx +++ b/source/DiscordClient.hx @@ -73,11 +73,11 @@ class DiscordClient public static function initialize() { - var discordHandlers:DiscordEventHandlers = DiscordEventHandlers.create(); + final handlers:DiscordEventHandlers = new DiscordEventHandlers(); discordHandlers.ready = Function.fromStaticFunction(onReady); discordHandlers.disconnected = Function.fromStaticFunction(onDisconnected); discordHandlers.errored = Function.fromStaticFunction(onError); - Discord.Initialize(clientID, cpp.RawPointer.addressOf(discordHandlers), 1, null); + Discord.Initialize(clientID, cpp.RawPointer.addressOf(discordHandlers), true, null); if(!isInitialized) trace("Discord Client initialized"); @@ -171,7 +171,7 @@ final class DiscordPresence function new() { - __presence = DiscordRichPresence.create(); + __presence = new DiscordRichPresence(); } public function toString():String From e05788106ca63dd119b6ca3743bf521974f8ee38 Mon Sep 17 00:00:00 2001 From: Altertoriel Date: Sun, 22 Dec 2024 22:21:56 +0900 Subject: [PATCH 4/4] oops --- source/DiscordClient.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/DiscordClient.hx b/source/DiscordClient.hx index 17b56b51c18..56ca9dd89ae 100644 --- a/source/DiscordClient.hx +++ b/source/DiscordClient.hx @@ -73,7 +73,7 @@ class DiscordClient public static function initialize() { - final handlers:DiscordEventHandlers = new DiscordEventHandlers(); + final discordHandlers:DiscordEventHandlers = new DiscordEventHandlers(); discordHandlers.ready = Function.fromStaticFunction(onReady); discordHandlers.disconnected = Function.fromStaticFunction(onDisconnected); discordHandlers.errored = Function.fromStaticFunction(onError);