diff --git a/source/funkin/macros/DefinesMacro.hx b/source/funkin/macros/DefinesMacro.hx new file mode 100644 index 00000000..58bfaeb8 --- /dev/null +++ b/source/funkin/macros/DefinesMacro.hx @@ -0,0 +1,32 @@ +package funkin.macros; + +#if macro +import sys.io.Process; +import haxe.macro.Context; +import haxe.macro.Compiler; +import haxe.macro.Expr; +#end + +class DefinesMacro { + /** + * Returns the defined values + */ + public static var defines(get, null):Map; + + // GETTERS + #if REGION + private static inline function get_defines() + return __getDefines(); + #end + + // INTERNAL MACROS + #if REGION + private static macro function __getDefines() { + #if display + return macro $v{[]}; + #else + return macro $v{Context.getDefines()}; + #end + } + #end +} \ No newline at end of file diff --git a/source/funkin/macros/ScriptsMacro.hx b/source/funkin/macros/ScriptsMacro.hx index f75ee6f9..af4a94bf 100644 --- a/source/funkin/macros/ScriptsMacro.hx +++ b/source/funkin/macros/ScriptsMacro.hx @@ -13,7 +13,7 @@ class ScriptsMacro { for(inc in ["flixel", "away3d", "flx3d", "sys", "DateTools", "EReg", "Lambda", "StringBuf", "haxe.crypto", "haxe.display", "haxe.exceptions", "haxe.extern", "scripting"]) { Compiler.include(inc); } - + // FOR ABSTRACTS Compiler.addGlobalMetadata('haxe.xml', '@:build(hscript.UsingHandler.build())'); Compiler.addGlobalMetadata('haxe.CallStack', '@:build(hscript.UsingHandler.build())'); diff --git a/source/funkin/macros/StdDeprecationsRemover.hx b/source/funkin/macros/StdDeprecationsRemover.hx index d98cb598..f2ed753e 100644 --- a/source/funkin/macros/StdDeprecationsRemover.hx +++ b/source/funkin/macros/StdDeprecationsRemover.hx @@ -9,7 +9,7 @@ import haxe.macro.Compiler; * Removes all deprecations errors related to `Std.is` * Written by Yoshman29 to keep you sane. * Feel free to use this macro on your mod. - * + * * Line to add in project.xml: * `` */ diff --git a/source/funkin/scripting/Script.hx b/source/funkin/scripting/Script.hx index 08366e37..c98bfc2a 100644 --- a/source/funkin/scripting/Script.hx +++ b/source/funkin/scripting/Script.hx @@ -53,6 +53,7 @@ class Script extends FlxBasic implements IFlxDestroyable { // Engine related stuff "engine" => { commit: funkin.macros.GitCommitMacro.commitNumber, + hash: funkin.macros.GitCommitMacro.commitHash, build: 2675, // 2675 being the last build num before it was removed name: "Codename Engine" }, @@ -90,46 +91,12 @@ class Script extends FlxBasic implements IFlxDestroyable { ]; } public static function getDefaultPreprocessors():Map { - return [ - "CODENAME_ENGINE" => true, - "CODENAME_VER" => Application.current.meta.get('version'), - "CODENAME_BUILD" => 2675, - "CODENAME_COMMIT" => funkin.macros.GitCommitMacro.commitNumber, - "desktop" => #if desktop true #else false #end, - "windows" => #if windows true #else false #end, - "hl" => #if hl true #else false #end, - "neko" => #if neko true #else false #end, - "linux" => #if linux true #else false #end, - "mac" => #if mac true #else false #end, - "macos" => #if macos true #else false #end, - "android" => #if android true #else false #end, - "web" => #if web true #else false #end, - "js" => #if js true #else false #end, - "html5" => #if html5 true #else false #end, - "flash" => #if flash true #else false #end, - "sys" => #if sys true #else false #end, - "mobile" => #if mobile true #else false #end, - "air" => #if air true #else false #end, - "ios" => #if ios true #else false #end, - "tvos" => #if tvos true #else false #end, - "cpp" => #if cpp true #else false #end, - "dom" => #if dom true #else false #end, - "cs" => #if cs true #else false #end, - "electron" => #if electron true #else false #end, - "emscripten" => #if emscripten true #else false #end, - "nodejs" => #if nodejs true #else false #end, - "rpi" => #if rpi true #else false #end, - "cppia" => #if cppia true #else false #end, - "commonjs" => #if commonjs true #else false #end, - "debug" => #if debug true #else false #end, - "release" => #if release true #else false #end, - "final" => #if final true #else false #end, - "MOD_SUPPORT" => #if MOD_SUPPORT true #else false #end, - "GLOBAL_SCRIPT" => #if GLOBAL_SCRIPT true #else false #end, - "SOFTCODED_STATES" => #if SOFTCODED_STATES true #else false #end, - "USE_SOURCE_ASSETS" => #if USE_SOURCE_ASSETS true #else false #end, - "USE_ADAPTED_ASSETS" => #if USE_ADAPTED_ASSETS true #else false #end, - ]; + var defines = funkin.macros.DefinesMacro.defines; + defines.set("CODENAME_ENGINE", true); + defines.set("CODENAME_VER", Application.current.meta.get('version')); + defines.set("CODENAME_BUILD", 2675); // 2675 being the last build num before it was removed + defines.set("CODENAME_COMMIT", funkin.macros.GitCommitMacro.commitNumber); + return defines; } /** * All available script extensions