Move Tracy debug message into trace()
This commit is contained in:
committed by
Cameron Taylor
parent
bdcd7b8a91
commit
04a7007f6e
@@ -86,6 +86,10 @@ class InitState extends FlxState
|
||||
// Disable the thing on Windows where it tries to send a bug report to Microsoft because why do they care?
|
||||
WindowUtil.disableCrashHandler();
|
||||
|
||||
#if FEATURE_DEBUG_TRACY
|
||||
funkin.util.WindowUtil.initTracy();
|
||||
#end
|
||||
|
||||
// This ain't a pixel art game! (most of the time)
|
||||
FlxSprite.defaultAntialiasing = true;
|
||||
|
||||
|
||||
@@ -799,8 +799,6 @@ class PlayState extends MusicBeatSubState
|
||||
|
||||
public override function update(elapsed:Float):Void
|
||||
{
|
||||
// TOTAL: 9.42% CPU Time when profiled in VS 2019.
|
||||
|
||||
if (criticalFailure) return;
|
||||
|
||||
super.update(elapsed);
|
||||
|
||||
@@ -74,10 +74,14 @@ class AnimateAtlasCharacter extends BaseCharacter
|
||||
|
||||
override function onCreate(event:ScriptEvent):Void
|
||||
{
|
||||
trace('Creating Animate Atlas character: ' + this.characterId);
|
||||
// Display a custom scope for debugging purposes.
|
||||
#if FEATURE_DEBUG_TRACY
|
||||
cpp.vm.tracy.TracyProfiler.zoneScoped('AnimateAtlasCharacter.create(${this.characterId})');
|
||||
#end
|
||||
|
||||
try
|
||||
{
|
||||
trace('Loading assets for Animate Atlas character "${characterId}"', flixel.util.FlxColor.fromString("#89CFF0"));
|
||||
var atlasSprite:FlxAtlasSprite = loadAtlasSprite();
|
||||
setSprite(atlasSprite);
|
||||
|
||||
|
||||
@@ -149,6 +149,7 @@ class BaseCharacter extends Bopper
|
||||
public function new(id:String, renderType:CharacterRenderType)
|
||||
{
|
||||
super(CharacterDataParser.DEFAULT_DANCEEVERY);
|
||||
|
||||
this.characterId = id;
|
||||
|
||||
ignoreExclusionPref = ["sing"];
|
||||
|
||||
@@ -26,7 +26,10 @@ class MultiSparrowCharacter extends BaseCharacter
|
||||
|
||||
override function onCreate(event:ScriptEvent):Void
|
||||
{
|
||||
trace('Creating Multi-Sparrow character: ' + this.characterId);
|
||||
// Display a custom scope for debugging purposes.
|
||||
#if FEATURE_DEBUG_TRACY
|
||||
cpp.vm.tracy.TracyProfiler.zoneScoped('MultiSparrowCharacter.create(${this.characterId})');
|
||||
#end
|
||||
|
||||
buildSprites();
|
||||
super.onCreate(event);
|
||||
@@ -53,6 +56,8 @@ class MultiSparrowCharacter extends BaseCharacter
|
||||
|
||||
function buildSpritesheet():Void
|
||||
{
|
||||
trace('Loading assets for Multi-Sparrow character "${characterId}"', flixel.util.FlxColor.fromString("#89CFF0"));
|
||||
|
||||
var assetList = [];
|
||||
for (anim in _data.animations)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,10 @@ class PackerCharacter extends BaseCharacter
|
||||
|
||||
override function onCreate(event:ScriptEvent):Void
|
||||
{
|
||||
trace('Creating Packer character: ' + this.characterId);
|
||||
// Display a custom scope for debugging purposes.
|
||||
#if FEATURE_DEBUG_TRACY
|
||||
cpp.vm.tracy.TracyProfiler.zoneScoped('PackerCharacter.create(${this.characterId})');
|
||||
#end
|
||||
|
||||
loadSpritesheet();
|
||||
loadAnimations();
|
||||
@@ -28,7 +31,7 @@ class PackerCharacter extends BaseCharacter
|
||||
|
||||
function loadSpritesheet():Void
|
||||
{
|
||||
trace('[PACKERCHAR] Loading spritesheet ${_data.assetPath} for ${characterId}');
|
||||
trace('Loading assets for Packer character "${characterId}"', flixel.util.FlxColor.fromString("#89CFF0"));
|
||||
|
||||
var tex:FlxFramesCollection = Paths.getPackerAtlas(_data.assetPath);
|
||||
if (tex == null)
|
||||
|
||||
@@ -21,7 +21,10 @@ class SparrowCharacter extends BaseCharacter
|
||||
|
||||
override function onCreate(event:ScriptEvent):Void
|
||||
{
|
||||
trace('Creating Sparrow character: ' + this.characterId);
|
||||
// Display a custom scope for debugging purposes.
|
||||
#if FEATURE_DEBUG_TRACY
|
||||
cpp.vm.tracy.TracyProfiler.zoneScoped('SparrowCharacter.create(${this.characterId})');
|
||||
#end
|
||||
|
||||
loadSpritesheet();
|
||||
loadAnimations();
|
||||
@@ -31,7 +34,7 @@ class SparrowCharacter extends BaseCharacter
|
||||
|
||||
function loadSpritesheet()
|
||||
{
|
||||
trace('[SPARROWCHAR] Loading spritesheet ${_data.assetPath} for ${characterId}');
|
||||
trace('Loading assets for Sparrow character "${characterId}"', flixel.util.FlxColor.fromString("#89CFF0"));
|
||||
|
||||
var tex:FlxFramesCollection = Paths.getSparrowAtlas(_data.assetPath);
|
||||
if (tex == null)
|
||||
|
||||
@@ -807,7 +807,10 @@ class Strumline extends FlxSpriteGroup
|
||||
|
||||
if (holdNoteSprite != null)
|
||||
{
|
||||
var noteKindStyle:NoteStyle = NoteKindManager.getNoteStyle(note.kind, this.noteStyle.id) ?? this.noteStyle;
|
||||
var noteKindStyle:NoteStyle = NoteKindManager.getNoteStyle(note.kind, this.noteStyle.id);
|
||||
if (noteKindStyle == null) noteKindStyle = NoteKindManager.getNoteStyle(note.kind, null);
|
||||
if (noteKindStyle == null) noteKindStyle = this.noteStyle;
|
||||
|
||||
holdNoteSprite.setupHoldNoteGraphic(noteKindStyle);
|
||||
|
||||
holdNoteSprite.parentStrumline = this;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package funkin.play.notes.notekind;
|
||||
|
||||
import funkin.data.song.SongData.SongNoteData;
|
||||
import funkin.modding.events.ScriptEventDispatcher;
|
||||
import funkin.modding.events.ScriptEvent;
|
||||
import funkin.ui.debug.charting.util.ChartEditorDropdowns;
|
||||
@@ -82,6 +83,16 @@ class NoteKindManager
|
||||
return NoteStyleRegistry.instance.fetchEntry(noteStyleId);
|
||||
}
|
||||
|
||||
public static function listNoteStyles(songNoteDatas:Array<SongNoteData>):Array<NoteStyle>
|
||||
{
|
||||
var results:Array<NoteStyle> = [];
|
||||
for (songNoteData in songNoteDatas)
|
||||
{
|
||||
var noteStyle:NoteStyle = getNoteStyle(songNoteData.kind, null);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the note style id from the given note kind
|
||||
* @param noteKind Note kind name
|
||||
|
||||
@@ -34,6 +34,30 @@ class WindowUtil
|
||||
#end
|
||||
}
|
||||
|
||||
#if FEATURE_DEBUG_TRACY
|
||||
/**
|
||||
* Initialize Tracy.
|
||||
* NOTE: Call this from the main thread ONLY!
|
||||
*/
|
||||
public static function initTracy():Void
|
||||
{
|
||||
// Apply a marker to indicate frame end for the Tracy profiler.
|
||||
// Do this only if Tracy is configured to prevent lag.
|
||||
openfl.Lib.current.stage.addEventListener(openfl.events.Event.EXIT_FRAME, (e:openfl.events.Event) -> {
|
||||
cpp.vm.tracy.TracyProfiler.frameMark();
|
||||
});
|
||||
|
||||
var appInfoMessage = funkin.util.logging.CrashHandler.buildSystemInfo();
|
||||
|
||||
trace("Friday Night Funkin': Connection to Tracy profiler successful.");
|
||||
|
||||
// Post system info like Git hash
|
||||
cpp.vm.tracy.TracyProfiler.messageAppInfo(appInfoMessage);
|
||||
|
||||
cpp.vm.tracy.TracyProfiler.setThreadName("main");
|
||||
}
|
||||
#end
|
||||
|
||||
/**
|
||||
* Runs platform-specific code to open a path in the file explorer.
|
||||
* @param targetPath The path to open.
|
||||
@@ -91,14 +115,6 @@ class WindowUtil
|
||||
windowExit.dispatch(exitCode);
|
||||
});
|
||||
|
||||
#if FEATURE_DEBUG_TRACY
|
||||
// Apply a marker to indicate frame end for the Tracy profiler.
|
||||
// Do this only if Tracy is configured to prevent lag.
|
||||
openfl.Lib.current.stage.addEventListener(openfl.events.Event.EXIT_FRAME, (e:openfl.events.Event) -> {
|
||||
cpp.vm.tracy.TracyProfiler.frameMark();
|
||||
});
|
||||
#end
|
||||
|
||||
openfl.Lib.current.stage.addEventListener(openfl.events.KeyboardEvent.KEY_DOWN, (e:openfl.events.KeyboardEvent) -> {
|
||||
for (key in PlayerSettings.player1.controls.getKeysForAction(WINDOW_FULLSCREEN))
|
||||
{
|
||||
|
||||
@@ -2,14 +2,20 @@ package funkin.util.logging;
|
||||
|
||||
class AnsiTrace
|
||||
{
|
||||
// mostly a copy of haxe.Log.trace()
|
||||
// but adds nice cute ANSI things
|
||||
/**
|
||||
* Output a message to the log.
|
||||
* Called when using `trace()`, and modified from the default to support ANSI colors.
|
||||
* @param v The value to print.
|
||||
*/
|
||||
public static function trace(v:Dynamic, ?info:haxe.PosInfos)
|
||||
{
|
||||
#if (NO_FEATURE_LOG_TRACE && !FEATURE_DEBUG_FUNCTIONS)
|
||||
return;
|
||||
#end
|
||||
var str = formatOutput(v, info);
|
||||
#if FEATURE_DEBUG_TRACY
|
||||
cpp.vm.tracy.TracyProfiler.message(str, flixel.util.FlxColor.WHITE);
|
||||
#end
|
||||
#if js
|
||||
if (js.Syntax.typeof(untyped console) != "undefined" && (untyped console).log != null) (untyped console).log(str);
|
||||
#elseif lua
|
||||
@@ -31,7 +37,10 @@ class AnsiTrace
|
||||
public static inline var BOLD = "\x1b[1m";
|
||||
public static inline var ITALIC = "\x1b[3m";
|
||||
|
||||
// where the real mf magic happens with ansi stuff!
|
||||
/**
|
||||
* Format the output to use ANSI colors.
|
||||
* Edited from the standard `trace()` implementation.
|
||||
*/
|
||||
public static function formatOutput(v:Dynamic, infos:haxe.PosInfos):String
|
||||
{
|
||||
var str = Std.string(v);
|
||||
@@ -52,6 +61,9 @@ class AnsiTrace
|
||||
return pstr + ": " + str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print color pixel art of BF in ANSI format.
|
||||
*/
|
||||
public static function traceBF()
|
||||
{
|
||||
#if (sys && debug)
|
||||
@@ -74,7 +86,10 @@ class AnsiTrace
|
||||
return (colorSupported ? ansiCol : "");
|
||||
}
|
||||
|
||||
// generated using https://dom111.github.io/image-to-ansi/
|
||||
/**
|
||||
* Color pixel art of BF in ANSI format.
|
||||
* Generated using https://dom111.github.io/image-to-ansi/
|
||||
*/
|
||||
public static var ansiBF:Array<String> = [
|
||||
"\x1b[39m\x1b[49m \x1b[48;2;154;23;70m \x1b[49m \x1b[m",
|
||||
"\x1b[39m\x1b[49m \x1b[48;2;154;23;70m \x1b[48;2;184;46;83m \x1b[48;2;246;87;102m \x1b[48;2;239;83;100m \x1b[48;2;154;23;70m \x1b[48;2;154;23;69m \x1b[49m \x1b[m",
|
||||
|
||||
@@ -117,6 +117,7 @@ class CrashHandler
|
||||
|
||||
sys.io.File.saveContent('$LOG_FOLDER/crash${critical ? '-critical' : ''}-${DateUtil.generateTimestamp()}.log', buildCrashReport(message));
|
||||
}
|
||||
#end
|
||||
|
||||
static function buildCrashReport(message:String):String
|
||||
{
|
||||
@@ -126,21 +127,7 @@ class CrashHandler
|
||||
|
||||
fullContents += '\n';
|
||||
|
||||
fullContents += 'Generated by: ${Constants.GENERATED_BY}\n';
|
||||
fullContents += ' Git hash: ${Constants.GIT_HASH} (${Constants.GIT_HAS_LOCAL_CHANGES ? 'MODIFIED' : 'CLEAN'})\n';
|
||||
fullContents += 'System timestamp: ${DateUtil.generateTimestamp()}\n';
|
||||
var driverInfo = FlxG?.stage?.context3D?.driverInfo ?? 'N/A';
|
||||
fullContents += 'Driver info: ${driverInfo}\n';
|
||||
fullContents += 'Platform: ${Sys.systemName()}\n';
|
||||
fullContents += 'Render method: ${renderMethod()}\n';
|
||||
|
||||
fullContents += '\n';
|
||||
|
||||
fullContents += '=====================\n';
|
||||
|
||||
fullContents += '\n';
|
||||
|
||||
fullContents += MemoryUtil.buildGCInfo();
|
||||
fullContents += buildSystemInfo();
|
||||
|
||||
fullContents += '\n\n';
|
||||
|
||||
@@ -197,7 +184,27 @@ class CrashHandler
|
||||
|
||||
return fullContents;
|
||||
}
|
||||
#end
|
||||
|
||||
public static function buildSystemInfo():String
|
||||
{
|
||||
var fullContents = 'Generated by: ${Constants.GENERATED_BY}\n';
|
||||
fullContents += ' Git hash: ${Constants.GIT_HASH} (${Constants.GIT_HAS_LOCAL_CHANGES ? 'MODIFIED' : 'CLEAN'})\n';
|
||||
fullContents += 'System timestamp: ${DateUtil.generateTimestamp()}\n';
|
||||
var driverInfo = FlxG?.stage?.context3D?.driverInfo ?? 'N/A';
|
||||
fullContents += 'Driver info: ${driverInfo}\n';
|
||||
fullContents += 'Platform: ${Sys.systemName()}\n';
|
||||
fullContents += 'Render method: ${renderMethod()}\n';
|
||||
|
||||
fullContents += '\n';
|
||||
|
||||
fullContents += '=====================\n';
|
||||
|
||||
fullContents += '\n';
|
||||
|
||||
fullContents += MemoryUtil.buildGCInfo();
|
||||
|
||||
return fullContents;
|
||||
}
|
||||
|
||||
static function generateErrorMessage(error:UncaughtErrorEvent):String
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user