Asset custom ready.
This commit is contained in:
@@ -94,8 +94,14 @@ errorret_t assetLoad(const char_t *filename, void *output) {
|
||||
errorChain(ret);
|
||||
break;
|
||||
|
||||
case ASSET_LOAD_STRAT_TEST:
|
||||
assertUnreachable("Asset load strategy not implemented yet.");
|
||||
case ASSET_LOAD_STRAT_CUSTOM:
|
||||
assertNotNull(def->custom, "Asset load function cannot be NULL.");
|
||||
assetcustom_t customData = {
|
||||
.zipFile = file,
|
||||
.output = output
|
||||
};
|
||||
errorChain(def->custom(&customData));
|
||||
break;
|
||||
|
||||
default:
|
||||
assertUnreachable("Unknown asset load strategy.");
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "error/error.h"
|
||||
#include <zip.h>
|
||||
#include "assettype.h"
|
||||
|
||||
#if ASSET_TYPE == wad
|
||||
#else
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#pragma once
|
||||
#include "type/assetpaletteimage.h"
|
||||
#include "type/assetalphaimage.h"
|
||||
#include "type/assetlanguage.h"
|
||||
#include <zip.h>
|
||||
|
||||
typedef enum {
|
||||
ASSET_TYPE_NULL,
|
||||
@@ -19,18 +21,21 @@ typedef enum {
|
||||
|
||||
typedef enum {
|
||||
ASSET_LOAD_STRAT_ENTIRE,
|
||||
ASSET_LOAD_STRAT_TEST
|
||||
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);
|
||||
struct {
|
||||
void *test;
|
||||
} test;
|
||||
errorret_t (*custom)(assetcustom_t *custom);
|
||||
};
|
||||
} assettypedef_t;
|
||||
|
||||
@@ -55,10 +60,7 @@ static const assettypedef_t ASSET_TYPE_DEFINITIONS[ASSET_TYPE_COUNT] = {
|
||||
|
||||
[ASSET_TYPE_LANGUAGE] = {
|
||||
.header = "DLF",
|
||||
.loadStrategy = ASSET_LOAD_STRAT_TEST,
|
||||
.dataSize = 0, // Variable size
|
||||
.test = {
|
||||
.test = NULL
|
||||
}
|
||||
.loadStrategy = ASSET_LOAD_STRAT_CUSTOM,
|
||||
.custom = assetLanguageInit
|
||||
}
|
||||
};
|
||||
@@ -8,4 +8,5 @@ target_sources(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
assetalphaimage.c
|
||||
assetpaletteimage.c
|
||||
assetlanguage.c
|
||||
)
|
||||
@@ -5,4 +5,10 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "assetlanguage.h"
|
||||
#include "asset/asset.h"
|
||||
|
||||
errorret_t assetLanguageInit(assetcustom_t *custom) {
|
||||
zip_fclose(custom->zipFile);
|
||||
|
||||
errorOk();
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "error/error.h"
|
||||
#include "locale/language/keys.h"
|
||||
|
||||
#define ASSET_LANG_CHUNK_CHAR_COUNT 6 * 1024 // 6 KB per chunk
|
||||
@@ -27,3 +28,13 @@ typedef struct {
|
||||
assetlanguagestring_t strings[LANG_KEY_COUNT];
|
||||
} assetlanguageheader_t;
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct assetcustom_s assetcustom_t;
|
||||
|
||||
/**
|
||||
* Receiving function from the asset manager to initialize language assets.
|
||||
*
|
||||
* @param custom Pointer to custom asset loading data.
|
||||
* @return Error code.
|
||||
*/
|
||||
errorret_t assetLanguageInit(assetcustom_t *custom);
|
||||
Reference in New Issue
Block a user