Skip to content

Commit c050ea7

Browse files
committed
Small optimizations
1 parent 52f0612 commit c050ea7

File tree

8 files changed

+186
-179
lines changed

8 files changed

+186
-179
lines changed

commandline/Main.hx

Lines changed: 97 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -3,111 +3,111 @@ package;
33
import commands.*;
44

55
class Main {
6-
public static var commands:Array<Command> = [];
6+
public static var commands:Array<Command> = [];
77

8-
public static function initCommands() {
9-
commands = [
10-
{
11-
names: ["setup"],
12-
doc: "Setups (or updates) all libraries required for the engine.",
13-
func: Update.main,
14-
dDoc: "This command runs through all libraries in libs.xml, and install them.\nIf they're already installed, they will be updated."
15-
},
16-
{
17-
names: ["help", null],
18-
doc: "Shows help. Pass a command name to get additional help.",
19-
func: help,
20-
dDoc: "Usage: help <cmd>\n\nFor example, use \"cne help test\" to get additional help on the test command."
21-
},
22-
{
23-
names: ["test"],
24-
doc: "Creates a non final test build, then runs it.",
25-
func: Compiler.test,
26-
dDoc: "Usage: test <optional args>\n" +
27-
"\nThis will create a quick debug build binded to the source then run it, which means:" +
28-
"\n- The assets WON'T be copied over - Assets will be read from the game's source." +
29-
"\n- This build WON'T be ready for release - Running anywhere else than in the bin folder will result in a crash from missing assets" +
30-
"\n- This build will also use the mods folder from the source directory." +
31-
"\n\nIf you want a full build which contains all assets, run \"cne release\" or \"cne test-release\"" +
32-
"\nAdditional arguments will be sent to the lime compiler."
33-
},
34-
{
35-
names: ["build"],
36-
doc: "Creates a non final test build, without running it.",
37-
func: Compiler.build,
38-
dDoc: "Usage: build <optional arguments>\n" +
39-
"\nThis will create a quick debug build binded to the source then run it, which means:" +
40-
"\n- The assets WON'T be copied over - Assets will be read from the game's source." +
41-
"\n- This build WON'T be ready for release - Running anywhere else than in the bin folder will result in a crash from missing assets" +
42-
"\n- This build will also use the mods folder from the source directory." +
43-
"\n\nIf you want a full build which contains all assets, run \"cne release\" or \"cne test-release\"" +
44-
"\nAdditional arguments will be sent to the lime compiler."
45-
},
46-
{
47-
names: ["release"],
48-
doc: "Creates a final non debug build, containing all assets.",
49-
func: Compiler.release,
50-
dDoc: "Usage: release <optional arguments>\n" +
51-
"\nThis will create a final ready-for-release build, which means this build will be able to be release on websites such as GameBanana without worrying about source-dependant stuff."
52-
},
53-
{
54-
names: ["test-release"],
55-
doc: "Creates a final non debug build, containing all assets.",
56-
func: Compiler.testRelease,
57-
dDoc: "Usage: release <optional arguments>\n" +
58-
"\nThis will create and run a final ready-for-release build, which means this build will be able to be release on websites such as GameBanana without worrying about source-dependant stuff."
59-
}
60-
];
61-
}
8+
public static function initCommands() {
9+
commands = [
10+
{
11+
names: ["setup"],
12+
doc: "Setups (or updates) all libraries required for the engine.",
13+
func: Update.main,
14+
dDoc: "This command runs through all libraries in libs.xml, and install them.\nIf they're already installed, they will be updated."
15+
},
16+
{
17+
names: ["help", null],
18+
doc: "Shows help. Pass a command name to get additional help.",
19+
func: help,
20+
dDoc: "Usage: help <cmd>\n\nFor example, use \"cne help test\" to get additional help on the test command."
21+
},
22+
{
23+
names: ["test"],
24+
doc: "Creates a non final test build, then runs it.",
25+
func: Compiler.test,
26+
dDoc: "Usage: test <optional args>\n" +
27+
"\nThis will create a quick debug build binded to the source then run it, which means:" +
28+
"\n- The assets WON'T be copied over - Assets will be read from the game's source." +
29+
"\n- This build WON'T be ready for release - Running anywhere else than in the bin folder will result in a crash from missing assets" +
30+
"\n- This build will also use the mods folder from the source directory." +
31+
"\n\nIf you want a full build which contains all assets, run \"cne release\" or \"cne test-release\"" +
32+
"\nAdditional arguments will be sent to the lime compiler."
33+
},
34+
{
35+
names: ["build"],
36+
doc: "Creates a non final test build, without running it.",
37+
func: Compiler.build,
38+
dDoc: "Usage: build <optional arguments>\n" +
39+
"\nThis will create a quick debug build binded to the source then run it, which means:" +
40+
"\n- The assets WON'T be copied over - Assets will be read from the game's source." +
41+
"\n- This build WON'T be ready for release - Running anywhere else than in the bin folder will result in a crash from missing assets" +
42+
"\n- This build will also use the mods folder from the source directory." +
43+
"\n\nIf you want a full build which contains all assets, run \"cne release\" or \"cne test-release\"" +
44+
"\nAdditional arguments will be sent to the lime compiler."
45+
},
46+
{
47+
names: ["release"],
48+
doc: "Creates a final non debug build, containing all assets.",
49+
func: Compiler.release,
50+
dDoc: "Usage: release <optional arguments>\n" +
51+
"\nThis will create a final ready-for-release build, which means this build will be able to be release on websites such as GameBanana without worrying about source-dependant stuff."
52+
},
53+
{
54+
names: ["test-release"],
55+
doc: "Creates a final non debug build, containing all assets.",
56+
func: Compiler.testRelease,
57+
dDoc: "Usage: release <optional arguments>\n" +
58+
"\nThis will create and run a final ready-for-release build, which means this build will be able to be release on websites such as GameBanana without worrying about source-dependant stuff."
59+
}
60+
];
61+
}
6262

63-
public static function main() {
64-
initCommands();
65-
var args = Sys.args();
66-
var commandName = args.shift();
67-
if (commandName != null)
68-
commandName = commandName.toLowerCase();
69-
for(c in commands) {
70-
if (c.names.contains(commandName)) {
71-
c.func(args);
72-
return;
73-
}
74-
}
75-
}
63+
public static function main() {
64+
initCommands();
65+
var args = Sys.args();
66+
var commandName = args.shift();
67+
if (commandName != null)
68+
commandName = commandName.toLowerCase();
69+
for(c in commands) {
70+
if (c.names.contains(commandName)) {
71+
c.func(args);
72+
return;
73+
}
74+
}
75+
}
7676

77-
public static function help(args:Array<String>) {
78-
var cmdName = args.shift();
79-
if (cmdName != null) {
80-
cmdName = cmdName.toLowerCase();
77+
public static function help(args:Array<String>) {
78+
var cmdName = args.shift();
79+
if (cmdName != null) {
80+
cmdName = cmdName.toLowerCase();
8181

82-
var matchingCommand = null;
83-
for(c in commands) if (c.names.contains(cmdName)) {
84-
matchingCommand = c;
85-
break;
86-
}
82+
var matchingCommand = null;
83+
for(c in commands) if (c.names.contains(cmdName)) {
84+
matchingCommand = c;
85+
break;
86+
}
8787

88-
if (matchingCommand == null) {
89-
Sys.println('help - Command named ${cmdName} not found.');
90-
return;
91-
}
88+
if (matchingCommand == null) {
89+
Sys.println('help - Command named ${cmdName} not found.');
90+
return;
91+
}
9292

93-
Sys.println('${matchingCommand.names.join(", ")}');
94-
Sys.println("---");
95-
Sys.println(matchingCommand.dDoc);
93+
Sys.println('${matchingCommand.names.join(", ")}');
94+
Sys.println("---");
95+
Sys.println(matchingCommand.dDoc);
9696

97-
return;
98-
}
99-
// shows help
100-
Sys.println("Codename Engine Command Line utility");
101-
Sys.println('Available commands (${commands.length}):\n');
102-
for(line in commands) {
103-
Sys.println('${line.names.join(", ")} - ${line.doc}');
104-
}
105-
}
97+
return;
98+
}
99+
// shows help
100+
Sys.println("Codename Engine Command Line utility");
101+
Sys.println('Available commands (${commands.length}):\n');
102+
for(line in commands) {
103+
Sys.println('${line.names.join(", ")} - ${line.doc}');
104+
}
105+
}
106106
}
107107

108108
typedef Command = {
109-
var names:Array<String>;
110-
var func:Array<String>->Void;
111-
var ?doc:String;
112-
var ?dDoc:String;
109+
var names:Array<String>;
110+
var func:Array<String>->Void;
111+
var ?doc:String;
112+
var ?dDoc:String;
113113
}

commandline/commands/Compiler.hx

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
package commands;
22

33
class Compiler {
4-
public static function test(args:Array<String>) {
5-
__build(args, ["test", getBuildTarget(), "-D", "TEST_BUILD"]);
6-
}
7-
public static function build(args:Array<String>) {
8-
__build(args, ["build", getBuildTarget(), "-D", "TEST_BUILD"]);
9-
}
10-
public static function release(args:Array<String>) {
11-
__build(args, ["build", getBuildTarget()]);
12-
}
13-
public static function testRelease(args:Array<String>) {
14-
__build(args, ["test", getBuildTarget()]);
15-
}
4+
public static function test(args:Array<String>) {
5+
__build(args, ["test", getBuildTarget(), "-D", "TEST_BUILD"]);
6+
}
7+
public static function build(args:Array<String>) {
8+
__build(args, ["build", getBuildTarget(), "-D", "TEST_BUILD"]);
9+
}
10+
public static function release(args:Array<String>) {
11+
__build(args, ["build", getBuildTarget()]);
12+
}
13+
public static function testRelease(args:Array<String>) {
14+
__build(args, ["test", getBuildTarget()]);
15+
}
1616

17-
private static function __build(args:Array<String>, arg:Array<String>) {
18-
for(a in args)
19-
arg.push(a);
20-
Sys.command("lime", arg);
21-
}
17+
private static function __build(args:Array<String>, arg:Array<String>) {
18+
for(a in args)
19+
arg.push(a);
20+
Sys.command("lime", arg);
21+
}
2222

23-
private static function getBuildTarget() {
24-
return switch(Sys.systemName()) {
25-
case "Windows":
26-
"windows";
27-
case "Mac":
28-
"macos";
29-
case "Linux":
30-
"linux";
31-
case def:
32-
def.toLowerCase();
33-
}
34-
}
23+
private static function getBuildTarget() {
24+
return switch(Sys.systemName()) {
25+
case "Windows":
26+
"windows";
27+
case "Mac":
28+
"macos";
29+
case "Linux":
30+
"linux";
31+
case def:
32+
def.toLowerCase();
33+
}
34+
}
3535
}

commandline/commands/Update.hx

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import sys.io.Process;
77
import sys.FileSystem;
88

99
class Update {
10-
public static function main(args:Array<String>) {
10+
public static function main(args:Array<String>) {
1111
prettyPrint("Preparing installation...");
1212

1313
// to prevent messing with currently installed libs
14-
if (!FileSystem.exists('.haxelib'))
15-
FileSystem.createDirectory('.haxelib');
16-
17-
var libs:Array<Library> = [];
18-
var libsXML:Access = new Access(Xml.parse(File.getContent('./libs.xml')).firstElement());
14+
if (!FileSystem.exists('.haxelib'))
15+
FileSystem.createDirectory('.haxelib');
16+
17+
var libs:Array<Library> = [];
18+
var libsXML:Access = new Access(Xml.parse(File.getContent('./libs.xml')).firstElement());
1919

2020
for (libNode in libsXML.elements) {
2121
var lib:Library = {
@@ -33,23 +33,23 @@ class Update {
3333
libs.push(lib);
3434
}
3535

36-
for(lib in libs) {
37-
// install libs
38-
var globalism = lib.global == "true" ? "--global" : "";
39-
switch(lib.type) {
40-
case "lib":
41-
prettyPrint((lib.global == "true" ? "Globally installing" : "Locally installing") + ' "${lib.name}"...');
42-
Sys.command('haxelib $globalism install ${lib.name} ${lib.version != null ? " " + lib.version : " "}');
43-
case "git":
44-
prettyPrint((lib.global == "true" ? "Globally installing" : "Locally installing") + ' "${lib.name}" from git url "${lib.url}"');
45-
if (lib.ref != null)
46-
Sys.command('haxelib $globalism git ${lib.name} ${lib.url} ${lib.ref}');
47-
else
48-
Sys.command('haxelib $globalism git ${lib.name} ${lib.url}');
49-
default:
50-
prettyPrint('Cannot resolve library of type "${lib.type}"');
51-
}
52-
}
36+
for(lib in libs) {
37+
// install libs
38+
var globalism = lib.global == "true" ? "--global" : "";
39+
switch(lib.type) {
40+
case "lib":
41+
prettyPrint((lib.global == "true" ? "Globally installing" : "Locally installing") + ' "${lib.name}"...');
42+
Sys.command('haxelib $globalism install ${lib.name} ${lib.version != null ? " " + lib.version : " "}');
43+
case "git":
44+
prettyPrint((lib.global == "true" ? "Globally installing" : "Locally installing") + ' "${lib.name}" from git url "${lib.url}"');
45+
if (lib.ref != null)
46+
Sys.command('haxelib $globalism git ${lib.name} ${lib.url} ${lib.ref}');
47+
else
48+
Sys.command('haxelib $globalism git ${lib.name} ${lib.url}');
49+
default:
50+
prettyPrint('Cannot resolve library of type "${lib.type}"');
51+
}
52+
}
5353

5454
var proc = new Process('haxe --version');
5555
proc.exitCode(true);
@@ -76,24 +76,24 @@ class Update {
7676
}
7777
}
7878
}
79-
}
79+
}
8080

81-
public static function prettyPrint(text:String) {
82-
var header = "══════";
83-
for(i in 0...(text.length-(text.lastIndexOf("\n")+1)))
84-
header += "";
85-
Sys.println("");
86-
Sys.println('$header');
87-
Sys.println('$text');
88-
Sys.println('$header');
89-
}
81+
public static function prettyPrint(text:String) {
82+
var header = "══════";
83+
for(i in 0...(text.length-(text.lastIndexOf("\n")+1)))
84+
header += "";
85+
Sys.println("");
86+
Sys.println('$header');
87+
Sys.println('$text');
88+
Sys.println('$header');
89+
}
9090
}
9191

9292
typedef Library = {
93-
var name:String;
94-
var type:String;
95-
var ?global:String;
96-
var ?version:String;
97-
var ?ref:String;
98-
var ?url:String;
93+
var name:String;
94+
var type:String;
95+
var ?global:String;
96+
var ?version:String;
97+
var ?ref:String;
98+
var ?url:String;
9999
}

libs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<libraries>
33
<!-- OpenFL & Lime (Required for Flixel) -->
44
<lib name="openfl" />
5-
<lib name="lime" version="8.0.2"/>
5+
<lib name="lime" />
66

77
<!-- Flixel -->
88
<git name="flixel" url="https://github.com/FNF-CNE-Devs/flixel" />

source/funkin/backend/system/framerate/SystemInfo.hx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ class SystemInfo extends FramerateCategory {
116116
}
117117

118118
static function formatSysInfo() {
119-
if (osInfo != "Unknown") __formattedSysText = 'System: $osInfo';
119+
__formattedSysText = "";
120+
if (osInfo != "Unknown") __formattedSysText += 'System: $osInfo';
120121
if (cpuName != "Unknown") __formattedSysText += '\nCPU: $cpuName ${openfl.system.Capabilities.cpuArchitecture} ${(openfl.system.Capabilities.supports64BitProcesses ? '64-Bit' : '32-Bit')}';
121122
if (gpuName != cpuName || vRAM != "Unknown") {
122123
var gpuNameKnown = gpuName != "Unknown" && gpuName != cpuName;

0 commit comments

Comments
 (0)