Merge branch 'main' into pr/397
This commit is contained in:
@@ -11,8 +11,7 @@ class Logs {
|
||||
|
||||
public static var nativeTrace = Log.trace;
|
||||
public static function init() {
|
||||
|
||||
Log.trace = function(v : Dynamic, ?infos : Null<haxe.PosInfos>) {
|
||||
Log.trace = function(v:Dynamic, ?infos:Null<haxe.PosInfos>) {
|
||||
var data = [
|
||||
logText('${infos.fileName}:${infos.lineNumber}: ', CYAN),
|
||||
logText(Std.string(v))
|
||||
@@ -28,22 +27,48 @@ class Logs {
|
||||
__showInConsole(prepareColoredTrace(data, TRACE));
|
||||
};
|
||||
|
||||
LogFrontEnd.onLogs = function(Data, Style, FireOnce) {
|
||||
LogFrontEnd.onLogs = function(data, style, fireOnce) {
|
||||
var prefix = "[FLIXEL]";
|
||||
var color:ConsoleColor = LIGHTGRAY;
|
||||
var level:Level = INFO;
|
||||
if (Style == LogStyle.CONSOLE) {prefix = "> "; color = WHITE; level = INFO; } else
|
||||
if (Style == LogStyle.ERROR) {prefix = "[FLIXEL]"; color = RED; level = ERROR; } else
|
||||
if (Style == LogStyle.NORMAL) {prefix = "[FLIXEL]"; color = WHITE; level = INFO; } else
|
||||
if (Style == LogStyle.NOTICE) {prefix = "[FLIXEL]"; color = GREEN; level = VERBOSE;} else
|
||||
if (Style == LogStyle.WARNING) {prefix = "[FLIXEL]"; color = YELLOW; level = WARNING;}
|
||||
if (style == LogStyle.CONSOLE) // cant place a switch here as these arent inline values - Nex
|
||||
{
|
||||
prefix = "> ";
|
||||
color = WHITE;
|
||||
level = INFO;
|
||||
}
|
||||
else if (style == LogStyle.ERROR)
|
||||
{
|
||||
prefix = "[FLIXEL]";
|
||||
color = RED;
|
||||
level = ERROR;
|
||||
}
|
||||
else if (style == LogStyle.NORMAL)
|
||||
{
|
||||
prefix = "[FLIXEL]";
|
||||
color = WHITE;
|
||||
level = INFO;
|
||||
}
|
||||
else if (style == LogStyle.NOTICE)
|
||||
{
|
||||
prefix = "[FLIXEL]";
|
||||
color = GREEN;
|
||||
level = VERBOSE;
|
||||
}
|
||||
else if (style == LogStyle.WARNING)
|
||||
{
|
||||
prefix = "[FLIXEL]";
|
||||
color = YELLOW;
|
||||
level = WARNING;
|
||||
}
|
||||
|
||||
var d:Dynamic = Data;
|
||||
var d:Dynamic = data;
|
||||
if (!(d is Array))
|
||||
d = [d];
|
||||
var a:Array<Dynamic> = d;
|
||||
var strs = [for(e in a) Std.string(e)];
|
||||
for(e in strs) {
|
||||
for(e in strs)
|
||||
{
|
||||
Logs.trace('$prefix $e', level, color);
|
||||
}
|
||||
};
|
||||
@@ -55,12 +80,18 @@ class Logs {
|
||||
logText('[ '),
|
||||
logText('${Std.string(time.getHours()).addZeros(2)}:${Std.string(time.getMinutes()).addZeros(2)}:${Std.string(time.getSeconds()).addZeros(2)}', DARKMAGENTA),
|
||||
logText(' |'),
|
||||
switch(level) {
|
||||
case WARNING: logText(' WARNING ', DARKYELLOW);
|
||||
case ERROR: logText(' ERROR ', DARKRED);
|
||||
case TRACE: logText(' TRACE ', GRAY);
|
||||
case VERBOSE: logText(' VERBOSE ', DARKMAGENTA);
|
||||
default: logText(' INFORMATION ', CYAN);
|
||||
switch (level)
|
||||
{
|
||||
case WARNING:
|
||||
logText(' WARNING ', DARKYELLOW);
|
||||
case ERROR:
|
||||
logText(' ERROR ', DARKRED);
|
||||
case TRACE:
|
||||
logText(' TRACE ', GRAY);
|
||||
case VERBOSE:
|
||||
logText(' VERBOSE ', DARKMAGENTA);
|
||||
default:
|
||||
logText(' INFORMATION ', CYAN);
|
||||
},
|
||||
logText('] ')
|
||||
];
|
||||
@@ -77,7 +108,7 @@ class Logs {
|
||||
}
|
||||
|
||||
public static function __showInConsole(text:Array<LogText>) {
|
||||
#if sys
|
||||
#if (sys && !mobile)
|
||||
while(__showing) {
|
||||
Sys.sleep(0.05);
|
||||
}
|
||||
@@ -89,20 +120,30 @@ class Logs {
|
||||
NativeAPI.setConsoleColors();
|
||||
Sys.print("\r\n");
|
||||
__showing = false;
|
||||
#elseif mobile
|
||||
while(__showing) {
|
||||
Sys.sleep(0.05);
|
||||
}
|
||||
__showing = true;
|
||||
@:privateAccess
|
||||
Sys.print([for(t in text) t.text].join(""));
|
||||
__showing = false;
|
||||
#else
|
||||
@:privateAccess
|
||||
nativeTrace([for(t in text) t.text].join(""));
|
||||
#end
|
||||
}
|
||||
|
||||
public static function traceColored(text:Array<LogText>, level:Level = INFO) {
|
||||
public static function traceColored(text:Array<LogText>, level:Level = INFO)
|
||||
__showInConsole(prepareColoredTrace(text, level));
|
||||
}
|
||||
|
||||
public static function trace(text:String, level:Level = INFO, color:ConsoleColor = LIGHTGRAY) {
|
||||
traceColored([{
|
||||
text: text,
|
||||
color: color
|
||||
}], level);
|
||||
traceColored([
|
||||
{
|
||||
text: text,
|
||||
color: color
|
||||
}
|
||||
], level);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +154,8 @@ enum abstract Level(Int) {
|
||||
var TRACE = 3;
|
||||
var VERBOSE = 4;
|
||||
}
|
||||
|
||||
typedef LogText = {
|
||||
var text:String;
|
||||
var color:ConsoleColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,6 +166,8 @@ class Main extends Sprite
|
||||
}
|
||||
|
||||
public static function refreshAssets() {
|
||||
WindowUtils.resetTitle();
|
||||
|
||||
FlxSoundTray.volumeChangeSFX = Paths.sound('menu/volume');
|
||||
FlxSoundTray.volumeUpChangeSFX = null;
|
||||
FlxSoundTray.volumeDownChangeSFX = null;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package funkin.backend.system.framerate;
|
||||
|
||||
import funkin.backend.scripting.ModState;
|
||||
|
||||
class FlixelInfo extends FramerateCategory {
|
||||
public function new() {
|
||||
super("Flixel Info");
|
||||
@@ -14,7 +16,12 @@ class FlixelInfo extends FramerateCategory {
|
||||
for(_ in FlxG.bitmap._cache.keys())
|
||||
c++;
|
||||
|
||||
_text = 'State: ${Type.getClassName(Type.getClass(FlxG.state))}';
|
||||
if((FlxG.state is ModState)) {
|
||||
var state:ModState = cast FlxG.state;
|
||||
_text = "Mod State: " + state.scriptName;
|
||||
} else {
|
||||
_text = 'State: ${Type.getClassName(Type.getClass(FlxG.state))}';
|
||||
}
|
||||
_text += '\nObject Count: ${FlxG.state.members.length}';
|
||||
_text += '\nCamera Count: ${FlxG.cameras.list.length}';
|
||||
_text += '\nBitmaps Count: ${c}';
|
||||
@@ -22,9 +29,9 @@ class FlixelInfo extends FramerateCategory {
|
||||
_text += '\nFlxG.game Childs Count: ${FlxG.game.numChildren}';
|
||||
// _text += '\nCached objects count: ${cachedObjects}';
|
||||
#if FLX_POINT_POOL
|
||||
var points = flixel.math.FlxPoint.FlxBasePoint.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}';
|
||||
//_text += '\nPoint Count: ${points._count}';
|
||||
#end
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ package funkin.backend.system.github;
|
||||
|
||||
#if GITHUB_API
|
||||
import haxe.Json;
|
||||
import haxe.Exception;
|
||||
#end
|
||||
import haxe.Exception;
|
||||
|
||||
// TODO: Document further and perhaps make this a Haxelib.
|
||||
class GitHub {
|
||||
|
||||
@@ -42,26 +42,12 @@ class HashLinkFixer {
|
||||
var cl = clRef.get();
|
||||
|
||||
if (cl.isAbstract || cl.isExtern || cl.isInterface) return fields;
|
||||
if (!cl.name.endsWith("_Impl_") && !cl.name.endsWith("_HSX") && !cl.name.endsWith("_HSC") && !cl.name.endsWith("_HLFHelper")) {
|
||||
var metas = cl.meta.get();
|
||||
|
||||
if (!cl.name.endsWith("_Impl_") && !cl.name.endsWith("_HSX") && !cl.name.endsWith("_HSC")) {
|
||||
if(cl.params.length > 0)
|
||||
return fields;
|
||||
|
||||
if(cl.module == "EReg") return fields; // private typedef in same class
|
||||
if(cl.module == "hl.Format") return fields; // enum in same class
|
||||
|
||||
var definedFields = [];
|
||||
|
||||
var helperClass = macro class {
|
||||
|
||||
};
|
||||
|
||||
helperClass.pos = cl.pos;
|
||||
|
||||
var module = cl.module + "_HLFHelper";
|
||||
var hcClassName = cl.name + "_HLFHelper";
|
||||
|
||||
for(f in fields.copy()) {
|
||||
if (f == null)
|
||||
continue;
|
||||
@@ -70,10 +56,12 @@ class HashLinkFixer {
|
||||
|
||||
if(definedFields.contains(f.name)) continue; // no duplicate fields
|
||||
|
||||
var hlNativeMeta = null;
|
||||
var hasHlNative = false;
|
||||
for(m in f.meta)
|
||||
if (m.name == ":hlNative") {
|
||||
hasHlNative = true;
|
||||
hlNativeMeta = m;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -92,16 +80,39 @@ class HashLinkFixer {
|
||||
var overrideExpr:Expr;
|
||||
var returns:Bool = !fun.ret.match(TPath({name: "Void"}));
|
||||
|
||||
var printer = new haxe.macro.Printer();
|
||||
if(cl.module == "hl.Gc" && fun.ret == null) returns = false; // fix since they dont explicitly set :Void
|
||||
if(cl.module == "hl.Format" && fun.ret == null) returns = false; // fix since they dont explicitly set :Void
|
||||
|
||||
var name = 'hlf_${f.name}';
|
||||
|
||||
var arguments = fun.args == null ? [] : [for(a in fun.args) macro $i{a.name}];
|
||||
|
||||
var funcExpr:Expr = returns ? {
|
||||
//macro return $i{name}($a{arguments});
|
||||
macro return @:privateAccess $i{hcClassName}.$name($a{arguments});
|
||||
} : {
|
||||
macro @:privateAccess $i{hcClassName}.$name($a{arguments});
|
||||
};
|
||||
var funcExpr:Expr = macro @:privateAccess $i{name}($a{arguments});
|
||||
if(returns) funcExpr = macro return $funcExpr;
|
||||
|
||||
var cleanMeta = f.meta.copy().filter(function(m) return m.name != ":hlNative");
|
||||
var hasBareMeta = hlNativeMeta.params.length == 0;
|
||||
|
||||
var meta = f.meta.copy();
|
||||
switch hlNativeMeta {
|
||||
case {params: []}:
|
||||
meta = [{name: ":hlNative", params: [macro "std", macro $v{f.name}], pos: Context.currentPos()}].concat(cleanMeta);
|
||||
case {params: [_.expr => EConst(CString(name))]}:
|
||||
meta = [{name: ":hlNative", params: [macro "std", macro $v{name}], pos: Context.currentPos()}].concat(cleanMeta);
|
||||
case {params: [_.expr => EConst(CFloat(version))]}:
|
||||
var curVersion = Context.definedValue("hl_ver");
|
||||
if(curVersion == null) curVersion = "";
|
||||
if(version > curVersion) {
|
||||
meta = cleanMeta;
|
||||
if(f.meta.filter((m) -> m.name == ":noExpr").length > 0)
|
||||
Context.error("Missing function body", f.pos);
|
||||
funcExpr = fun.expr; // restore to default behaviour
|
||||
} else {
|
||||
meta = [{name: ":hlNative", params: [macro "std", macro $v{f.name}], pos: Context.currentPos()}].concat(cleanMeta);
|
||||
}
|
||||
default:
|
||||
}
|
||||
|
||||
var fiel:Field = {
|
||||
name: name,
|
||||
@@ -109,50 +120,32 @@ class HashLinkFixer {
|
||||
kind: FFun({
|
||||
ret: fun.ret,
|
||||
params: fun.params.copy(),
|
||||
expr: fun.expr,
|
||||
expr: funcExpr,
|
||||
args: fun.args.copy()
|
||||
}),
|
||||
access: f.access.copy(),
|
||||
meta: f.meta.copy()
|
||||
access: f.access.copy().filter(function(a) return a != APublic && a != APrivate).concat([APrivate]),
|
||||
meta: meta
|
||||
};
|
||||
helperClass.fields.push(fiel);
|
||||
fields.push(fiel);
|
||||
definedFields.push(f.name);
|
||||
|
||||
// Remove meta from original function
|
||||
for(m in f.meta.copy())
|
||||
if (m.name == ":hlNative") {
|
||||
f.meta.remove(m);
|
||||
}
|
||||
|
||||
fun.expr = funcExpr;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
helperClass.pack = cl.pack.copy();
|
||||
helperClass.pos = cl.pos;
|
||||
helperClass.name = hcClassName;
|
||||
|
||||
if(definedFields.length > 0) {
|
||||
/*if(definedFields.length > 0) {
|
||||
trace(cl.module);
|
||||
|
||||
/*for(m in metas.copy()) {
|
||||
trace(" " + m.name);
|
||||
if(m.name == ":coreApi") {
|
||||
metas.remove(m);
|
||||
}
|
||||
}*/
|
||||
|
||||
var imports = Context.getLocalImports().copy();
|
||||
Context.defineModule(module, [helperClass], imports);
|
||||
|
||||
Context.getLocalImports().push({
|
||||
path: [for(m in module.split(".")) {
|
||||
name: m,
|
||||
pos: Context.currentPos()
|
||||
}],
|
||||
mode: INormal
|
||||
});
|
||||
}
|
||||
var printer = new haxe.macro.Printer();
|
||||
for(field in fields) if(field.name.startsWith("hlf_"))
|
||||
Sys.println(printer.printField(field));
|
||||
}*/
|
||||
}
|
||||
|
||||
return fields;
|
||||
|
||||
@@ -62,6 +62,7 @@ class AudioSwitchFix {
|
||||
}
|
||||
}
|
||||
|
||||
@:dox(hide)
|
||||
typedef PlayingSound = {
|
||||
var sound:FlxSound;
|
||||
var time:Float;
|
||||
|
||||
@@ -101,7 +101,7 @@ class AsyncUpdater {
|
||||
progress.files = files.length;
|
||||
progress.step = DOWNLOADING_ASSETS;
|
||||
trace('starting assets download');
|
||||
doFile([for(e in files) e], [for(e in fileNames) e], function() {
|
||||
doFile(files.copy(), fileNames.copy(), function() {
|
||||
progress.curFile = -1;
|
||||
progress.curFileName = null;
|
||||
progress.files = 1;
|
||||
|
||||
Reference in New Issue
Block a user