58 lines
1.4 KiB
C
58 lines
1.4 KiB
C
/**
|
|
* Copyright (c) 2025 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "error/error.h"
|
|
#include "duskdefs.h"
|
|
#include <zip.h>
|
|
#include "script/scriptcontext.h"
|
|
|
|
#define ASSET_SCRIPT_BUFFER_SIZE 1024
|
|
|
|
typedef struct assetscript_s {
|
|
zip_file_t *zip;
|
|
char_t buffer[ASSET_SCRIPT_BUFFER_SIZE];
|
|
} assetscript_t;
|
|
|
|
typedef struct assetcustom_s assetcustom_t;
|
|
|
|
/**
|
|
* Receiving function from the asset manager to handle script assets.
|
|
*
|
|
* @param custom Custom asset loading data.
|
|
* @return Error code.
|
|
*/
|
|
errorret_t assetScriptHandler(assetcustom_t custom);
|
|
|
|
/**
|
|
* Initializes a script asset.
|
|
*
|
|
* @param script Script asset to initialize.
|
|
* @param zipFile Zip file handle for the script asset.
|
|
* @return Error code.
|
|
*/
|
|
errorret_t assetScriptInit(assetscript_t *script, zip_file_t *zipFile);
|
|
|
|
/**
|
|
* Reader function for Lua to read script data from the asset.
|
|
*
|
|
* @param L Lua state.
|
|
* @param data Pointer to the assetscript_t structure.
|
|
* @param size Pointer to store the size of the read data.
|
|
* @return Pointer to the read data buffer.
|
|
*/
|
|
const char_t * assetScriptReader(lua_State* L, void* data, size_t* size);
|
|
|
|
/**
|
|
* Disposes of a script asset, freeing any allocated resources.
|
|
*
|
|
* @param script Script asset to dispose of.
|
|
* @return Error code.
|
|
*/
|
|
errorret_t assetScriptDispose(assetscript_t *script);
|
|
|