Skip to content

Commit

Permalink
remove haxe4 compile conditions (#2489)
Browse files Browse the repository at this point in the history
  • Loading branch information
Geokureli authored Jan 26, 2022
1 parent d2f6fc0 commit 98f4ab3
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 50 deletions.
8 changes: 0 additions & 8 deletions flixel/animation/FlxAnimationController.hx
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,13 @@ class FlxAnimationController implements IFlxDestroyable
* If assigned, will be called each time the current animation's frame changes.
* A function that has 3 parameters: a string name, a frame number, and a frame index.
*/
#if haxe4
public var callback:(name:String, frameNumber:Int, frameIndex:Int) -> Void;
#else
public var callback:String->Int->Int->Void;
#end

/**
* If assigned, will be called each time the current animation finishes.
* A function that has 1 parameter: a string name - animation name.
*/
#if haxe4
public var finishCallback:(name:String) -> Void;
#else
public var finishCallback:String->Void;
#end

/**
* Internal, reference to owner sprite.
Expand Down
4 changes: 0 additions & 4 deletions flixel/effects/particles/FlxEmitter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ typedef FlxEmitter = FlxTypedEmitter<FlxParticle>;
* at set intervals by setting their positions and velocities accordingly.
* It is easy to use and relatively efficient, relying on `FlxGroup`'s RECYCLE POWERS.
*/
#if (haxe_ver >= "4.0.0")
class FlxTypedEmitter<T:FlxSprite & IFlxParticle> extends FlxTypedGroup<T>
#else
class FlxTypedEmitter<T:(FlxSprite, IFlxParticle)> extends FlxTypedGroup<T>
#end
{
/**
* Set your own particle class type here. The custom class must extend `FlxParticle`. Default is `FlxParticle`.
Expand Down
6 changes: 1 addition & 5 deletions flixel/graphics/frames/FlxAtlasFrames.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ import flixel.math.FlxPoint;
import flixel.math.FlxRect;
import flixel.system.FlxAssets.FlxGraphicAsset;
import flixel.system.FlxAssets.FlxTexturePackerSource;
import haxe.Json;
import openfl.Assets;
#if haxe4
import haxe.Json;
import haxe.xml.Access;
#else
import haxe.xml.Fast as Access;
#end

/**
* Atlas frames collection. It makes possible to use texture atlases in Flixel.
Expand Down
4 changes: 0 additions & 4 deletions flixel/graphics/frames/FlxBitmapFont.hx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ import flixel.system.FlxAssets.FlxAngelCodeSource;
import flixel.system.FlxAssets.FlxBitmapFontGraphicAsset;
import flixel.util.FlxColor;
import openfl.Assets;
#if haxe4
import haxe.xml.Access;
#else
import haxe.xml.Fast as Access;
#end

using flixel.util.FlxUnicodeUtil;

Expand Down
4 changes: 2 additions & 2 deletions flixel/system/macros/FlxDefines.hx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ class FlxDefines

static function checkDependencyCompatibility()
{
#if (haxe_ver < "3.4")
abortVersion("Haxe", "3.4.0 or newer", "haxe_ver", (macro null).pos);
#if (haxe_ver < "4.0.5")
abortVersion("Haxe", "4.0.5 or newer", "haxe_ver", (macro null).pos);
#end

#if !nme
Expand Down
30 changes: 3 additions & 27 deletions flixel/util/FlxUnicodeUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,49 @@ package flixel.util;

/**
* Just an internal helper to deal with the deprecation of `haxe.Utf8` - not considered public API.
* Todo: Remove and use Unicode strings
*/
@:dox(hide)
@:noCompletion
class FlxUnicodeUtil
{
public static inline function uLength(s:String):Int
{
#if haxe4
return (s : UnicodeString).length;
#else
return haxe.Utf8.length(s);
#end
}

public static inline function uEquals(a:String, b:String):Bool
{
#if haxe4
return (a : UnicodeString) == (b : UnicodeString);
#else
return haxe.Utf8.compare(a, b) == 0;
#end
}

public static inline function uSub(s:String, pos:Int, len:Int):String
{
#if haxe4
return (s : UnicodeString).substr(pos, len);
#else
return haxe.Utf8.sub(s, pos, len);
#end
}

public static inline function uCharCodeAt(s:String, index:Int):Null<Int>
{
#if haxe4
return (s : UnicodeString).charCodeAt(index);
#else
return haxe.Utf8.charCodeAt(s, index);
#end
}
}

@:dox(hide)
@:noCompletion
abstract UnicodeBuffer(#if haxe4 UnicodeString #else haxe.Utf8 #end)
abstract UnicodeBuffer(UnicodeString)
{
public inline function new(s:String = "")
{
this = #if haxe4 s #else new haxe.Utf8() #end;
this = s;
}

public inline function addChar(c:Int):UnicodeBuffer
{
#if haxe4
return new UnicodeBuffer(this + String.fromCharCode(c));
#else
this.addChar(c);
return cast this;
#end
}

public inline function toString():String
{
#if haxe4
return this;
#else
return this.toString();
#end
}
}

0 comments on commit 98f4ab3

Please sign in to comment.