mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
add assets_manager_set_fallback_load_asset
This commit is contained in:
parent
f78d9344d6
commit
73377f4b2d
@ -544,6 +544,11 @@ asset_info_t* assets_manager_load_ex(assets_manager_t* am, asset_type_t type, ui
|
||||
return am->custom_load_asset(am->custom_load_asset_ctx, type, subtype, name);
|
||||
}
|
||||
info = assets_manager_load_impl(am, type, subtype, name);
|
||||
|
||||
if (info == NULL && am->fallback_load_asset != NULL) {
|
||||
info = am->fallback_load_asset(am->fallback_load_asset_ctx, type, subtype, name);
|
||||
}
|
||||
|
||||
if (info != NULL) {
|
||||
assets_manager_dispatch_event(am, EVT_ASSET_MANAGER_LOAD_ASSET, info);
|
||||
}
|
||||
@ -832,6 +837,16 @@ ret_t assets_manager_set_custom_load_asset(assets_manager_t* am,
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_t assets_manager_set_fallback_load_asset(assets_manager_t* am,
|
||||
assets_manager_load_asset_t fallback_load_asset,
|
||||
void* ctx) {
|
||||
return_value_if_fail(am != NULL, RET_BAD_PARAMS);
|
||||
am->fallback_load_asset_ctx = ctx;
|
||||
am->fallback_load_asset = fallback_load_asset;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_t assets_manager_destroy(assets_manager_t* am) {
|
||||
return_value_if_fail(am != NULL, RET_BAD_PARAMS);
|
||||
emitter_deinit(EMITTER(am));
|
||||
|
@ -84,6 +84,9 @@ struct _assets_manager_t {
|
||||
|
||||
void* custom_load_asset_ctx;
|
||||
assets_manager_load_asset_t custom_load_asset;
|
||||
|
||||
void* fallback_load_asset_ctx;
|
||||
assets_manager_load_asset_t fallback_load_asset;
|
||||
|
||||
void* custom_build_asset_dir_ctx;
|
||||
assets_manager_build_asset_dir_t custom_build_asset_dir;
|
||||
@ -331,6 +334,19 @@ ret_t assets_manager_set_custom_load_asset(assets_manager_t* am,
|
||||
assets_manager_load_asset_t custom_load_asset,
|
||||
void* ctx);
|
||||
|
||||
/**
|
||||
* @method assets_manager_set_fallback_load_asset
|
||||
* 设置一个函数,该函数在找不到资源时加载后补资源。
|
||||
*
|
||||
* @param {assets_manager_t*} am asset manager对象。
|
||||
* @param {assets_manager_load_asset_t} fallback_load_asset 回调函数。
|
||||
* @param {void*} ctx 回调函数的上下文。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t assets_manager_set_fallback_load_asset(assets_manager_t* am,
|
||||
assets_manager_load_asset_t fallback_load_asset,
|
||||
void* ctx);
|
||||
/**
|
||||
* @method assets_manager_clear_cache
|
||||
* 清除指定类型的缓存。
|
||||
|
Loading…
Reference in New Issue
Block a user