Skip to content

Commit

Permalink
Merge branch 'dev' into release6
Browse files Browse the repository at this point in the history
  • Loading branch information
Geokureli committed Jan 14, 2025
2 parents 073fa1a + 21cb868 commit 662dc33
Show file tree
Hide file tree
Showing 11 changed files with 166 additions and 104 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.4"]
haxe-version: ["4.2.5", "4.3.6"]
target: [html5, hl, neko, flash, cpp]
fail-fast: false
runs-on: ubuntu-latest
Expand Down
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ We removed many features and utilities that were previously deprecated
- `FlxAssets.FlxTexturePackerSource`: Use `FlxTexturePackerJsonAsset`, instead
- `FlxUnicodeUtil`: Use `UnicodeString`, instead

5.9.0 (TBD)
5.9.0 (December 12, 2024)
------------------------------
#### New features:
- `FlxInputText`: Add improved input text to core flixel (flixel-ui's implementation will be deprecated) ([#3219](https://github.com/HaxeFlixel/flixel/pull/3219))
Expand Down Expand Up @@ -64,6 +64,9 @@ We removed many features and utilities that were previously deprecated
- `FlxG.assets`: A way to overwrite and customize the way HaxeFlixel fetches or produces assets from ids ([#2982](https://github.com/HaxeFlixel/flixel/pull/2982))
- `FlxG.cameras`: Add `insert` method ([#3290](https://github.com/HaxeFlixel/flixel/pull/3290))
- `FlxSave`: Allow custom handling of parsing errors ([#3286](https://github.com/HaxeFlixel/flixel/pull/3286))
- `FlxDirectionFlags`: Add `up`, `down`, `left` and `right` fields ([#3303](https://github.com/HaxeFlixel/flixel/pull/3303))
- `FlxG.assets`: Add `getSoundAddExt` ([#3311](https://github.com/HaxeFlixel/flixel/pull/3311))
- `FlxG.assets`: Add `-DFLX_DEFAULT_SOUND_EXT` to automatically append file extension to sound asset ids ([#3314](https://github.com/HaxeFlixel/flixel/pull/3314))

#### Changes and improvements:
- `FlxKey`: Add `NONE` to `fromStringMap` and `toStringMap` ([#3119](https://github.com/HaxeFlixel/flixel/pull/3119))
Expand Down Expand Up @@ -100,7 +103,7 @@ We removed many features and utilities that were previously deprecated
- Debug Watch: Resize the watch window when watchers are added or removed ([#3251](https://github.com/HaxeFlixel/flixel/pull/3251))
- Reduce memory of Flixel's embedded assets via oxipng ([#3257](https://github.com/HaxeFlixel/flixel/pull/3257))
- Debug Stats: Improve accuracy of "Total Memory" in OpenFL 9.4.0 ([#3266](https://github.com/HaxeFlixel/flixel/pull/3266))
- `FlxGraphic`: Improve checks for max texture size ([#3279](https://github.com/HaxeFlixel/flixel/pull/3279))
- `FlxGraphic`: Improve checks for max texture size ([#3279](https://github.com/HaxeFlixel/flixel/pull/3279))([#3295](https://github.com/HaxeFlixel/flixel/pull/3295))
- Debugging: Stop dispatching onFocus event when closing debugger ([#3271](https://github.com/HaxeFlixel/flixel/pull/3271))

#### Bugfixes:
Expand All @@ -114,6 +117,7 @@ We removed many features and utilities that were previously deprecated
- Debug Console: Fix arrow keys ([#3247](https://github.com/HaxeFlixel/flixel/pull/3247))
- `FlxGame`: Fix `ACTIVATE` and `DEACTIVATE` event dispatches ([#3260](https://github.com/HaxeFlixel/flixel/pull/3260))
- `FlxAction`: Fix bug where multiple `check` calls wipe analog fields ([#3277](https://github.com/HaxeFlixel/flixel/pull/3277))
- `FlxKeyManager`: Remove events on destroy, preventing crashes ([#3299](https://github.com/HaxeFlixel/flixel/pull/3299))

5.8.0 (April 19, 2024)
------------------------------
Expand Down
8 changes: 4 additions & 4 deletions flixel/graphics/frames/FlxAtlasFrames.hx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ class FlxAtlasFrames extends FlxFramesCollection
/**
* Parsing method for atlases generated from Aseprite's JSON export options. Note that Aseprite
* and Texture Packer use the same JSON format, however this method honors frames' `duration`
* whereas `fromTexturePackerJson` ignores it by default (for backwrds compatibility reasons).
* whereas `fromTexturePackerJson` ignores it by default (for backwards compatibility reasons).
*
* @param source The image source (can be `FlxGraphic`, `String`, or `BitmapData`).
* @param description Contents of JSON file with atlas description.
* You can get it with `FlxG.assets.getText(path/to/description.json)`.
* Or you can just a pass path to the JSON file in the assets directory.
* Or you can just pass a path to the JSON file in the assets directory.
* You can also directly pass in the parsed object.
* @return Newly created `FlxAtlasFrames` collection.
* @see [Exporting texture atlases with Aseprite](https://www.aseprite.org/docs/sprite-sheet/#texture-atlases)
Expand All @@ -56,10 +56,10 @@ class FlxAtlasFrames extends FlxFramesCollection
* @param source The image source (can be `FlxGraphic`, `String`, or `BitmapData`).
* @param description Contents of JSON file with atlas description.
* You can get it with `FlxG.assets.getText(path/to/description.json)`.
* Or you can just a pass path to the JSON file in the assets directory.
* Or you can just pass a path to the JSON file in the assets directory.
* You can also directly pass in the parsed object.
* @param useFrameDuration If true, any frame durations defined in the JSON will override the
* frameRate set in you `FlxAnimationController`.
* frameRate set in your `FlxAnimationController`.
* Note: You can also use `fromAseprite` which uses duration.
* @return Newly created `FlxAtlasFrames` collection.
*/
Expand Down
71 changes: 32 additions & 39 deletions flixel/graphics/tile/FlxGraphicsShader.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,59 @@ import openfl.display.GraphicsShader;

class FlxGraphicsShader extends GraphicsShader
{
@:glVertexSource("
#pragma header
@:glVertexHeader("
attribute float alpha;
attribute vec4 colorMultiplier;
attribute vec4 colorOffset;
uniform bool hasColorTransform;
void main(void)
")
@:glVertexBody("
openfl_Alphav = openfl_Alpha * alpha;
if (hasColorTransform)
{
#pragma body
openfl_Alphav = openfl_Alpha * alpha;
if (hasColorTransform)
if (openfl_HasColorTransform)
{
openfl_ColorOffsetv = (openfl_ColorOffsetv * colorMultiplier) + (colorOffset / 255.0);
openfl_ColorMultiplierv *= colorMultiplier;
}
else
{
openfl_ColorOffsetv = colorOffset / 255.0;
openfl_ColorMultiplierv = colorMultiplier;
}
}")
}
")
@:glFragmentHeader("
uniform bool hasTransform;
uniform bool hasTransform; // TODO: Is this still needed? Apparently, yes!
uniform bool hasColorTransform;
vec4 flixel_texture2D(sampler2D bitmap, vec2 coord)
{
vec4 color = texture2D(bitmap, coord);
if (!hasTransform)
{
if (!(hasTransform || openfl_HasColorTransform))
return color;
}
if (color.a == 0.0)
{
return vec4(0.0, 0.0, 0.0, 0.0);
}
if (!hasColorTransform)
{
return color * openfl_Alphav;
}
color = vec4(color.rgb / color.a, color.a);
color = clamp(openfl_ColorOffsetv + (color * openfl_ColorMultiplierv), 0.0, 1.0);
if (color.a > 0.0)
if (openfl_HasColorTransform || hasColorTransform)
{
return vec4(color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav);
color = vec4 (color.rgb / color.a, color.a);
vec4 mult = vec4 (openfl_ColorMultiplierv.rgb, 1.0);
color = clamp (openfl_ColorOffsetv + (color * mult), 0.0, 1.0);
if (color.a == 0.0)
return vec4 (0.0, 0.0, 0.0, 0.0);
return vec4 (color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav);
}
return vec4(0.0, 0.0, 0.0, 0.0);
return color * openfl_Alphav;
}
")
@:glFragmentSource("
#pragma header
void main(void)
{
gl_FragColor = flixel_texture2D(bitmap, openfl_TextureCoordv);
}")
@:glFragmentBody("
gl_FragColor = flixel_texture2D(bitmap, openfl_TextureCoordv);
")
public function new()
{
super();
Expand Down
2 changes: 2 additions & 0 deletions flixel/sound/FlxSound.hx
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ class FlxSound extends FlxBasic
/**
* One of the main setup functions for sounds, this function loads a sound from an embedded MP3.
*
* **Note:** If the `FLX_DEFAULT_SOUND_EXT` flag is enabled, you may omit the file extension
*
* @param EmbeddedSound An embedded Class object representing an MP3 file.
* @param Looped Whether or not this sound should loop endlessly.
* @param AutoDestroy Whether or not this FlxSound instance should be destroyed when the sound finishes playing.
Expand Down
56 changes: 53 additions & 3 deletions flixel/system/frontEnds/AssetFrontEnd.hx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ class AssetFrontEnd
public function new () {}
#end

#if (FLX_DEFAULT_SOUND_EXT == "1" || FLX_NO_DEFAULT_SOUND_EXT)
public final defaultSoundExtension:String = #if flash ".mp3" #else ".ogg" #end;
#else
public final defaultSoundExtension:String = '.${haxe.macro.Compiler.getDefine("FLX_DEFAULT_SOUND_EXT")}';
#end

/**
* Used by methods like `getAsset`, `getBitmapData`, `getText`, their "unsafe" counterparts and
* the like to get assets synchronously. Can be set to a custom function to avoid the existing
Expand Down Expand Up @@ -231,6 +237,12 @@ class AssetFrontEnd
*/
public dynamic function exists(id:String, ?type:FlxAssetType)
{
#if FLX_DEFAULT_SOUND_EXT
// add file extension
if (type == SOUND)
id = addSoundExt(id);
#end

#if FLX_STANDARD_ASSETS_DIRECTORY
return Assets.exists(id, type.toOpenFlType());
#else
Expand All @@ -253,6 +265,12 @@ class AssetFrontEnd
*/
public dynamic function isLocal(id:String, ?type:FlxAssetType, useCache = true)
{
#if FLX_DEFAULT_SOUND_EXT
// add file extension
if (type == SOUND)
id = addSoundExt(id);
#end

#if FLX_STANDARD_ASSETS_DIRECTORY
return Assets.isLocal(id, type.toOpenFlType(), useCache);
#else
Expand Down Expand Up @@ -327,11 +345,13 @@ class AssetFrontEnd
*/
public inline function getSoundUnsafe(id:String, useCache = true):Sound
{
return cast getAssetUnsafe(id, SOUND, useCache);
return cast getAssetUnsafe(addSoundExtIf(id), SOUND, useCache);
}

/**
* Gets an instance of a sound, logs when the asset is not found
* Gets an instance of a sound, logs when the asset is not found.
*
* **Note:** If the `FLX_DEFAULT_SOUND_EXT` flag is enabled, you may omit the file extension
*
* @param id The ID or asset path for the sound
* @param useCache Whether to allow use of the asset cache (if one exists)
Expand All @@ -340,7 +360,37 @@ class AssetFrontEnd
*/
public inline function getSound(id:String, useCache = true, ?logStyle:LogStyle):Sound
{
return cast getAsset(id, SOUND, useCache, logStyle);
return cast getAsset(addSoundExtIf(id), SOUND, useCache, logStyle);
}

/**
* Gets an instance of a sound, logs when the asset is not found
*
* @param id The ID or asset path for the sound
* @param useCache Whether to allow use of the asset cache (if one exists)
* @param logStyle How to log, if the asset is not found. Uses `LogStyle.ERROR` by default
* @return A new `Sound` object Note: Dos not return a `FlxSound`
*/
public inline function getSoundAddExt(id:String, useCache = true, ?logStyle:LogStyle):Sound
{
return getSound(addSoundExt(id), useCache, logStyle);
}

inline function addSoundExtIf(id:String)
{
#if FLX_DEFAULT_SOUND_EXT
return addSoundExt(id);
#else
return id;
#end
}

inline function addSoundExt(id:String)
{
if (!id.endsWith(".mp3") && !id.endsWith(".ogg") && !id.endsWith(".wav"))
return id + defaultSoundExtension;

return id;
}

/**
Expand Down
Loading

0 comments on commit 662dc33

Please sign in to comment.