Merge remote-tracking branch 'upstream/main'
This commit is contained in:
@@ -94,6 +94,14 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
|
||||
public override function update(elapsed:Float)
|
||||
{
|
||||
super.update(elapsed);
|
||||
|
||||
// hate how it looks like but hey at least its optimized and fast - Nex
|
||||
if (!debugMode && isAnimFinished()) {
|
||||
var name = getAnimName() + '-loop';
|
||||
if (animation.exists(name))
|
||||
playAnim(name, false, lastAnimContext);
|
||||
}
|
||||
|
||||
if (animateAtlas != null)
|
||||
animateAtlas.update(elapsed);
|
||||
}
|
||||
@@ -328,6 +336,10 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
|
||||
return (animateAtlas != null) ? atlasPlayingAnim : animation.name;
|
||||
}
|
||||
|
||||
public inline function isAnimReversed():Bool {
|
||||
return animateAtlas != null ? animateAtlas.anim.reversed : animation.curAnim != null ? animation.curAnim.reversed : false;
|
||||
}
|
||||
|
||||
public inline function removeAnimation(name:String) {
|
||||
if (animateAtlas != null)
|
||||
@:privateAccess animateAtlas.anim.animsMap.remove(name);
|
||||
|
||||
@@ -821,6 +821,91 @@ class CoolUtil
|
||||
var file = new haxe.io.Path(file);
|
||||
return file.file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string of "1..3,5,7..9,8..5" into an array of numbers like [1,2,3,5,7,8,9,8,7,6,5]
|
||||
* @param input String to parse
|
||||
* @return Array of numbers
|
||||
*/
|
||||
public static function parseNumberRange(input:String):Array<Int> {
|
||||
var result:Array<Int> = [];
|
||||
var parts:Array<String> = input.split(",");
|
||||
|
||||
for (part in parts) {
|
||||
part = part.trim();
|
||||
var idx = part.indexOf("..");
|
||||
if (idx != -1) {
|
||||
var start = Std.parseInt(part.substring(0, idx).trim());
|
||||
var end = Std.parseInt(part.substring(idx + 2).trim());
|
||||
|
||||
if(start == null || end == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (start < end) {
|
||||
for (j in start...end + 1) {
|
||||
result.push(j);
|
||||
}
|
||||
} else {
|
||||
for (j in end...start + 1) {
|
||||
result.push(start + end - j);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var num = Std.parseInt(part);
|
||||
if (num != null) {
|
||||
result.push(num);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an array of numbers into a string of ranges.
|
||||
* Example: [1,2,3,5,7,8,9,8,7,6,5] -> "1..3,5,7..9,8..5"
|
||||
* @param numbers Array of numbers
|
||||
* @return String representing the ranges
|
||||
*/
|
||||
public static function formatNumberRange(numbers:Array<Int>, seperator:String = ","):String {
|
||||
if (numbers.length == 0) return "";
|
||||
|
||||
var result:Array<String> = [];
|
||||
var i = 0;
|
||||
|
||||
while (i < numbers.length) {
|
||||
var start = numbers[i];
|
||||
var end = start;
|
||||
var direction = 0; // 0: no sequence, 1: increasing, -1: decreasing
|
||||
|
||||
if (i + 1 < numbers.length) { // detect direction of sequence
|
||||
if (numbers[i + 1] == end + 1) {
|
||||
direction = 1;
|
||||
} else if (numbers[i + 1] == end - 1) {
|
||||
direction = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(direction != 0) {
|
||||
while (i + 1 < numbers.length && (numbers[i + 1] == end + direction)) {
|
||||
end = numbers[i + 1];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (start == end) { // no direction
|
||||
result.push('${start}');
|
||||
} else if (start + direction == end) { // 1 step increment
|
||||
result.push('${start},${end}');
|
||||
} else { // store as range
|
||||
result.push('${start}..${end}');
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return result.join(seperator);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -209,14 +209,7 @@ class XMLUtil {
|
||||
if (anim.has.y) animData.y = Std.parseFloat(anim.att.y).getDefault(animData.y);
|
||||
if (anim.has.loop) animData.loop = anim.att.loop == "true";
|
||||
if (anim.has.forced) animData.forced = anim.att.forced == "true";
|
||||
if (anim.has.indices) {
|
||||
var indicesSplit = anim.att.indices.split(",");
|
||||
for(indice in indicesSplit) {
|
||||
var i = Std.parseInt(indice.trim());
|
||||
if (i != null)
|
||||
animData.indices.push(i);
|
||||
}
|
||||
}
|
||||
if (anim.has.indices) animData.indices = CoolUtil.parseNumberRange(anim.att.indices);
|
||||
|
||||
return animData;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user