Skip to content

Commit 64c29b0

Browse files
FlxAnimateSettings specification
1 parent ae89e02 commit 64c29b0

3 files changed

Lines changed: 25 additions & 7 deletions

File tree

source/funkin/backend/FunkinSprite.hx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import haxe.io.Path;
1919
import flixel.graphics.frames.FlxFrame;
2020
import flixel.math.FlxAngle;
2121
import animate.internal.RenderTexture;
22+
import animate.FlxAnimateFrames;
2223

2324
enum abstract XMLAnimType(Int)
2425
{
@@ -73,6 +74,8 @@ class FunkinSprite extends FlxAnimate implements IBeatReceiver implements IOffse
7374
public var beatOffset:Int = 0;
7475
public var skipNegativeBeats:Bool = false;
7576

77+
public var animateSettings:FlxAnimateSettings = {};
78+
7679
var _rect2:FlxRect;
7780

7881
public function new(?X:Float = 0, ?Y:Float = 0, ?SimpleGraphic:FlxGraphicAsset)
@@ -140,7 +143,7 @@ class FunkinSprite extends FlxAnimate implements IBeatReceiver implements IOffse
140143
public function loadSprite(path:String, Unique:Bool = false, Key:String = null)
141144
{
142145
var noExt = Path.withoutExtension(path);
143-
frames = Paths.getFrames(path, true);
146+
frames = Paths.getFrames(path, true, null, null, animateSettings);
144147
return this;
145148
}
146149

source/funkin/backend/assets/Paths.hx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ class Paths
175175
inline static public function getSparrowAtlas(key:String, ?library:String, ?ext:String)
176176
return FlxAtlasFrames.fromSparrow(image(key, library, ext), file('images/$key.xml', library));
177177

178-
inline static public function getAnimateAtlasAlt(key:String)
179-
return FlxAnimateFrames.fromAnimate(key);
178+
inline static public function getAnimateAtlasAlt(key:String, ?settings:FlxAnimateSettings)
179+
return FlxAnimateFrames.fromAnimate(key, null, null, null, false, settings);
180180

181181
inline static public function getSparrowAtlasAlt(key:String, ?ext:String)
182182
return FlxAtlasFrames.fromSparrow('$key.${ext != null ? ext : Flags.IMAGE_EXT}', '$key.xml');
@@ -201,15 +201,15 @@ class Paths
201201
* @param key Path to the frames
202202
* @param library (Additional) library to load the frames from.
203203
*/
204-
public static function getFrames(key:String, assetsPath:Bool = false, ?library:String, ?ext:String = null) {
204+
public static function getFrames(key:String, assetsPath:Bool = false, ?library:String, ?ext:String = null, ?animateSettings:FlxAnimateSettings) {
205205
if (tempFramesCache.exists(key)) {
206206
var frames = tempFramesCache[key];
207207
if (frames != null && frames.parent != null && frames.parent.bitmap != null && frames.parent.bitmap.readable)
208208
return frames;
209209
else
210210
tempFramesCache.remove(key);
211211
}
212-
return tempFramesCache[key] = loadFrames(assetsPath ? key : Paths.image(key, library, true, ext), false, null, false, ext);
212+
return tempFramesCache[key] = loadFrames(assetsPath ? key : Paths.image(key, library, true, ext), false, null, false, ext, animateSettings);
213213
}
214214

215215
/**
@@ -246,7 +246,7 @@ class Paths
246246
* @param Ext Extension of the image.
247247
* @return FlxFramesCollection Frames
248248
*/
249-
static function loadFrames(path:String, Unique:Bool = false, Key:String = null, SkipAtlasCheck:Bool = false, SkipMultiCheck:Bool = false, ?Ext:String = null):FlxFramesCollection {
249+
static function loadFrames(path:String, Unique:Bool = false, Key:String = null, SkipAtlasCheck:Bool = false, SkipMultiCheck:Bool = false, ?Ext:String = null, ?animateSettings:FlxAnimateSettings):FlxFramesCollection {
250250
var noExt = Path.withoutExtension(path);
251251
var ext = Ext != null ? Ext : Flags.IMAGE_EXT;
252252

@@ -268,7 +268,7 @@ class Paths
268268
}
269269
return finalFrames;
270270
} else if (Assets.exists('$noExt/Animation.json')) {
271-
return Paths.getAnimateAtlasAlt(noExt);
271+
return Paths.getAnimateAtlasAlt(noExt, animateSettings);
272272
} else if (Assets.exists('$noExt.xml')) {
273273
return Paths.getSparrowAtlasAlt(noExt, ext);
274274
} else if (Assets.exists('$noExt.txt')) {

source/funkin/game/Character.hx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import haxe.Exception;
2626
import haxe.io.Path;
2727
import haxe.xml.Access;
2828
import openfl.geom.ColorTransform;
29+
import animate.FlxAnimateFrames;
2930

3031
using StringTools;
3132

@@ -383,6 +384,20 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
383384
}
384385
if (xml.x.exists("antialiasing")) antialiasing = (xml.x.get("antialiasing") == "true");
385386
if (xml.x.exists("sprite")) sprite = xml.x.get("sprite");
387+
if (xml.x.exists("swfMode")) animateSettings.swfMode = (xml.x.get("swfMode") == "true");
388+
if (xml.x.exists("cacheOnLoad")) animateSettings.cacheOnLoad = (xml.x.get("cacheOnLoad") == "true");
389+
if (xml.x.exists("filterQuality")) {
390+
var val = xml.x.get("filterQuality");
391+
var qualityInt = Std.parseInt(val);
392+
if (qualityInt != null) {
393+
animateSettings.filterQuality = cast(qualityInt, FilterQuality);
394+
} else {
395+
var values = ["high", "medium", "low", "rudy"];
396+
var index = values.indexOf(val.toLowerCase());
397+
if (index > -1)
398+
animateSettings.filterQuality = cast(index, FilterQuality);
399+
}
400+
}
386401

387402
var hasInterval:Bool = xml.x.exists("interval");
388403
if (hasInterval) beatInterval = Std.parseInt(xml.x.get("interval"));

0 commit comments

Comments
 (0)