Merge branch 'main' into translations-system
This commit is contained in:
@@ -78,9 +78,9 @@ class ControlsMacro
|
||||
});
|
||||
|
||||
function buildBindControl(s:String, prefix:String) {
|
||||
var prefixxed = prefix + s;
|
||||
var prefixed = prefix + s;
|
||||
|
||||
return macro bindKeys(Control.$s, Options.$prefixxed);
|
||||
return macro bindKeys(Control.$s, Options.$prefixed);
|
||||
}
|
||||
|
||||
fields.push({
|
||||
|
||||
@@ -9,7 +9,7 @@ class DefinesMacro {
|
||||
/**
|
||||
* Returns the defined values
|
||||
*/
|
||||
public static var defines(get, null):Map<String, Dynamic>;
|
||||
public static var defines(get, never):Map<String, Dynamic>;
|
||||
|
||||
// GETTERS
|
||||
#if REGION
|
||||
|
||||
@@ -184,7 +184,7 @@ class FlagMacro {
|
||||
}
|
||||
|
||||
case TPath({name: "Array", pack: []}):
|
||||
Context.error("Flag " + field.name + " cannot be an Array that isnt a String or Bool or TrimmedString or Int or Float", field.pos);
|
||||
Context.error("Flag " + field.name + " cannot be an Array that isn't a String or Bool or TrimmedString or Int or Float", field.pos);
|
||||
case TPath({name: "Map", pack: []}):
|
||||
Context.error("Flag " + field.name + " cannot be a Map<K, V>", field.pos);
|
||||
default:
|
||||
|
||||
@@ -42,20 +42,9 @@ class FunkinSaveMacro {
|
||||
/**
|
||||
* SAVE FUNCTION
|
||||
*/
|
||||
var saveFuncBlocks:Array<Expr> = [for(f in fieldNames)
|
||||
macro ${{
|
||||
pos: Context.currentPos(),
|
||||
expr: EConst(CIdent(saveFieldName))
|
||||
}}.data.$f = ${{
|
||||
pos: Context.currentPos(),
|
||||
expr: EConst(CIdent(f))
|
||||
}}
|
||||
];
|
||||
var saveFuncBlocks:Array<Expr> = [for(f in fieldNames) macro $i{saveFieldName}.data.$f = $i{f}];
|
||||
|
||||
saveFuncBlocks.push(macro ${{
|
||||
pos: Context.currentPos(),
|
||||
expr: EConst(CIdent(saveFieldName))
|
||||
}}.flush());
|
||||
saveFuncBlocks.push(macro $i{saveFieldName}.flush());
|
||||
|
||||
fields.push({
|
||||
pos: Context.currentPos(),
|
||||
@@ -81,16 +70,8 @@ class FunkinSaveMacro {
|
||||
expr: {
|
||||
pos: Context.currentPos(),
|
||||
expr: EBlock([for(f in fieldNames)
|
||||
macro if (${{
|
||||
pos: Context.currentPos(),
|
||||
expr: EConst(CIdent(saveFieldName))
|
||||
}}.data.$f != null) ${{
|
||||
pos: Context.currentPos(),
|
||||
expr: EConst(CIdent(f))
|
||||
}} = ${{
|
||||
pos: Context.currentPos(),
|
||||
expr: EConst(CIdent(saveFieldName))
|
||||
}}.data.$f
|
||||
macro if ($i{saveFieldName}.data.$f != null)
|
||||
$i{f} = $i{saveFieldName}.data.$f
|
||||
])
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -8,11 +8,27 @@ class GitCommitMacro {
|
||||
/**
|
||||
* Returns the current commit number
|
||||
*/
|
||||
public static var commitNumber(get, null):Int;
|
||||
public static var commitNumber(get, never):Int;
|
||||
/**
|
||||
* Returns the current commit hash
|
||||
*/
|
||||
public static var commitHash(get, null):String;
|
||||
public static var commitHash(get, never):String;
|
||||
/**
|
||||
* Returns the current commit hash in long format
|
||||
*/
|
||||
public static var commitHashLong(get, never):String;
|
||||
/**
|
||||
* Returns the current commit message
|
||||
*/
|
||||
public static var commitMessage(get, never):String;
|
||||
/**
|
||||
* Returns the current commit author
|
||||
*/
|
||||
public static var commitAuthor(get, never):String;
|
||||
/**
|
||||
* Returns the current commit date + time
|
||||
**/
|
||||
public static var commitDate(get, never):Date;
|
||||
|
||||
// GETTERS
|
||||
#if REGION
|
||||
@@ -21,6 +37,15 @@ class GitCommitMacro {
|
||||
|
||||
private static inline function get_commitHash()
|
||||
return __getCommitHash();
|
||||
private static inline function get_commitHashLong()
|
||||
return __getCommitHashLong();
|
||||
|
||||
private static inline function get_commitMessage()
|
||||
return __getCommitMessage();
|
||||
private static inline function get_commitAuthor()
|
||||
return __getCommitAuthor();
|
||||
private static inline function get_commitDate()
|
||||
return __getCommitDate();
|
||||
#end
|
||||
|
||||
// INTERNAL MACROS
|
||||
@@ -52,5 +77,77 @@ class GitCommitMacro {
|
||||
return macro $v{0}
|
||||
#end
|
||||
}
|
||||
|
||||
private static macro function __getCommitHashLong() {
|
||||
#if display
|
||||
return macro $v{"-"};
|
||||
#else
|
||||
try {
|
||||
var proc = new Process('git', ['rev-parse', 'HEAD'], false);
|
||||
proc.exitCode(true);
|
||||
|
||||
return macro $v{proc.stdout.readLine()};
|
||||
} catch(e) {}
|
||||
return macro $v{"-"}
|
||||
#end
|
||||
}
|
||||
|
||||
private static macro function __getCommitMessage() {
|
||||
#if display
|
||||
return macro $v{"-"};
|
||||
#else
|
||||
try {
|
||||
var proc = new Process('git', ['log', '-1', '--pretty=%B'], false);
|
||||
proc.exitCode(true);
|
||||
var all = proc.stdout.readAll().toString();
|
||||
while(StringTools.endsWith(all, "\r\n")) all = all.substr(0, all.length - 2);
|
||||
while(StringTools.endsWith(all, "\n")) all = all.substr(0, all.length - 1);
|
||||
while(StringTools.endsWith(all, "\r")) all = all.substr(0, all.length - 1);
|
||||
|
||||
return macro $v{all};
|
||||
} catch(e) {}
|
||||
return macro $v{"-"}
|
||||
#end
|
||||
}
|
||||
|
||||
private static macro function __getCommitAuthor() {
|
||||
#if display
|
||||
return macro $v{"-"};
|
||||
#else
|
||||
try {
|
||||
var proc = new Process('git', ['log', '-1', '--pretty=%an'], false);
|
||||
proc.exitCode(true);
|
||||
|
||||
return macro $v{StringTools.trim(proc.stdout.readLine())};
|
||||
} catch(e) {}
|
||||
return macro $v{"-"}
|
||||
#end
|
||||
}
|
||||
|
||||
private static macro function __getCommitDate() {
|
||||
#if display
|
||||
return macro $v{Date.now()};
|
||||
#else
|
||||
try {
|
||||
// get the time in UTC format
|
||||
var oldTz = Sys.getEnv("TZ");
|
||||
Sys.putEnv("TZ", "UTC0");
|
||||
var proc = new Process('git', ['log', "--date='format-local:%Y-%m-%dT%H:%M:%SZ'", '-1', '--pretty=%cd'], false);
|
||||
proc.exitCode(true);
|
||||
Sys.putEnv("TZ", oldTz);
|
||||
|
||||
var rawDate = StringTools.trim(proc.stdout.readLine());
|
||||
|
||||
try {
|
||||
Date.fromString(rawDate);
|
||||
} catch(e) {
|
||||
throw 'Invalid date format: $rawDate';
|
||||
}
|
||||
|
||||
return macro Date.fromString($v{rawDate});
|
||||
} catch(e) {}
|
||||
return macro Date.fromString("1970-01-01T00:00:00"); // failed to parse date
|
||||
#end
|
||||
}
|
||||
#end
|
||||
}
|
||||
@@ -24,14 +24,8 @@ class OptionsMacro {
|
||||
var ptwoname = 'P2_$name';
|
||||
var newFuncExpr:Expr = macro {
|
||||
var a:Array<FlxKey> = [];
|
||||
for(e in ${{
|
||||
pos: Context.currentPos(),
|
||||
expr: EConst(CIdent(ponename))
|
||||
}}) a.push(e);
|
||||
for(e in ${{
|
||||
pos: Context.currentPos(),
|
||||
expr: EConst(CIdent(ptwoname))
|
||||
}}) a.push(e);
|
||||
for(e in $i{ponename}) a.push(e);
|
||||
for(e in $i{ptwoname}) a.push(e);
|
||||
return a;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user