Fixed bug with last commit + more bug fixes
This commit is contained in:
@@ -79,7 +79,8 @@ class GlobalScript {
|
|||||||
call("update", [FlxG.elapsed]);
|
call("update", [FlxG.elapsed]);
|
||||||
});
|
});
|
||||||
|
|
||||||
onModSwitch(#if MOD_SUPPORT ModsFolder.currentModFolder #else null #end);
|
// Commented this out, because it might be the cause why global runs twice - Neo
|
||||||
|
//onModSwitch(#if MOD_SUPPORT ModsFolder.currentModFolder #else null #end);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function event<T:CancellableEvent>(name:String, event:T):T {
|
public static function event<T:CancellableEvent>(name:String, event:T):T {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package funkin.backend.system;
|
package funkin.backend.system;
|
||||||
|
|
||||||
import lime.utils.AssetLibrary;
|
import lime.utils.AssetLibrary as LimeAssetLibrary;
|
||||||
import lime.utils.AssetType;
|
import lime.utils.AssetType;
|
||||||
import flixel.util.FlxColor;
|
import flixel.util.FlxColor;
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ class Flags {
|
|||||||
public static var COMMIT_HASH:String = GitCommitMacro.commitHash;
|
public static var COMMIT_HASH:String = GitCommitMacro.commitHash;
|
||||||
public static var COMMIT_MESSAGE:String = 'Commit $COMMIT_NUMBER ($COMMIT_HASH)';
|
public static var COMMIT_MESSAGE:String = 'Commit $COMMIT_NUMBER ($COMMIT_HASH)';
|
||||||
|
|
||||||
@:lazy public static var TITLE:String = Application.current.meta.get('title');
|
@:lazy public static var TITLE:String = Application.current.meta.get('name');
|
||||||
@:lazy public static var VERSION:String = Application.current.meta.get('version');
|
@:lazy public static var VERSION:String = Application.current.meta.get('version');
|
||||||
|
|
||||||
@:lazy public static var VERSION_MESSAGE:String = 'Codename Engine v$VERSION';
|
@:lazy public static var VERSION_MESSAGE:String = 'Codename Engine v$VERSION';
|
||||||
@@ -161,45 +161,64 @@ class Flags {
|
|||||||
*/
|
*/
|
||||||
@:bypass public static var customFlags:Map<String, String> = [];
|
@:bypass public static var customFlags:Map<String, String> = [];
|
||||||
|
|
||||||
public static function load() {
|
public static function loadFromData(flags:Map<String, String>, data:String) {
|
||||||
var flags:Map<String, String> = [];
|
var trimmed:String;
|
||||||
|
var splitContent = [for(e in data.split("\n")) if ((trimmed = e.trim()) != "") trimmed];
|
||||||
|
|
||||||
final flagsPath = Paths.getPath("flags.ini");
|
for(line in splitContent) {
|
||||||
|
if(line.startsWith(";")) continue;
|
||||||
|
if(line.startsWith("#")) continue;
|
||||||
|
if(line.startsWith("//")) continue;
|
||||||
|
if(line.length == 0) continue;
|
||||||
|
if(line.charAt(0) == "[" && line.charAt(line.length-1) == "]") continue;
|
||||||
|
|
||||||
for(lib in Paths.assetsTree.libraries) {
|
var index = line.indexOf("=");
|
||||||
if(lib.exists(flagsPath, AssetType.TEXT)) {
|
if(index == -1) continue;
|
||||||
var data:String = lib.getAsset(flagsPath, AssetType.TEXT);
|
var name = line.substr(0, index).trim();
|
||||||
var trimmed:String;
|
var value = line.substr(index+1).trim();
|
||||||
var splitContent = [for(e in data.split("\n")) if ((trimmed = e.trim()) != "") trimmed];
|
|
||||||
|
|
||||||
for(line in splitContent) {
|
var wasQuoted = value.length > 1 && value.charCodeAt(0) == '"'.code && value.charCodeAt(value.length-1) == '"'.code;
|
||||||
if(line.startsWith(";")) continue;
|
if(wasQuoted) value = value.substr(1, value.length - 2);
|
||||||
if(line.startsWith("#")) continue;
|
if((!wasQuoted && value.length == 0) || name.length == 0)
|
||||||
if(line.startsWith("//")) continue;
|
continue;
|
||||||
if(line.length == 0) continue;
|
|
||||||
if(line.charAt(0) == "[" && line.charAt(line.length-1) == "]") continue;
|
|
||||||
|
|
||||||
var index = line.indexOf("=");
|
if(!flags.exists(name))
|
||||||
if(index == -1) continue;
|
flags[name] = value;
|
||||||
var name = line.substr(0, index).trim();
|
|
||||||
var value = line.substr(index+1).trim();
|
|
||||||
|
|
||||||
var wasQuoted = value.length > 1 && value.charCodeAt(0) == '"'.code && value.charCodeAt(value.length-1) == '"'.code;
|
|
||||||
if(wasQuoted) value = value.substr(1, value.length - 2);
|
|
||||||
if((!wasQuoted && value.length == 0) || name.length == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(!flags.exists(name))
|
|
||||||
flags[name] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function loadFromDatas(files:Array<String>) {
|
||||||
|
var flags:Map<String, String> = [];
|
||||||
|
for(file in files) {
|
||||||
|
var data:String = Assets.getText(file);
|
||||||
|
if(data != null)
|
||||||
|
loadFromData(flags, data);
|
||||||
|
}
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function parseFlags(flags:Map<String, String>) {
|
||||||
customFlags = [];
|
customFlags = [];
|
||||||
reset();
|
reset();
|
||||||
for(name=>value in flags)
|
for(name=>value in flags)
|
||||||
if(!parse(name, value)) {
|
if(!parse(name, value))
|
||||||
customFlags.set(name, value);
|
customFlags.set(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the flags from the assets.
|
||||||
|
**/
|
||||||
|
public static function load(?libs:Array<LimeAssetLibrary> = null) {
|
||||||
|
if (libs == null)
|
||||||
|
libs = Paths.assetsTree.libraries;
|
||||||
|
final flagsPath = Paths.getPath("flags.ini");
|
||||||
|
var datas:Array<String> = [
|
||||||
|
for(lib in libs)
|
||||||
|
if(lib.exists(flagsPath, AssetType.TEXT))
|
||||||
|
lib.getAsset(flagsPath, AssetType.TEXT)
|
||||||
|
];
|
||||||
|
|
||||||
|
var flags:Map<String, String> = loadFromDatas(datas);
|
||||||
|
parseFlags(flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,10 +92,7 @@ class FlagMacro {
|
|||||||
case macro: Array<Float>:
|
case macro: Array<Float>:
|
||||||
parser = macro value.split(",").map((e) -> Std.parseFloat(e));
|
parser = macro value.split(",").map((e) -> Std.parseFloat(e));
|
||||||
case macro: Array<Bool>:
|
case macro: Array<Bool>:
|
||||||
parser = macro value.split(",").map((e) -> {
|
parser = macro value.split(",").map(parseBool);
|
||||||
e = e.trim();
|
|
||||||
e == "true" || e == "t" || e == "1";
|
|
||||||
});
|
|
||||||
case macro: TrimmedString:
|
case macro: TrimmedString:
|
||||||
field.kind = FVar(macro: String, expr);
|
field.kind = FVar(macro: String, expr);
|
||||||
parser = macro value.trim();
|
parser = macro value.trim();
|
||||||
@@ -106,7 +103,7 @@ class FlagMacro {
|
|||||||
case macro: Float:
|
case macro: Float:
|
||||||
parser = macro Std.parseFloat(value);
|
parser = macro Std.parseFloat(value);
|
||||||
case macro: Bool:
|
case macro: Bool:
|
||||||
parser = macro value == "true" || value == "t" || value == "1";
|
parser = macro parseBool(value);
|
||||||
case TPath({name: "Allow", pack: [], params: params}):
|
case TPath({name: "Allow", pack: [], params: params}):
|
||||||
final NONE = 0;
|
final NONE = 0;
|
||||||
final STRING = 1;
|
final STRING = 1;
|
||||||
@@ -276,6 +273,22 @@ class FlagMacro {
|
|||||||
meta: []
|
meta: []
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fields.push({
|
||||||
|
name: "parseBool",
|
||||||
|
access: [APrivate, AStatic],
|
||||||
|
kind: FFun({
|
||||||
|
args: [{name: "e", type: macro: String}],
|
||||||
|
expr: macro {
|
||||||
|
e = e.trim();
|
||||||
|
return e == "true" || e == "t" || e == "1";
|
||||||
|
},
|
||||||
|
ret: macro: Bool
|
||||||
|
}),
|
||||||
|
pos: Context.currentPos(),
|
||||||
|
doc: null,
|
||||||
|
meta: []
|
||||||
|
});
|
||||||
|
|
||||||
//var printer = new haxe.macro.Printer();
|
//var printer = new haxe.macro.Printer();
|
||||||
//for(field in fields) {
|
//for(field in fields) {
|
||||||
// trace(printer.printField(field));
|
// trace(printer.printField(field));
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class WindowUtils {
|
|||||||
* Resets the window title to the application name and resets the prefix and suffix.
|
* Resets the window title to the application name and resets the prefix and suffix.
|
||||||
**/
|
**/
|
||||||
public static inline function resetTitle() {
|
public static inline function resetTitle() {
|
||||||
title = Flags.TITLE;
|
title = Flags.TITLE == null ? Lib.application.meta.get('name') : Flags.TITLE;
|
||||||
resetAffixes();
|
resetAffixes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,18 +65,18 @@ class WindowUtils {
|
|||||||
|
|
||||||
// backwards compat
|
// backwards compat
|
||||||
@:noCompletion public static var endfix(get, set):String;
|
@:noCompletion public static var endfix(get, set):String;
|
||||||
@:noCompletion private static function set_endfix(value:String):String {
|
@:noCompletion private inline static function set_endfix(value:String):String {
|
||||||
return suffix = value;
|
return suffix = value;
|
||||||
}
|
}
|
||||||
@:noCompletion private static function get_endfix():String {
|
@:noCompletion private inline static function get_endfix():String {
|
||||||
return suffix;
|
return suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@:noCompletion public static var winTitle(get, set):String;
|
@:noCompletion public static var winTitle(get, set):String;
|
||||||
@:noCompletion private static function get_winTitle():String {
|
@:noCompletion private inline static function get_winTitle():String {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
@:noCompletion private static function set_winTitle(value:String):String {
|
@:noCompletion private inline static function set_winTitle(value:String):String {
|
||||||
return title = value;
|
return title = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user