Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 55 additions & 65 deletions source/funkin/Assets.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import funkin.util.macro.ConsoleMacro;
* Later we'll add Funkin-specific caching to this.
*/
@:nullSafety
@:build(funkin.util.macro.BlacklistClassMacro.build(
{
classes: ["openfl.utils.Assets"],
customWrapMode: 'Blacklist',
ignoreList: ['cache']
}))
class Assets implements ConsoleClass
{
/**
Expand All @@ -17,167 +23,151 @@ class Assets implements ConsoleClass

/**
* Get the file system path for an asset
*
* This function exists and is generated at build time.
* @param path The asset path to load from, relative to the assets folder
* @return The path to the asset on the file system
*/
public static function getPath(path:String):String
{
return openfl.utils.Assets.getPath(path);
}
// public static function getPath(path:String):String

/**
* Load bytes from an asset
* May cause stutters or throw an error if the asset is not cached
*
* This function exists and is generated at build time.
* @param path The asset path to load from
* @return The byte contents of the file
*/
public static function getBytes(path:String):haxe.io.Bytes
{
return openfl.utils.Assets.getBytes(path);
}
// public static function getBytes(path:String):haxe.io.Bytes

/**
* Load bytes from an asset asynchronously
*
* This function exists and is generated at build time.
* @param path The asset path to load from
* @return A future which promises to return the byte contents of the file
*/
public static function loadBytes(path:String):Future<openfl.utils.ByteArray>
{
return openfl.utils.Assets.loadBytes(path);
}
// public static function loadBytes(path:String):Future<openfl.utils.ByteArray>;

/**
* Load text from an asset.
* May cause stutters or throw an error if the asset is not cached
*
* This function exists and is generated at build time.
* @param path The asset path to load from
* @return The text contents of the file
*/
public static function getText(path:String):String
{
return openfl.utils.Assets.getText(path);
}
// public static function getText(path:String):String

/**
* Load text from an asset asynchronously
*
* This function exists and is generated at build time.
* @param path The asset path to load from
* @return A future which promises to return the text contents of the file
*/
public static function loadText(path:String):Future<String>
{
return openfl.utils.Assets.loadText(path);
}
// public static function loadText(path:String):Future<String>

/**
* Load a Sound file from an asset
* May cause stutters or throw an error if the asset is not cached
*
* This function exists and is generated at build time.
* @param path The asset path to load from
* @return The loaded sound
*/
public static function getSound(path:String):openfl.media.Sound
{
return openfl.utils.Assets.getSound(path);
}
// public static function getSound(path:String):openfl.media.Sound

/**
* Load a Sound file from an asset asynchronously
*
* This function exists and is generated at build time.
* @param path The asset path to load from
* @return A future which promises to return the loaded sound
*/
public static function loadSound(path:String):Future<openfl.media.Sound>
{
return openfl.utils.Assets.loadSound(path);
}
// public static function loadSound(path:String):Future<openfl.media.Sound>

/**
* Load a Sound file from an asset, with optimizations specific to long-duration music
* May cause stutters or throw an error if the asset is not cached
*
* This function exists and is generated at build time.
* @param path The asset path to load from
* @return The loaded sound
*/
public static function getMusic(path:String):openfl.media.Sound
{
return openfl.utils.Assets.getMusic(path);
}
// public static function getMusic(path:String):openfl.media.Sound

/**
* Load a Sound file from an asset asynchronously, with optimizations specific to long-duration music
*
* This function exists and is generated at build time.
* @param path The asset path to load from
* @return A future which promises to return the loaded sound
*/
public static function loadMusic(path:String):Future<openfl.media.Sound>
{
return openfl.utils.Assets.loadMusic(path);
}
// public static function loadMusic(path:String):Future<openfl.media.Sound>

/**
* Load a Bitmap from an asset
* May cause stutters or throw an error if the asset is not cached
*
* This function exists and is generated at build time.
* @param path The asset path to load from
* @return The loaded Bitmap image
*/
public static function getBitmapData(path:String, useCache:Bool = true):openfl.display.BitmapData
{
return openfl.utils.Assets.getBitmapData(path, useCache);
}

// public static function getBitmapData(path:String, useCache:Bool = true):openfl.display.BitmapData

/**
* Load a Bitmap from an asset asynchronously
*
* This function exists and is generated at build time.
* @param path The asset path to load from
* @return The future which promises to return the loaded Bitmap image
*/
public static function loadBitmapData(path:String):Future<openfl.display.BitmapData>
{
return openfl.utils.Assets.loadBitmapData(path);
}
// public static function loadBitmapData(path:String):Future<openfl.display.BitmapData>

/**
* Determines whether the given asset of the given type exists.
*
* This function exists and is generated at build time.
* @param path The asset path to check
* @param type The asset type to check
* @return Whether the asset exists
*/
public static function exists(path:String, ?type:openfl.utils.AssetType):Bool
{
return openfl.utils.Assets.exists(path, type);
}
// public static function exists(path:String, ?type:openfl.utils.AssetType):Bool

/**
* Retrieve a list of all assets of the given type
*
* This function exists and is generated at build time.
* @param type The asset type to check
* @return A list of asset paths
*/
public static function list(?type:openfl.utils.AssetType):Array<String>
{
return openfl.utils.Assets.list(type);
}
// public static function list(?type:openfl.utils.AssetType):Array<String>

/**
* Checks if a library with the given name exists.
*
* This function exists and is generated at build time.
* @param name The name to check.
* @return Whether or not the library exists.
*/
public static function hasLibrary(name:String):Bool
{
return openfl.utils.Assets.hasLibrary(name);
}
// public static function hasLibrary(name:String):Bool

/**
* Retrieves a library with the given name.
*
* This function exists and is generated at build time.
* @param name The name of the library to get.
* @return The library with the given name.
*/
public static function getLibrary(name:String):lime.utils.AssetLibrary
{
return openfl.utils.Assets.getLibrary(name);
}
// public static function getLibrary(name:String):lime.utils.AssetLibrary

/**
* Loads a library with the given name.
*
* This function exists and is generated at build time.
* @param name The name of the library to load.
* @return An `AssetLibary` object.
*/
public static function loadLibrary(name:String):Future<openfl.utils.AssetLibrary>
{
return openfl.utils.Assets.loadLibrary(name);
}
// public static function loadLibrary(name:String):Future<openfl.utils.AssetLibrary>
}
5 changes: 1 addition & 4 deletions source/funkin/modding/PolymodHandler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,7 @@ class PolymodHandler
// System.load() can load malicious DLLs
Polymod.blacklistImport('lime.system.System');

// `lime.utils.Assets`
// Literally just has a private `resolveClass` function for some reason?
Polymod.blacklistImport('lime.utils.Assets');
Polymod.blacklistImport('openfl.utils.Assets');
// TODO: Document these I guess?
Polymod.blacklistImport('openfl.Lib');
Polymod.blacklistImport('openfl.system.ApplicationDomain');
Polymod.blacklistImport('openfl.net.SharedObject');
Expand Down
Loading