/** * Copyright (c) 2025 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "type/assetpaletteimage.h" #include "type/assetalphaimage.h" #include "type/assetlanguage.h" #include "type/assetmap.h" #include "type/assetchunk.h" #include "type/assetscript.h" #include typedef enum { ASSET_TYPE_NULL, ASSET_TYPE_PALETTE_IMAGE, ASSET_TYPE_ALPHA_IMAGE, ASSET_TYPE_LANGUAGE, ASSET_TYPE_MAP, ASSET_TYPE_CHUNK, ASSET_TYPE_SCRIPT, ASSET_TYPE_COUNT, } assettype_t; typedef enum { ASSET_LOAD_STRAT_ENTIRE, ASSET_LOAD_STRAT_CUSTOM } assetloadstrat_t; typedef struct assetcustom_s { zip_file_t *zipFile; void *output; } assetcustom_t; typedef struct { const char_t *header; const size_t dataSize; const assetloadstrat_t loadStrategy; union { errorret_t (*entire)(void *data, void *output); errorret_t (*custom)(assetcustom_t custom); }; } assettypedef_t; static const assettypedef_t ASSET_TYPE_DEFINITIONS[ASSET_TYPE_COUNT] = { [ASSET_TYPE_NULL] = { 0 }, [ASSET_TYPE_PALETTE_IMAGE] = { .header = "DPI", .loadStrategy = ASSET_LOAD_STRAT_ENTIRE, .dataSize = sizeof(assetpaletteimage_t), .entire = assetPaletteImageLoad }, [ASSET_TYPE_ALPHA_IMAGE] = { .header = "DAI", .loadStrategy = ASSET_LOAD_STRAT_ENTIRE, .dataSize = sizeof(assetalphaimage_t), .entire = assetAlphaImageLoad }, [ASSET_TYPE_LANGUAGE] = { .header = "DLF", .loadStrategy = ASSET_LOAD_STRAT_CUSTOM, .custom = assetLanguageHandler }, [ASSET_TYPE_MAP] = { .header = "DMF", .loadStrategy = ASSET_LOAD_STRAT_ENTIRE, .dataSize = sizeof(1), .entire = assetMapLoad }, [ASSET_TYPE_CHUNK] = { .header = "DCF", .loadStrategy = ASSET_LOAD_STRAT_CUSTOM, .custom = assetChunkLoad }, [ASSET_TYPE_SCRIPT] = { .header = "DSF", .loadStrategy = ASSET_LOAD_STRAT_CUSTOM, .custom = assetScriptHandler } };