Skip to content
This repository was archived by the owner on Jun 17, 2026. It is now read-only.

Commit 816b7c1

Browse files
committed
guys there was a singular fucking pair of {} causing the console to constantly refresh
also logs system coded by yours truly for Adventure Engine (NOT AN FNF ENGINE, my fnf engine is Char Engine)
1 parent 6f5271f commit 816b7c1

4 files changed

Lines changed: 93 additions & 144 deletions

File tree

Project.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<define name="TITLE_SCREEN_EASTER_EGG" if="officialBuild"/> <!-- DELETE THE if="officialBuild" for enabling this on an unofficial build -->
5454
<define name="CRASH_HANDLER" if="desktop release" />
5555
<define name="SOFTCODED_STATES" if="MODS_ALLOWED"/>
56+
<define name="GLOBAL_SCRIPT" if="MODS_ALLOWED"/>
5657

5758
<define name="DEV"/>
5859

source/Main.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import openfl.display.Sprite;
1111
import openfl.events.Event;
1212
import openfl.display.StageScaleMode;
1313
import codename.modding.ModsFolder;
14+
import codename.backend.system.Logs;
1415

1516
//crash handler stuff
1617
#if CRASH_HANDLER
@@ -91,6 +92,7 @@ class Main extends Sprite
9192
}
9293

9394
Paths.assetsTree = new AssetsLibraryList();
95+
Logs.init();
9496

9597
ClientPrefs.loadDefaultStuff();
9698
addChild(new FlxGame(gameWidth, gameHeight, initialState, framerate, framerate, skipSplash, startFullscreen));
Lines changed: 89 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,107 @@
11
package codename.backend.system;
22

3-
import flixel.system.debug.log.LogStyle;
4-
import flixel.system.frontEnds.LogFrontEnd;
53
import haxe.Log;
6-
import codename.backend.utils.NativeAPI;
7-
import codename.backend.utils.NativeAPI.ConsoleColor;
4+
import haxe.PosInfos;
5+
import lime.app.Application;
6+
using codename.backend.system.Logs.LogTools;
87

9-
class Logs {
10-
private static var __showing:Bool = false;
8+
class AlertParams
9+
{
10+
public var content:String = 'None';
11+
public var title:Null<String> = null;
1112

12-
public static var nativeTrace = Log.trace;
13-
public static function init() {
14-
Log.trace = function(v:Dynamic, ?infos:Null<haxe.PosInfos>) {
15-
var data = [
16-
logText('${infos.fileName}:${infos.lineNumber}: ', CYAN),
17-
logText(Std.string(v))
18-
];
13+
public function new(content:String = 'None', ?title:Null<String>)
14+
{
15+
this.content = content;
16+
this.title = title;
17+
}
18+
}
1919

20-
if (infos.customParams != null) {
21-
for (i in infos.customParams) {
22-
data.push(
23-
logText("," + Std.string(i))
24-
);
25-
}
26-
}
27-
__showInConsole(prepareColoredTrace(data, TRACE));
28-
};
20+
class LogTools
21+
{
22+
@:deprecated('The level.toLevel() function will soon be removed from backend.LogTools.') public static inline function toLevel(level:Level):String
23+
{
24+
return levelToString(level);
25+
}
2926

30-
LogUtils.onLogs = function(data, style, fireOnce) {
31-
var prefix = "[FLIXEL]";
32-
var color:ConsoleColor = LIGHTGRAY;
33-
var level:Level = INFO;
34-
if (style == LogStyle.CONSOLE) // cant place a switch here as these arent inline values - Nex
35-
{
36-
prefix = "> ";
37-
color = WHITE;
38-
level = INFO;
39-
}
40-
else if (style == LogStyle.ERROR)
41-
{
42-
prefix = "[FLIXEL]";
43-
color = RED;
44-
level = ERROR;
45-
}
46-
else if (style == LogStyle.NORMAL)
47-
{
48-
prefix = "[FLIXEL]";
49-
color = WHITE;
50-
level = INFO;
51-
}
52-
else if (style == LogStyle.NOTICE)
53-
{
54-
prefix = "[FLIXEL]";
55-
color = GREEN;
56-
level = VERBOSE;
57-
}
58-
else if (style == LogStyle.WARNING)
59-
{
60-
prefix = "[FLIXEL]";
61-
color = YELLOW;
62-
level = WARNING;
63-
}
27+
public static inline function levelToString(level:Level):String
28+
{
29+
switch (level)
30+
{
31+
case INFO | NONE:
32+
return '[ INFO ]';
33+
case WARNING:
34+
return '[ WARNING ]';
35+
case ERROR:
36+
return '[ ERROR ]';
37+
default:
38+
return '[ MISC ]';
39+
}
40+
}
6441

65-
var d:Dynamic = data;
66-
if (!(d is Array))
67-
d = [d];
68-
var a:Array<Dynamic> = d;
69-
var strs = [for(e in a) Std.string(e)];
70-
for(e in strs)
71-
{
72-
Logs.trace('$prefix $e', level, color);
73-
}
74-
};
75-
}
42+
public static inline function spawnAlertWindow(params:AlertParams, ?infos:haxe.PosInfos)
43+
{
44+
Logs.traceNew(params.content, ERROR, infos);
45+
Application.current.window.alert(params.content, params.title);
46+
}
47+
}
7648

77-
public static function prepareColoredTrace(text:Array<LogText>, level:Level = INFO) {
78-
var time = Date.now();
79-
var superCoolText = [
80-
logText('[ '),
81-
logText('${Std.string(time.getHours()).addZeros(2)}:${Std.string(time.getMinutes()).addZeros(2)}:${Std.string(time.getSeconds()).addZeros(2)}', DARKMAGENTA),
82-
logText(' |'),
83-
switch (level)
84-
{
85-
case WARNING:
86-
logText(' WARNING ', DARKYELLOW);
87-
case ERROR:
88-
logText(' ERROR ', DARKRED);
89-
case TRACE:
90-
logText(' TRACE ', GRAY);
91-
case VERBOSE:
92-
logText(' VERBOSE ', DARKMAGENTA);
93-
default:
94-
logText(' INFORMATION ', CYAN);
95-
},
96-
logText('] ')
97-
];
98-
for(k=>e in superCoolText)
99-
text.insert(k, e);
100-
return text;
101-
}
49+
class Logs
50+
{
51+
public static var nativeTrace = Log.trace;
10252

103-
public static function logText(text:String, color:ConsoleColor = LIGHTGRAY):LogText {
104-
return {
105-
text: text,
106-
color: color
107-
};
108-
}
53+
public static function init()
54+
{
55+
Log.trace = traceOverride;
56+
}
10957

110-
public static function __showInConsole(text:Array<LogText>) {
111-
#if (sys && !mobile)
112-
while(__showing) {
113-
Sys.sleep(0.05);
114-
}
115-
__showing = true;
116-
for(t in text) {
117-
NativeAPI.setConsoleColors(t.color);
118-
Sys.print(t.text);
119-
}
120-
NativeAPI.setConsoleColors();
121-
Sys.print("\r\n");
122-
__showing = false;
123-
#elseif mobile
124-
while(__showing) {
125-
Sys.sleep(0.05);
126-
}
127-
__showing = true;
128-
@:privateAccess
129-
Sys.print([for(t in text) t.text].join(""));
130-
__showing = false;
131-
#else
132-
@:privateAccess
133-
nativeTrace([for(t in text) t.text].join(""));
134-
#end
135-
}
58+
static function levelToInt(l:Level):Int
59+
{
60+
switch(l)
61+
{
62+
case INFO:
63+
return 0;
64+
case MISC:
65+
return 1;
66+
case NONE:
67+
return 2;
68+
case WARNING:
69+
return 3;
70+
case ERROR:
71+
return 4;
72+
}
73+
}
13674

137-
public static function traceColored(text:Array<LogText>, level:Level = INFO)
138-
__showInConsole(prepareColoredTrace(text, level));
75+
static function traceOverride(v:Dynamic, ?infos:PosInfos):Void traceNew(v, NONE, infos);
13976

140-
public static function trace(text:String, level:Level = INFO, color:ConsoleColor = LIGHTGRAY) {
141-
traceColored([
142-
{
143-
text: text,
144-
color: color
145-
}
146-
], level);
147-
}
77+
public static function traceNew(v:Dynamic, level:Level, ?infos:PosInfos):Void
78+
{
79+
var str = '${level.toLevel()} : ' + Log.formatOutput(v, infos).replace('\n\n', '\n').replace('\n', '\n${level.toLevel()} : ${infos.fileName}:${infos.lineNumber}: ');
80+
#if js
81+
if (js.Syntax.typeof(untyped console) != "undefined" && (untyped console).log != null)
82+
(untyped console).log(str);
83+
#elseif lua
84+
untyped __define_feature__("use._hx_print", _hx_print(str));
85+
#elseif sys
86+
Sys.println(str);
87+
#else
88+
throw new haxe.exceptions.NotImplementedException()
89+
#end
90+
}
14891
}
14992

150-
enum abstract Level(Int) {
151-
var INFO = 0;
152-
var WARNING = 1;
153-
var ERROR = 2;
154-
var TRACE = 3;
155-
var VERBOSE = 4;
93+
enum abstract TraceStyle(String) {
94+
var ALL = 'ALL';
95+
var WARNINGS_PLUS = 'WARNINGS+';
96+
var ERRORS_ONLY = 'ERRORS_ONLY';
97+
var NONE = 'NONE';
15698
}
15799

158-
typedef LogText = {
159-
var text:String;
160-
var color:ConsoleColor;
100+
enum abstract Level(Int)
101+
{
102+
var INFO = 0;
103+
var MISC = 1;
104+
var NONE = 2;
105+
var WARNING = 3;
106+
var ERROR = 4;
161107
}

source/codename/scripting/GlobalScript.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class GlobalScript {
5353
onModSwitch(#if MOD_SUPPORT ModsFolder.currentModFolder #else null #end);
5454
}
5555
}
56-
if (FlxG.keys.justPressed.F2){}
56+
if (FlxG.keys.justPressed.F2)
5757
NativeAPI.allocConsole();
5858
});
5959
FlxG.signals.preDraw.add(function() {

0 commit comments

Comments
 (0)