From 278eaa119d2860ec3ff6f87d5857cb296ed8290b Mon Sep 17 00:00:00 2001 From: HEIHUAa <112499486+HEIHUAa@users.noreply.github.com> Date: Thu, 19 Mar 2026 20:45:59 +0800 Subject: [PATCH 1/5] StringBuf --- .../backend/system/framerate/AssetTreeInfo.hx | 54 ++++++++++++++----- .../backend/system/framerate/ConductorInfo.hx | 26 ++++++--- .../backend/system/framerate/FlixelInfo.hx | 33 +++++++----- .../backend/system/framerate/MemoryCounter.hx | 5 +- .../backend/system/framerate/StatsInfo.hx | 12 +++-- .../backend/system/framerate/SystemInfo.hx | 51 ++++++++++++++---- 6 files changed, 136 insertions(+), 45 deletions(-) diff --git a/source/funkin/backend/system/framerate/AssetTreeInfo.hx b/source/funkin/backend/system/framerate/AssetTreeInfo.hx index 1414904f5f..38e21e9d73 100644 --- a/source/funkin/backend/system/framerate/AssetTreeInfo.hx +++ b/source/funkin/backend/system/framerate/AssetTreeInfo.hx @@ -22,32 +22,62 @@ class AssetTreeInfo extends FramerateCategory { lastUpdateTime = 0; - var text = 'Not initialized yet\n'; + var text = "Not initialized yet\n"; if (Paths.assetsTree != null){ text = ""; + var buf = new StringBuf(); for(l in Paths.assetsTree.libraries) { var l = AssetsLibraryList.getCleanLibrary(l); var tag = l.tag.toString().toUpperCase(); - text += '[$tag] '; + buf.add("["); + buf.add(tag); + buf.add("] "); var className = Type.getClassName(Type.getClass(l)); className = className.substr(className.lastIndexOf(".") + 1); #if TRANSLATIONS_SUPPORT - if (l is TranslatedAssetLibrary) - text += '${className} - ${cast(l, TranslatedAssetLibrary).langFolder} for (${cast(l, TranslatedAssetLibrary).forLibrary.modName})\n'; - else #end if (l is ScriptedAssetLibrary) - text += '${className} - ${cast(l, ScriptedAssetLibrary).scriptName} (${cast(l, ScriptedAssetLibrary).modName} | ${cast(l, ScriptedAssetLibrary).libName} | ${cast(l, ScriptedAssetLibrary).prefix})\n'; - else if (l is IModsAssetLibrary) - text += '${className} - ${cast(l, IModsAssetLibrary).modName} - ${cast(l, IModsAssetLibrary).libName} (${cast(l, IModsAssetLibrary).prefix})\n'; - else - text += Std.string(l) + '\n'; + if (l is TranslatedAssetLibrary) { + buf.add(className); + buf.add(" - "); + buf.add(cast(l, TranslatedAssetLibrary).langFolder); + buf.add(" for ("); + buf.add(cast(l, TranslatedAssetLibrary).forLibrary.modName); + buf.add(")\n"); + } + else #end if (l is ScriptedAssetLibrary) { + buf.add(className); + buf.add(" - "); + buf.add(cast(l, ScriptedAssetLibrary).scriptName); + buf.add(" ("); + buf.add(cast(l, ScriptedAssetLibrary).modName); + buf.add(" | "); + buf.add(cast(l, ScriptedAssetLibrary).libName); + buf.add(" | "); + buf.add(cast(l, ScriptedAssetLibrary).prefix); + buf.add(")\n"); + } + else if (l is IModsAssetLibrary) { + buf.add(className); + buf.add(" - "); + buf.add(cast(l, IModsAssetLibrary).modName); + buf.add(" - "); + buf.add(cast(l, IModsAssetLibrary).libName); + buf.add(" ("); + buf.add(cast(l, IModsAssetLibrary).prefix); + buf.add(")\n"); + } + else { + buf.add(Std.string(l)); + buf.add("\n"); + } } + text = buf.toString(); + if (text != "") + text = text.substr(0, text.length-1); } - if (text != "") - text = text.substr(0, text.length-1); this.text.text = text; super.__enterFrame(t); diff --git a/source/funkin/backend/system/framerate/ConductorInfo.hx b/source/funkin/backend/system/framerate/ConductorInfo.hx index e615bbbaf9..45500c9574 100644 --- a/source/funkin/backend/system/framerate/ConductorInfo.hx +++ b/source/funkin/backend/system/framerate/ConductorInfo.hx @@ -7,12 +7,26 @@ class ConductorInfo extends FramerateCategory { public override function __enterFrame(t:Int) { if (alpha <= 0.05) return; - _text = 'Current Song Position: ${Math.floor(Conductor.songPosition * 1000) / 1000}'; - _text += '\n - ${Conductor.curBeat} beats'; - _text += '\n - ${Conductor.curStep} steps'; - _text += '\n - ${Conductor.curMeasure} measures'; - _text += '\nCurrent BPM: ${Conductor.bpm}'; - _text += '\nTime Signature: ${Conductor.beatsPerMeasure}/${Conductor.denominator}'; + + var buf = new StringBuf(); + buf.add("Current Song Position: "); + buf.add(Math.floor(Conductor.songPosition * 1000) / 1000); + buf.add("\n - "); + buf.add(Conductor.curBeat); + buf.add(" beats"); + buf.add("\n - "); + buf.add(Conductor.curStep); + buf.add(" steps"); + buf.add("\n - "); + buf.add(Conductor.curMeasure); + buf.add(" measures"); + buf.add("\nCurrent BPM: "); + buf.add(Conductor.bpm); + buf.add("\nTime Signature: "); + buf.add(Conductor.beatsPerMeasure); + buf.add("/"); + buf.add(Conductor.denominator); + _text = buf.toString(); this.text.text = _text; super.__enterFrame(t); diff --git a/source/funkin/backend/system/framerate/FlixelInfo.hx b/source/funkin/backend/system/framerate/FlixelInfo.hx index c485468c97..9f12cd0fd3 100644 --- a/source/funkin/backend/system/framerate/FlixelInfo.hx +++ b/source/funkin/backend/system/framerate/FlixelInfo.hx @@ -10,28 +10,37 @@ class FlixelInfo extends FramerateCategory { public override function __enterFrame(t:Int) { if (alpha <= 0.05) return; - @:privateAccess { var c:Int = Lambda.count(FlxG.bitmap._cache); + var buf = new StringBuf(); if((FlxG.state is ModState)) { var state:ModState = cast FlxG.state; - _text = "Mod State: " + state.scriptName; + buf.add("Mod State: "); + buf.add(state.scriptName); } else { - _text = 'State: ${Type.getClassName(Type.getClass(FlxG.state))}'; + buf.add("State: "); + buf.add(Type.getClassName(Type.getClass(FlxG.state))); + } + buf.add("\nObject Count: "); + buf.add(FlxG.state.members.length); + buf.add("\nCamera Count: "); + buf.add(FlxG.cameras.list.length); + buf.add("\nBitmaps Count: "); + buf.add(c); + buf.add("\nSounds Count: "); + buf.add(FlxG.sound.list.length); + buf.add("\nFlxG.game Childs Count: "); + buf.add(FlxG.game.numChildren); + if(FlxG.renderBlit) { + buf.add("\nBlitting Render: true"); } - _text += '\nObject Count: ${FlxG.state.members.length}'; - _text += '\nCamera Count: ${FlxG.cameras.list.length}'; - _text += '\nBitmaps Count: ${c}'; - _text += '\nSounds Count: ${FlxG.sound.list.length}'; - _text += '\nFlxG.game Childs Count: ${FlxG.game.numChildren}'; - if(FlxG.renderBlit) _text += '\nBlitting Render: true'; - // _text += '\nCached objects count: ${cachedObjects}'; #if FLX_POINT_POOL //var points = flixel.math.FlxPoint.FlxBasePoint.pool; - //_text += '\nPoint Count: ${points._count} | +${points.made} | -${points.gotten} | ${points.balance} | >${points.putted}'; - //_text += '\nPoint Count: ${points._count}'; + //buf.add('\nPoint Count: ${points._count} | +${points.made} | -${points.gotten} | ${points.balance} | >${points.putted}'); + //buf.add('\nPoint Count: ${points._count}'); #end + _text = buf.toString(); } this.text.text = _text; diff --git a/source/funkin/backend/system/framerate/MemoryCounter.hx b/source/funkin/backend/system/framerate/MemoryCounter.hx index 068399b512..6c0ec08327 100644 --- a/source/funkin/backend/system/framerate/MemoryCounter.hx +++ b/source/funkin/backend/system/framerate/MemoryCounter.hx @@ -46,7 +46,10 @@ class MemoryCounter extends Sprite { memory = mem; if (memoryPeak < memory) memoryPeak = memory; memoryText.text = CoolUtil.getSizeString(memory); - memoryPeakText.text = ' / ${CoolUtil.getSizeString(memoryPeak)}'; + var buf = new StringBuf(); + buf.add(" / "); + buf.add(CoolUtil.getSizeString(memoryPeak)); + memoryPeakText.text = buf.toString(); updateLabelPosition(); } diff --git a/source/funkin/backend/system/framerate/StatsInfo.hx b/source/funkin/backend/system/framerate/StatsInfo.hx index 937bdb1062..ab9247afb1 100644 --- a/source/funkin/backend/system/framerate/StatsInfo.hx +++ b/source/funkin/backend/system/framerate/StatsInfo.hx @@ -11,9 +11,15 @@ class StatsInfo extends FramerateCategory { public override function __enterFrame(t:Int) { if (alpha <= 0.05) return; - _text = "totalDC: " + Context3DStats.totalDrawCalls(); - _text += "\nstageDC: " + Context3DStats.contextDrawCalls(DrawCallContext.STAGE); - _text += "\nstage3DDC: " + Context3DStats.contextDrawCalls(DrawCallContext.STAGE3D); + + var buf = new StringBuf(); + buf.add("totalDC: "); + buf.add(Context3DStats.totalDrawCalls()); + buf.add("\nstageDC: "); + buf.add(Context3DStats.contextDrawCalls(DrawCallContext.STAGE)); + buf.add("\nstage3DDC: "); + buf.add(Context3DStats.contextDrawCalls(DrawCallContext.STAGE3D)); + _text = buf.toString(); this.text.text = _text; super.__enterFrame(t); diff --git a/source/funkin/backend/system/framerate/SystemInfo.hx b/source/funkin/backend/system/framerate/SystemInfo.hx index 4de57190f2..a0e50c1ba9 100644 --- a/source/funkin/backend/system/framerate/SystemInfo.hx +++ b/source/funkin/backend/system/framerate/SystemInfo.hx @@ -137,21 +137,43 @@ class SystemInfo extends FramerateCategory { } static function formatSysInfo() { - __formattedSysText = ""; - if (osInfo != "Unknown") __formattedSysText += 'System: $osInfo'; - if (cpuName != "Unknown") __formattedSysText += '\nCPU: $cpuName ${openfl.system.Capabilities.cpuArchitecture} ${(openfl.system.Capabilities.supports64BitProcesses ? '64-Bit' : '32-Bit')}'; + var buf = new StringBuf(); + if (osInfo != "Unknown") { + buf.add("System: "); + buf.add(osInfo); + } + if (cpuName != "Unknown") { + buf.add("\nCPU: "); + buf.add(cpuName); + buf.add(" "); + buf.add(openfl.system.Capabilities.cpuArchitecture); + buf.add(" "); + buf.add(openfl.system.Capabilities.supports64BitProcesses ? "64-Bit" : "32-Bit"); + } if (gpuName != cpuName || vRAM != "Unknown") { var gpuNameKnown = gpuName != "Unknown" && gpuName != cpuName; var vramKnown = vRAM != "Unknown"; - if(gpuNameKnown || vramKnown) __formattedSysText += "\n"; + if(gpuNameKnown || vramKnown) buf.add("\n"); - if(gpuNameKnown) __formattedSysText += 'GPU: $gpuName'; - if(gpuNameKnown && vramKnown) __formattedSysText += " | "; - if(vramKnown) __formattedSysText += 'VRAM: $vRAM'; // 1000 bytes of vram (apus) + if(gpuNameKnown) { + buf.add("GPU: "); + buf.add(gpuName); + } + if(gpuNameKnown && vramKnown) buf.add(" | "); + if(vramKnown) { + buf.add("VRAM: "); + buf.add(vRAM); + } + } + //if (gpuMaxSize != "Unknown") buf.add('\nMax Bitmap Size: $gpuMaxSize'); + if (totalMem != "Unknown" && memType != "Unknown") { + buf.add("\nTotal MEM: "); + buf.add(totalMem); + buf.add(" "); + buf.add(memType); } - //if (gpuMaxSize != "Unknown") __formattedSysText += '\nMax Bitmap Size: $gpuMaxSize'; - if (totalMem != "Unknown" && memType != "Unknown") __formattedSysText += '\nTotal MEM: $totalMem $memType'; + __formattedSysText = buf.toString(); } static function getSizeString(size:Float):String { @@ -172,8 +194,15 @@ class SystemInfo extends FramerateCategory { public override function __enterFrame(t:Int) { if (alpha <= 0.05) return; - _text = __formattedSysText; - _text += '${__formattedSysText == "" ? "" : "\n"}Garbage Collector: ${MemoryUtil.disableCount > 0 ? "OFF" : "ON"} (${MemoryUtil.disableCount})'; + var buf = new StringBuf(); + buf.add(__formattedSysText); + if (__formattedSysText != "") buf.add("\n"); + buf.add("Garbage Collector: "); + buf.add(MemoryUtil.disableCount > 0 ? "OFF" : "ON"); + buf.add(" ("); + buf.add(MemoryUtil.disableCount); + buf.add(")"); + _text = buf.toString(); this.text.text = _text; super.__enterFrame(t); From d2518d6e6323974a956a7abe72cbc9556cff1b61 Mon Sep 17 00:00:00 2001 From: HEIHUAa <112499486+HEIHUAa@users.noreply.github.com> Date: Thu, 19 Mar 2026 20:47:43 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20MemoryCounter.hx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/funkin/backend/system/framerate/MemoryCounter.hx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/source/funkin/backend/system/framerate/MemoryCounter.hx b/source/funkin/backend/system/framerate/MemoryCounter.hx index 6c0ec08327..c10048acf6 100644 --- a/source/funkin/backend/system/framerate/MemoryCounter.hx +++ b/source/funkin/backend/system/framerate/MemoryCounter.hx @@ -45,11 +45,7 @@ class MemoryCounter extends Sprite { memory = mem; if (memoryPeak < memory) memoryPeak = memory; - memoryText.text = CoolUtil.getSizeString(memory); - var buf = new StringBuf(); - buf.add(" / "); - buf.add(CoolUtil.getSizeString(memoryPeak)); - memoryPeakText.text = buf.toString(); + memoryPeakText.text = ' / ${CoolUtil.getSizeString(memoryPeak)}'; updateLabelPosition(); } From 4a7b982f70a46a23820cb7feb76f444703d61fde Mon Sep 17 00:00:00 2001 From: HEIHUAa <112499486+HEIHUAa@users.noreply.github.com> Date: Fri, 20 Mar 2026 17:06:47 +0800 Subject: [PATCH 3/5] macro --- .../backend/system/framerate/AssetTreeInfo.hx | 43 ++++--------------- .../backend/system/framerate/ConductorInfo.hx | 23 +++------- .../backend/system/framerate/FlixelInfo.hx | 27 +++++------- .../system/framerate/FramerateCategory.hx | 11 +++++ .../backend/system/framerate/StatsInfo.hx | 9 ++-- .../backend/system/framerate/SystemInfo.hx | 31 ++++--------- 6 files changed, 46 insertions(+), 98 deletions(-) diff --git a/source/funkin/backend/system/framerate/AssetTreeInfo.hx b/source/funkin/backend/system/framerate/AssetTreeInfo.hx index 38e21e9d73..654b793136 100644 --- a/source/funkin/backend/system/framerate/AssetTreeInfo.hx +++ b/source/funkin/backend/system/framerate/AssetTreeInfo.hx @@ -31,47 +31,20 @@ class AssetTreeInfo extends FramerateCategory { var tag = l.tag.toString().toUpperCase(); - buf.add("["); - buf.add(tag); - buf.add("] "); + addLineMacro(buf, '[', tag, '] '); var className = Type.getClassName(Type.getClass(l)); className = className.substr(className.lastIndexOf(".") + 1); #if TRANSLATIONS_SUPPORT if (l is TranslatedAssetLibrary) { - buf.add(className); - buf.add(" - "); - buf.add(cast(l, TranslatedAssetLibrary).langFolder); - buf.add(" for ("); - buf.add(cast(l, TranslatedAssetLibrary).forLibrary.modName); - buf.add(")\n"); - } - else #end if (l is ScriptedAssetLibrary) { - buf.add(className); - buf.add(" - "); - buf.add(cast(l, ScriptedAssetLibrary).scriptName); - buf.add(" ("); - buf.add(cast(l, ScriptedAssetLibrary).modName); - buf.add(" | "); - buf.add(cast(l, ScriptedAssetLibrary).libName); - buf.add(" | "); - buf.add(cast(l, ScriptedAssetLibrary).prefix); - buf.add(")\n"); - } - else if (l is IModsAssetLibrary) { - buf.add(className); - buf.add(" - "); - buf.add(cast(l, IModsAssetLibrary).modName); - buf.add(" - "); - buf.add(cast(l, IModsAssetLibrary).libName); - buf.add(" ("); - buf.add(cast(l, IModsAssetLibrary).prefix); - buf.add(")\n"); - } - else { - buf.add(Std.string(l)); - buf.add("\n"); + addLineMacro(buf, className, ' - ', cast(l, TranslatedAssetLibrary).langFolder, ' for (', cast(l, TranslatedAssetLibrary).forLibrary.modName, ')','\n'); + } else #end if (l is ScriptedAssetLibrary) { + addLineMacro(buf, className, ' - ', cast(l, ScriptedAssetLibrary).scriptName, ' (', cast(l, ScriptedAssetLibrary).modName, ' | ', cast(l, ScriptedAssetLibrary).libName, ' | ', cast(l, ScriptedAssetLibrary).prefix, ')','\n'); + } else if (l is IModsAssetLibrary) { + addLineMacro(buf, className, ' - ', cast(l, IModsAssetLibrary).modName, ' - ', cast(l, IModsAssetLibrary).libName, ' (', cast(l, IModsAssetLibrary).prefix, ')','\n'); + } else { + addLineMacro(buf, Std.string(l), '\n'); } } text = buf.toString(); diff --git a/source/funkin/backend/system/framerate/ConductorInfo.hx b/source/funkin/backend/system/framerate/ConductorInfo.hx index 45500c9574..411a473b8c 100644 --- a/source/funkin/backend/system/framerate/ConductorInfo.hx +++ b/source/funkin/backend/system/framerate/ConductorInfo.hx @@ -9,23 +9,12 @@ class ConductorInfo extends FramerateCategory { if (alpha <= 0.05) return; var buf = new StringBuf(); - buf.add("Current Song Position: "); - buf.add(Math.floor(Conductor.songPosition * 1000) / 1000); - buf.add("\n - "); - buf.add(Conductor.curBeat); - buf.add(" beats"); - buf.add("\n - "); - buf.add(Conductor.curStep); - buf.add(" steps"); - buf.add("\n - "); - buf.add(Conductor.curMeasure); - buf.add(" measures"); - buf.add("\nCurrent BPM: "); - buf.add(Conductor.bpm); - buf.add("\nTime Signature: "); - buf.add(Conductor.beatsPerMeasure); - buf.add("/"); - buf.add(Conductor.denominator); + addLineMacro(buf, 'Current Song Position: ', Math.floor(Conductor.songPosition * 1000) / 1000, 's'); + addLineMacro(buf, '\n - ', Conductor.curBeat, ' beats'); + addLineMacro(buf, '\n - ', Conductor.curStep, ' steps'); + addLineMacro(buf, '\n - ', Conductor.curMeasure, ' measures'); + addLineMacro(buf, '\nCurrent BPM: ', Conductor.bpm); + addLineMacro(buf, '\nTime Signature: ', Conductor.beatsPerMeasure, '/', Conductor.denominator); _text = buf.toString(); this.text.text = _text; diff --git a/source/funkin/backend/system/framerate/FlixelInfo.hx b/source/funkin/backend/system/framerate/FlixelInfo.hx index 9f12cd0fd3..7d17f13970 100644 --- a/source/funkin/backend/system/framerate/FlixelInfo.hx +++ b/source/funkin/backend/system/framerate/FlixelInfo.hx @@ -16,29 +16,22 @@ class FlixelInfo extends FramerateCategory { if((FlxG.state is ModState)) { var state:ModState = cast FlxG.state; - buf.add("Mod State: "); - buf.add(state.scriptName); + addLineMacro(buf, 'Mod State: ', state.scriptName); } else { - buf.add("State: "); - buf.add(Type.getClassName(Type.getClass(FlxG.state))); + addLineMacro(buf, 'State: ', Type.getClassName(Type.getClass(FlxG.state))); } - buf.add("\nObject Count: "); - buf.add(FlxG.state.members.length); - buf.add("\nCamera Count: "); - buf.add(FlxG.cameras.list.length); - buf.add("\nBitmaps Count: "); - buf.add(c); - buf.add("\nSounds Count: "); - buf.add(FlxG.sound.list.length); - buf.add("\nFlxG.game Childs Count: "); - buf.add(FlxG.game.numChildren); + addLineMacro(buf, '\nObject Count: ', FlxG.state.members.length); + addLineMacro(buf, '\nCamera Count: ', FlxG.cameras.list.length); + addLineMacro(buf, '\nBitmaps Count: ', c); + addLineMacro(buf, '\nSounds Count: ', FlxG.sound.list.length); + addLineMacro(buf, '\nFlxG.game Childs Count: ', FlxG.game.numChildren); if(FlxG.renderBlit) { - buf.add("\nBlitting Render: true"); + addLineMacro(buf, '\nBlitting Render: ', true); } #if FLX_POINT_POOL //var points = flixel.math.FlxPoint.FlxBasePoint.pool; - //buf.add('\nPoint Count: ${points._count} | +${points.made} | -${points.gotten} | ${points.balance} | >${points.putted}'); - //buf.add('\nPoint Count: ${points._count}'); + //addLineMacro(buf, '\nPoint Count: ', points._count, ' | +', points.made, ' | -', points.gotten, ' | ', points.balance, ' | >', points.putted); + //addLineMacro(buf, '\nPoint Count: ', points._count); #end _text = buf.toString(); } diff --git a/source/funkin/backend/system/framerate/FramerateCategory.hx b/source/funkin/backend/system/framerate/FramerateCategory.hx index db89137f37..1ce007c5fb 100644 --- a/source/funkin/backend/system/framerate/FramerateCategory.hx +++ b/source/funkin/backend/system/framerate/FramerateCategory.hx @@ -52,4 +52,15 @@ class FramerateCategory extends Sprite { bgSprite.scaleX = width; bgSprite.scaleY = height; } + + public static inline function addLine(buf:StringBuf, ...values:Array):Void { + for (v in values) buf.add(v); + } + + @:dox(hide) public static macro function addLineMacro(buf:Expr, args:Array):Expr { + var exprs = []; + for (arg in args) + exprs.push(macro $buf.add($arg)); + return macro $b{exprs}; + } } diff --git a/source/funkin/backend/system/framerate/StatsInfo.hx b/source/funkin/backend/system/framerate/StatsInfo.hx index ab9247afb1..f29ff990c2 100644 --- a/source/funkin/backend/system/framerate/StatsInfo.hx +++ b/source/funkin/backend/system/framerate/StatsInfo.hx @@ -13,12 +13,9 @@ class StatsInfo extends FramerateCategory { if (alpha <= 0.05) return; var buf = new StringBuf(); - buf.add("totalDC: "); - buf.add(Context3DStats.totalDrawCalls()); - buf.add("\nstageDC: "); - buf.add(Context3DStats.contextDrawCalls(DrawCallContext.STAGE)); - buf.add("\nstage3DDC: "); - buf.add(Context3DStats.contextDrawCalls(DrawCallContext.STAGE3D)); + addLineMacro(buf, 'totalDC: ', Context3DStats.totalDrawCalls()); + addLineMacro(buf, '\nstageDC: ', Context3DStats.contextDrawCalls(DrawCallContext.STAGE)); + addLineMacro(buf, '\nstage3DDC: ', Context3DStats.contextDrawCalls(DrawCallContext.STAGE3D)); _text = buf.toString(); this.text.text = _text; diff --git a/source/funkin/backend/system/framerate/SystemInfo.hx b/source/funkin/backend/system/framerate/SystemInfo.hx index a0e50c1ba9..3ac2ac27b5 100644 --- a/source/funkin/backend/system/framerate/SystemInfo.hx +++ b/source/funkin/backend/system/framerate/SystemInfo.hx @@ -139,16 +139,10 @@ class SystemInfo extends FramerateCategory { static function formatSysInfo() { var buf = new StringBuf(); if (osInfo != "Unknown") { - buf.add("System: "); - buf.add(osInfo); + addLineMacro(buf, 'System: ', osInfo); } if (cpuName != "Unknown") { - buf.add("\nCPU: "); - buf.add(cpuName); - buf.add(" "); - buf.add(openfl.system.Capabilities.cpuArchitecture); - buf.add(" "); - buf.add(openfl.system.Capabilities.supports64BitProcesses ? "64-Bit" : "32-Bit"); + addLineMacro(buf, '\nCPU: ', cpuName, ' ', openfl.system.Capabilities.cpuArchitecture, ' ', openfl.system.Capabilities.supports64BitProcesses ? '64-Bit' : '32-Bit'); } if (gpuName != cpuName || vRAM != "Unknown") { var gpuNameKnown = gpuName != "Unknown" && gpuName != cpuName; @@ -157,21 +151,16 @@ class SystemInfo extends FramerateCategory { if(gpuNameKnown || vramKnown) buf.add("\n"); if(gpuNameKnown) { - buf.add("GPU: "); - buf.add(gpuName); + addLineMacro(buf, 'GPU: ', gpuName); } if(gpuNameKnown && vramKnown) buf.add(" | "); if(vramKnown) { - buf.add("VRAM: "); - buf.add(vRAM); + addLineMacro(buf, 'VRAM: ', vRAM); } } - //if (gpuMaxSize != "Unknown") buf.add('\nMax Bitmap Size: $gpuMaxSize'); + //if (gpuMaxSize != "Unknown") addLineMacro(buf, '\nMax Bitmap Size: ',gpuMaxSize); if (totalMem != "Unknown" && memType != "Unknown") { - buf.add("\nTotal MEM: "); - buf.add(totalMem); - buf.add(" "); - buf.add(memType); + addLineMacro(buf, '\nTotal MEM: ', totalMem, ' ', memType); } __formattedSysText = buf.toString(); } @@ -196,12 +185,8 @@ class SystemInfo extends FramerateCategory { var buf = new StringBuf(); buf.add(__formattedSysText); - if (__formattedSysText != "") buf.add("\n"); - buf.add("Garbage Collector: "); - buf.add(MemoryUtil.disableCount > 0 ? "OFF" : "ON"); - buf.add(" ("); - buf.add(MemoryUtil.disableCount); - buf.add(")"); + if (__formattedSysText != '') buf.add('\n'); + addLineMacro(buf, 'Garbage Collector: ', MemoryUtil.disableCount > 0 ? 'OFF' : 'ON', '(', MemoryUtil.disableCount, ')'); _text = buf.toString(); this.text.text = _text; From ee23e2938eafb68c6e83cc21082085722ca7d960 Mon Sep 17 00:00:00 2001 From: HEIHUAa <112499486+HEIHUAa@users.noreply.github.com> Date: Fri, 20 Mar 2026 17:40:26 +0800 Subject: [PATCH 4/5] StringMacro --- .../backend/system/framerate/AssetTreeInfo.hx | 11 +++++----- .../backend/system/framerate/ConductorInfo.hx | 14 +++++++------ .../backend/system/framerate/FlixelInfo.hx | 21 ++++++++++--------- .../system/framerate/FramerateCategory.hx | 7 ------- .../backend/system/framerate/MemoryCounter.hx | 1 + .../backend/system/framerate/StatsInfo.hx | 7 ++++--- .../backend/system/framerate/SystemInfo.hx | 15 ++++++------- .../backend/system/macros/StringMacro.hx | 15 +++++++++++++ 8 files changed, 53 insertions(+), 38 deletions(-) create mode 100644 source/funkin/backend/system/macros/StringMacro.hx diff --git a/source/funkin/backend/system/framerate/AssetTreeInfo.hx b/source/funkin/backend/system/framerate/AssetTreeInfo.hx index 654b793136..5ba439c85a 100644 --- a/source/funkin/backend/system/framerate/AssetTreeInfo.hx +++ b/source/funkin/backend/system/framerate/AssetTreeInfo.hx @@ -6,6 +6,7 @@ import funkin.backend.assets.TranslatedAssetLibrary; import funkin.backend.assets.AssetsLibraryList; import funkin.backend.assets.IModsAssetLibrary; import funkin.backend.assets.ScriptedAssetLibrary; +import funkin.backend.system.macros.StringMacro; class AssetTreeInfo extends FramerateCategory { private var lastUpdateTime:Float = 1; @@ -31,20 +32,20 @@ class AssetTreeInfo extends FramerateCategory { var tag = l.tag.toString().toUpperCase(); - addLineMacro(buf, '[', tag, '] '); + StringMacro.addLine(buf, '[', tag, '] '); var className = Type.getClassName(Type.getClass(l)); className = className.substr(className.lastIndexOf(".") + 1); #if TRANSLATIONS_SUPPORT if (l is TranslatedAssetLibrary) { - addLineMacro(buf, className, ' - ', cast(l, TranslatedAssetLibrary).langFolder, ' for (', cast(l, TranslatedAssetLibrary).forLibrary.modName, ')','\n'); + StringMacro.addLine(buf, className, ' - ', cast(l, TranslatedAssetLibrary).langFolder, ' for (', cast(l, TranslatedAssetLibrary).forLibrary.modName, ')','\n'); } else #end if (l is ScriptedAssetLibrary) { - addLineMacro(buf, className, ' - ', cast(l, ScriptedAssetLibrary).scriptName, ' (', cast(l, ScriptedAssetLibrary).modName, ' | ', cast(l, ScriptedAssetLibrary).libName, ' | ', cast(l, ScriptedAssetLibrary).prefix, ')','\n'); + StringMacro.addLine(buf, className, ' - ', cast(l, ScriptedAssetLibrary).scriptName, ' (', cast(l, ScriptedAssetLibrary).modName, ' | ', cast(l, ScriptedAssetLibrary).libName, ' | ', cast(l, ScriptedAssetLibrary).prefix, ')','\n'); } else if (l is IModsAssetLibrary) { - addLineMacro(buf, className, ' - ', cast(l, IModsAssetLibrary).modName, ' - ', cast(l, IModsAssetLibrary).libName, ' (', cast(l, IModsAssetLibrary).prefix, ')','\n'); + StringMacro.addLine(buf, className, ' - ', cast(l, IModsAssetLibrary).modName, ' - ', cast(l, IModsAssetLibrary).libName, ' (', cast(l, IModsAssetLibrary).prefix, ')','\n'); } else { - addLineMacro(buf, Std.string(l), '\n'); + StringMacro.addLine(buf, Std.string(l), '\n'); } } text = buf.toString(); diff --git a/source/funkin/backend/system/framerate/ConductorInfo.hx b/source/funkin/backend/system/framerate/ConductorInfo.hx index 411a473b8c..6de1a4229e 100644 --- a/source/funkin/backend/system/framerate/ConductorInfo.hx +++ b/source/funkin/backend/system/framerate/ConductorInfo.hx @@ -1,5 +1,7 @@ package funkin.backend.system.framerate; +import funkin.backend.system.macros.StringMacro; + class ConductorInfo extends FramerateCategory { public function new() { super("Conductor Info"); @@ -9,12 +11,12 @@ class ConductorInfo extends FramerateCategory { if (alpha <= 0.05) return; var buf = new StringBuf(); - addLineMacro(buf, 'Current Song Position: ', Math.floor(Conductor.songPosition * 1000) / 1000, 's'); - addLineMacro(buf, '\n - ', Conductor.curBeat, ' beats'); - addLineMacro(buf, '\n - ', Conductor.curStep, ' steps'); - addLineMacro(buf, '\n - ', Conductor.curMeasure, ' measures'); - addLineMacro(buf, '\nCurrent BPM: ', Conductor.bpm); - addLineMacro(buf, '\nTime Signature: ', Conductor.beatsPerMeasure, '/', Conductor.denominator); + StringMacro.addLine(buf, 'Current Song Position: ', Math.floor(Conductor.songPosition * 1000) / 1000); + StringMacro.addLine(buf, '\n - ', Conductor.curBeat, ' beats'); + StringMacro.addLine(buf, '\n - ', Conductor.curStep, ' steps'); + StringMacro.addLine(buf, '\n - ', Conductor.curMeasure, ' measures'); + StringMacro.addLine(buf, '\nCurrent BPM: ', Conductor.bpm); + StringMacro.addLine(buf, '\nTime Signature: ', Conductor.beatsPerMeasure, '/', Conductor.denominator); _text = buf.toString(); this.text.text = _text; diff --git a/source/funkin/backend/system/framerate/FlixelInfo.hx b/source/funkin/backend/system/framerate/FlixelInfo.hx index 7d17f13970..502c0de412 100644 --- a/source/funkin/backend/system/framerate/FlixelInfo.hx +++ b/source/funkin/backend/system/framerate/FlixelInfo.hx @@ -1,6 +1,7 @@ package funkin.backend.system.framerate; import funkin.backend.scripting.ModState; +import funkin.backend.system.macros.StringMacro; class FlixelInfo extends FramerateCategory { public function new() { @@ -16,22 +17,22 @@ class FlixelInfo extends FramerateCategory { if((FlxG.state is ModState)) { var state:ModState = cast FlxG.state; - addLineMacro(buf, 'Mod State: ', state.scriptName); + StringMacro.addLine(buf, 'Mod State: ', state.scriptName); } else { - addLineMacro(buf, 'State: ', Type.getClassName(Type.getClass(FlxG.state))); + StringMacro.addLine(buf, 'State: ', Type.getClassName(Type.getClass(FlxG.state))); } - addLineMacro(buf, '\nObject Count: ', FlxG.state.members.length); - addLineMacro(buf, '\nCamera Count: ', FlxG.cameras.list.length); - addLineMacro(buf, '\nBitmaps Count: ', c); - addLineMacro(buf, '\nSounds Count: ', FlxG.sound.list.length); - addLineMacro(buf, '\nFlxG.game Childs Count: ', FlxG.game.numChildren); + StringMacro.addLine(buf, '\nObject Count: ', FlxG.state.members.length); + StringMacro.addLine(buf, '\nCamera Count: ', FlxG.cameras.list.length); + StringMacro.addLine(buf, '\nBitmaps Count: ', c); + StringMacro.addLine(buf, '\nSounds Count: ', FlxG.sound.list.length); + StringMacro.addLine(buf, '\nFlxG.game Childs Count: ', FlxG.game.numChildren); if(FlxG.renderBlit) { - addLineMacro(buf, '\nBlitting Render: ', true); + StringMacro.addLine(buf, '\nBlitting Render: ', true); } #if FLX_POINT_POOL //var points = flixel.math.FlxPoint.FlxBasePoint.pool; - //addLineMacro(buf, '\nPoint Count: ', points._count, ' | +', points.made, ' | -', points.gotten, ' | ', points.balance, ' | >', points.putted); - //addLineMacro(buf, '\nPoint Count: ', points._count); + //StringMacro.addLine(buf, '\nPoint Count: ', points._count, ' | +', points.made, ' | -', points.gotten, ' | ', points.balance, ' | >', points.putted); + //StringMacro.addLine(buf, '\nPoint Count: ', points._count); #end _text = buf.toString(); } diff --git a/source/funkin/backend/system/framerate/FramerateCategory.hx b/source/funkin/backend/system/framerate/FramerateCategory.hx index 1ce007c5fb..0bae85b2db 100644 --- a/source/funkin/backend/system/framerate/FramerateCategory.hx +++ b/source/funkin/backend/system/framerate/FramerateCategory.hx @@ -56,11 +56,4 @@ class FramerateCategory extends Sprite { public static inline function addLine(buf:StringBuf, ...values:Array):Void { for (v in values) buf.add(v); } - - @:dox(hide) public static macro function addLineMacro(buf:Expr, args:Array):Expr { - var exprs = []; - for (arg in args) - exprs.push(macro $buf.add($arg)); - return macro $b{exprs}; - } } diff --git a/source/funkin/backend/system/framerate/MemoryCounter.hx b/source/funkin/backend/system/framerate/MemoryCounter.hx index c10048acf6..068399b512 100644 --- a/source/funkin/backend/system/framerate/MemoryCounter.hx +++ b/source/funkin/backend/system/framerate/MemoryCounter.hx @@ -45,6 +45,7 @@ class MemoryCounter extends Sprite { memory = mem; if (memoryPeak < memory) memoryPeak = memory; + memoryText.text = CoolUtil.getSizeString(memory); memoryPeakText.text = ' / ${CoolUtil.getSizeString(memoryPeak)}'; updateLabelPosition(); diff --git a/source/funkin/backend/system/framerate/StatsInfo.hx b/source/funkin/backend/system/framerate/StatsInfo.hx index f29ff990c2..048a1fd08b 100644 --- a/source/funkin/backend/system/framerate/StatsInfo.hx +++ b/source/funkin/backend/system/framerate/StatsInfo.hx @@ -3,6 +3,7 @@ package funkin.backend.system.framerate; #if (gl_stats && !disable_cffi && (!html5 || !canvas)) import openfl.display._internal.stats.Context3DStats; import openfl.display._internal.stats.DrawCallContext; +import funkin.backend.system.macros.StringMacro; class StatsInfo extends FramerateCategory { public function new() { @@ -13,9 +14,9 @@ class StatsInfo extends FramerateCategory { if (alpha <= 0.05) return; var buf = new StringBuf(); - addLineMacro(buf, 'totalDC: ', Context3DStats.totalDrawCalls()); - addLineMacro(buf, '\nstageDC: ', Context3DStats.contextDrawCalls(DrawCallContext.STAGE)); - addLineMacro(buf, '\nstage3DDC: ', Context3DStats.contextDrawCalls(DrawCallContext.STAGE3D)); + StringMacro.addLine(buf, 'totalDC: ', Context3DStats.totalDrawCalls()); + StringMacro.addLine(buf, '\nstageDC: ', Context3DStats.contextDrawCalls(DrawCallContext.STAGE)); + StringMacro.addLine(buf, '\nstage3DDC: ', Context3DStats.contextDrawCalls(DrawCallContext.STAGE3D)); _text = buf.toString(); this.text.text = _text; diff --git a/source/funkin/backend/system/framerate/SystemInfo.hx b/source/funkin/backend/system/framerate/SystemInfo.hx index 3ac2ac27b5..6f092cb37f 100644 --- a/source/funkin/backend/system/framerate/SystemInfo.hx +++ b/source/funkin/backend/system/framerate/SystemInfo.hx @@ -9,6 +9,7 @@ import cpp.UInt64; #end using StringTools; +import funkin.backend.system.macros.StringMacro; class SystemInfo extends FramerateCategory { public static var osInfo:String = "Unknown"; @@ -139,10 +140,10 @@ class SystemInfo extends FramerateCategory { static function formatSysInfo() { var buf = new StringBuf(); if (osInfo != "Unknown") { - addLineMacro(buf, 'System: ', osInfo); + StringMacro.addLine(buf, 'System: ', osInfo); } if (cpuName != "Unknown") { - addLineMacro(buf, '\nCPU: ', cpuName, ' ', openfl.system.Capabilities.cpuArchitecture, ' ', openfl.system.Capabilities.supports64BitProcesses ? '64-Bit' : '32-Bit'); + StringMacro.addLine(buf, '\nCPU: ', cpuName, ' ', openfl.system.Capabilities.cpuArchitecture, ' ', openfl.system.Capabilities.supports64BitProcesses ? '64-Bit' : '32-Bit'); } if (gpuName != cpuName || vRAM != "Unknown") { var gpuNameKnown = gpuName != "Unknown" && gpuName != cpuName; @@ -151,16 +152,16 @@ class SystemInfo extends FramerateCategory { if(gpuNameKnown || vramKnown) buf.add("\n"); if(gpuNameKnown) { - addLineMacro(buf, 'GPU: ', gpuName); + StringMacro.addLine(buf, 'GPU: ', gpuName); } if(gpuNameKnown && vramKnown) buf.add(" | "); if(vramKnown) { - addLineMacro(buf, 'VRAM: ', vRAM); + StringMacro.addLine(buf, 'VRAM: ', vRAM); } } - //if (gpuMaxSize != "Unknown") addLineMacro(buf, '\nMax Bitmap Size: ',gpuMaxSize); + //if (gpuMaxSize != "Unknown") StringMacro.addLine(buf, '\nMax Bitmap Size: ',gpuMaxSize); if (totalMem != "Unknown" && memType != "Unknown") { - addLineMacro(buf, '\nTotal MEM: ', totalMem, ' ', memType); + StringMacro.addLine(buf, '\nTotal MEM: ', totalMem, ' ', memType); } __formattedSysText = buf.toString(); } @@ -186,7 +187,7 @@ class SystemInfo extends FramerateCategory { var buf = new StringBuf(); buf.add(__formattedSysText); if (__formattedSysText != '') buf.add('\n'); - addLineMacro(buf, 'Garbage Collector: ', MemoryUtil.disableCount > 0 ? 'OFF' : 'ON', '(', MemoryUtil.disableCount, ')'); + StringMacro.addLine(buf, 'Garbage Collector: ', MemoryUtil.disableCount > 0 ? 'OFF' : 'ON', '(', MemoryUtil.disableCount, ')'); _text = buf.toString(); this.text.text = _text; diff --git a/source/funkin/backend/system/macros/StringMacro.hx b/source/funkin/backend/system/macros/StringMacro.hx new file mode 100644 index 0000000000..627959c5ae --- /dev/null +++ b/source/funkin/backend/system/macros/StringMacro.hx @@ -0,0 +1,15 @@ +package funkin.backend.system.macros; + +#if macro +import haxe.macro.Context; +import haxe.macro.Expr; +#end + +class StringMacro { + @:dox(hide) public static macro function addLine(buf:Expr, args:Array):Expr { + var exprs = []; + for (arg in args) + exprs.push(macro $buf.add($arg)); + return macro $b{exprs}; + } +} \ No newline at end of file From 9251540261f02b56f2dfbb401091242498bd4063 Mon Sep 17 00:00:00 2001 From: HEIHUAa <112499486+HEIHUAa@users.noreply.github.com> Date: Fri, 20 Mar 2026 17:42:28 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20SystemInfo.hx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/funkin/backend/system/framerate/SystemInfo.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/backend/system/framerate/SystemInfo.hx b/source/funkin/backend/system/framerate/SystemInfo.hx index 6f092cb37f..c07736a770 100644 --- a/source/funkin/backend/system/framerate/SystemInfo.hx +++ b/source/funkin/backend/system/framerate/SystemInfo.hx @@ -187,7 +187,7 @@ class SystemInfo extends FramerateCategory { var buf = new StringBuf(); buf.add(__formattedSysText); if (__formattedSysText != '') buf.add('\n'); - StringMacro.addLine(buf, 'Garbage Collector: ', MemoryUtil.disableCount > 0 ? 'OFF' : 'ON', '(', MemoryUtil.disableCount, ')'); + StringMacro.addLine(buf, 'Garbage Collector: ', MemoryUtil.disableCount > 0 ? 'OFF' : 'ON', ' (', MemoryUtil.disableCount, ')'); _text = buf.toString(); this.text.text = _text;