From b44bca68d9bc3e58e77534822fb788e157f1ddd3 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Sun, 27 Apr 2014 22:18:31 +0200 Subject: [PATCH] Fixing things up. --- spine-c/include/spine/AttachmentLoader.h | 3 ++- spine-c/include/spine/extension.h | 3 ++- spine-c/src/spine/AtlasAttachmentLoader.c | 2 +- spine-c/src/spine/AttachmentLoader.c | 11 +++++++---- spine-c/src/spine/SkeletonJson.c | 5 +++-- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/spine-c/include/spine/AttachmentLoader.h b/spine-c/include/spine/AttachmentLoader.h index b0c321c0a..4088e0c47 100644 --- a/spine-c/include/spine/AttachmentLoader.h +++ b/spine-c/include/spine/AttachmentLoader.h @@ -56,7 +56,8 @@ struct spAttachmentLoader { void spAttachmentLoader_dispose (spAttachmentLoader* self); /* Returns 0 to not load an attachment. If 0 is returned and spAttachmentLoader.error1 is set, an error occurred. */ -spAttachment* spAttachmentLoader_newAttachment (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name); +spAttachment* spAttachmentLoader_newAttachment (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name, + const char* path); #ifdef SPINE_SHORT_NAMES typedef spAttachmentLoader AttachmentLoader; diff --git a/spine-c/include/spine/extension.h b/spine-c/include/spine/extension.h index 193c22fda..082a3a146 100644 --- a/spine-c/include/spine/extension.h +++ b/spine-c/include/spine/extension.h @@ -108,7 +108,8 @@ char* _readFile (const char* path, int* length); void _spAttachmentLoader_init (spAttachmentLoader* self, /**/ void (*dispose) (spAttachmentLoader* self), /**/ -spAttachment* (*newAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name)); + spAttachment* (*newAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name, + const char* path)); void _spAttachmentLoader_deinit (spAttachmentLoader* self); void _spAttachmentLoader_setError (spAttachmentLoader* self, const char* error1, const char* error2); void _spAttachmentLoader_setUnknownTypeError (spAttachmentLoader* self, spAttachmentType type); diff --git a/spine-c/src/spine/AtlasAttachmentLoader.c b/spine-c/src/spine/AtlasAttachmentLoader.c index 84031d245..e9e1f5ada 100644 --- a/spine-c/src/spine/AtlasAttachmentLoader.c +++ b/spine-c/src/spine/AtlasAttachmentLoader.c @@ -32,7 +32,7 @@ #include spAttachment* _spAtlasAttachmentLoader_newAttachment (spAttachmentLoader* loader, spSkin* skin, spAttachmentType type, - const char* name) { + const char* name, const char* path) { spAtlasAttachmentLoader* self = SUB_CAST(spAtlasAttachmentLoader, loader); switch (type) { case ATTACHMENT_REGION: { diff --git a/spine-c/src/spine/AttachmentLoader.c b/spine-c/src/spine/AttachmentLoader.c index 77ca1baa3..ab0c04c36 100644 --- a/spine-c/src/spine/AttachmentLoader.c +++ b/spine-c/src/spine/AttachmentLoader.c @@ -33,13 +33,15 @@ #include typedef struct _spAttachmentLoaderVtable { - spAttachment* (*newAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name); + spAttachment* (*newAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name, + const char* path); void (*dispose) (spAttachmentLoader* self); } _spAttachmentLoaderVtable; void _spAttachmentLoader_init (spAttachmentLoader* self, /**/ void (*dispose) (spAttachmentLoader* self), /**/ -spAttachment* (*newAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name)) { + spAttachment* (*newAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name, + const char* path)) { CONST_CAST(_spAttachmentLoaderVtable*, self->vtable) = NEW(_spAttachmentLoaderVtable); VTABLE(spAttachmentLoader, self)->dispose = dispose; VTABLE(spAttachmentLoader, self)->newAttachment = newAttachment; @@ -56,12 +58,13 @@ void spAttachmentLoader_dispose (spAttachmentLoader* self) { FREE(self); } -spAttachment* spAttachmentLoader_newAttachment (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name) { +spAttachment* spAttachmentLoader_newAttachment (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name, + const char* path) { FREE(self->error1); FREE(self->error2); self->error1 = 0; self->error2 = 0; - return VTABLE(spAttachmentLoader, self)->newAttachment(self, skin, type, name); + return VTABLE(spAttachmentLoader, self)->newAttachment(self, skin, type, name, path); } void _spAttachmentLoader_setError (spAttachmentLoader* self, const char* error1, const char* error2) { diff --git a/spine-c/src/spine/SkeletonJson.c b/spine-c/src/spine/SkeletonJson.c index c94172725..7859395b9 100644 --- a/spine-c/src/spine/SkeletonJson.c +++ b/spine-c/src/spine/SkeletonJson.c @@ -414,6 +414,7 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha spAttachment* attachment; const char* skinAttachmentName = attachmentMap->name; const char* attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName); + const char* path = Json_getString(attachmentMap, "path", 0); const char* color; const char* typeString = Json_getString(attachmentMap, "type", "region"); @@ -428,7 +429,7 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha return 0; } - attachment = spAttachmentLoader_newAttachment(self->attachmentLoader, skin, type, attachmentName); + attachment = spAttachmentLoader_newAttachment(self->attachmentLoader, skin, type, attachmentName, path); if (!attachment) { if (self->attachmentLoader->error1) { spSkeletonData_dispose(skeletonData); @@ -449,7 +450,7 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha regionAttachment->width = Json_getFloat(attachmentMap, "width", 32) * self->scale; regionAttachment->height = Json_getFloat(attachmentMap, "height", 32) * self->scale; - color = Json_getString(slotMap, "color", 0); + color = Json_getString(attachmentMap, "color", 0); if (color) { regionAttachment->r = toColor(color, 0); regionAttachment->g = toColor(color, 1);