Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions source/funkin/Preferences.hx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,25 @@ class Preferences
return value;
}

/**
* If enabled, statistic peaks will be shown on the debug display.
* @default `true`
*/
public static var showStatPeaks(get, set):Bool;

static function get_showStatPeaks():Bool
{
return Save?.instance?.options?.showStatPeaks ?? true;
}

static function set_showStatPeaks(value:Bool):Bool
{
var save:Save = Save.instance;
save.options.showStatPeaks = value;
save.flush();
return value;
}

/**
* Opacity of the debug display's background.
* @default `50`
Expand Down
7 changes: 7 additions & 0 deletions source/funkin/save/Save.hx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class Save implements ConsoleClass
flashingLights: true,
zoomCamera: true,
debugDisplay: 'Off',
showStatPeaks: true,
debugDisplayBGOpacity: 50,
subtitles: true,
hapticsMode: 'All',
Expand Down Expand Up @@ -1629,6 +1630,12 @@ typedef SaveDataOptions =
*/
var debugDisplay:String;

/**
* If enabled, statistic peaks will be shown on the debug display.
* @default `true`
*/
var showStatPeaks:Bool;

/**
* Opacity of the debug display's background.
* @default `50`
Expand Down
71 changes: 53 additions & 18 deletions source/funkin/ui/debug/FunkinDebugDisplay.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class FunkinDebugDisplay extends Sprite
public var backgroundOpacity(default, set):Float = 0.5;

var currentFPS:Int;
var currentFPSPeak:Int;
var deltaTimeout:Float;
var times:Array<Float>;
var color:Int;
Expand Down Expand Up @@ -59,6 +60,7 @@ class FunkinDebugDisplay extends Sprite
this.x = x;
this.y = y;
this.currentFPS = 0;
this.currentFPSPeak = 0;
this.deltaTimeout = 0.0;
#if !html5
this.gcMem = 0.0;
Expand Down Expand Up @@ -173,6 +175,8 @@ class FunkinDebugDisplay extends Sprite

currentFPS = times.length;

if (currentFPS > currentFPSPeak) currentFPSPeak = currentFPS;

#if !html5
gcMem = MemoryUtil.getGCMemory();

Expand All @@ -198,7 +202,7 @@ class FunkinDebugDisplay extends Sprite
deltaTimeout = 0.0;
}

function updateAdvancedDisplay():Void
function updateAdvancedDisplay():Void
{
updateFPSGraph();
#if !html5
Expand All @@ -207,19 +211,36 @@ class FunkinDebugDisplay extends Sprite
#end

final info:Array<String> = [];
info.push('FPS: $currentFPS');
info.push('AVG FPS: ${Math.floor(fpsGraph.average())}');
info.push('1% LOW FPS: ${Math.floor(fpsGraph.lowest())}');
fpsGraph.textDisplay.text = info.join('\n');
if (Preferences.showStatPeaks)
{
info.push('FPS: $currentFPS / $currentFPSPeak');
info.push('AVG FPS: ${Math.floor(fpsGraph.average())}');
info.push('1% LOW FPS: ${Math.floor(fpsGraph.lowest())}');
fpsGraph.textDisplay.text = info.join('\n');

#if !html5
gcMemGraph.textDisplay.text = 'GC MEM: ${FlxStringUtil.formatBytes(gcMem).toLowerCase()} / ${FlxStringUtil.formatBytes(gcMemPeak).toLowerCase()}';
#if !html5
gcMemGraph.textDisplay.text = 'GC MEM: ${FlxStringUtil.formatBytes(gcMem).toLowerCase()} / ${FlxStringUtil.formatBytes(gcMemPeak).toLowerCase()}';

if (taskMemGraph != null)
{
taskMemGraph.textDisplay.text = 'TASK MEM: ${FlxStringUtil.formatBytes(taskMem).toLowerCase()} / ${FlxStringUtil.formatBytes(taskMemPeak).toLowerCase()}';
if (taskMemGraph != null)
{
taskMemGraph.textDisplay.text = 'TASK MEM: ${FlxStringUtil.formatBytes(taskMem).toLowerCase()} / ${FlxStringUtil.formatBytes(taskMemPeak).toLowerCase()}';
}
#end
} else {
info.push('FPS: $currentFPS');
info.push('AVG FPS: ${Math.floor(fpsGraph.average())}');
info.push('1% LOW FPS: ${Math.floor(fpsGraph.lowest())}');
fpsGraph.textDisplay.text = info.join('\n');

#if !html5
gcMemGraph.textDisplay.text = 'GC MEM: ${FlxStringUtil.formatBytes(gcMem).toLowerCase()}';

if (taskMemGraph != null)
{
taskMemGraph.textDisplay.text = 'TASK MEM: ${FlxStringUtil.formatBytes(taskMem).toLowerCase()}';
}
#end
}
#end
}

function updateSimpleDisplay():Void
Expand All @@ -228,16 +249,30 @@ class FunkinDebugDisplay extends Sprite
{
final info:Array<String> = [];

info.push('FPS: $currentFPS');
if (Preferences.showStatPeaks)
{
info.push('FPS: $currentFPS / $currentFPSPeak');

#if !html5
info.push('GC MEM: ${FlxStringUtil.formatBytes(gcMem).toLowerCase()} / ${FlxStringUtil.formatBytes(gcMemPeak).toLowerCase()}');
#if !html5
info.push('GC MEM: ${FlxStringUtil.formatBytes(gcMem).toLowerCase()} / ${FlxStringUtil.formatBytes(gcMemPeak).toLowerCase()}');

if (MemoryUtil.supportsTaskMem())
info.push('TASK MEM: ${FlxStringUtil.formatBytes(taskMem).toLowerCase()} / ${FlxStringUtil.formatBytes(taskMemPeak).toLowerCase()}');
#end
if (MemoryUtil.supportsTaskMem())
info.push('TASK MEM: ${FlxStringUtil.formatBytes(taskMem).toLowerCase()} / ${FlxStringUtil.formatBytes(taskMemPeak).toLowerCase()}');
#end

infoDisplay.text = info.join('\n');
} else {
info.push('FPS: $currentFPS');

#if !html5
info.push('GC MEM: ${FlxStringUtil.formatBytes(gcMem).toLowerCase()}');

if (MemoryUtil.supportsTaskMem())
info.push('TASK MEM: ${FlxStringUtil.formatBytes(taskMem).toLowerCase()}');
#end

infoDisplay.text = info.join('\n');
infoDisplay.text = info.join('\n');
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions source/funkin/ui/options/PreferencesMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ class PreferencesMenu extends Page<OptionsState.OptionsMenuPageName>
], (key:String, value:DebugDisplayMode) -> {
Preferences.debugDisplay = value;
}, Preferences.debugDisplay);
createPrefItemCheckbox('Show Statistic Peaks', 'If enabled, statistic peaks will be shown in the debug display.', function(value:Bool):Void {
Preferences.showStatPeaks = value;
}, Preferences.showStatPeaks);
createPrefItemPercentage('Debug Display BG', "Adjust the debug display's background opacity.", function(value:Int):Void {
Preferences.debugDisplayBGOpacity = value;
}, Preferences.debugDisplayBGOpacity);
Expand Down