Skip to content

Commit 33549f5

Browse files
committed
frakits i will boil you
1 parent f5104eb commit 33549f5

5 files changed

Lines changed: 35 additions & 102 deletions

File tree

source/funkin/backend/FunkinSprite.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class FunkinSprite extends FlxAnimate implements IBeatReceiver implements IOffse
120120

121121
if (casted != null) {
122122
spr.skew.set(casted.skew.x, casted.skew.y);
123-
spr.animOffsets = casted.animOffsets.copy();
123+
for (i => p in casted.animOffsets) spr.addOffset(i, p.x, p.y);
124124
spr.zoomFactor = casted.zoomFactor;
125125
spr.angleFactor = casted.angleFactor;
126126
}

source/funkin/backend/assets/MultiFramesCollection.hx

Lines changed: 0 additions & 72 deletions
This file was deleted.

source/funkin/backend/assets/Paths.hx

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class Paths
3838
for (extension in extArray) {
3939
var extPath:String = sanitizedPath + '.$extension';
4040
if (OpenFlAssets.exists(extPath)) {
41-
trace(extPath, OpenFlAssets.exists(extPath));
4241
returnedPath = extPath;
4342
break;
4443
}
@@ -125,12 +124,12 @@ class Paths
125124
return OpenFlAssets.exists(diff) ? diff : getPath('songs/$song/song/Inst$suffix', null, ext != null ? ext : Flags.SOUND_EXT);
126125
}
127126

128-
static public function image(key:String, ?library:String, checkForAtlas:Bool = false, ?ext:OneOfTwo<String, Array<String>>) {
127+
static public function image(key:String, ?library:String, checkForAtlas:Bool = true, ?ext:OneOfTwo<String, Array<String>>) {
129128
if (checkForAtlas) {
130-
var atlasPath = getPath('images/$key/spritemap', library, ext != null ? ext : Flags.IMAGE_EXT);
129+
var atlasPath = getPath('images/$key/spritemap1', library, ext != null ? ext : Flags.IMAGE_EXT);
131130
var multiplePath = getPath('images/$key/1', library, ext != null ? ext : Flags.IMAGE_EXT);
132131
if (atlasPath != null && OpenFlAssets.exists(atlasPath)) return atlasPath.substr(0, atlasPath.length - 14);
133-
if (multiplePath != null && OpenFlAssets.exists(multiplePath)) return multiplePath.substr(0, multiplePath.length - 6);
132+
if (multiplePath != null && OpenFlAssets.exists(multiplePath)) return multiplePath;
134133
}
135134
return getPath('images/$key', library, ext != null ? ext : Flags.IMAGE_EXT);
136135
}
@@ -245,9 +244,10 @@ class Paths
245244
public static function framesExists(key:String, checkAtlas:Bool = false, checkMulti:Bool = true, assetsPath:Bool = false, ?library:String) {
246245
var path = assetsPath ? key : Paths.image(key, library, true);
247246
var noExt = Path.withoutExtension(path);
247+
var ext = Path.extension(path);
248248
if(checkAtlas && Assets.exists('$noExt/Animation.json'))
249249
return true;
250-
if(checkMulti && Assets.exists('$noExt/1.png'))
250+
if(checkMulti && Assets.exists('$noExt/1.$ext'))
251251
return true;
252252
if(Assets.exists('$noExt.xml'))
253253
return true;
@@ -266,17 +266,18 @@ class Paths
266266
* @param ext (Additional) Extension of the images.
267267
* @return FlxFramesCollection Frames
268268
*/
269-
public static function getMultiFrames(sheets:Array<String>, ?unique:Bool = true, ?key:String = null, ?ext:OneOfTwo<String, Array<String>> = null, ?animateSettings:FlxAnimateSettings):FlxFramesCollection {
270-
// TODO: cache properly
271-
if (sheets.length == 1) return loadFrames(sheets[0], unique, key, false, false, animateSettings);
269+
public static function getMultiFrames(sheets:Array<String>, ?unique:Bool = true, ?key:String = null, ?skipMulti:Bool = false, ?ext:OneOfTwo<String, Array<String>> = null, ?animateSettings:FlxAnimateSettings):FlxFramesCollection {
270+
if (sheets.length == 1) return loadFrames('${sheets[0]}.$ext', unique, key, false, false, animateSettings);
272271
if (key == null) key = 'combo/' + sheets.join(',');
273272
var graphic = FlxG.bitmap.add("flixel/images/logo/default.png", unique, key);
274273
var sprFrames:FlxAtlasFrames = new FlxAtlasFrames(graphic);
275274
try {
276275
for (x => path in sheets) {
277-
var noExt = haxe.io.Path.withoutExtension(Paths.image(path, null, true, ext));
276+
final coolPath = Paths.image(path, null, true, ext);
277+
final noExt = haxe.io.Path.withoutExtension(coolPath);
278+
final ext = haxe.io.Path.extension(coolPath);
278279
@:privateAccess
279-
var newFrames = cast Paths.loadFrames(noExt, true, key + '_$path', false, false, animateSettings);
280+
var newFrames = cast Paths.loadFrames('$noExt.$ext', true, key + '_$path', false, skipMulti, animateSettings);
280281
if (newFrames == null) {
281282
Logs.warn('There is no Bitmap asset for "$noExt". Skipping...');
282283
continue;
@@ -302,24 +303,24 @@ class Paths
302303
static function loadFrames(path:String, Unique:Bool = false, Key:String = null, SkipAtlasCheck:Bool = false, SkipMultiCheck:Bool = false, ?animateSettings:FlxAnimateSettings):FlxFramesCollection {
303304
var noExt = Path.withoutExtension(path);
304305
var ext = Path.extension(path);
305-
306+
// there NEEDS to be a better way dude
307+
if (!SkipMultiCheck && noExt.endsWith('/1'))
308+
noExt = noExt.substr(0, noExt.length - 2);
306309
if (!SkipMultiCheck && Assets.exists('$noExt/1.${ext}')) {
307-
// MULTIPLE SPRITESHEETS!!
308-
309-
var graphic = FlxG.bitmap.add("flixel/images/logo/default.png", false, '$noExt/mult');
310-
var frames = MultiFramesCollection.findFrame(graphic);
311-
if (frames != null)
312-
return frames;
313-
314-
var cur = 1;
315-
var finalFrames = new MultiFramesCollection(graphic);
316-
while(Assets.exists('$noExt/$cur.${ext}')) {
317-
var spr = loadFrames('$noExt/$cur.${ext}', false, null, false, true);
318-
finalFrames.addFrames(spr);
310+
var cur:Int = 1;
311+
final finalFrames = [];
312+
while (Assets.exists('$noExt/$cur.${ext}')) {
313+
finalFrames.push('${noExt.substr(
314+
// there should be a Paths.unimage tbh
315+
'assets/images/'.length
316+
)}/$cur');
319317
cur++;
320318
}
321-
return finalFrames;
319+
return getMultiFrames(finalFrames, true,
320+
'$noExt/mult', true, ext, animateSettings);
322321
} else if (!SkipAtlasCheck && Assets.exists('$noExt/Animation.json')) {
322+
// ???
323+
if (noExt.endsWith('/')) noExt = noExt.substr(0, noExt.length - 1);
323324
return Paths.getAnimateAtlasAlt(noExt, animateSettings);
324325
} else if (Assets.exists('$noExt.xml')) {
325326
return Paths.getSparrowAtlasAlt(noExt, ext);

source/funkin/backend/system/Flags.hx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ class Flags {
6262
public static var REPO_URL:String = 'https://github.com/$REPO_OWNER/$REPO_NAME';
6363

6464
/**
65-
* Preferred sound extension for the game's audio files.
66-
* Currently is set to `mp3` for web targets, and `ogg` for other targets.
65+
* Preferred file extensions for the game's audio files.
6766
*/
6867
public static var SOUND_EXT:Array<String> = ["ogg", "mp3", "flac", "wav"];
69-
public static var VIDEO_EXT:Array<String> = ["mp4", "webm"]; // is there any more?
68+
public static var VIDEO_EXT:Array<String> = ["mp4", "webm", "mkv", "mov"]; // is there any more? // yes frakits
7069
public static var IMAGE_EXT:Array<String> = ["png", "jpg", "jpeg"];
7170

7271
public static var DEFAULT_DISCORD_LOGO_KEY:String = "icon";

source/funkin/editors/ui/UIFileExplorer.hx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package funkin.editors.ui;
22

33
import haxe.io.Bytes;
44
import lime.ui.FileDialog;
5+
import flixel.util.typeLimit.OneOfTwo;
56
#if lime_funkin
67
import lime.ui.FileDialogFilter;
78
#end
@@ -21,9 +22,13 @@ class UIFileExplorer extends UISliceSprite {
2122

2223
public var fileType:Array<String> = ["txt"];
2324

24-
public function new(x:Float, y:Float, ?w:Int, ?h:Int, fileType:Array<String>, ?onFile:(String, Bytes)->Void) {
25+
public function new(x:Float, y:Float, ?w:Int, ?h:Int, fileType:OneOfTwo<String, Array<String>>, ?onFile:(String, Bytes)->Void) {
2526
super(x, y, (w != null ? w : 320), (h != null ? h : 58), 'editors/ui/inputbox');
26-
if (fileType != null) this.fileType = fileType;
27+
if (fileType != null) {
28+
// backward compat with custom editors
29+
if (fileType is String) fileType = cast(fileType, String).split(';');
30+
this.fileType = fileType;
31+
}
2732

2833
if (onFile != null) this.onFile = onFile;
2934

0 commit comments

Comments
 (0)