mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Fixing things up.
This commit is contained in:
parent
ca9274539e
commit
b44bca68d9
@ -56,7 +56,8 @@ struct spAttachmentLoader {
|
|||||||
void spAttachmentLoader_dispose (spAttachmentLoader* self);
|
void spAttachmentLoader_dispose (spAttachmentLoader* self);
|
||||||
|
|
||||||
/* Returns 0 to not load an attachment. If 0 is returned and spAttachmentLoader.error1 is set, an error occurred. */
|
/* 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
|
#ifdef SPINE_SHORT_NAMES
|
||||||
typedef spAttachmentLoader AttachmentLoader;
|
typedef spAttachmentLoader AttachmentLoader;
|
||||||
|
|||||||
@ -108,7 +108,8 @@ char* _readFile (const char* path, int* length);
|
|||||||
|
|
||||||
void _spAttachmentLoader_init (spAttachmentLoader* self, /**/
|
void _spAttachmentLoader_init (spAttachmentLoader* self, /**/
|
||||||
void (*dispose) (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_deinit (spAttachmentLoader* self);
|
||||||
void _spAttachmentLoader_setError (spAttachmentLoader* self, const char* error1, const char* error2);
|
void _spAttachmentLoader_setError (spAttachmentLoader* self, const char* error1, const char* error2);
|
||||||
void _spAttachmentLoader_setUnknownTypeError (spAttachmentLoader* self, spAttachmentType type);
|
void _spAttachmentLoader_setUnknownTypeError (spAttachmentLoader* self, spAttachmentType type);
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
spAttachment* _spAtlasAttachmentLoader_newAttachment (spAttachmentLoader* loader, spSkin* skin, spAttachmentType type,
|
spAttachment* _spAtlasAttachmentLoader_newAttachment (spAttachmentLoader* loader, spSkin* skin, spAttachmentType type,
|
||||||
const char* name) {
|
const char* name, const char* path) {
|
||||||
spAtlasAttachmentLoader* self = SUB_CAST(spAtlasAttachmentLoader, loader);
|
spAtlasAttachmentLoader* self = SUB_CAST(spAtlasAttachmentLoader, loader);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ATTACHMENT_REGION: {
|
case ATTACHMENT_REGION: {
|
||||||
|
|||||||
@ -33,13 +33,15 @@
|
|||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
typedef struct _spAttachmentLoaderVtable {
|
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);
|
void (*dispose) (spAttachmentLoader* self);
|
||||||
} _spAttachmentLoaderVtable;
|
} _spAttachmentLoaderVtable;
|
||||||
|
|
||||||
void _spAttachmentLoader_init (spAttachmentLoader* self, /**/
|
void _spAttachmentLoader_init (spAttachmentLoader* self, /**/
|
||||||
void (*dispose) (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);
|
CONST_CAST(_spAttachmentLoaderVtable*, self->vtable) = NEW(_spAttachmentLoaderVtable);
|
||||||
VTABLE(spAttachmentLoader, self)->dispose = dispose;
|
VTABLE(spAttachmentLoader, self)->dispose = dispose;
|
||||||
VTABLE(spAttachmentLoader, self)->newAttachment = newAttachment;
|
VTABLE(spAttachmentLoader, self)->newAttachment = newAttachment;
|
||||||
@ -56,12 +58,13 @@ void spAttachmentLoader_dispose (spAttachmentLoader* self) {
|
|||||||
FREE(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->error1);
|
||||||
FREE(self->error2);
|
FREE(self->error2);
|
||||||
self->error1 = 0;
|
self->error1 = 0;
|
||||||
self->error2 = 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) {
|
void _spAttachmentLoader_setError (spAttachmentLoader* self, const char* error1, const char* error2) {
|
||||||
|
|||||||
@ -414,6 +414,7 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
|
|||||||
spAttachment* attachment;
|
spAttachment* attachment;
|
||||||
const char* skinAttachmentName = attachmentMap->name;
|
const char* skinAttachmentName = attachmentMap->name;
|
||||||
const char* attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName);
|
const char* attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName);
|
||||||
|
const char* path = Json_getString(attachmentMap, "path", 0);
|
||||||
const char* color;
|
const char* color;
|
||||||
|
|
||||||
const char* typeString = Json_getString(attachmentMap, "type", "region");
|
const char* typeString = Json_getString(attachmentMap, "type", "region");
|
||||||
@ -428,7 +429,7 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
attachment = spAttachmentLoader_newAttachment(self->attachmentLoader, skin, type, attachmentName);
|
attachment = spAttachmentLoader_newAttachment(self->attachmentLoader, skin, type, attachmentName, path);
|
||||||
if (!attachment) {
|
if (!attachment) {
|
||||||
if (self->attachmentLoader->error1) {
|
if (self->attachmentLoader->error1) {
|
||||||
spSkeletonData_dispose(skeletonData);
|
spSkeletonData_dispose(skeletonData);
|
||||||
@ -449,7 +450,7 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
|
|||||||
regionAttachment->width = Json_getFloat(attachmentMap, "width", 32) * self->scale;
|
regionAttachment->width = Json_getFloat(attachmentMap, "width", 32) * self->scale;
|
||||||
regionAttachment->height = Json_getFloat(attachmentMap, "height", 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) {
|
if (color) {
|
||||||
regionAttachment->r = toColor(color, 0);
|
regionAttachment->r = toColor(color, 0);
|
||||||
regionAttachment->g = toColor(color, 1);
|
regionAttachment->g = toColor(color, 1);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user