mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Allow access to the skin in attachment loader.
This commit is contained in:
parent
8cae181c37
commit
7453edd1e5
@ -27,6 +27,7 @@
|
|||||||
#define SPINE_ATTACHMENTLOADER_H_
|
#define SPINE_ATTACHMENTLOADER_H_
|
||||||
|
|
||||||
#include <spine/Attachment.h>
|
#include <spine/Attachment.h>
|
||||||
|
#include <spine/Skin.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
namespace spine {
|
namespace spine {
|
||||||
@ -44,7 +45,7 @@ struct AttachmentLoader {
|
|||||||
void AttachmentLoader_dispose (AttachmentLoader* self);
|
void AttachmentLoader_dispose (AttachmentLoader* self);
|
||||||
|
|
||||||
/* Returns 0 to not load an attachment. If 0 is returned and AttachmentLoader.error1 is set, an error occurred. */
|
/* Returns 0 to not load an attachment. If 0 is returned and AttachmentLoader.error1 is set, an error occurred. */
|
||||||
Attachment* AttachmentLoader_newAttachment (AttachmentLoader* self, AttachmentType type, const char* name);
|
Attachment* AttachmentLoader_newAttachment (AttachmentLoader* self, Skin* skin, AttachmentType type, const char* name);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -150,7 +150,7 @@ void _AtlasPage_deinit (AtlasPage* self);
|
|||||||
|
|
||||||
void _AttachmentLoader_init (AttachmentLoader* self, //
|
void _AttachmentLoader_init (AttachmentLoader* self, //
|
||||||
void (*dispose) (AttachmentLoader* self), //
|
void (*dispose) (AttachmentLoader* self), //
|
||||||
Attachment* (*newAttachment) (AttachmentLoader* self, AttachmentType type, const char* name));
|
Attachment* (*newAttachment) (AttachmentLoader* self, Skin* skin, AttachmentType type, const char* name));
|
||||||
void _AttachmentLoader_deinit (AttachmentLoader* self);
|
void _AttachmentLoader_deinit (AttachmentLoader* self);
|
||||||
void _AttachmentLoader_setError (AttachmentLoader* self, const char* error1, const char* error2);
|
void _AttachmentLoader_setError (AttachmentLoader* self, const char* error1, const char* error2);
|
||||||
void _AttachmentLoader_setUnknownTypeError (AttachmentLoader* self, AttachmentType type);
|
void _AttachmentLoader_setUnknownTypeError (AttachmentLoader* self, AttachmentType type);
|
||||||
|
|||||||
@ -34,7 +34,7 @@ void _AtlasAttachmentLoader_dispose (AttachmentLoader* self) {
|
|||||||
_AttachmentLoader_deinit(self);
|
_AttachmentLoader_deinit(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
Attachment* _AtlasAttachmentLoader_newAttachment (AttachmentLoader* loader, AttachmentType type, const char* name) {
|
Attachment* _AtlasAttachmentLoader_newAttachment (AttachmentLoader* loader, Skin* skin, AttachmentType type, const char* name) {
|
||||||
AtlasAttachmentLoader* self = SUB_CAST(AtlasAttachmentLoader, loader);
|
AtlasAttachmentLoader* self = SUB_CAST(AtlasAttachmentLoader, loader);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ATTACHMENT_REGION: {
|
case ATTACHMENT_REGION: {
|
||||||
|
|||||||
@ -32,13 +32,13 @@ namespace spine {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct _AttachmentLoaderVtable {
|
typedef struct _AttachmentLoaderVtable {
|
||||||
Attachment* (*newAttachment) (AttachmentLoader* self, AttachmentType type, const char* name);
|
Attachment* (*newAttachment) (AttachmentLoader* self, Skin* skin, AttachmentType type, const char* name);
|
||||||
void (*dispose) (AttachmentLoader* self);
|
void (*dispose) (AttachmentLoader* self);
|
||||||
} _AttachmentLoaderVtable;
|
} _AttachmentLoaderVtable;
|
||||||
|
|
||||||
void _AttachmentLoader_init (AttachmentLoader* self, //
|
void _AttachmentLoader_init (AttachmentLoader* self, //
|
||||||
void (*dispose) (AttachmentLoader* self), //
|
void (*dispose) (AttachmentLoader* self), //
|
||||||
Attachment* (*newAttachment) (AttachmentLoader* self, AttachmentType type, const char* name)) {
|
Attachment* (*newAttachment) (AttachmentLoader* self, Skin* skin, AttachmentType type, const char* name)) {
|
||||||
CONST_CAST(_AttachmentLoaderVtable*, self->vtable) = NEW(_AttachmentLoaderVtable);
|
CONST_CAST(_AttachmentLoaderVtable*, self->vtable) = NEW(_AttachmentLoaderVtable);
|
||||||
VTABLE(AttachmentLoader, self) ->dispose = dispose;
|
VTABLE(AttachmentLoader, self) ->dispose = dispose;
|
||||||
VTABLE(AttachmentLoader, self) ->newAttachment = newAttachment;
|
VTABLE(AttachmentLoader, self) ->newAttachment = newAttachment;
|
||||||
@ -54,12 +54,12 @@ void AttachmentLoader_dispose (AttachmentLoader* self) {
|
|||||||
VTABLE(AttachmentLoader, self) ->dispose(self);
|
VTABLE(AttachmentLoader, self) ->dispose(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
Attachment* AttachmentLoader_newAttachment (AttachmentLoader* self, AttachmentType type, const char* name) {
|
Attachment* AttachmentLoader_newAttachment (AttachmentLoader* self, Skin* skin, AttachmentType type, const char* name) {
|
||||||
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(AttachmentLoader, self) ->newAttachment(self, type, name);
|
return VTABLE(AttachmentLoader, self) ->newAttachment(self, skin, type, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _AttachmentLoader_setError (AttachmentLoader* self, const char* error1, const char* error2) {
|
void _AttachmentLoader_setError (AttachmentLoader* self, const char* error1, const char* error2) {
|
||||||
|
|||||||
@ -349,7 +349,7 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Attachment* attachment = AttachmentLoader_newAttachment(self->attachmentLoader, type, attachmentName);
|
Attachment* attachment = AttachmentLoader_newAttachment(self->attachmentLoader, skin, type, attachmentName);
|
||||||
if (!attachment) {
|
if (!attachment) {
|
||||||
if (self->attachmentLoader->error1) {
|
if (self->attachmentLoader->error1) {
|
||||||
SkeletonData_dispose(skeletonData);
|
SkeletonData_dispose(skeletonData);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user