Fixing things up.

This commit is contained in:
NathanSweet 2014-04-27 22:18:31 +02:00
parent ca9274539e
commit b44bca68d9
5 changed files with 15 additions and 9 deletions

View File

@ -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;

View File

@ -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);

View File

@ -32,7 +32,7 @@
#include <spine/extension.h>
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: {

View File

@ -33,13 +33,15 @@
#include <spine/extension.h>
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) {

View File

@ -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);