assets_manager_set_custom_build_asset_dir support ctx

This commit is contained in:
lixianjing 2019-10-24 21:56:43 +08:00
parent 97051e8ebc
commit 697ce454d6
3 changed files with 9 additions and 5 deletions

View File

@ -7,6 +7,7 @@
* 修改软键盘弹出时出现屏保的问题。
* 完善new.cpp/new.hpp (感谢陈谭提供补丁)。
* 修改windows中文件名的问题感谢大恒提供补丁
* assets\_manager\_set\_custom\_build\_dir增加回调函数上下文。
* 2019/10/23
* 修改clone出来的edit的显示问题。

View File

@ -167,7 +167,7 @@ static ret_t build_asset_filename_custom(assets_manager_t* am, char* path, uint3
const char* name, const char* extname) {
if (am->custom_build_asset_dir != NULL) {
char sep[2] = {TK_PATH_SEP, 0};
return_value_if_fail(am->custom_build_asset_dir(path, size, theme, ratio, subpath) == RET_OK,
return_value_if_fail(am->custom_build_asset_dir(am->custom_build_asset_dir_ctx, path, size, theme, ratio, subpath) == RET_OK,
RET_FAIL);
return_value_if_fail(tk_str_append(path, size, sep) == RET_OK, RET_FAIL);
return_value_if_fail(tk_str_append(path, size, name) == RET_OK, RET_FAIL);
@ -694,8 +694,9 @@ ret_t assets_manager_deinit(assets_manager_t* am) {
}
ret_t assets_manager_set_custom_build_asset_dir(
assets_manager_t* am, assets_manager_build_asset_dir_t custom_build_asset_dir) {
assets_manager_t* am, assets_manager_build_asset_dir_t custom_build_asset_dir, void* ctx) {
return_value_if_fail(am != NULL, RET_BAD_PARAMS);
am->custom_build_asset_dir_ctx = ctx;
am->custom_build_asset_dir = custom_build_asset_dir;
return RET_OK;

View File

@ -28,7 +28,7 @@
BEGIN_C_DECLS
typedef ret_t (*assets_manager_build_asset_dir_t)(char* path, uint32_t size, const char* theme,
typedef ret_t (*assets_manager_build_asset_dir_t)(void* ctx, char* path, uint32_t size, const char* theme,
const char* ratio, const char* subpath);
/**
@ -73,6 +73,7 @@ struct _assets_manager_t {
char* res_root;
locale_info_t* locale_info;
system_info_t* system_info;
void* custom_build_asset_dir_ctx;
assets_manager_build_asset_dir_t custom_build_asset_dir;
};
@ -231,12 +232,13 @@ ret_t assets_manager_preload(assets_manager_t* am, asset_type_t type, const char
*
*
* @param {assets_manager_t*} am asset manager对象
* @param {assets_manager_build_asset_dir_t} custom_build_asset_dir
* @param {assets_manager_build_asset_dir_t} custom_build_asset_dir
* @param {void*} ctx
*
* @return {ret_t} RET_OK表示成功
*/
ret_t assets_manager_set_custom_build_asset_dir(
assets_manager_t* am, assets_manager_build_asset_dir_t custom_build_asset_dir);
assets_manager_t* am, assets_manager_build_asset_dir_t custom_build_asset_dir, void* ctx);
/**
* @method assets_manager_clear_cache