From c466e1aa124f3769a3efc8efcceef307a7608833 Mon Sep 17 00:00:00 2001 From: KarimAkra Date: Sun, 22 Dec 2024 23:57:10 +0200 Subject: [PATCH] Refactor positioning of FPS and memory counters for mobile --- source/Main.hx | 6 +++--- .../system/scaleModes/FullScreenScaleMode.hx | 18 +++++++++--------- source/funkin/Preferences.hx | 16 ---------------- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/source/Main.hx b/source/Main.hx index 56ad3ac88..15c7ab7bc 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -184,7 +184,7 @@ class Main extends Sprite { fpsCounter.scaleX = fpsCounter.scaleY = #if android (scale > 1 ? scale : 1) #else (scale < 1 ? scale : 1) #end; #if mobile - fpsCounter.x = 10 + FullScreenScaleMode.notchSize.x; + fpsCounter.x = FlxG.game.x + FullScreenScaleMode.notchSize.x +; #end } @@ -192,9 +192,9 @@ class Main extends Sprite { memoryCounter.scaleX = memoryCounter.scaleY = scale; - memoryCounter.y = 13 * #if android (scale > 1 ? scale : 1) #else (scale < 1 ? scale : 1) #end; + memoryCounter.y = FlxG.game.y + (13 * #if android (scale > 1 ? scale : 1) #else (scale < 1 ? scale : 1) #end); #if mobile - memoryCounter.x = 10 + FullScreenScaleMode.notchSize.x; + memoryCounter.x = FlxG.game.x + FullScreenScaleMode.notchSize.x + 10; #end } } diff --git a/source/flixel/system/scaleModes/FullScreenScaleMode.hx b/source/flixel/system/scaleModes/FullScreenScaleMode.hx index b54da21dd..61381dd36 100644 --- a/source/flixel/system/scaleModes/FullScreenScaleMode.hx +++ b/source/flixel/system/scaleModes/FullScreenScaleMode.hx @@ -156,8 +156,8 @@ class FullScreenScaleMode extends flixel.system.scaleModes.BaseScaleMode { final game = FlxG.game; - cutoutBitmaps[i] = bitmap = new Bitmap(new BitmapData(ratioAxis == X ? Math.ceil(cutoutSize.x / 2) : Math.ceil(instance.gameSize.x), - ratioAxis == Y ? Math.ceil(cutoutSize.y / 2) : Math.ceil(instance.gameSize.y), true, 0xFF000000)); + cutoutBitmaps[i] = bitmap = new Bitmap(new BitmapData(ratioAxis == X ? Math.ceil(cutoutSize.x / 2) : Math.ceil(FlxG.scaleMode.gameSize.x), + ratioAxis == Y ? Math.ceil(cutoutSize.y / 2) : Math.ceil(FlxG.scaleMode.gameSize.y), true, 0xFF000000)); game.parent.addChildAt(bitmap, game.parent.getChildIndex(game) + 1); } @@ -166,8 +166,8 @@ class FullScreenScaleMode extends flixel.system.scaleModes.BaseScaleMode if (ratioAxis == X) { - bitmap.x = (i == 0) ? -bitmap.width : instance.gameSize.x; - targetX = (i == 0) ? 0 : instance.gameSize.x - bitmap.width; + bitmap.x = (i == 0) ? -bitmap.width : FlxG.scaleMode.gameSize.x; + targetX = (i == 0) ? 0 : FlxG.scaleMode.gameSize.x - bitmap.width; bitmap.y = 0; targetY = 0; } @@ -175,8 +175,8 @@ class FullScreenScaleMode extends flixel.system.scaleModes.BaseScaleMode { bitmap.x = 0; targetX = 0; - bitmap.y = (i == 0) ? -bitmap.height : instance.gameSize.y; - targetY = (i == 0) ? 0 : instance.gameSize.y - bitmap.height; + bitmap.y = (i == 0) ? -bitmap.height : FlxG.scaleMode.gameSize.y; + targetY = (i == 0) ? 0 : FlxG.scaleMode.gameSize.y - bitmap.height; } bitmap.alpha = 0; @@ -206,12 +206,12 @@ class FullScreenScaleMode extends flixel.system.scaleModes.BaseScaleMode { if (bitmap == null) { - trace("[WARNING] Tried to remove a cutout bar but there don't seem to be any cuout bars."); + trace("[WARNING] Tried to remove a cutout bar but there don't seem to be any."); continue; } - final targetX:Float = (i == 0 || ratioAxis == Y) ? ratioAxis == Y ? 0 : -bitmap.width : instance.gameSize.x; - final targetY:Float = (i == 0 || ratioAxis == X) ? ratioAxis == X ? 0 : -bitmap.height : instance.gameSize.y; + final targetX:Float = (i == 0 || ratioAxis == Y) ? ratioAxis == Y ? 0 : -bitmap.width : FlxG.scaleMode.gameSize.x; + final targetY:Float = (i == 0 || ratioAxis == X) ? ratioAxis == X ? 0 : -bitmap.height : FlxG.scaleMode.gameSize.y; if (tweenDuration > 0.0) { diff --git a/source/funkin/Preferences.hx b/source/funkin/Preferences.hx index 0d4b5f8ba..b15245faf 100644 --- a/source/funkin/Preferences.hx +++ b/source/funkin/Preferences.hx @@ -398,36 +398,20 @@ class Preferences if (show) { // Enable the debug display. - #if mobile - FlxG.game.addChild(Main.fpsCounter); - #else FlxG.stage.addChild(Main.fpsCounter); - #end #if !html5 - #if mobile - FlxG.game.addChild(Main.memoryCounter); - #else FlxG.stage.addChild(Main.memoryCounter); #end - #end } else { // Disable the debug display. - #if mobile - FlxG.game.removeChild(Main.fpsCounter); - #else FlxG.stage.removeChild(Main.fpsCounter); - #end #if !html5 - #if mobile - FlxG.game.removeChild(Main.memoryCounter); - #else FlxG.stage.removeChild(Main.memoryCounter); #end - #end } }