Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/HaxeFlixel/flixel into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Geokureli committed Aug 21, 2024
2 parents fc01c6e + 0573fe3 commit f692c60
Show file tree
Hide file tree
Showing 5 changed files with 263 additions and 99 deletions.
33 changes: 21 additions & 12 deletions flixel/system/debug/log/LogStyle.hx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ class LogStyle
/**
* A callback function that is called when this LogStyle is used
*/
@:deprecated("callbackFunction is deprecated, use callback, instead")
public var callbackFunction:()->Void;

/**
* A callback function that is called when this LogStyle is used
*/
public var callback:(data:Any)->Void;

/**
* Whether an exception is thrown when this LogStyle is used.
Expand All @@ -50,19 +56,21 @@ class LogStyle
/**
* Create a new LogStyle to be used in conjunction with `FlxG.log.advanced()`
*
* @param prefix A prefix which is always attached to the start of the logged data
* @param color The text color
* @param size The text size
* @param bold Whether the text is bold or not
* @param italic Whether the text is italic or not
* @param underlined Whether the text is underlined or not
* @param errorSound A sound to be played when this LogStyle is used
* @param openConsole Whether the console should be forced to open when this LogStyle is used
* @param callback A callback function that is called when this LogStyle is used
* @param throwError Whether an error is thrown when this LogStyle is used
* @param prefix A prefix which is always attached to the start of the logged data
* @param color The text color
* @param size The text size
* @param bold Whether the text is bold or not
* @param italic Whether the text is italic or not
* @param underlined Whether the text is underlined or not
* @param errorSound A sound to be played when this LogStyle is used
* @param openConsole Whether the console should be forced to open when this LogStyle is used
* @param callbackFunction A callback function that is called when this LogStyle is used
* @param callback A callback function that is called when this LogStyle is used
* @param throwError Whether an error is thrown when this LogStyle is used
*/
@:haxe.warning("-WDeprecated")
public function new(prefix = "", color = "FFFFFF", size = 12, bold = false, italic = false, underlined = false,
?errorSound:String, openConsole = false, ?callback:()->Void, throwException = false)
?errorSound:String, openConsole = false, ?callbackFunction:()->Void, ?callback:(Any)->Void, throwException = false)
{
this.prefix = prefix;
this.color = color;
Expand All @@ -72,7 +80,8 @@ class LogStyle
this.underlined = underlined;
this.errorSound = errorSound;
this.openConsole = openConsole;
this.callbackFunction = callback;
this.callbackFunction = callbackFunction;
this.callback = callback;
this.throwException = throwException;
}

Expand Down
10 changes: 7 additions & 3 deletions flixel/system/frontEnds/LogFrontEnd.hx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class LogFrontEnd
* @param style The LogStyle to use, for example LogStyle.WARNING. You can also create your own by importing the LogStyle class.
* @param fireOnce Whether you only want to log the Data in case it hasn't been added already
*/
public function advanced(data:Dynamic, ?style:LogStyle, fireOnce = false):Void
@:haxe.warning("-WDeprecated")
public function advanced(data:Any, ?style:LogStyle, fireOnce = false):Void
{
if (style == null)
style = LogStyle.NORMAL;
Expand Down Expand Up @@ -74,6 +75,9 @@ class LogFrontEnd

if (style.callbackFunction != null)
style.callbackFunction();

if (style.callback != null)
style.callback(data);
}
#end

Expand Down Expand Up @@ -109,9 +113,9 @@ class LogFrontEnd
* @param data The data that has been traced
* @param info Information about the position at which trace() was called
*/
function processTraceData(data:Dynamic, ?info:PosInfos):Void
function processTraceData(data:Any, ?info:PosInfos):Void
{
var paramArray:Array<Dynamic> = [data];
var paramArray:Array<Any> = [data];

if (info.customParams != null)
{
Expand Down
73 changes: 47 additions & 26 deletions flixel/text/FlxBitmapText.hx
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,18 @@ class FlxBitmapText extends FlxSprite
* NOTE: If the borderSize is 1, borderQuality of 0 or 1 will have the exact same effect (and performance).
*/
public var borderQuality(default, set):Float = 0;


/**
* Internal handler for deprecated `shadowOffset` field
*/
var _shadowOffset:FlxPoint = FlxPoint.get(1, 1);

/**
* Offset that is applied to the shadow border style, if active.
* x and y are multiplied by borderSize. Default is (1, 1), or lower-right corner.
* `x` and `y` are multiplied by `borderSize`. Default is `(1, 1)`, or lower-right corner.
*/
public var shadowOffset(default, null):FlxPoint;
@:deprecated("shadowOffset is deprecated, use setBorderStyle(SHADOW_XY(offsetX, offsetY)), instead") // 5.9.0
public var shadowOffset(get, never):FlxPoint;

/**
* Specifies whether the text should have a background. It is recommended to use a
Expand Down Expand Up @@ -220,8 +226,6 @@ class FlxBitmapText extends FlxSprite

this.font = (font == null) ? FlxBitmapFont.getDefaultFont() : font;

shadowOffset = FlxPoint.get(1, 1);

if (FlxG.renderBlit)
{
pixels = new BitmapData(1, 1, true, FlxColor.TRANSPARENT);
Expand All @@ -247,7 +251,7 @@ class FlxBitmapText extends FlxSprite
_lines = null;
_linesWidth = null;

shadowOffset = FlxDestroyUtil.put(shadowOffset);
_shadowOffset = FlxDestroyUtil.put(_shadowOffset);
textBitmap = FlxDestroyUtil.dispose(textBitmap);

_colorParams = null;
Expand Down Expand Up @@ -1293,34 +1297,46 @@ class FlxBitmapText extends FlxSprite

var delta:Int = Std.int(borderSize / iterations);

var iterationsX:Int = 1;
var iterationsY:Int = 1;
var deltaX:Int = 1;
var deltaY:Int = 1;

if (borderStyle == FlxTextBorderStyle.SHADOW)
{
iterationsX = Math.round(Math.abs(shadowOffset.x) * borderQuality);
iterationsX = (iterationsX <= 0) ? 1 : iterationsX;

iterationsY = Math.round(Math.abs(shadowOffset.y) * borderQuality);
iterationsY = (iterationsY <= 0) ? 1 : iterationsY;

deltaX = Math.round(shadowOffset.x / iterationsX);
deltaY = Math.round(shadowOffset.y / iterationsY);
}

// render border
switch (borderStyle)
{
case SHADOW:
case SHADOW if (_shadowOffset.x != 1 || _shadowOffset.y != 1):
var iterationsX = Math.round(Math.abs(_shadowOffset.x) * borderQuality);
iterationsX = (iterationsX <= 0) ? 1 : iterationsX;

var iterationsY = Math.round(Math.abs(_shadowOffset.y) * borderQuality);
iterationsY = (iterationsY <= 0) ? 1 : iterationsY;

final deltaX = Math.round(_shadowOffset.x / iterationsX);
final deltaY = Math.round(_shadowOffset.y / iterationsY);

for (iterY in 0...iterationsY)
{
for (iterX in 0...iterationsX)
{
drawText(deltaX * (iterX + 1), deltaY * (iterY + 1), isFront, bitmap, useTiles);
}
}

case SHADOW:
final iterations = borderQuality < 1 ? 1 : Std.int(Math.abs(borderSize) * borderQuality);
final delta = borderSize / iterations;
var i = iterations + 1;
while (i-- > 1)
{
drawText(Std.int(delta * i), Std.int(delta * i), isFront, bitmap, useTiles);
}

case SHADOW_XY(shadowX, shadowY):
// Size is max of both, so (4, 4) has 4 iterations, just like SHADOW
final size = Math.max(shadowX, shadowY);
final iterations = borderQuality < 1 ? 1 : Std.int(size * borderQuality);
var i = iterations + 1;
while (i-- > 1)
{
drawText(Std.int(shadowX / iterations * i), Std.int(shadowY / iterations * i), isFront, bitmap, useTiles);
}

case OUTLINE:
// Render an outline around the text
// (do 8 offset draw calls)
Expand Down Expand Up @@ -1482,7 +1498,7 @@ class FlxBitmapText extends FlxSprite
borderQuality = quality;
if (borderStyle == FlxTextBorderStyle.SHADOW)
{
shadowOffset.set(borderSize, borderSize);
_shadowOffset.set(borderSize, borderSize);
}
pendingTextBitmapChange = true;
}
Expand Down Expand Up @@ -1742,7 +1758,12 @@ class FlxBitmapText extends FlxSprite
checkPendingChanges(true);
return super.get_height();
}


inline function get_shadowOffset()
{
return _shadowOffset;
}

/**
* Checks if the specified code is one of the Unicode Combining Diacritical Marks
* @param Code The charactercode we want to check
Expand Down
1 change: 1 addition & 0 deletions flixel/text/FlxInputText.hx
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ class FlxInputText extends FlxText implements IFlxInputText
*/
override function destroy():Void
{
endFocus();
manager.unregisterInputText(this);

FlxDestroyUtil.destroy(onEnter);
Expand Down
Loading

0 comments on commit f692c60

Please sign in to comment.