Skip to content

Commit

Permalink
Merge remote-tracking branch 'flixel/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteMasterEric committed May 28, 2024
2 parents a523c3b + 2759aff commit 4b45f98
Show file tree
Hide file tree
Showing 22 changed files with 222 additions and 75 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,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 All @@ -29,7 +29,7 @@ jobs:
haxelib install haxelib 4.0.3
haxelib dev flixel-addons .
- uses: HaxeFlixel/setup-flixel@master
- uses: HaxeFlixel/setup-flixel@v1
with:
haxe-version: current
flixel-versions: dev
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"[haxe]": {
"editor.formatOnSave": true
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modifications"
}
}
30 changes: 28 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
3.2.1 (September 26, 2023)
3.2.3 (May 15, 2024)
------------------------------

#### Changes and improvements:
- `FlxClickArea`: Compatibility with Flixel 5.7.0 ([425](https://github.com/HaxeFlixel/flixel-addons/pull/425))

#### Bugfixes:
- `FlxBackdrop`: fix matrix leaks ([426](https://github.com/HaxeFlixel/flixel-addons/pull/426))
- `FlxRuntimeShader`: Fix errors with flixel-docs CI ([429](https://github.com/HaxeFlixel/flixel-addons/pull/429))

3.2.2 (March 10, 2024)
------------------------------
#### Dependencies:
- Minimum versions allowed:
- Flixel: 5.3.0
- OpenFl: 9.2.2
- Lime: 8.0.2
- Haxe: 4.2.5

#### Changes and improvements:
- `FlxFSM`: Fix `FlxPool` deprecation warnings from Flixel 5.4.0 ([#409](https://github.com/HaxeFlixel/flixel-addons/pull/409))
- `TransitionData`: add `cameraMode` field to help ensure the transition shows on top ([#410](https://github.com/HaxeFlixel/flixel-addons/pull/410))
- `FlxRuntimeShader`: Throw incompatibility error on nme or flash ([#414](https://github.com/HaxeFlixel/flixel-addons/pull/414))
- `FlxNestedSprite`: Prevent drawing default png ([#412](https://github.com/HaxeFlixel/flixel-addons/pull/412))

#### Bugfixes:
- `TransitionFade`: Fix bug with persistent images ([#415](https://github.com/HaxeFlixel/flixel-addons/pull/415))

3.2.1 (September 26, 2023)
------------------------------
#### Changes and improvements:
- `FlxMouseSpring`: Now works with `FlxSprite` rather than just `FlxExtendedSprite` ([#405](https://github.com/HaxeFlixel/flixel-addons/pull/405))
- `FlxExtendedSprite`: Deprecated for `FlxExtendedMouseSprite`, no longer uses `FlxMouseControl` ([#405](https://github.com/HaxeFlixel/flixel-addons/pull/405))


#### Bugfixes:
- `FlxBackdrop`: Change spacing constructor args to floats ([#408](https://github.com/HaxeFlixel/flixel-addons/pull/408))

Expand Down
91 changes: 48 additions & 43 deletions flixel/addons/display/FlxBackdrop.hx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class FlxBackdrop extends FlxSprite

var _blitOffset:FlxPoint = FlxPoint.get();
var _blitGraphic:FlxGraphic = null;
var _tileMatrix:FlxMatrix = new FlxMatrix();
var _prevDrawParams:BackdropDrawParams =
{
graphicKey:null,
Expand Down Expand Up @@ -82,9 +83,10 @@ class FlxBackdrop extends FlxSprite

override function destroy():Void
{
spacing = FlxDestroyUtil.destroy(spacing);
_blitOffset = FlxDestroyUtil.destroy(_blitOffset);
spacing = FlxDestroyUtil.put(spacing);
_blitOffset = FlxDestroyUtil.put(_blitOffset);
_blitGraphic = FlxDestroyUtil.destroy(_blitGraphic);
_tileMatrix = null;

super.destroy();
}
Expand Down Expand Up @@ -113,6 +115,9 @@ class FlxBackdrop extends FlxSprite
drawToLargestCamera();
}

#if (flixel >= "5.7.0")
final cameras = getCamerasLegacy();
#end
for (camera in cameras)
{
if (!camera.visible || !camera.exists || !isOnScreen(camera))
Expand Down Expand Up @@ -146,10 +151,8 @@ class FlxBackdrop extends FlxSprite
camera = FlxG.camera;

var bounds = getScreenBounds(_rect, camera);
var view = camera.getViewRect();
if (repeatAxes.x) bounds.x = view.x;
if (repeatAxes.y) bounds.y = view.y;
view.put();
if (repeatAxes.x) bounds.x = camera.viewMarginLeft;
if (repeatAxes.y) bounds.y = camera.viewMarginTop;

return camera.containsRect(bounds);
}
Expand All @@ -158,20 +161,20 @@ class FlxBackdrop extends FlxSprite
{
var largest:FlxCamera = null;
var largestArea = 0.0;
var view = FlxRect.get();
#if (flixel >= "5.7.0")
final cameras = getCamerasLegacy(); // else use this.cameras
#end
for (camera in cameras)
{
if (!camera.visible || !camera.exists || !isOnScreen(camera))
continue;

camera.getViewRect(view);
if (view.width * view.height > largestArea)
if (camera.viewWidth * camera.viewHeight > largestArea)
{
largest = camera;
largestArea = view.width * view.height;
largestArea = camera.viewWidth * camera.viewHeight;
}
}
view.put();

if (largest != null)
regenGraphic(largest);
Expand Down Expand Up @@ -199,7 +202,7 @@ class FlxBackdrop extends FlxSprite
final frame = drawBlit ? _blitGraphic.imageFrame.frame : _frame;

// The distance between repeated sprites, in screen space
var tileSize = FlxPoint.get(frame.frame.width, frame.frame.height);
final tileSize = FlxPoint.get(frame.frame.width, frame.frame.height);
if (drawDirect)
tileSize.addPoint(spacing);

Expand All @@ -208,24 +211,25 @@ class FlxBackdrop extends FlxSprite
var tilesY = 1;
if (repeatAxes != NONE)
{
var view = camera.getViewRect();
final viewMargins = camera.getViewMarginRect();
if (repeatAxes.x)
{
final left = modMin(_point.x + frameWidth, tileSize.x, view.left) - frameWidth;
final right = modMax(_point.x, tileSize.x, view.right) + tileSize.x;
final left = modMin(_point.x + frameWidth, tileSize.x, viewMargins.left) - frameWidth;
final right = modMax(_point.x, tileSize.x, viewMargins.right) + tileSize.x;
tilesX = Math.round((right - left) / tileSize.x);
final origTileSizeX = frameWidth + spacing.x;
_point.x = modMin(_point.x + frameWidth, origTileSizeX, view.left) - frameWidth;
_point.x = modMin(_point.x + frameWidth, origTileSizeX, viewMargins.left) - frameWidth;
}

if (repeatAxes.y)
{
final top = modMin(_point.y + frameHeight, tileSize.y, view.top) - frameHeight;
final bottom = modMax(_point.y, tileSize.y, view.bottom) + tileSize.y;
final top = modMin(_point.y + frameHeight, tileSize.y, viewMargins.top) - frameHeight;
final bottom = modMax(_point.y, tileSize.y, viewMargins.bottom) + tileSize.y;
tilesY = Math.round((bottom - top) / tileSize.y);
final origTileSizeY = frameHeight + spacing.y;
_point.y = modMin(_point.y + frameHeight, origTileSizeY, view.top) - frameHeight;
_point.y = modMin(_point.y + frameHeight, origTileSizeY, viewMargins.top) - frameHeight;
}
viewMargins.put();
}

if (drawBlit)
Expand Down Expand Up @@ -254,6 +258,7 @@ class FlxBackdrop extends FlxSprite
}
}

tileSize.put();
camera.buffer.unlock();
}

Expand All @@ -273,7 +278,7 @@ class FlxBackdrop extends FlxSprite
_matrix.translate(-origin.x, -origin.y);

// The distance between repeated sprites, in screen space
var tileSize = FlxPoint.get(frame.frame.width, frame.frame.height);
final tileSize = FlxPoint.get(frame.frame.width, frame.frame.height);

if (drawDirect)
{
Expand Down Expand Up @@ -311,59 +316,59 @@ class FlxBackdrop extends FlxSprite
var tilesY = 1;
if (repeatAxes != NONE)
{
final view = camera.getViewRect();
final viewMargins = camera.getViewMarginRect();
final bounds = getScreenBounds(camera);
if (repeatAxes.x)
{
final origTileSizeX = (frameWidth + spacing.x) * scale.x;
final left = modMin(bounds.right, origTileSizeX, view.left) - bounds.width;
final right = modMax(bounds.left, origTileSizeX, view.right) + origTileSizeX;
final left = modMin(bounds.right, origTileSizeX, viewMargins.left) - bounds.width;
final right = modMax(bounds.left, origTileSizeX, viewMargins.right) + origTileSizeX;
tilesX = Math.round((right - left) / tileSize.x);
_point.x = left + _point.x - bounds.x;
}

if (repeatAxes.y)
{
final origTileSizeY = (frameHeight + spacing.y) * scale.y;
final top = modMin(bounds.bottom, origTileSizeY, view.top) - bounds.height;
final bottom = modMax(bounds.top, origTileSizeY, view.bottom) + origTileSizeY;
final top = modMin(bounds.bottom, origTileSizeY, viewMargins.top) - bounds.height;
final bottom = modMax(bounds.top, origTileSizeY, viewMargins.bottom) + origTileSizeY;
tilesY = Math.round((bottom - top) / tileSize.y);
_point.y = top + _point.y - bounds.y;
}
view.put();
viewMargins.put();
bounds.put();
}
_point.addPoint(origin);
if (drawBlit)
_point.addPoint(_blitOffset);

final mat = new FlxMatrix();
for (tileX in 0...tilesX)
{
for (tileY in 0...tilesY)
{
mat.copyFrom(_matrix);
_tileMatrix.copyFrom(_matrix);

mat.translate(_point.x + (tileSize.x * tileX), _point.y + (tileSize.y * tileY));
_tileMatrix.translate(_point.x + (tileSize.x * tileX), _point.y + (tileSize.y * tileY));

if (isPixelPerfectRender(camera))
{
mat.tx = Math.floor(mat.tx);
mat.ty = Math.floor(mat.ty);
_tileMatrix.tx = Math.floor(_tileMatrix.tx);
_tileMatrix.ty = Math.floor(_tileMatrix.ty);
}

if (FlxG.renderBlit)
{
final pixels = drawBlit ? _blitGraphic.bitmap: framePixels;
camera.drawPixels(frame, pixels, mat, colorTransform, blend, antialiasing, shader);
camera.drawPixels(frame, pixels, _tileMatrix, colorTransform, blend, antialiasing, shader);
}
else
{
drawItem.addQuad(frame, mat, colorTransform);
drawItem.addQuad(frame, _tileMatrix, colorTransform);
}
}
}

tileSize.put();
if (FlxG.renderBlit)
camera.buffer.unlock();
}
Expand Down Expand Up @@ -407,7 +412,7 @@ class FlxBackdrop extends FlxSprite
(frameHeight + spacing.y) * scale.y
);

var view = camera.getViewRect();
final viewMargins = camera.getViewMarginRect();
var tilesX = 1;
var tilesY = 1;
if (repeatAxes != NONE)
Expand All @@ -416,22 +421,22 @@ class FlxBackdrop extends FlxSprite
switch (blitMode)
{
case AUTO | SPLIT (1):
if (repeatAxes.x) tilesX = Math.ceil(view.width / tileSize.x) + 1;
if (repeatAxes.y) tilesY = Math.ceil(view.height / tileSize.y) + 1;
if (repeatAxes.x) tilesX = Math.ceil(viewMargins.width / tileSize.x) + 1;
if (repeatAxes.y) tilesY = Math.ceil(viewMargins.height / tileSize.y) + 1;
case MAX_TILES(1) | MAX_TILES_XY(1, 1):
case MAX_TILES(max):
if (repeatAxes.x) tilesX = min(max, Math.ceil(view.width / tileSize.x) + 1);
if (repeatAxes.y) tilesY = min(max, Math.ceil(view.height / tileSize.y) + 1);
if (repeatAxes.x) tilesX = min(max, Math.ceil(viewMargins.width / tileSize.x) + 1);
if (repeatAxes.y) tilesY = min(max, Math.ceil(viewMargins.height / tileSize.y) + 1);
case MAX_TILES_XY(maxX, maxY):
if (repeatAxes.x) tilesX = min(maxX, Math.ceil(view.width / tileSize.x) + 1);
if (repeatAxes.y) tilesY = min(maxY, Math.ceil(view.height / tileSize.y) + 1);
if (repeatAxes.x) tilesX = min(maxX, Math.ceil(viewMargins.width / tileSize.x) + 1);
if (repeatAxes.y) tilesY = min(maxY, Math.ceil(viewMargins.height / tileSize.y) + 1);
case SPLIT(portions):
if (repeatAxes.x) tilesX = repeatAxes.x ? Math.ceil(view.width / tileSize.x / portions + 1) : 1;
if (repeatAxes.y) tilesY = repeatAxes.y ? Math.ceil(view.height / tileSize.y / portions + 1) : 1;
if (repeatAxes.x) tilesX = repeatAxes.x ? Math.ceil(viewMargins.width / tileSize.x / portions + 1) : 1;
if (repeatAxes.y) tilesY = repeatAxes.y ? Math.ceil(viewMargins.height / tileSize.y / portions + 1) : 1;
}
}

view.put();
viewMargins.put();

if (matchPrevDrawParams(tilesX, tilesY))
{
Expand Down
3 changes: 2 additions & 1 deletion flixel/addons/display/FlxNestedSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ class FlxNestedSprite extends FlxSprite

override public function draw():Void
{
super.draw();
if(_frame != null)
super.draw();

for (child in children)
{
Expand Down
11 changes: 10 additions & 1 deletion flixel/addons/display/FlxRuntimeShader.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
package flixel.addons.display;

import flixel.system.FlxAssets.FlxShader;
#if (nme || flash)
#if (FLX_NO_COVERAGE_TEST && !(doc_gen))
#error "FlxRuntimeShader isn't available with nme or flash."
#end
#else
import flixel.graphics.tile.FlxGraphicsShader;
#end
#if lime
import lime.utils.Float32Array;
#end
import openfl.display.BitmapData;
import openfl.display.ShaderInput;
import openfl.display.ShaderParameter;
Expand Down
2 changes: 1 addition & 1 deletion flixel/addons/display/FlxSliceSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ class FlxSliceSprite extends FlxStrip
renderSprite.y = y;
renderSprite.scale.copyFrom(scale);
renderSprite.scrollFactor.set(scrollFactor.x, scrollFactor.y);
renderSprite.cameras = cameras;
renderSprite._cameras = _cameras;
renderSprite.draw();
}
else
Expand Down
2 changes: 1 addition & 1 deletion flixel/addons/display/FlxTiledSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class FlxTiledSprite extends FlxStrip
renderSprite.x = x;
renderSprite.y = y;
renderSprite.scrollFactor.set(scrollFactor.x, scrollFactor.y);
renderSprite.cameras = cameras;
renderSprite._cameras = _cameras;
renderSprite.draw();
}
else
Expand Down
2 changes: 1 addition & 1 deletion flixel/addons/editors/spine/FlxSpine.hx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class FlxSpine extends FlxSprite
{
wrapper.x = 0;
wrapper.y = 0;
wrapper.cameras = cameras;
wrapper._cameras = _cameras;

#if (flash || openfl >= "4.0.0")
wrapper.vertices.length = verticesLength;
Expand Down
4 changes: 2 additions & 2 deletions flixel/addons/effects/FlxTrail.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import flixel.animation.FlxAnimation;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.group.FlxGroup;
import flixel.group.FlxSpriteGroup;
import flixel.group.*;
import flixel.system.FlxAssets;
import flixel.util.FlxArrayUtil;
import flixel.util.FlxDestroyUtil;
Expand All @@ -17,7 +17,7 @@ import flixel.math.FlxPoint;
* Feel free to use this class and adjust it to your needs.
* @author Gama11
*/
class FlxTrail extends FlxSpriteGroup
class FlxTrail extends #if (flixel < "5.7.0") FlxSpriteGroup #else FlxSpriteContainer #end
{
/**
* Stores the FlxSprite the trail is attached to.
Expand Down
6 changes: 6 additions & 0 deletions flixel/addons/effects/chainable/FlxEffectSprite.hx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Loading

0 comments on commit 4b45f98

Please sign in to comment.