folder content
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
bf.xml
|
||||
gf.xml
|
||||
dad.xml
|
||||
gf.xml
|
||||
mom-car.xml
|
||||
monster.xml
|
||||
pico.xml
|
||||
spooky.xml
|
||||
+1
-1
@@ -1 +1 @@
|
||||
263
|
||||
267
|
||||
@@ -176,6 +176,7 @@ class ChartingState extends MusicBeatState
|
||||
add(curRenderedNotes);
|
||||
add(curRenderedSustains);
|
||||
|
||||
trace(Paths.getFolderContent('data/characters/'));
|
||||
super.create();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ class Main extends Sprite
|
||||
var gameHeight:Int = 720; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom).
|
||||
var initialState:Class<FlxState> = TitleState; // The FlxState the game starts with.
|
||||
var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions.
|
||||
var framerate:Int = 60; // How many frames per second the game should run at.
|
||||
var framerate:Int = 120; // How many frames per second the game should run at.
|
||||
var skipSplash:Bool = true; // Whether to skip the flixel splash screen that appears in release mode.
|
||||
var startFullscreen:Bool = false; // Whether to start the game in fullscreen on desktop targets
|
||||
|
||||
|
||||
@@ -894,8 +894,8 @@ class PlayState extends MusicBeatState
|
||||
|
||||
if (camZooming)
|
||||
{
|
||||
FlxG.camera.zoom = lerp(defaultCamZoom, FlxG.camera.zoom, 0.95);
|
||||
camHUD.zoom = lerp(1, camHUD.zoom, 0.95);
|
||||
FlxG.camera.zoom = lerp(FlxG.camera.zoom, defaultCamZoom, 0.05);
|
||||
camHUD.zoom = lerp(camHUD.zoom, 1, 0.05);
|
||||
}
|
||||
|
||||
FlxG.watch.addQuick("beatShit", curBeat);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package funkin.mods;
|
||||
|
||||
/**
|
||||
* COPIED DIRECTLY FROM LIME SOURCE CAUSE LIME IS SO FUCKING DUMB!!
|
||||
*/
|
||||
class LimeLibrarySymbol
|
||||
{
|
||||
public var library:lime.utils.AssetLibrary;
|
||||
public var libraryName:String;
|
||||
public var symbolName:String;
|
||||
|
||||
public inline function new(id:String)
|
||||
{
|
||||
var colonIndex = id.indexOf(":");
|
||||
libraryName = id.substring(0, colonIndex);
|
||||
symbolName = id.substring(colonIndex + 1);
|
||||
library = lime.utils.Assets.getLibrary(libraryName);
|
||||
}
|
||||
|
||||
public inline function isLocal(?type)
|
||||
return library.isLocal(symbolName, type);
|
||||
|
||||
public inline function exists(?type)
|
||||
return library.exists(symbolName, type);
|
||||
}
|
||||
@@ -107,6 +107,21 @@ class ModsAssetLibrary extends AssetLibrary {
|
||||
return getAssetPath();
|
||||
}
|
||||
|
||||
public function getFiles(folder:String):Array<String> {
|
||||
if (!folder.endsWith("/")) folder = folder + "/";
|
||||
if (!__parseAsset(folder)) return [];
|
||||
var path = getAssetPath();
|
||||
|
||||
try {
|
||||
var result:Array<String> = [];
|
||||
for(e in FileSystem.readDirectory(path))
|
||||
if (!FileSystem.isDirectory('$path$e'))
|
||||
result.push(e);
|
||||
return result;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
public override function exists(asset:String, type:String):Bool {
|
||||
if(!__parseAsset(asset)) return false;
|
||||
|
||||
|
||||
@@ -4,7 +4,11 @@ import openfl.utils.Assets;
|
||||
import openfl.utils.AssetManifest;
|
||||
import openfl.utils.AssetLibrary;
|
||||
import flixel.graphics.FlxGraphic;
|
||||
|
||||
#if sys
|
||||
import sys.FileSystem;
|
||||
#end
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxState;
|
||||
import haxe.io.Path;
|
||||
@@ -139,6 +143,7 @@ class ModsFolder {
|
||||
|
||||
private static function onStateSwitch(newState:FlxState) {
|
||||
Assets.cache.clear();
|
||||
lime.utils.Assets.cache.clear();
|
||||
|
||||
if (currentModFolder == null) return;
|
||||
#if sys
|
||||
@@ -146,7 +151,7 @@ class ModsFolder {
|
||||
@:privateAccess
|
||||
for(bmap in FlxG.bitmap._cache) {
|
||||
if (bmap.assetsKey != null) {
|
||||
var e = new LibrarySymbol(bmap.assetsKey);
|
||||
var e = new LimeLibrarySymbol(bmap.assetsKey);
|
||||
if (e.library is openfl.utils.AssetLibrary) {
|
||||
@:privateAccess
|
||||
e.library = cast(e.library, openfl.utils.AssetLibrary).__proxy;
|
||||
@@ -166,25 +171,4 @@ class ModsFolder {
|
||||
|
||||
#end
|
||||
}
|
||||
}
|
||||
|
||||
class LibrarySymbol
|
||||
{
|
||||
public var library:lime.utils.AssetLibrary;
|
||||
public var libraryName:String;
|
||||
public var symbolName:String;
|
||||
|
||||
public inline function new(id:String)
|
||||
{
|
||||
var colonIndex = id.indexOf(":");
|
||||
libraryName = id.substring(0, colonIndex);
|
||||
symbolName = id.substring(colonIndex + 1);
|
||||
library = lime.utils.Assets.getLibrary(libraryName);
|
||||
}
|
||||
|
||||
public inline function isLocal(?type)
|
||||
return library.isLocal(symbolName, type);
|
||||
|
||||
public inline function exists(?type)
|
||||
return library.exists(symbolName, type);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package funkin.system;
|
||||
|
||||
import funkin.mods.LimeLibrarySymbol;
|
||||
import flixel.FlxG;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import openfl.utils.AssetType;
|
||||
@@ -147,23 +148,40 @@ class Paths
|
||||
return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library));
|
||||
}
|
||||
|
||||
inline static public function getFolderContent(key:String, includeSource:Bool = false, ?library:String):Array<String> {
|
||||
inline static public function getFolderContent(key:String, includeSource:Bool = true, scanSource:Bool = false):Array<String> {
|
||||
// designed to work both on windows and web
|
||||
|
||||
while(key.charAt(key.length-1) == "/") key.substr(0, key.length-1);
|
||||
var path = getPath('$key/.foldercontent', TEXT, library);
|
||||
if (!key.endsWith("/")) key = key + "/";
|
||||
|
||||
if (ModsFolder.currentModFolder == null)
|
||||
return getFolderContent(key, false, true);
|
||||
|
||||
var libThing = new LimeLibrarySymbol(scanSource ? getPreloadPath(key) : getLibraryPathForce(key, 'mods/${ModsFolder.currentModFolder}'));
|
||||
var library = libThing.library;
|
||||
|
||||
if (library is openfl.utils.AssetLibrary) {
|
||||
var lib = cast(libThing.library, openfl.utils.AssetLibrary);
|
||||
@:privateAccess
|
||||
if (lib.__proxy != null) library = lib.__proxy;
|
||||
}
|
||||
|
||||
var content:Array<String> = [];
|
||||
if (OpenFlAssets.exists(path)) {
|
||||
var text = OpenFlAssets.getText(path);
|
||||
for(e in text.split("\n")) content.push(e.trim());
|
||||
if (library is funkin.mods.ModsAssetLibrary) {
|
||||
// easy task, can immediatly scan for files!
|
||||
var lib = cast(library, funkin.mods.ModsAssetLibrary);
|
||||
content = lib.getFiles(libThing.symbolName);
|
||||
} else {
|
||||
// TODO!!
|
||||
}
|
||||
|
||||
if (includeSource) {
|
||||
var path = getPath('$key/.foldercontent', TEXT, library, true);
|
||||
if (OpenFlAssets.exists(path)) {
|
||||
var text = OpenFlAssets.getText(path);
|
||||
for(e in text.split("\n")) content.push(e.trim());
|
||||
}
|
||||
var sourceResult = getFolderContent(key, false, true);
|
||||
for(e in sourceResult)
|
||||
if (!content.contains(e))
|
||||
content.push(e);
|
||||
}
|
||||
|
||||
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user