1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-09-20 09:09:00 +00:00
Funkin/source/funkin/util/macro/FlxMacro.hx

38 lines
1.3 KiB
Haxe
Raw Normal View History

package funkin.util.macro;
2022-01-26 19:19:57 +00:00
2023-12-07 19:29:45 +00:00
#if !display
2022-01-26 19:19:57 +00:00
#if macro
class FlxMacro
{
/**
* A macro to be called targeting the `FlxBasic` class.
* @return An array of fields that the class contains.
*/
public static macro function buildFlxBasic():Array<haxe.macro.Expr.Field>
{
var pos:haxe.macro.Expr.Position = haxe.macro.Context.currentPos();
// The FlxBasic class. We can add new properties to this class.
var cls:haxe.macro.Type.ClassType = haxe.macro.Context.getLocalClass().get();
// The fields of the FlxClass.
var fields:Array<haxe.macro.Expr.Field> = haxe.macro.Context.getBuildFields();
2022-01-26 19:19:57 +00:00
// haxe.macro.Context.info('[INFO] ${cls.name}: Adding zIndex attribute...', pos);
2022-01-26 19:19:57 +00:00
// Here, we add the zIndex attribute to all FlxBasic objects.
// This has no functional code tied to it, but it can be used as a target value
// for the FlxTypedGroup.sort method, to rearrange the objects in the scene.
fields = fields.concat([
{
name: "zIndex", // Field name.
access: [haxe.macro.Expr.Access.APublic], // Access level
2023-06-08 20:30:45 +00:00
kind: haxe.macro.Expr.FieldType.FVar(macro :Int, macro $v{0}), // Variable type and default value
pos: pos, // The field's position in code.
}
]);
2022-01-26 19:19:57 +00:00
return fields;
}
2022-01-26 19:19:57 +00:00
}
#end
2023-12-07 19:29:45 +00:00
#end