diff --git a/source/debug/FPSCounter.hx b/source/debug/FPSCounter.hx index 950b94413c3..136cf91461a 100644 --- a/source/debug/FPSCounter.hx +++ b/source/debug/FPSCounter.hx @@ -13,11 +13,11 @@ class FPSCounter extends TextField /** The current memory usage (WARNING: this is NOT your total program memory usage, rather it shows the garbage collector memory) **/ - public var memory(get, never):Float; + public var memory(get, never):Float; inline function get_memory():Float return Memory.gay(); - var mempeak:Float = 0; + var mempeak:Float = 0; @:noCompletion private var times:Array; @@ -39,10 +39,10 @@ class FPSCounter extends TextField times = []; } - var timeColor:Float = 0.0; + var timeColor:Float = 0.0; var fpsMultiplier:Float = 1.0; - var deltaTimeout:Float = 0.0; + var deltaTimeout:Float = 0.0; public var timeoutDelay:Float = 50; // Event Handlers override function __enterFrame(deltaTime:Float):Void @@ -50,21 +50,23 @@ class FPSCounter extends TextField final now:Float = haxe.Timer.stamp() * 1000; times.push(now); while (times[0] < now - 1000 / fpsMultiplier) times.shift(); - if (deltaTimeout < timeoutDelay) { + if (deltaTimeout <= timeoutDelay) + { deltaTimeout += deltaTime; return; } - if (Std.isOfType(FlxG.state, PlayState) && !PlayState.instance.trollingMode) { + if (Std.isOfType(FlxG.state, PlayState) && !PlayState.instance.trollingMode) + { try { fpsMultiplier = PlayState.instance.playbackRate; } catch (e:Dynamic) { fpsMultiplier = 1.0; } } else fpsMultiplier = 1.0; - if (memory > mempeak) mempeak = memory; - - currentFPS = Math.min(FlxG.drawFramerate, times.length) / fpsMultiplier; - updateText(); + if (memory > mempeak) mempeak = memory; + + currentFPS = Math.min(FlxG.drawFramerate, times.length) / fpsMultiplier; + updateText(); if (ClientPrefs.rainbowFPS) { @@ -79,21 +81,24 @@ class FPSCounter extends TextField if (currentFPS <= ClientPrefs.framerate / 3 && currentFPS >= ClientPrefs.framerate / 4) textColor = 0xFFFF8000; - + if (currentFPS <= ClientPrefs.framerate / 4) textColor = 0xFFFF0000; } deltaTimeout = 0.0; } - public dynamic function updateText():Void { // so people can override it in hscript + public dynamic function updateText():Void // so people can override it in hscript + { text = (ClientPrefs.showFPS ? "FPS: " + (ClientPrefs.ffmpegMode ? ClientPrefs.targetFPS : Math.round(currentFPS)) : ""); - if (ClientPrefs.ffmpegMode) { + if (ClientPrefs.ffmpegMode) + { text += " (Rendering Mode)"; } - + if (ClientPrefs.showRamUsage) text += "\nRAM: " + FlxStringUtil.formatBytes(memory) + (ClientPrefs.showMaxRamUsage ? " / " + FlxStringUtil.formatBytes(mempeak) : ""); - if (ClientPrefs.debugInfo) { + if (ClientPrefs.debugInfo) + { text += '\nState: ${Type.getClassName(Type.getClass(FlxG.state))}'; if (FlxG.state.subState != null) text += '\nSubstate: ${Type.getClassName(Type.getClass(FlxG.state.subState))}';