diff --git a/flixel/addons/effects/chainable/FlxEffectSprite.hx b/flixel/addons/effects/chainable/FlxEffectSprite.hx index 37d64ba3..cfc87a99 100644 --- a/flixel/addons/effects/chainable/FlxEffectSprite.hx +++ b/flixel/addons/effects/chainable/FlxEffectSprite.hx @@ -1,5 +1,11 @@ package flixel.addons.effects.chainable; +// TODO: remove this check when min flixel version is 5.6.0, +// So that FlxAddonDefines will handle this +#if (flixel < "5.3.0") +#error "Flixel-Addons is not compatible with flixel versions older than 5.3.0"; +#end + import flixel.FlxCamera; import flixel.FlxSprite; import flixel.graphics.FlxGraphic; diff --git a/flixel/addons/system/macros/FlxAddonDefines.hx b/flixel/addons/system/macros/FlxAddonDefines.hx new file mode 100644 index 00000000..0d787d42 --- /dev/null +++ b/flixel/addons/system/macros/FlxAddonDefines.hx @@ -0,0 +1,62 @@ +package flixel.addons.system.macros; + +import haxe.macro.Compiler; +import haxe.macro.Context; +import haxe.macro.Expr.Position; + +// private enum UserAddonDefines {} +// private enum HelperAddonDefines {} + +/** + * The purpose of these "defines" classes is mainly to properly communicate version compatibility + * among flixel libs, we shouldn't be overly concerned with backwards compatibility, but we do want + * to know when a change breaks compatibility between Flixel-Addons and Flixel. + * + * @since 3.2.2 + */ +@:allow(flixel.system.macros.FlxDefines) +@:access(flixel.system.macros.FlxDefines) +class FlxAddonDefines +{ + /** + * Called from `flixel.system.macros.FlxDefines` on versions 5.6.0 or later + */ + public static function run() + { + #if !display + checkCompatibility(); + #end + } + + static function checkCompatibility() + { + /** this function is only ran in flixel versions 5.6.0 or later, meaning this error will + * never happen. So we've added flixel version checks in the following modules: + * - `FlxEffectSprite` + * - `FlxTypeText` + * - `FlxTransitionableState` + * - `FlxWeapon` + * + * When the minimum version of flixel is changed to 5.6.0 or greater, remove the above + * checks and this comment. + */ + #if (flixel < "5.3.0") + FlxDefines.abortVersion("Flixel", "5.3.0 or newer", "flixel", (macro null).pos); + #end + } + + static function isValidUserDefine(define:Any) + { + return false; + } + + static function abortVersion(dependency:String, supported:String, found:String, pos:Position) + { + abort('Flixel-Addons: Unsupported $dependency version! Supported versions are $supported (found ${Context.definedValue(found)}).', pos); + } + + static function abort(message:String, pos:Position) + { + Context.fatalError(message, pos); + } +} diff --git a/flixel/addons/text/FlxTypeText.hx b/flixel/addons/text/FlxTypeText.hx index 7fd492cd..2774ef5f 100644 --- a/flixel/addons/text/FlxTypeText.hx +++ b/flixel/addons/text/FlxTypeText.hx @@ -1,5 +1,11 @@ package flixel.addons.text; +// TODO: remove this check when min flixel version is 5.6.0, +// So that FlxAddonDefines will handle this +#if (flixel < "5.3.0") +#error "Flixel-Addons is not compatible with flixel versions older than 5.3.0"; +#end + import flixel.FlxG; import flixel.input.keyboard.FlxKey; import flixel.math.FlxMath; diff --git a/flixel/addons/transition/FlxTransitionableState.hx b/flixel/addons/transition/FlxTransitionableState.hx index f298cc68..3dea1507 100644 --- a/flixel/addons/transition/FlxTransitionableState.hx +++ b/flixel/addons/transition/FlxTransitionableState.hx @@ -1,5 +1,11 @@ package flixel.addons.transition; +// TODO: remove this check when min flixel version is 5.6.0, +// So that FlxAddonDefines will handle this +#if (flixel < "5.3.0") +#error "Flixel-Addons is not compatible with flixel versions older than 5.3.0"; +#end + import flixel.FlxState; /** diff --git a/flixel/addons/weapon/FlxWeapon.hx b/flixel/addons/weapon/FlxWeapon.hx index 289786fe..0c43dd37 100644 --- a/flixel/addons/weapon/FlxWeapon.hx +++ b/flixel/addons/weapon/FlxWeapon.hx @@ -1,5 +1,11 @@ package flixel.addons.weapon; +// TODO: remove this check when min flixel version is 5.6.0, +// So that FlxAddonDefines will handle this +#if (flixel < "5.3.0") +#error "Flixel-Addons is not compatible with flixel versions older than 5.3.0"; +#end + import flixel.FlxBasic; import flixel.FlxG; import flixel.FlxObject;