Skip to content

Commit

Permalink
Type Dynamic callbacks in Assets
Browse files Browse the repository at this point in the history
  • Loading branch information
RblSb committed Nov 4, 2023
1 parent f1dc068 commit b078c23
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions Sources/kha/Assets.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@ import haxe.Unserializer;

using StringTools;

typedef AssetData = {
name: String,
files: Array<String>,
file_sizes: Array<Int>,
type: String,
// image
?original_width: Int,
?original_height: Int,
// shader
?inputs: Array<AssetShaderVar>,
?outputs: Array<AssetShaderVar>,
?uniforms: Array<AssetShaderVar>,
?types: Array<{
name: String,
members: Array<AssetShaderVar>,
}>
}

private typedef AssetShaderVar = {
type: String,
name: String
}

@:build(kha.internal.AssetsBuilder.build("image"))
private class ImageList {
public function new() {}
Expand Down Expand Up @@ -76,8 +99,8 @@ class Assets {
Additionally by default all sounds are decompressed. The uncompressSoundsFilter can be used to avoid that.
Uncompressed sounds can still be played using Audio.stream which is recommended for music.
*/
public static function loadEverything(callback: Void->Void, filter: Dynamic->Bool = null, uncompressSoundsFilter: Dynamic->Bool = null,
?failed: AssetError->Void): Void {
public static function loadEverything(callback: ()->Void, filter: (item:AssetData)->Bool = null, uncompressSoundsFilter: (soundItem:AssetData)->Bool = null,
?failed: (err:AssetError)->Void): Void {
final lists: Array<Dynamic> = [ImageList, SoundList, BlobList, FontList, VideoList];
final listInstances: Array<Dynamic> = [images, sounds, blobs, fonts, videos];
var fileCount = 0;
Expand Down

0 comments on commit b078c23

Please sign in to comment.