Skip to content

Commit

Permalink
Merge remote-tracking branch 'flixel/dev' into dev-6.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteMasterEric committed Feb 13, 2024
2 parents 2afdd54 + 1074fb0 commit 4d054bd
Show file tree
Hide file tree
Showing 15 changed files with 454 additions and 192 deletions.
30 changes: 19 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
- `FlxCamera`: Smoother camera lerping, particularly with non-fixed timesteps ([#2922](https://github.com/HaxeFlixel/flixel/pull/2922))
- `FlxState`: Remove deprecated `switchTo` ([#2733](https://github.com/HaxeFlixel/flixel/pull/2733))Z
- `FlxG`: Add deprecation warning on `switchState` with instances ([#2733](https://github.com/HaxeFlixel/flixel/pull/2733))Z
5.6.2 (February 10, 2024)
#### Changes and improvements:
- `FlxBitmapFont`: Prevent crashes from missing xml fields in `fromAngelCode` ([#3029](https://github.com/HaxeFlixel/flixel/pull/3029))

5.6.1 (February 9, 2024)
#### Changes and improvements:
- `FlxBitmapFont`: Downgraded crashes of missing xml fields to warnings in `fromAngelCode` ([#3025](https://github.com/HaxeFlixel/flixel/pull/3025))
- Corrected documenation for the recent `FlxG.switchstate` arg changes

5.6.0 (February 2, 2024)

Expand Down Expand Up @@ -78,7 +86,7 @@
- **README.md**: Add Turkish translations
- `AssetPaths`: Add `allFiles` field, and an arg in `FlxAssets.buildFileReferences` to change the identifier ([#2807](https://github.com/HaxeFlixel/flixel/pull/2807))
- Debug tools: Add ways to remove custom debug tools ([#2792](https://github.com/HaxeFlixel/flixel/pull/2792))
- `FlxG.console`: Add `removeByAlias`, `removeEnum`, `removeClass`, `removeObject` and `removeFunction`
- `FlxG.console`: Add `removeByAlias`, `removeEnum`, `removeClass`, `removeObject` and `removeFunction`
- `FlxG.game.debugger.interaction`: Add `removeTool`
- `FlxText`: Add `fieldHeight` field ([#2789](https://github.com/HaxeFlixel/flixel/pull/2789))
- `FlxG`: Add compiler flag `FLX_NO_SAVE` to remove `FlxG.save` (also counter-flag `FLX_SAVE`) ([#2840](https://github.com/HaxeFlixel/flixel/pull/2840))
Expand Down Expand Up @@ -218,7 +226,7 @@
- `AssetPaths`: various fixes ([#2680](https://github.com/HaxeFlixel/flixel/pull/2680))
- apply `include`/`exclude` args to files, not directories
- default file renamer will replace spaces with underscore

#### New features:
- `FlxKeys`: Added `SCROLL_LOCK`, `NUMLOCK`, `WINDOWS`, `MENU`, `BREAK` and `NUMPADSLASH` keys ([#2638](https://github.com/HaxeFlixel/flixel/pull/2638))

Expand Down Expand Up @@ -256,7 +264,7 @@ The alpha was causing issues with CI due to haxelib issues. We're foregoing the
- `WatchFrontEnd`: added `FlxG.watch.addFunction` ([#2500](https://github.com/HaxeFlixel/flixel/pull/2500))
- `FlxPoint`: added binary operators `+`, `-`, `+=`, `-=`, `*`, and `*=` ([#2557](https://github.com/HaxeFlixel/flixel/pull/2557))
- `FlxColor`: added `rgb` getter and setter ([#2555](https://github.com/HaxeFlixel/flixel/pull/2555))
- `FlxSave`: added `mergeDataFrom`, `mergeData` `status`, `isBound` and `isEmpty`
- `FlxSave`: added `mergeDataFrom`, `mergeData` `status`, `isBound` and `isEmpty`
([#2566](https://github.com/HaxeFlixel/flixel/pull/2566))
([#2584](https://github.com/HaxeFlixel/flixel/pull/2584))
- `FlxAnimation` - added `loopPoint` to allow looping to a frame other than the starting frame ([#2621](https://github.com/HaxeFlixel/flixel/pull/2621))
Expand Down Expand Up @@ -571,7 +579,7 @@ The alpha was causing issues with CI due to haxelib issues. We're foregoing the
- fixed selections being canceled on interaction with debugger UI ([897f21f](https://github.com/HaxeFlixel/flixel/commit/897f21f))
- `FlxG.html5`: fixed `platform` detecting iPhone and iPod as "Mac" ([#2052](https://github.com/HaxeFlixel/flixel/issues/2052))
- `FlxTilemap`: fixed a missing bounds check in `getTileIndexByCoords()` ([#2024](https://github.com/HaxeFlixel/flixel/issues/2024))
- `FlxAnalog`: fixed mouse input without `FLX_NO_TOUCH` ([#2067](https://github.com/HaxeFlixel/flixel/issues/2067))
- `FlxAnalog`: fixed mouse input without `FLX_NO_TOUCH` ([#2067](https://github.com/HaxeFlixel/flixel/issues/2067))
- `flixel.input`: fixed `Float` being used for tick values ([#2071](https://github.com/HaxeFlixel/flixel/issues/2071))
- `FlxCamera`: fixed object visibility for `zoom < 1` ([#2003](https://github.com/HaxeFlixel/flixel/issues/2003))
- `FlxEmitter`: fixed issues with `lifespan == 0` ([#2074](https://github.com/HaxeFlixel/flixel/issues/2074))
Expand Down Expand Up @@ -730,7 +738,7 @@ The alpha was causing issues with CI due to haxelib issues. We're foregoing the
* `FlxTween`: fixed nested tween chains ([#1871](https://github.com/HaxeFlixel/flixel/issues/1871))
* `FlxTypedGroup`: fixed recursion in `forEachOfType()` ([#1876](https://github.com/HaxeFlixel/flixel/issues/1876))
* `Tracker`: [Neko] fixed a crash in `setVisible()` ([#1879](https://github.com/HaxeFlixel/flixel/issues/1879))
* Fixed some flixel-internal fields being accessible when they shouldn't be ([#1849](https://github.com/HaxeFlixel/flixel/issues/1849))
* Fixed some flixel-internal fields being accessible when they shouldn't be ([#1849](https://github.com/HaxeFlixel/flixel/issues/1849))

#### Changes and improvements:

Expand All @@ -739,7 +747,7 @@ The alpha was causing issues with CI due to haxelib issues. We're foregoing the
* `FlxSpriteUtil`: changed `alphaMask()` arguments from `Dynamic` to `FlxGraphicAsset` ([#1806](https://github.com/HaxeFlixel/flixel/issues/1806))
* `FlxG.signals`: changed `preUpdate` to be dispatched _after_ `FlxG.elapsed` is updated ([#1836](https://github.com/HaxeFlixel/flixel/issues/1836))
* `FlxG.debugger`: changed `drawDebugChanged` to be dispatched _after_ `drawDebug` is updated
* `FlxDefines`: added a check for incompatible OpenFL / Lime versions (should be < 4.0.0 / < 3.0.0 respectively)
* `FlxDefines`: added a check for incompatible OpenFL / Lime versions (should be < 4.0.0 / < 3.0.0 respectively)

4.0.1 (March 19, 2016)
------------------------------
Expand All @@ -756,7 +764,7 @@ The alpha was causing issues with CI due to haxelib issues. We're foregoing the
* `FlxStringUtil.formatMoney()`:
* fixed formatting for `Amount < 0` ([#1754](https://github.com/HaxeFlixel/flixel/issues/1754))
* fixed formatting for negative amounts
* [HTML5] fixed formatting for amounts > Int32
* [HTML5] fixed formatting for amounts > Int32
* Debugger Stats window: fixed paused time being taken into account for average FPS

4.0.0 (February 16, 2016)
Expand Down Expand Up @@ -996,7 +1004,7 @@ The alpha was causing issues with CI due to haxelib issues. We're foregoing the

* `FlxAssets`:
* `cacheSounds()` -> `FlxG.sound.cacheAll()` ([#1097](https://github.com/HaxeFlixel/flixel/issues/1097))
* OpenFL live asset reloading is now supported (native targets)
* OpenFL live asset reloading is now supported (native targets)
* `FlxSound`
* can now be used even if `FLX_NO_SOUND_SYSTEM` is enabled ([#1199](https://github.com/HaxeFlixel/flixel/issues/1199))
* `looped` is now `public`
Expand Down Expand Up @@ -1038,7 +1046,7 @@ The alpha was causing issues with CI due to haxelib issues. We're foregoing the
added `setRect()` method which allows you to set a rectangular region of tiles to the provided index
* `FlxTile`:
added `frame` variable which holds tile's "graphic"
* `FlxTileblock`:
* `FlxTileblock`:
* added `setTile()` and `tileSprite` ([#1300](https://github.com/HaxeFlixel/flixel/issues/1300))
* added `loadFrames()` method which allows you to use frames collection as a source of graphic
* `FlxTilemap`:
Expand Down Expand Up @@ -1097,7 +1105,7 @@ The alpha was causing issues with CI due to haxelib issues. We're foregoing the
* `FlxColor`:
* `FlxColor` is now an `abstract`, interchangeable with `Int` - the `FlxColorUtil` functions have been merged into it ([#1027](https://github.com/HaxeFlixel/flixel/issues/1027))
* the color presets have been reduced to a smaller, more useful selection ([#1117](https://github.com/HaxeFlixel/flixel/issues/1117))
* `FlxPath`:
* `FlxPath`:
* the original `FlxObject#immovable` value is now restored after completion
* `active` is now only true when in progress
* fixed velocity being set even if the object position matches the current node
Expand All @@ -1121,5 +1129,5 @@ The alpha was causing issues with CI due to haxelib issues. We're foregoing the

* Added an initialization macro that aborts compilation with helpful errors when:
* targeting older SWF versions with invalid defines
* using an unsupported Haxe version
* using an unsupported Haxe version
* Flixel sound assets are now being embedded via `embed="true"`
6 changes: 3 additions & 3 deletions flixel/FlxG.hx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class FlxG
* The HaxeFlixel version, in semantic versioning syntax. Use `Std.string()`
* on it to get a `String` formatted like this: `"HaxeFlixel MAJOR.MINOR.PATCH-COMMIT_SHA"`.
*/
public static var VERSION(default, null):FlxVersion = new FlxVersion(5, 6, 0);
public static var VERSION(default, null):FlxVersion = new FlxVersion(5, 6, 2);

/**
* Internal tracker for game object.
Expand Down Expand Up @@ -371,8 +371,8 @@ class FlxG
* Attempts to switch from the current game state to `nextState`.
* The state switch is successful if `switchTo()` of the current `state` returns `true`.
* @param nextState A constructor for the initial state, ex: `PlayState.new` or `()->new PlayState()`.
* Note: Before Flixel 6, this took a `FlxState` instance, this has been
* deprecated, but is still available, for backwards compatibility.
* Note: Before Flixel 5.6.0, this took a `FlxState` instance,
* this is still available, for backwards compatibility.
*/
public static inline function switchState(nextState:NextState):Void
{
Expand Down
4 changes: 2 additions & 2 deletions flixel/animation/FlxAnimationController.hx
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,8 @@ class FlxAnimationController implements IFlxDestroyable
{
final name = frames[0].name;
final postIndex = name.indexOf(".", prefix.length);
final postFix = name.substring(postIndex == -1 ? name.length : postIndex, name.length);
FlxFrame.sort(frames, prefix.length, postFix.length);
final suffix = name.substring(postIndex == -1 ? name.length : postIndex, name.length);
FlxFrame.sortFrames(frames, prefix, suffix);

for (frame in frames)
{
Expand Down
75 changes: 57 additions & 18 deletions flixel/graphics/frames/FlxFrame.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import openfl.display.BitmapData;
import openfl.geom.Point;
import openfl.geom.Rectangle;
import flixel.graphics.FlxGraphic;
import flixel.math.FlxMath;
import flixel.math.FlxMatrix;
import flixel.math.FlxPoint;
import flixel.math.FlxRect;
Expand Down Expand Up @@ -32,29 +33,67 @@ class FlxFrame implements IFlxDestroyable
* Temp matrix helper, used internally
*/
static var _matrix = new FlxMatrix();

/**
* Sorts an array of `FlxFrame` objects by their name, e.g.
* `["tiles-001.png", "tiles-003.png", "tiles-002.png"]`
* with `"tiles-".length == prefixLength` and `".png".length == postfixLength`.
* Sorts frames based on the value of the frames' name between the prefix and suffix.
* Uses `Std.parseInt` to parse the value, if the result is `null`, 0 is used, if the result
* is a negative number, the absolute valute is used.
*
* @param frames The list of frames to sort
* @param prefix Everything in the frames' name *before* the order
* @param suffix Everything in the frames' name *after* the order
* @param warn Whether to warn on invalid names
*/
public static function sort(frames:Array<FlxFrame>, prefixLength:Int, postfixLength:Int):Void
public static inline function sortFrames(frames:Array<FlxFrame>, prefix:String, ?suffix:String, warn = true):Void
{
ArraySort.sort(frames, sortByName.bind(_, _, prefixLength, postfixLength));
sortHelper(frames, prefix.length, suffix == null ? 0 : suffix.length, warn);
}

public static function sortByName(frame1:FlxFrame, frame2:FlxFrame, prefixLength:Int, postfixLength:Int):Int

/**
* Sorts frames based on the value of the frames' name between the prefix and suffix.
* Uses `Std.parseInt` to parse the value, if the result is `null`, 0 is used, if the result
* is a negative number, the absolute valute is used.
*
* @param frames The list of frames to sort
* @param prefix Everything in the frames' name *before* the order
* @param suffix Everything in the frames' name *after* the order
* @param warn Whether to warn on invalid names
*/
public static function sort(frames:Array<FlxFrame>, prefixLength:Int, suffixLength:Int, warn = true):Void
{
var name1:String = frame1.name;
var name2:String = frame2.name;
var num1:Null<Int> = Std.parseInt(name1.substring(prefixLength, name1.length - postfixLength));
var num2:Null<Int> = Std.parseInt(name2.substring(prefixLength, name2.length - postfixLength));
if (num1 == null)
num1 = 0;
if (num2 == null)
num2 = 0;

return num1 - num2;
sortHelper(frames, prefixLength, suffixLength, warn);
}

static function sortHelper(frames:Array<FlxFrame>, prefixLength:Int, suffixLength:Int, warn = true):Void
{
if (warn)
{
for (frame in frames)
checkValidName(frame.name, prefixLength, suffixLength);
}

ArraySort.sort(frames, sortByName.bind(_, _, prefixLength, suffixLength));
}

static inline function checkValidName(name:String, prefixLength:Int, suffixLength:Int)
{
final nameSub = name.substring(prefixLength, name.length - suffixLength);
final num:Null<Int> = Std.parseInt(nameSub);
if (num == null)
FlxG.log.warn('Could not parse frame number of "$nameSub" in frame named "$name"');
else if (num < 0)
FlxG.log.warn('Found negative frame number "$nameSub" in frame named "$name"');
}

public static function sortByName(frame1:FlxFrame, frame2:FlxFrame, prefixLength:Int, suffixLength:Int):Int
{
inline function getNameOrder(name:String):Int
{
final num:Null<Int> = Std.parseInt(name.substring(prefixLength, name.length - suffixLength));
return if (num == null) 0 else FlxMath.absInt(num);
}

return getNameOrder(frame1.name) - getNameOrder(frame2.name);
}

public var name:String;
Expand Down
4 changes: 2 additions & 2 deletions flixel/graphics/frames/FlxTileFrames.hx
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ class FlxTileFrames extends FlxFramesCollection
{
var name:String = framesToAdd[0].name;
var postIndex:Int = name.indexOf(".", Prefix.length);
var postFix:String = name.substring(postIndex == -1 ? name.length : postIndex, name.length);
var suffix:String = name.substring(postIndex == -1 ? name.length : postIndex, name.length);

FlxFrame.sort(framesToAdd, Prefix.length, postFix.length);
FlxFrame.sortFrames(framesToAdd, Prefix, suffix);
return FlxTileFrames.fromFrames(framesToAdd);
}

Expand Down
15 changes: 7 additions & 8 deletions flixel/graphics/frames/bmfont/BMFont.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package flixel.graphics.frames.bmfont;
import flixel.system.FlxAssets;
import haxe.io.Bytes;
import haxe.io.BytesInput;
import haxe.xml.Access;
import openfl.utils.Assets;

using StringTools;
Expand Down Expand Up @@ -34,16 +33,16 @@ class BMFont

public static function fromXml(xml:Xml)
{
final xmlAccess = new Access(xml);
final info = BMFontInfo.fromXml(xmlAccess.node.info);
final common = BMFontCommon.fromXml(xmlAccess.node.common);
final pages = BMFontPage.listFromXml(xmlAccess.node.pages);
final chars = BMFontChar.listFromXml(xmlAccess.node.chars);
final main = new BMFontXml(xml);
final info = BMFontInfo.fromXml(main.node.get("info"));
final common = BMFontCommon.fromXml(main.node.get("common"));
final pages = BMFontPage.listFromXml(main.node.get("pages"));
final chars = BMFontChar.listFromXml(main.node.get("chars"));
var kerning:Array<BMFontKerning> = null;

if (xmlAccess.hasNode.kernings)
if (main.hasNode("kernings"))
{
kerning = BMFontKerning.listFromXml(xmlAccess.node.kernings);
kerning = BMFontKerning.listFromXml(main.node.get("kernings"));
}

return new BMFont(info, common, pages, chars, kerning);
Expand Down
29 changes: 14 additions & 15 deletions flixel/graphics/frames/bmfont/BMFontChar.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package flixel.graphics.frames.bmfont;

import haxe.io.BytesInput;
import haxe.xml.Access;
import UnicodeString;

using StringTools;
Expand Down Expand Up @@ -29,26 +28,26 @@ class BMFontChar
public var chnl:Int;
public var letter:Null<String> = null;

static inline function fromXml(charNode:Access):BMFontChar
static inline function fromXml(charNode:BMFontXml):BMFontChar
{
return {
id: Std.parseInt(charNode.att.id),
x: Std.parseInt(charNode.att.x),
y: Std.parseInt(charNode.att.y),
width: Std.parseInt(charNode.att.width),
height: Std.parseInt(charNode.att.height),
xoffset: (charNode.has.xoffset) ? Std.parseInt(charNode.att.xoffset) : 0,
yoffset: (charNode.has.yoffset) ? Std.parseInt(charNode.att.yoffset) : 0,
xadvance: (charNode.has.xadvance) ? Std.parseInt(charNode.att.xadvance) : 0,
page: Std.parseInt(charNode.att.page),
chnl: Std.parseInt(charNode.att.chnl),
letter: charNode.has.letter ? charNode.att.letter : null
id: charNode.att.int("id"),
x: charNode.att.int("x"),
y: charNode.att.int("y"),
width: charNode.att.int("width"),
height: charNode.att.int("height"),
xoffset: charNode.att.intSafe("xoffset", 0),
yoffset: charNode.att.intSafe("yoffset", 0),
xadvance: charNode.att.intSafe("xadvance", 0),
page: charNode.att.intSafe("page", -1),
chnl: charNode.att.intSafe("chnl", -1),
letter: charNode.att.stringSafe("letter")
};
}

static function listFromXml(charsNode:Access):Array<BMFontChar>
static function listFromXml(charsNode:BMFontXml):Array<BMFontChar>
{
final chars = charsNode.nodes.char;
final chars = charsNode.nodes("char");
return [ for (char in chars) fromXml(char) ];
}

Expand Down
31 changes: 15 additions & 16 deletions flixel/graphics/frames/bmfont/BMFontCommon.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package flixel.graphics.frames.bmfont;

import haxe.io.BytesInput;
import haxe.xml.Access;

/**
* Common data used internally via `FlxBitmapFont.fromAngelCode` to serialize text, xml or binary
Expand All @@ -25,20 +24,20 @@ class BMFontCommon
public var greenChnl:Int;
public var blueChnl:Int;

static function fromXml(commonNode:Access):BMFontCommon
static function fromXml(commonNode:BMFontXml):BMFontCommon
{
return
{
lineHeight: Std.parseInt(commonNode.att.lineHeight),
base: Std.parseInt(commonNode.att.base),
scaleW: Std.parseInt(commonNode.att.scaleW),
scaleH: Std.parseInt(commonNode.att.scaleH),
pages: Std.parseInt(commonNode.att.pages),
packed: commonNode.att.packed != '0',
alphaChnl: (commonNode.has.alphaChnl) ? Std.parseInt(commonNode.att.alphaChnl) : 0,
redChnl: (commonNode.has.redChnl) ? Std.parseInt(commonNode.att.redChnl) : 0,
greenChnl: (commonNode.has.greenChnl) ? Std.parseInt(commonNode.att.greenChnl) : 0,
blueChnl: (commonNode.has.blueChnl) ? Std.parseInt(commonNode.att.blueChnl) : 0
lineHeight: commonNode.att.int("lineHeight"),
base: commonNode.att.intSafe("base", -1),
scaleW: commonNode.att.intWarn("scaleW", 1),
scaleH: commonNode.att.intWarn("scaleH", 1),
pages: commonNode.att.intSafe("pages", 0),
packed: commonNode.att.boolSafe("packed", false),
alphaChnl: commonNode.att.intSafe("alphaChnl", 0),
redChnl: commonNode.att.intSafe("redChnl", 0),
greenChnl: commonNode.att.intSafe("greenChnl", 0),
blueChnl: commonNode.att.intSafe("blueChnl", 0)
};
}

Expand All @@ -50,10 +49,10 @@ class BMFontCommon
var scaleH:Int = 1;
var pages:Int = 0;
var packed:Bool = false;
var alphaChnl:Int = -1;
var redChnl:Int = -1;
var greenChnl:Int = -1;
var blueChnl:Int = -1;
var alphaChnl:Int = 0;
var redChnl:Int = 0;
var greenChnl:Int = 0;
var blueChnl:Int = 0;

BMFontUtil.forEachAttribute(commonText,
function(key:String, value:String)
Expand Down
Loading

0 comments on commit 4d054bd

Please sign in to comment.