folder content

This commit is contained in:
Yoshman29
2022-10-09 03:17:30 +02:00
parent 6ef396b3ae
commit 0a46a5c1d1
9 changed files with 80 additions and 45 deletions
-8
View File
@@ -1,8 +0,0 @@
bf.xml
gf.xml
dad.xml
gf.xml
mom-car.xml
monster.xml
pico.xml
spooky.xml
+1 -1
View File
@@ -1 +1 @@
263 267
+1
View File
@@ -176,6 +176,7 @@ class ChartingState extends MusicBeatState
add(curRenderedNotes); add(curRenderedNotes);
add(curRenderedSustains); add(curRenderedSustains);
trace(Paths.getFolderContent('data/characters/'));
super.create(); super.create();
} }
+1 -1
View File
@@ -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 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 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 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 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 var startFullscreen:Bool = false; // Whether to start the game in fullscreen on desktop targets
+2 -2
View File
@@ -894,8 +894,8 @@ class PlayState extends MusicBeatState
if (camZooming) if (camZooming)
{ {
FlxG.camera.zoom = lerp(defaultCamZoom, FlxG.camera.zoom, 0.95); FlxG.camera.zoom = lerp(FlxG.camera.zoom, defaultCamZoom, 0.05);
camHUD.zoom = lerp(1, camHUD.zoom, 0.95); camHUD.zoom = lerp(camHUD.zoom, 1, 0.05);
} }
FlxG.watch.addQuick("beatShit", curBeat); FlxG.watch.addQuick("beatShit", curBeat);
+25
View File
@@ -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);
}
+15
View File
@@ -107,6 +107,21 @@ class ModsAssetLibrary extends AssetLibrary {
return getAssetPath(); 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 { public override function exists(asset:String, type:String):Bool {
if(!__parseAsset(asset)) return false; if(!__parseAsset(asset)) return false;
+6 -22
View File
@@ -4,7 +4,11 @@ import openfl.utils.Assets;
import openfl.utils.AssetManifest; import openfl.utils.AssetManifest;
import openfl.utils.AssetLibrary; import openfl.utils.AssetLibrary;
import flixel.graphics.FlxGraphic; import flixel.graphics.FlxGraphic;
#if sys
import sys.FileSystem; import sys.FileSystem;
#end
import flixel.FlxG; import flixel.FlxG;
import flixel.FlxState; import flixel.FlxState;
import haxe.io.Path; import haxe.io.Path;
@@ -139,6 +143,7 @@ class ModsFolder {
private static function onStateSwitch(newState:FlxState) { private static function onStateSwitch(newState:FlxState) {
Assets.cache.clear(); Assets.cache.clear();
lime.utils.Assets.cache.clear();
if (currentModFolder == null) return; if (currentModFolder == null) return;
#if sys #if sys
@@ -146,7 +151,7 @@ class ModsFolder {
@:privateAccess @:privateAccess
for(bmap in FlxG.bitmap._cache) { for(bmap in FlxG.bitmap._cache) {
if (bmap.assetsKey != null) { if (bmap.assetsKey != null) {
var e = new LibrarySymbol(bmap.assetsKey); var e = new LimeLibrarySymbol(bmap.assetsKey);
if (e.library is openfl.utils.AssetLibrary) { if (e.library is openfl.utils.AssetLibrary) {
@:privateAccess @:privateAccess
e.library = cast(e.library, openfl.utils.AssetLibrary).__proxy; e.library = cast(e.library, openfl.utils.AssetLibrary).__proxy;
@@ -166,25 +171,4 @@ class ModsFolder {
#end #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);
} }
+29 -11
View File
@@ -1,5 +1,6 @@
package funkin.system; package funkin.system;
import funkin.mods.LimeLibrarySymbol;
import flixel.FlxG; import flixel.FlxG;
import flixel.graphics.frames.FlxAtlasFrames; import flixel.graphics.frames.FlxAtlasFrames;
import openfl.utils.AssetType; import openfl.utils.AssetType;
@@ -147,23 +148,40 @@ class Paths
return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library)); 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 // designed to work both on windows and web
while(key.charAt(key.length-1) == "/") key.substr(0, key.length-1); if (!key.endsWith("/")) key = key + "/";
var path = getPath('$key/.foldercontent', TEXT, library);
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> = []; var content:Array<String> = [];
if (OpenFlAssets.exists(path)) { if (library is funkin.mods.ModsAssetLibrary) {
var text = OpenFlAssets.getText(path); // easy task, can immediatly scan for files!
for(e in text.split("\n")) content.push(e.trim()); var lib = cast(library, funkin.mods.ModsAssetLibrary);
content = lib.getFiles(libThing.symbolName);
} else {
// TODO!!
} }
if (includeSource) { if (includeSource) {
var path = getPath('$key/.foldercontent', TEXT, library, true); var sourceResult = getFolderContent(key, false, true);
if (OpenFlAssets.exists(path)) { for(e in sourceResult)
var text = OpenFlAssets.getText(path); if (!content.contains(e))
for(e in text.split("\n")) content.push(e.trim()); content.push(e);
}
} }
return content; return content;
} }
} }