Skip to content

Commit

Permalink
Merge branch 'dev' into replay-duration
Browse files Browse the repository at this point in the history
  • Loading branch information
Geokureli committed May 9, 2024
2 parents ed38a21 + 27c47e5 commit 80e4e47
Show file tree
Hide file tree
Showing 36 changed files with 619 additions and 270 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
build:
strategy:
matrix:
haxe-version: ["4.2.5", "4.3.3", latest]
haxe-version: ["4.2.5", "4.3.3"]
target: [html5, hl, neko, flash, cpp]
fail-fast: false
runs-on: ubuntu-latest
Expand Down
50 changes: 48 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
5.7.0 (TBD)
5.8.1 (TBD)

#### Changes and improvements:
- `FlxKey`: Add `NONE` to `fromStringMap` and `toStringMap` ([#3119](https://github.com/HaxeFlixel/flixel/pull/3119))
- `FlxPreloader`: Improve documentation ([#3119](https://github.com/HaxeFlixel/flixel/pull/3119))

#### Bugfixes:
-

5.8.0 (April 19, 2024)

#### New features:
- `FlxBitmapText`: Add `getRenderedText` ([#3120](https://github.com/HaxeFlixel/flixel/pull/3120))

#### Bugfixes:
- `FlxSpriteGroup`: Fix propegation of `cameras` field to members ([#3118](https://github.com/HaxeFlixel/flixel/pull/3118))
- `FlxBitmapText`: Fix wrap issues caused from kerning ([#3120](https://github.com/HaxeFlixel/flixel/pull/3120))

5.7.2 (April 17, 2024)
#### Bugfixes:
- `FlxSpriteGroup`: Better long term fix for members cameras ([#3116](https://github.com/HaxeFlixel/flixel/pull/3116))

5.7.1 (April 16, 2024)
#### Bugfixes:
- `FlxImageFrame`: Prevent null ref from destroyed graphics ([#3113](https://github.com/HaxeFlixel/flixel/pull/3113))
- `FlxSpriteGroup`: Fix issue where members draw to the wrong cameras ([#3113](https://github.com/HaxeFlixel/flixel/pull/3113))

5.7.0 (April 16, 2024)

#### New features:
- `FlxBitmapFont`: Added `setCharFrame` ([#3037](https://github.com/HaxeFlixel/flixel/pull/3037))
Expand All @@ -8,7 +35,10 @@
- `FlxG.plugins`: Added `drawOnTop` field ([#3057](https://github.com/HaxeFlixel/flixel/pull/3057))
- `FlxCamera`: Added `stopFade`, `stopFlash`, and `stopShake` ([#3063](https://github.com/HaxeFlixel/flixel/pull/3063))
- `FlxRect`: Added `containsXY` ([#3069](https://github.com/HaxeFlixel/flixel/pull/3069))

- `FlxDebugger`: Added button to toggle `ignoreDrawDebug` on selected objects ([#3071](https://github.com/HaxeFlixel/flixel/pull/3071))
- `FlxTween`: Add tween-based `flicker()` system ([#3086](https://github.com/HaxeFlixel/flixel/pull/3086))
- `FlxButton`: Add `DISABLED` state ([#3087](https://github.com/HaxeFlixel/flixel/pull/3087))
- `FlxBitmapFont`: Honor kerning data from BMFont files ([#3035](https://github.com/HaxeFlixel/flixel/pull/3035))

#### Changes and improvements:
- `FlxBitmapText`: Honor `scale` when changing `width` and `height` ([#3037](https://github.com/HaxeFlixel/flixel/pull/3037))
Expand All @@ -17,6 +47,22 @@
- `FlxText`: Removed references to `FlxUnicodeUtil` ([#3049](https://github.com/HaxeFlixel/flixel/pull/3049))
- `FlxObject`: Deprecated `health` and `hurt` ([#3065](https://github.com/HaxeFlixel/flixel/pull/3065))
- Added compiler flag `FLX_NO_HEALTH` to create your own replacement, if needed ([#3067](https://github.com/HaxeFlixel/flixel/pull/3067))
- Prevent building debug bitmaps in release mode ([#3077](https://github.com/HaxeFlixel/flixel/pull/3077))
- `FlxUnicodeUtil`: Deprecated ([#3078](https://github.com/HaxeFlixel/flixel/pull/3078))
- Various Changes brought up by EliteMasterEric ([#3085](https://github.com/HaxeFlixel/flixel/pull/3085))
- `FlxGraphic`: Check `isDestroyed` for better error messages when using destroyed graphics
- `FlxGraphic`: Prevent double destroy, and double adding of frame collections
- `FlxFlicker`: Prevent double `release()` calls
- `FlxDebugger`: Updated the URL to HaxeFlixel site ([#3102](https://github.com/HaxeFlixel/flixel/pull/3102))

#### Bugfixes:
- `FlxKeyboard`: Fix `PLUS` key on windows ([#3093](https://github.com/HaxeFlixel/flixel/pull/3093))
- `FlxSpriteContainer`: Fix error in `destroy` ([#3095](https://github.com/HaxeFlixel/flixel/pull/3095))
- `FlxSprite`: Fix `getGraphicMidpoint()` ([#3101](https://github.com/HaxeFlixel/flixel/pull/3101))
- `FlxPool`: Fix various point and rect pooling leaks ([#3103](https://github.com/HaxeFlixel/flixel/pull/3103))
([#3108](https://github.com/HaxeFlixel/flixel/pull/3108))
- `FlxAtlasFrames`: Prevent errors when adding frames of size 0 ([#3096](https://github.com/HaxeFlixel/flixel/pull/3096))
- `FlxSound`: Fix sound panning ([#2863](https://github.com/HaxeFlixel/flixel/pull/2863))

5.6.2 (February 10, 2024)
#### Changes and improvements:
Expand Down
16 changes: 8 additions & 8 deletions flixel/FlxCamera.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1477,14 +1477,14 @@ class FlxCamera extends FlxBasic
style = Style;
target = Target;
followLerp = Lerp;
var helper:Float;
var w:Float = 0;
var h:Float = 0;
_lastTargetPosition = null;
_lastTargetPosition = FlxDestroyUtil.put(_lastTargetPosition);
deadzone = FlxDestroyUtil.put(deadzone);

switch (Style)
{
case LOCKON:
var w:Float = 0;
var h:Float = 0;
if (target != null)
{
w = target.width;
Expand All @@ -1493,16 +1493,16 @@ class FlxCamera extends FlxBasic
deadzone = FlxRect.get((width - w) / 2, (height - h) / 2 - h * 0.25, w, h);

case PLATFORMER:
var w:Float = (width / 8);
var h:Float = (height / 3);
final w:Float = (width / 8);
final h:Float = (height / 3);
deadzone = FlxRect.get((width - w) / 2, (height - h) / 2 - h * 0.25, w, h);

case TOPDOWN:
helper = Math.max(width, height) / 4;
final helper = Math.max(width, height) / 4;
deadzone = FlxRect.get((width - helper) / 2, (height - helper) / 2, helper, helper);

case TOPDOWN_TIGHT:
helper = Math.max(width, height) / 8;
final helper = Math.max(width, height) / 8;
deadzone = FlxRect.get((width - helper) / 2, (height - helper) / 2, helper, helper);

case SCREEN_BY_SCREEN:
Expand Down
2 changes: 1 addition & 1 deletion 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, 7, 0);
public static var VERSION(default, null):FlxVersion = new FlxVersion(5, 8, 1);

/**
* Internal tracker for game object.
Expand Down
9 changes: 8 additions & 1 deletion flixel/FlxGame.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package flixel;
import flixel.graphics.tile.FlxDrawBaseItem;
import flixel.system.FlxSplash;
import flixel.util.FlxArrayUtil;
import flixel.util.FlxDestroyUtil;
import flixel.util.typeLimit.NextState;
import openfl.Assets;
import openfl.Lib;
Expand Down Expand Up @@ -756,7 +757,13 @@ class FlxGame extends Sprite
#end

#if FLX_POINTER_INPUT
FlxArrayUtil.clearArray(FlxG.swipes);
var len = FlxG.swipes.length;
while(len-- > 0)
{
final swipe = FlxG.swipes.pop();
if (swipe != null)
swipe.destroy();
}
#end

filters = filtersEnabled ? _filters : null;
Expand Down
2 changes: 1 addition & 1 deletion flixel/FlxSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ class FlxSprite extends FlxObject
{
if (point == null)
point = FlxPoint.get();
return point.set(x + frameWidth * 0.5, y + frameHeight * 0.5);
return point.set(x + frameWidth * 0.5 * scale.x, y + frameHeight * 0.5 * scale.y);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions flixel/graphics/FlxGraphic.hx
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ class FlxGraphic implements IFlxDestroyable
key = null;
assetsKey = null;
assetsClass = null;
imageFrame = null; // no need to dispose _imageFrame since it exists in imageFrames
imageFrame = FlxDestroyUtil.destroy(imageFrame);

if (frameCollections == null) // no need to destroy frame collections if it's already null
return;
Expand Down Expand Up @@ -602,7 +602,7 @@ class FlxGraphic implements IFlxDestroyable
function get_imageFrame():FlxImageFrame
{
if (imageFrame == null)
imageFrame = FlxImageFrame.fromRectangle(this, FlxRect.get(0, 0, bitmap.width, bitmap.height));
imageFrame = FlxImageFrame.fromRectangle(this);

return imageFrame;
}
Expand Down
26 changes: 22 additions & 4 deletions flixel/graphics/frames/FlxAtlasFrames.hx
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ class FlxAtlasFrames extends FlxFramesCollection

for (texture in data.nodes.SubTexture)
{
if (!texture.has.width && texture.has.w)
throw "Sparrow v1 is not supported, use Sparrow v2";

var name = texture.att.name;
var trimmed = texture.has.frameX;
var rotated = (texture.has.rotated && texture.att.rotated == "true");
Expand All @@ -262,25 +265,40 @@ class FlxAtlasFrames extends FlxFramesCollection

var rect = FlxRect.get(Std.parseFloat(texture.att.x), Std.parseFloat(texture.att.y), Std.parseFloat(texture.att.width),
Std.parseFloat(texture.att.height));

var size = if (trimmed)
{
new Rectangle(Std.parseInt(texture.att.frameX), Std.parseInt(texture.att.frameY), Std.parseInt(texture.att.frameWidth),
FlxRect.get(Std.parseInt(texture.att.frameX), Std.parseInt(texture.att.frameY), Std.parseInt(texture.att.frameWidth),
Std.parseInt(texture.att.frameHeight));
}
else
{
new Rectangle(0, 0, rect.width, rect.height);
FlxRect.get(0, 0, rect.width, rect.height);
}


var angle = rotated ? FlxFrameAngle.ANGLE_NEG_90 : FlxFrameAngle.ANGLE_0;

var offset = FlxPoint.get(-size.left, -size.top);
var offset = FlxPoint.get(-size.x, -size.y);
var sourceSize = FlxPoint.get(size.width, size.height);

if (rotated && !trimmed)
sourceSize.set(size.height, size.width);

// Prevents issues caused by adding frames of size 0
if (rect.width == 0 || rect.height == 0)
{
if (!trimmed)
size.setSize(1,1);

var frame = frames.addEmptyFrame(size);

frame.name = name;
frame.offset.copyFrom(offset);

continue;
}

frames.addAtlasFrame(rect, sourceSize, offset, name, angle, flipX, flipY);
}

Expand Down
64 changes: 23 additions & 41 deletions flixel/graphics/frames/FlxBitmapFont.hx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class FlxBitmapFont extends FlxFramesCollection
* Helper map where character's xAdvance are stored by char codes.
*/
var charAdvance:Map<Int, Int>;

var kerning:Map<Int, Map<Int, Int>>;

/**
* Atlas frame from which this font has been parsed.
Expand All @@ -88,6 +90,7 @@ class FlxBitmapFont extends FlxFramesCollection
parent.destroyOnNoUse = false;
charMap = new Map<Int, FlxFrame>();
charAdvance = new Map<Int, Int>();
kerning = new Map<Int, Map<Int, Int>>();
}

override public function destroy():Void
Expand Down Expand Up @@ -173,50 +176,13 @@ class FlxBitmapFont extends FlxFramesCollection
frame = graphic.imageFrame.frame;
}

var font:FlxBitmapFont = FlxBitmapFont.findFont(frame);
final font:FlxBitmapFont = FlxBitmapFont.findFont(frame);
if (font != null)
return font;

font = new FlxBitmapFont(frame);

final font = new FlxBitmapFont(frame);
final fontInfo = data.parse();

// how much to move the cursor when going to the next line.
font.lineHeight = fontInfo.common.lineHeight;
font.size = fontInfo.info.size;
font.fontName = fontInfo.info.face;
font.bold = fontInfo.info.bold;
font.italic = fontInfo.info.italic;

for (char in fontInfo.chars)
{
final frame = FlxRect.get();
frame.x = char.x; // X position within the bitmap image file.
frame.y = char.y; // Y position within the bitmap image file.
frame.width = char.width; // Width of the character in the image file.
frame.height = char.height; // Height of the character in the image file.

font.minOffsetX = (font.minOffsetX < -char.xoffset) ? -char.xoffset : font.minOffsetX;

if (char.id == -1)
{
throw 'Invalid font data!';
}

font.addCharFrame(char.id, frame, FlxPoint.weak(char.xoffset, char.yoffset), char.xadvance);

if (char.id == SPACE_CODE)
{
font.spaceWidth = char.xadvance;
}
else
{
font.lineHeight = (font.lineHeight > char.height + char.yoffset) ? font.lineHeight : char.height + char.yoffset;
}
}

font.updateSourceHeight();
return font;
return fontInfo.initBitmapFont(font);
}

/**
Expand Down Expand Up @@ -530,6 +496,22 @@ class FlxBitmapFont extends FlxFramesCollection
{
return charAdvance.exists(charCode) ? charAdvance.get(charCode) : 0;
}

public function getKerning(prevCode:Int, nextCode:Int):Int
{
if (kerning.exists(prevCode) && kerning[prevCode].exists(nextCode))
return kerning[prevCode][nextCode];
else
return 0;
}

public function addKerningPair(prevCode:Int, nextCode:Int, amount:Int)
{
if (!kerning.exists(prevCode))
kerning.set(prevCode, new Map<Int, Int>());

kerning[prevCode][nextCode] = amount;
}

public inline function getCharWidth(charCode:Int):Float
{
Expand Down Expand Up @@ -586,4 +568,4 @@ class FlxBitmapFont extends FlxFramesCollection
font.updateSourceHeight();
return font;
}
}
}
4 changes: 2 additions & 2 deletions flixel/graphics/frames/FlxFrame.hx
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ class FlxFrame implements IFlxDestroyable
return clippedFrame;
}

var clippedRect:FlxRect = FlxRect.get(0, 0).setSize(frame.width, frame.height);
final clippedRect:FlxRect = FlxRect.get(0, 0).setSize(frame.width, frame.height);
if (angle != FlxFrameAngle.ANGLE_0)
{
clippedRect.width = frame.height;
Expand All @@ -611,7 +611,7 @@ class FlxFrame implements IFlxDestroyable

clip.offset(-offset.x, -offset.y);
var frameRect:FlxRect = clippedRect.intersection(clip);
clippedRect = FlxDestroyUtil.put(clippedRect);
clippedRect.put();

if (frameRect.isEmpty)
{
Expand Down
4 changes: 3 additions & 1 deletion flixel/graphics/frames/FlxFramesCollection.hx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ class FlxFramesCollection implements IFlxDestroyable
*/
public function addSpriteSheetFrame(region:FlxRect):FlxFrame
{
var frame = new FlxFrame(parent);
// Ensure region not a weak rect
region = FlxRect.get().copyFrom(region);
final frame = new FlxFrame(parent);
frame.frame = checkFrame(region);
frame.sourceSize.set(region.width, region.height);
frame.offset.set(0, 0);
Expand Down
Loading

0 comments on commit 80e4e47

Please sign in to comment.