gf sad fix + AliasMacro (for backwards comp, manual impl for now)
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
<!DOCTYPE codename-engine-character>
|
||||
<character x="100" y="275" sprite="gf" icon="gf" color="#A5004D">
|
||||
<anim name="cheer" anim="GF Cheer" x="0" y="0" fps="24" loop="false"/>
|
||||
<anim name="singUP" anim="GF Up Note" x="0" y="0" fps="24" loop="false"/>
|
||||
<anim name="singLEFT" anim="GF left note" x="0" y="0" fps="24" loop="false"/>
|
||||
<anim name="singRIGHT" anim="GF Right Note" x="0" y="0" fps="24" loop="false"/>
|
||||
<anim name="singDOWN" anim="GF Down Note" x="0" y="0" fps="24" loop="false"/>
|
||||
<anim name="danceLeft" anim="GF Dancing Beat" x="0" y="0" fps="24" loop="false" indices="0..14"/>
|
||||
<anim name="danceRight" anim="GF Dancing Beat" x="0" y="0" fps="24" loop="false" indices="15..30"/>
|
||||
<anim name="hairBlow" anim="GF Dancing Beat Hair blowing" x="0" y="0" fps="24" loop="true" indices="0,1,2,3"/>
|
||||
<anim name="hairFall" anim="GF Dancing Beat Hair Landing" x="0" y="0" fps="24" loop="false" indices="0..11"/>
|
||||
<anim name="scared" anim="GF FEAR " x="0" y="0" fps="24" loop="true"/>
|
||||
<anim name="sad" anim="gf sad" x="0" y="0" fps="24" loop="true" indices="0..12"/>
|
||||
<character x="100" y="275" color="#A5004D">
|
||||
<anim name="cheer" anim="GF Cheer"/>
|
||||
<anim name="singUP" anim="GF Up Note"/>
|
||||
<anim name="singLEFT" anim="GF left note"/>
|
||||
<anim name="singRIGHT" anim="GF Right Note"/>
|
||||
<anim name="singDOWN" anim="GF Down Note"/>
|
||||
<anim name="danceLeft" anim="GF Dancing Beat" indices="0..14"/>
|
||||
<anim name="danceRight" anim="GF Dancing Beat" indices="15..30"/>
|
||||
<anim name="hairBlow" anim="GF Dancing Beat Hair blowing" loop="true" indices="0..3"/>
|
||||
<anim name="hairFall" anim="GF Dancing Beat Hair Landing" indices="0..11"/>
|
||||
<anim name="scared" anim="GF FEAR " loop="true"/>
|
||||
<anim name="sad" anim="gf sad" x="-51" y="315" loop="true" indices="0..12"/>
|
||||
</character>
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package funkin.backend.system.macros;
|
||||
|
||||
#if macro
|
||||
import sys.io.File;
|
||||
import haxe.macro.ComplexTypeTools;
|
||||
import haxe.macro.Printer;
|
||||
import haxe.macro.Expr.Position;
|
||||
import haxe.macro.Context;
|
||||
import haxe.macro.Expr.Field;
|
||||
import haxe.macro.Expr;
|
||||
|
||||
class AliasMacro {
|
||||
public static var aliasMetadata:Metadata = [{
|
||||
name: ":keep",
|
||||
pos: Context.currentPos()
|
||||
},{
|
||||
name: ":dox",
|
||||
pos: Context.currentPos(),
|
||||
params: [
|
||||
{
|
||||
expr: EConst(CIdent("hide")),
|
||||
pos: Context.currentPos()
|
||||
}
|
||||
]
|
||||
}];
|
||||
|
||||
public static function build():Array<Field> {
|
||||
#if display
|
||||
return Context.getBuildFields();
|
||||
#end
|
||||
|
||||
var fields = Context.getBuildFields();
|
||||
var ogFieldCount = fields.length;
|
||||
|
||||
for(i in 0...ogFieldCount) {
|
||||
var field = fields[i];
|
||||
if (field.meta == null) continue;
|
||||
|
||||
var previousAliases:Array<{name:String, pos:Position}> = [];
|
||||
for(meta in field.meta) {
|
||||
if (meta.name == ":alias" && meta.params != null) {
|
||||
for(p in meta.params) {
|
||||
switch(p.expr) {
|
||||
case EConst(CString(s, kind)):
|
||||
previousAliases.push({
|
||||
name: s,
|
||||
pos: p.pos
|
||||
});
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (previousAliases.length == 0) continue;
|
||||
|
||||
var ghostAccess = field.access.copy();
|
||||
ghostAccess.remove(AOverride);
|
||||
ghostAccess.remove(APublic);
|
||||
|
||||
for(alias in previousAliases) {
|
||||
var ghostField:Field = {
|
||||
name: alias.name,
|
||||
pos: alias.pos,
|
||||
kind: null,
|
||||
access: ghostAccess,
|
||||
meta: aliasMetadata
|
||||
};
|
||||
|
||||
switch(field.kind) {
|
||||
case FFun(f):
|
||||
var args:Array<Expr> = [for(a in f.args) {
|
||||
expr: EConst(CIdent(a.name)),
|
||||
pos: Context.currentPos()
|
||||
}];
|
||||
|
||||
ghostField.kind = FFun({
|
||||
args: f.args,
|
||||
params: f.params,
|
||||
ret: f.ret,
|
||||
expr: macro return $i{field.name}($a{args})
|
||||
});
|
||||
|
||||
default:
|
||||
var type = null;
|
||||
switch(field.kind) {
|
||||
case FVar(t, e):
|
||||
type = t;
|
||||
case FProp(get, set, t, e):
|
||||
type = t;
|
||||
default:
|
||||
}
|
||||
ghostField.kind = FProp("get", "set", type, null);
|
||||
|
||||
fields.push({
|
||||
name: 'get_${alias.name}',
|
||||
kind: FFun({
|
||||
args: [],
|
||||
expr: macro return $i{field.name},
|
||||
ret: type
|
||||
}),
|
||||
pos: alias.pos,
|
||||
meta: aliasMetadata
|
||||
});
|
||||
fields.push({
|
||||
name: 'set_${alias.name}',
|
||||
kind: FFun({
|
||||
args: [{
|
||||
name: '_${field.name}',
|
||||
type: type
|
||||
}],
|
||||
expr: macro return ($i{field.name} = $i{'_${field.name}'}),
|
||||
ret: type
|
||||
}),
|
||||
pos: alias.pos,
|
||||
meta: aliasMetadata
|
||||
});
|
||||
}
|
||||
|
||||
fields.push(ghostField);
|
||||
}
|
||||
|
||||
var docFooter = '_Aliases: ${[for(alias in previousAliases) '`${alias.name}`'].join(", ")}_';
|
||||
if (field.doc != null)
|
||||
field.doc += '\n\n$docFooter';
|
||||
else
|
||||
field.doc = docFooter;
|
||||
}
|
||||
trace(fields);
|
||||
|
||||
return fields;
|
||||
}
|
||||
}
|
||||
#end
|
||||
Reference in New Issue
Block a user