About to implement load strategy

This commit is contained in:
2025-11-08 08:32:21 -06:00
parent 9f88374627
commit cf2aacd75b
10 changed files with 80 additions and 40 deletions

View File

@@ -13,18 +13,25 @@ typedef enum {
ASSET_TYPE_NULL,
ASSET_TYPE_PALETTE_IMAGE,
ASSET_TYPE_ALPHA_IMAGE,
ASSET_TYPE_LANGUAGE,
ASSET_TYPE_COUNT,
} assettype_t;
typedef enum {
ASSET_LOAD_STRAT_ENTIRE,
ASSET_LOAD_STRAT_TEST
} assetloadstrat_t;
typedef struct {
const char_t *header;
const size_t dataSize;
const assetloadstrat_t loadStrategy;
errorret_t (*load)(void *data, void *output);
union {
errorret_t (*entire)(void *data, void *output);
struct {
void *test;
} test;
};
} assettypedef_t;
static const assettypedef_t ASSET_TYPE_DEFINITIONS[ASSET_TYPE_COUNT] = {
@@ -36,13 +43,22 @@ static const assettypedef_t ASSET_TYPE_DEFINITIONS[ASSET_TYPE_COUNT] = {
.header = "DPI",
.loadStrategy = ASSET_LOAD_STRAT_ENTIRE,
.dataSize = sizeof(assetpaletteimage_t),
.load = assetPaletteImageLoad
.entire = assetPaletteImageLoad
},
[ASSET_TYPE_ALPHA_IMAGE] = {
.header = "DAI",
.loadStrategy = ASSET_LOAD_STRAT_ENTIRE,
.dataSize = sizeof(assetalphaimage_t),
.load = assetAlphaImageLoad
.entire = assetAlphaImageLoad
},
[ASSET_TYPE_LANGUAGE] = {
.header = "DLF",
.loadStrategy = ASSET_LOAD_STRAT_TEST,
.dataSize = 0, // Variable size
.test = {
.test = NULL
}
}
};