Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flixel/graphics/atlas/FlxAtlas.hx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class FlxAtlas implements IFlxDestroyable
* You can omit it if you pass `String` or `Class<Dynamic>` as a `Graphic` source.
* @return Newly created and added node, or `null` if there is no space for it.
*/
public function addNode(Graphic:FlxGraphicSource, ?Key:String):FlxNode
public function addNode(Graphic:FlxGraphicAsset, ?Key:String):FlxNode
{
var key:String = FlxAssets.resolveKey(Graphic, Key);

Expand Down Expand Up @@ -602,7 +602,7 @@ class FlxAtlas implements IFlxDestroyable
* @param region Region of source image to use as a source graphic
* @return Generated `FlxTileFrames` for the added node
*/
public function addNodeWithSpacesAndBorders(Graphic:FlxGraphicSource, ?Key:String, tileSize:FlxPoint, tileSpacing:FlxPoint, ?tileBorder:FlxPoint,
public function addNodeWithSpacesAndBorders(Graphic:FlxGraphicAsset, ?Key:String, tileSize:FlxPoint, tileSpacing:FlxPoint, ?tileBorder:FlxPoint,
?region:FlxRect):FlxTileFrames
{
var key:String = FlxAssets.resolveKey(Graphic, Key);
Expand Down
26 changes: 18 additions & 8 deletions flixel/system/FlxAssets.hx
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@ class VirtualInputData extends #if nme ByteArray #else ByteArrayData #end {}
typedef FlxTexturePackerJsonAsset = FlxJsonAsset<TexturePackerAtlas>;
typedef FlxAsepriteJsonAsset = FlxJsonAsset<AseAtlas>;
typedef FlxSoundAsset = OneOfThree<String, Sound, Class<Sound>>;
typedef FlxGraphicAsset = OneOfThree<FlxGraphic, BitmapData, String>;
typedef FlxTilemapGraphicAsset = OneOfFour<FlxFramesCollection, FlxGraphic, BitmapData, String>;
typedef FlxBitmapFontGraphicAsset = OneOfFour<FlxFrame, FlxGraphic, BitmapData, String>;
abstract FlxGraphicSource(OneOfThree<BitmapData, Class<Dynamic>, String>) from BitmapData from Class<Dynamic> from String

abstract FlxGraphicAsset(OneOfFour<FlxGraphic, BitmapData, String, Class<Dynamic>>) from FlxGraphic to FlxGraphic from BitmapData to BitmapData from String to String from Class<Dynamic> to Class<Dynamic>
{
public function resolveBitmapData()
public inline function resolveBitmapData():BitmapData
{
return FlxAssets.resolveBitmapData(cast this);
}
}

@:deprecated("`FlxGraphicSource` is deprecated, use `FlxGraphicAsset` instead")
typedef FlxGraphicSource = FlxGraphicAsset;

abstract FlxAngelCodeAsset(OneOfThree<Xml, String, Bytes>) from Xml from String from Bytes
{
public inline function parse()
Expand All @@ -55,7 +58,6 @@ abstract FlxAngelCodeAsset(OneOfThree<Xml, String, Bytes>) from Xml from String
}
}


@:deprecated("`FlxAngelCodeXmlAsset` is deprecated, use `FlxAngelCodeAsset` instead")// 5.6.0
typedef FlxAngelCodeXmlAsset = FlxAngelCodeAsset;

Expand Down Expand Up @@ -304,9 +306,13 @@ class FlxAssets
* @param graphic input data to get BitmapData object for.
* @return BitmapData for specified Dynamic object.
*/
public static function resolveBitmapData(graphic:FlxGraphicSource):BitmapData
public static function resolveBitmapData(graphic:FlxGraphicAsset):BitmapData
{
if ((graphic is BitmapData))
if ((graphic is FlxGraphic))
{
return cast(graphic, FlxGraphic).bitmap;
}
else if ((graphic is BitmapData))
{
return cast graphic;
}
Expand All @@ -333,12 +339,16 @@ class FlxAssets
* @param key optional key string.
* @return Key String for specified Graphic object.
*/
public static function resolveKey(graphic:FlxGraphicSource, ?key:String):String
public static function resolveKey(graphic:FlxGraphicAsset, ?key:String):String
{
if (key != null)
return key;

if ((graphic is BitmapData))
if ((graphic is FlxGraphic))
{
return cast(graphic, FlxGraphic).key;
}
else if ((graphic is BitmapData))
{
return key;
}
Expand Down
2 changes: 1 addition & 1 deletion flixel/system/debug/FlxDebugger.hx
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class FlxDebugger extends openfl.display.Sprite
resetButtonLayout();
}

public function addWindowToggleButton(window:Window, icon:FlxGraphicSource):Void
public function addWindowToggleButton(window:Window, icon:FlxGraphicAsset):Void
{
var button = addButton(RIGHT, icon.resolveBitmapData(), window.toggleVisible, true, true);
window.toggleButton = button;
Expand Down
2 changes: 1 addition & 1 deletion flixel/system/debug/interaction/tools/Tool.hx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Tool extends Sprite implements IFlxDestroyable
return _brain.activeTool == this && _brain.visible;
}

function setButton(icon:FlxGraphicSource):Void
function setButton(icon:FlxGraphicAsset):Void
{
button = new FlxSystemButton(icon.resolveBitmapData(), onButtonClicked, true);
button.toggled = true;
Expand Down
2 changes: 1 addition & 1 deletion flixel/tile/FlxBaseTilemap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ class FlxBaseTilemap<Tile:FlxObject> extends FlxObject
* @return A reference to this instance of FlxTilemap, for chaining as usual :)
* @since 4.1.0
*/
public function loadMapFromGraphic(mapGraphic:FlxGraphicSource, invert = false, scale = 1, ?colorMap:Array<FlxColor>,
public function loadMapFromGraphic(mapGraphic:FlxGraphicAsset, invert = false, scale = 1, ?colorMap:Array<FlxColor>,
tileGraphic:FlxTilemapGraphicAsset, tileWidth = 0, tileHeight = 0, ?autoTile:FlxTilemapAutoTiling,
startingIndex = 0, drawIndex = 1, collideIndex = 1)
{
Expand Down
2 changes: 1 addition & 1 deletion flixel/util/FlxSpriteUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class FlxSpriteUtil
* @param mask The mask to apply. Remember the non-alpha zero areas are the parts that will display.
* @return The FlxSprite for chaining
*/
public static function alphaMask(output:FlxSprite, source:FlxGraphicSource, mask:FlxGraphicSource):FlxSprite
public static function alphaMask(output:FlxSprite, source:FlxGraphicAsset, mask:FlxGraphicAsset):FlxSprite
{
var data:BitmapData = FlxAssets.resolveBitmapData(source);
var maskData:BitmapData = FlxAssets.resolveBitmapData(mask);
Expand Down
2 changes: 1 addition & 1 deletion flixel/util/FlxStringUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ class FlxStringUtil
* @param colorMap An array of color values (alpha values are ignored) in the order they're intended to be assigned as indices
* @return A comma-separated string containing the level data in a FlxTilemap-friendly format.
*/
public static function imageToCSV(graphic:FlxGraphicSource, invert = false, scale = 1, ?colorMap:Array<FlxColor>):String
public static function imageToCSV(graphic:FlxGraphicAsset, invert = false, scale = 1, ?colorMap:Array<FlxColor>):String
{
return bitmapToCSV(graphic.resolveBitmapData(), invert, scale, colorMap);
}
Expand Down