diff --git a/defold-spine/src/comp_spine_model.cpp b/defold-spine/src/comp_spine_model.cpp index 2cf4e0e..f6ebe95 100644 --- a/defold-spine/src/comp_spine_model.cpp +++ b/defold-spine/src/comp_spine_model.cpp @@ -41,7 +41,7 @@ extern "C" { #include #include #include -#include +#include #include #include @@ -67,7 +67,7 @@ namespace dmSpine static const uint32_t INVALID_ANIMATION_INDEX = 0xFFFFFFFF; - static void ResourceReloadedCallback(const dmResource::ResourceReloadedParams& params); + static void ResourceReloadedCallback(const dmResource::ResourceReloadedParams* params); static void DestroyComponent(struct SpineModelWorld* world, uint32_t index); struct SpineModelWorld @@ -1314,7 +1314,7 @@ namespace dmSpine return dmGameSystem::SetMaterialConstant(GetMaterial(component), params.m_PropertyId, params.m_Value, params.m_Options.m_Index, CompSpineModelSetConstantCallback, component); } - static void ResourceReloadedCallback(const dmResource::ResourceReloadedParams& params) + static void ResourceReloadedCallback(const dmResource::ResourceReloadedParams* params) { // E.g. if the Spine json or atlas has changed, we may need to update things here diff --git a/defold-spine/src/res_spine_json.cpp b/defold-spine/src/res_spine_json.cpp index e8007ea..e50b32f 100644 --- a/defold-spine/src/res_spine_json.cpp +++ b/defold-spine/src/res_spine_json.cpp @@ -3,6 +3,12 @@ #include #include +#ifdef __MACH__ + #include +#else + #include +#endif + #include #include @@ -31,35 +37,35 @@ namespace dmSpine delete resource; } - static dmResource::Result ResourceTypeJson_Create(const dmResource::ResourceCreateParams& params) + static dmResource::Result ResourceTypeJson_Create(const dmResource::ResourceCreateParams* params) { - SpineJsonResource* resource = CreateResource(params.m_Buffer, params.m_BufferSize); + SpineJsonResource* resource = CreateResource(params->m_Buffer, params->m_BufferSize); if (!resource) { return dmResource::RESULT_OUT_OF_RESOURCES; } - params.m_Resource->m_Resource = (void*)resource; - params.m_Resource->m_ResourceSize = resource->m_Length; + dmResource::SetResource(params->m_Resource, resource); + dmResource::SetResourceSize(params->m_Resource, resource->m_Length); return dmResource::RESULT_OK; } - static dmResource::Result ResourceTypeJson_Destroy(const dmResource::ResourceDestroyParams& params) + static dmResource::Result ResourceTypeJson_Destroy(const dmResource::ResourceDestroyParams* params) { - SpineJsonResource* resource = (SpineJsonResource*)params.m_Resource->m_Resource; + SpineJsonResource* resource = (SpineJsonResource*)dmResource::GetResource(params->m_Resource); DestroyResource(resource); return dmResource::RESULT_OK; } - static dmResource::Result ResourceTypeJson_Recreate(const dmResource::ResourceRecreateParams& params) + static dmResource::Result ResourceTypeJson_Recreate(const dmResource::ResourceRecreateParams* params) { - SpineJsonResource* new_resource = CreateResource(params.m_Buffer, params.m_BufferSize); + SpineJsonResource* new_resource = CreateResource(params->m_Buffer, params->m_BufferSize); if (!new_resource) { return dmResource::RESULT_OUT_OF_RESOURCES; } - SpineJsonResource* old_resource = (SpineJsonResource*) params.m_Resource->m_Resource; + SpineJsonResource* old_resource = (SpineJsonResource*) dmResource::GetResource(params->m_Resource); // swap the internals // we wish to keep the "old" resource, since that pointer might be shared in the system @@ -70,20 +76,20 @@ namespace dmSpine new_resource->m_Json = tmp; DestroyResource(new_resource); - params.m_Resource->m_ResourceSize = old_resource->m_Length; + dmResource::SetResourceSize(params->m_Resource, old_resource->m_Length); return dmResource::RESULT_OK; } - static dmResource::Result ResourceTypeJson_Register(dmResource::ResourceTypeRegisterContext& ctx) + static ResourceResult ResourceTypeJson_Register(HResourceTypeContext ctx, HResourceType type) { - return dmResource::RegisterType(ctx.m_Factory, - ctx.m_Name, - 0, // context - 0, // preload - ResourceTypeJson_Create, - 0, // post create - ResourceTypeJson_Destroy, - ResourceTypeJson_Recreate); + return (ResourceResult)dmResource::SetupType(ctx, + type, + 0, // context + 0, // preload + ResourceTypeJson_Create, + 0, // post create + ResourceTypeJson_Destroy, + ResourceTypeJson_Recreate); } } diff --git a/defold-spine/src/res_spine_model.cpp b/defold-spine/src/res_spine_model.cpp index 6dcc05d..da41c7c 100644 --- a/defold-spine/src/res_spine_model.cpp +++ b/defold-spine/src/res_spine_model.cpp @@ -39,71 +39,71 @@ namespace dmSpine dmResource::Release(factory, resource->m_Material); } - static dmResource::Result ResourceTypeModel_Preload(const dmResource::ResourcePreloadParams& params) + static dmResource::Result ResourceTypeModel_Preload(const dmResource::ResourcePreloadParams* params) { dmGameSystemDDF::SpineModelDesc* ddf; - dmDDF::Result e = dmDDF::LoadMessage(params.m_Buffer, params.m_BufferSize, &dmGameSystemDDF_SpineModelDesc_DESCRIPTOR, (void**) &ddf); + dmDDF::Result e = dmDDF::LoadMessage(params->m_Buffer, params->m_BufferSize, &dmGameSystemDDF_SpineModelDesc_DESCRIPTOR, (void**) &ddf); if (e != dmDDF::RESULT_OK) { return dmResource::RESULT_DDF_ERROR; } - dmResource::PreloadHint(params.m_HintInfo, ddf->m_SpineScene); - dmResource::PreloadHint(params.m_HintInfo, ddf->m_Material); + dmResource::PreloadHint(params->m_HintInfo, ddf->m_SpineScene); + dmResource::PreloadHint(params->m_HintInfo, ddf->m_Material); - *params.m_PreloadData = ddf; + *params->m_PreloadData = ddf; return dmResource::RESULT_OK; } - static dmResource::Result ResourceTypeModel_Create(const dmResource::ResourceCreateParams& params) + static dmResource::Result ResourceTypeModel_Create(const dmResource::ResourceCreateParams* params) { SpineModelResource* model_resource = new SpineModelResource(); - model_resource->m_Ddf = (dmGameSystemDDF::SpineModelDesc*) params.m_PreloadData; - dmResource::Result r = AcquireResources(params.m_Factory, model_resource, params.m_Filename); + model_resource->m_Ddf = (dmGameSystemDDF::SpineModelDesc*) params->m_PreloadData; + dmResource::Result r = AcquireResources(params->m_Factory, model_resource, params->m_Filename); if (r == dmResource::RESULT_OK) { - params.m_Resource->m_Resource = (void*) model_resource; + dmResource::SetResource(params->m_Resource, model_resource); } else { - ReleaseResources(params.m_Factory, model_resource); + ReleaseResources(params->m_Factory, model_resource); delete model_resource; } return r; } - static dmResource::Result ResourceTypeModel_Destroy(const dmResource::ResourceDestroyParams& params) + static dmResource::Result ResourceTypeModel_Destroy(const dmResource::ResourceDestroyParams* params) { - SpineModelResource* model_resource = (SpineModelResource*)params.m_Resource->m_Resource; - ReleaseResources(params.m_Factory, model_resource); + SpineModelResource* model_resource = (SpineModelResource*)dmResource::GetResource(params->m_Resource); + ReleaseResources(params->m_Factory, model_resource); delete model_resource; return dmResource::RESULT_OK; } - static dmResource::Result ResourceTypeModel_Recreate(const dmResource::ResourceRecreateParams& params) + static dmResource::Result ResourceTypeModel_Recreate(const dmResource::ResourceRecreateParams* params) { dmGameSystemDDF::SpineModelDesc* ddf; - dmDDF::Result e = dmDDF::LoadMessage(params.m_Buffer, params.m_BufferSize, &dmGameSystemDDF_SpineModelDesc_DESCRIPTOR, (void**) &ddf); + dmDDF::Result e = dmDDF::LoadMessage(params->m_Buffer, params->m_BufferSize, &dmGameSystemDDF_SpineModelDesc_DESCRIPTOR, (void**) &ddf); if (e != dmDDF::RESULT_OK) { return dmResource::RESULT_DDF_ERROR; } - SpineModelResource* model_resource = (SpineModelResource*)params.m_Resource->m_Resource; - ReleaseResources(params.m_Factory, model_resource); + SpineModelResource* model_resource = (SpineModelResource*)dmResource::GetResource(params->m_Resource); + ReleaseResources(params->m_Factory, model_resource); model_resource->m_Ddf = ddf; - return AcquireResources(params.m_Factory, model_resource, params.m_Filename); + return AcquireResources(params->m_Factory, model_resource, params->m_Filename); } - static dmResource::Result ResourceTypeModel_Register(dmResource::ResourceTypeRegisterContext& ctx) + static ResourceResult ResourceTypeModel_Register(HResourceTypeContext ctx, HResourceType type) { - return dmResource::RegisterType(ctx.m_Factory, - ctx.m_Name, - 0, // context - ResourceTypeModel_Preload, - ResourceTypeModel_Create, - 0, // post create - ResourceTypeModel_Destroy, - ResourceTypeModel_Recreate); + return (ResourceResult)dmResource::SetupType(ctx, + type, + 0, // context + ResourceTypeModel_Preload, + ResourceTypeModel_Create, + 0, // post create + ResourceTypeModel_Destroy, + ResourceTypeModel_Recreate); } } diff --git a/defold-spine/src/res_spine_scene.cpp b/defold-spine/src/res_spine_scene.cpp index 509ff10..04c004f 100644 --- a/defold-spine/src/res_spine_scene.cpp +++ b/defold-spine/src/res_spine_scene.cpp @@ -133,71 +133,71 @@ namespace dmSpine delete[] resource->m_Regions; } - static dmResource::Result ResourceTypeScene_Preload(const dmResource::ResourcePreloadParams& params) + static dmResource::Result ResourceTypeScene_Preload(const dmResource::ResourcePreloadParams* params) { dmGameSystemDDF::SpineSceneDesc* ddf; - dmDDF::Result e = dmDDF::LoadMessage(params.m_Buffer, params.m_BufferSize, &dmGameSystemDDF_SpineSceneDesc_DESCRIPTOR, (void**) &ddf); + dmDDF::Result e = dmDDF::LoadMessage(params->m_Buffer, params->m_BufferSize, &dmGameSystemDDF_SpineSceneDesc_DESCRIPTOR, (void**) &ddf); if (e != dmDDF::RESULT_OK) { return dmResource::RESULT_DDF_ERROR; } - dmResource::PreloadHint(params.m_HintInfo, ddf->m_SpineJson); - dmResource::PreloadHint(params.m_HintInfo, ddf->m_Atlas); + dmResource::PreloadHint(params->m_HintInfo, ddf->m_SpineJson); + dmResource::PreloadHint(params->m_HintInfo, ddf->m_Atlas); - *params.m_PreloadData = ddf; + *params->m_PreloadData = ddf; return dmResource::RESULT_OK; } - static dmResource::Result ResourceTypeScene_Create(const dmResource::ResourceCreateParams& params) + static dmResource::Result ResourceTypeScene_Create(const dmResource::ResourceCreateParams* params) { SpineSceneResource* scene_resource = new SpineSceneResource(); - scene_resource->m_Ddf = (dmGameSystemDDF::SpineSceneDesc*) params.m_PreloadData; - dmResource::Result r = AcquireResources(params.m_Factory, scene_resource, params.m_Filename); + scene_resource->m_Ddf = (dmGameSystemDDF::SpineSceneDesc*) params->m_PreloadData; + dmResource::Result r = AcquireResources(params->m_Factory, scene_resource, params->m_Filename); if (r == dmResource::RESULT_OK) { - params.m_Resource->m_Resource = (void*) scene_resource; + dmResource::SetResource(params->m_Resource, scene_resource); } else { - ReleaseResources(params.m_Factory, scene_resource); + ReleaseResources(params->m_Factory, scene_resource); delete scene_resource; } return r; } - static dmResource::Result ResourceTypeScene_Destroy(const dmResource::ResourceDestroyParams& params) + static dmResource::Result ResourceTypeScene_Destroy(const dmResource::ResourceDestroyParams* params) { - SpineSceneResource* scene_resource = (SpineSceneResource*)params.m_Resource->m_Resource; - ReleaseResources(params.m_Factory, scene_resource); + SpineSceneResource* scene_resource = (SpineSceneResource*)dmResource::GetResource(params->m_Resource); + ReleaseResources(params->m_Factory, scene_resource); delete scene_resource; return dmResource::RESULT_OK; } - static dmResource::Result ResourceTypeScene_Recreate(const dmResource::ResourceRecreateParams& params) + static dmResource::Result ResourceTypeScene_Recreate(const dmResource::ResourceRecreateParams* params) { dmGameSystemDDF::SpineSceneDesc* ddf; - dmDDF::Result e = dmDDF::LoadMessage(params.m_Buffer, params.m_BufferSize, &dmGameSystemDDF_SpineSceneDesc_DESCRIPTOR, (void**) &ddf); + dmDDF::Result e = dmDDF::LoadMessage(params->m_Buffer, params->m_BufferSize, &dmGameSystemDDF_SpineSceneDesc_DESCRIPTOR, (void**) &ddf); if (e != dmDDF::RESULT_OK) { return dmResource::RESULT_DDF_ERROR; } - SpineSceneResource* resource = (SpineSceneResource*)params.m_Resource->m_Resource; - ReleaseResources(params.m_Factory, resource); + SpineSceneResource* resource = (SpineSceneResource*)dmResource::GetResource(params->m_Resource); + ReleaseResources(params->m_Factory, resource); resource->m_Ddf = ddf; - return AcquireResources(params.m_Factory, resource, params.m_Filename); + return AcquireResources(params->m_Factory, resource, params->m_Filename); } - static dmResource::Result ResourceTypeScene_Register(dmResource::ResourceTypeRegisterContext& ctx) + static ResourceResult ResourceTypeScene_Register(HResourceTypeContext ctx, HResourceType type) { - return dmResource::RegisterType(ctx.m_Factory, - ctx.m_Name, - 0, // context - ResourceTypeScene_Preload, - ResourceTypeScene_Create, - 0, // post create - ResourceTypeScene_Destroy, - ResourceTypeScene_Recreate); + return (ResourceResult)dmResource::SetupType(ctx, + type, + 0, // context + ResourceTypeScene_Preload, + ResourceTypeScene_Create, + 0, // post create + ResourceTypeScene_Destroy, + ResourceTypeScene_Recreate); } }