From 64c29b0d86d44afe07af79b52f8af0012502ce27 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Wed, 21 Jan 2026 20:12:25 +0100 Subject: [PATCH] FlxAnimateSettings specification --- source/funkin/backend/FunkinSprite.hx | 5 ++++- source/funkin/backend/assets/Paths.hx | 12 ++++++------ source/funkin/game/Character.hx | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/source/funkin/backend/FunkinSprite.hx b/source/funkin/backend/FunkinSprite.hx index 87cc1ecb..5d3a6d93 100644 --- a/source/funkin/backend/FunkinSprite.hx +++ b/source/funkin/backend/FunkinSprite.hx @@ -19,6 +19,7 @@ import haxe.io.Path; import flixel.graphics.frames.FlxFrame; import flixel.math.FlxAngle; import animate.internal.RenderTexture; +import animate.FlxAnimateFrames; enum abstract XMLAnimType(Int) { @@ -73,6 +74,8 @@ class FunkinSprite extends FlxAnimate implements IBeatReceiver implements IOffse public var beatOffset:Int = 0; public var skipNegativeBeats:Bool = false; + public var animateSettings:FlxAnimateSettings = {}; + var _rect2:FlxRect; public function new(?X:Float = 0, ?Y:Float = 0, ?SimpleGraphic:FlxGraphicAsset) @@ -140,7 +143,7 @@ class FunkinSprite extends FlxAnimate implements IBeatReceiver implements IOffse public function loadSprite(path:String, Unique:Bool = false, Key:String = null) { var noExt = Path.withoutExtension(path); - frames = Paths.getFrames(path, true); + frames = Paths.getFrames(path, true, null, null, animateSettings); return this; } diff --git a/source/funkin/backend/assets/Paths.hx b/source/funkin/backend/assets/Paths.hx index 8b823514..3b2fe26d 100644 --- a/source/funkin/backend/assets/Paths.hx +++ b/source/funkin/backend/assets/Paths.hx @@ -175,8 +175,8 @@ class Paths inline static public function getSparrowAtlas(key:String, ?library:String, ?ext:String) return FlxAtlasFrames.fromSparrow(image(key, library, ext), file('images/$key.xml', library)); - inline static public function getAnimateAtlasAlt(key:String) - return FlxAnimateFrames.fromAnimate(key); + inline static public function getAnimateAtlasAlt(key:String, ?settings:FlxAnimateSettings) + return FlxAnimateFrames.fromAnimate(key, null, null, null, false, settings); inline static public function getSparrowAtlasAlt(key:String, ?ext:String) return FlxAtlasFrames.fromSparrow('$key.${ext != null ? ext : Flags.IMAGE_EXT}', '$key.xml'); @@ -201,7 +201,7 @@ class Paths * @param key Path to the frames * @param library (Additional) library to load the frames from. */ - public static function getFrames(key:String, assetsPath:Bool = false, ?library:String, ?ext:String = null) { + public static function getFrames(key:String, assetsPath:Bool = false, ?library:String, ?ext:String = null, ?animateSettings:FlxAnimateSettings) { if (tempFramesCache.exists(key)) { var frames = tempFramesCache[key]; if (frames != null && frames.parent != null && frames.parent.bitmap != null && frames.parent.bitmap.readable) @@ -209,7 +209,7 @@ class Paths else tempFramesCache.remove(key); } - return tempFramesCache[key] = loadFrames(assetsPath ? key : Paths.image(key, library, true, ext), false, null, false, ext); + return tempFramesCache[key] = loadFrames(assetsPath ? key : Paths.image(key, library, true, ext), false, null, false, ext, animateSettings); } /** @@ -246,7 +246,7 @@ class Paths * @param Ext Extension of the image. * @return FlxFramesCollection Frames */ - static function loadFrames(path:String, Unique:Bool = false, Key:String = null, SkipAtlasCheck:Bool = false, SkipMultiCheck:Bool = false, ?Ext:String = null):FlxFramesCollection { + static function loadFrames(path:String, Unique:Bool = false, Key:String = null, SkipAtlasCheck:Bool = false, SkipMultiCheck:Bool = false, ?Ext:String = null, ?animateSettings:FlxAnimateSettings):FlxFramesCollection { var noExt = Path.withoutExtension(path); var ext = Ext != null ? Ext : Flags.IMAGE_EXT; @@ -268,7 +268,7 @@ class Paths } return finalFrames; } else if (Assets.exists('$noExt/Animation.json')) { - return Paths.getAnimateAtlasAlt(noExt); + return Paths.getAnimateAtlasAlt(noExt, animateSettings); } else if (Assets.exists('$noExt.xml')) { return Paths.getSparrowAtlasAlt(noExt, ext); } else if (Assets.exists('$noExt.txt')) { diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index e3792dc1..10c1695b 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -26,6 +26,7 @@ import haxe.Exception; import haxe.io.Path; import haxe.xml.Access; import openfl.geom.ColorTransform; +import animate.FlxAnimateFrames; using StringTools; @@ -383,6 +384,20 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset } if (xml.x.exists("antialiasing")) antialiasing = (xml.x.get("antialiasing") == "true"); if (xml.x.exists("sprite")) sprite = xml.x.get("sprite"); + if (xml.x.exists("swfMode")) animateSettings.swfMode = (xml.x.get("swfMode") == "true"); + if (xml.x.exists("cacheOnLoad")) animateSettings.cacheOnLoad = (xml.x.get("cacheOnLoad") == "true"); + if (xml.x.exists("filterQuality")) { + var val = xml.x.get("filterQuality"); + var qualityInt = Std.parseInt(val); + if (qualityInt != null) { + animateSettings.filterQuality = cast(qualityInt, FilterQuality); + } else { + var values = ["high", "medium", "low", "rudy"]; + var index = values.indexOf(val.toLowerCase()); + if (index > -1) + animateSettings.filterQuality = cast(index, FilterQuality); + } + } var hasInterval:Bool = xml.x.exists("interval"); if (hasInterval) beatInterval = Std.parseInt(xml.x.get("interval"));