Merge branch 'main' into base-fnf-port-remake

This commit is contained in:
⍚~Nex
2024-11-03 21:39:23 +01:00
26 changed files with 231 additions and 255 deletions
-52
View File
@@ -255,58 +255,6 @@ class Paths
content[k] = '$key$e';
}
return content;
/*
if (!key.endsWith("/")) key = key + "/";
if (ModsFolder.currentModFolder == null && !scanSource)
return getFolderContent(key, false, addPath, true);
var folderPath:String = scanSource ? getAssetsPath(key) : getLibraryPathForce(key, 'mods/${ModsFolder.currentModFolder}');
var libThing = new LimeLibrarySymbol(folderPath);
var library = libThing.library;
if (library is openfl.utils.AssetLibrary) {
var lib = cast(libThing.library, openfl.utils.AssetLibrary);
@:privateAccess
if (lib.__proxy != null) library = lib.__proxy;
}
var content:Array<String> = [];
#if MOD_SUPPORT
if (library is funkin.backend.assets.IModsAssetLibrary) {
// easy task, can immediately scan for files!
var lib = cast(library, funkin.backend.assets.IModsAssetLibrary);
content = lib.getFiles(libThing.symbolName);
if (addPath)
for(i in 0...content.length)
content[i] = '$folderPath${content[i]}';
} else #end {
@:privateAccess
for(k=>e in library.paths) {
if (k.toLowerCase().startsWith(libThing.symbolName.toLowerCase())) {
if (addPath) {
if (libThing.libraryName != "")
content.push('${libThing.libraryName}:$k');
else
content.push(k);
} else {
var barebonesFileName = k.substr(libThing.symbolName.length);
if (!barebonesFileName.contains("/"))
content.push(barebonesFileName);
}
}
}
}
if (includeSource) {
var sourceResult = getFolderContent(key, false, addPath, true);
for(e in sourceResult)
if (!content.contains(e))
content.push(e);
}
return content;
*/
}
// Used in Script.hx
+66 -24
View File
@@ -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;
}
}
+4 -1
View File
@@ -721,7 +721,10 @@ class CoolUtil
*/
@:noUsing public static inline function openURL(url:String) {
#if linux
Sys.command('/usr/bin/xdg-open', [url]);
// generally `xdg-open` should work in every distro
var cmd = Sys.command("xdg-open", [url]);
// run old command JUST IN CASE it fails, which it shouldn't
if (cmd != 0) cmd = Sys.command("/usr/bin/xdg-open", [url]);
#else
FlxG.openURL(url);
#end
+4 -2
View File
@@ -140,14 +140,16 @@ class MemoryUtil {
reg.match(process.stdout.readAll().toString());
if (process.exitCode() == 0) return reg.matched(1);
#elseif linux
var process = new HiddenProcess("sudo", ["dmidecode", "--type", "17"]);
/*var process = new HiddenProcess("sudo", ["dmidecode", "--type", "17"]);
if (process.exitCode() != 0) return "Unknown";
var lines = process.stdout.readAll().toString().split("\n");
for (line in lines) {
if (line.startsWith("Type:")) {
return line.substring("Type:".length).trim();
}
}
}*/
// TODO: sort of unsafe? also requires users to use `sudo`
// when launching the engine through the CLI, REIMPLEMENT LATER.
#end
return "Unknown";
}