-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compatibility checks with flixel (#419)
* check compatibility with flixel * update formatting settings * wrap in #if macro
- Loading branch information
Showing
6 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"[haxe]": { | ||
"editor.formatOnSave": true | ||
"editor.formatOnSave": true, | ||
"editor.formatOnSaveMode": "modifications" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package flixel.addons.system.macros; | ||
|
||
#if macro | ||
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); | ||
} | ||
} | ||
#end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters