mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +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_
|
||||
|
||||
#include <spine/Attachment.h>
|
||||
#include <spine/Skin.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace spine {
|
||||
@ -44,7 +45,7 @@ struct AttachmentLoader {
|
||||
void AttachmentLoader_dispose (AttachmentLoader* self);
|
||||
|
||||
/* 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
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ void _AtlasPage_deinit (AtlasPage* self);
|
||||
|
||||
void _AttachmentLoader_init (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_setError (AttachmentLoader* self, const char* error1, const char* error2);
|
||||
void _AttachmentLoader_setUnknownTypeError (AttachmentLoader* self, AttachmentType type);
|
||||
|
||||
@ -34,7 +34,7 @@ void _AtlasAttachmentLoader_dispose (AttachmentLoader* 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);
|
||||
switch (type) {
|
||||
case ATTACHMENT_REGION: {
|
||||
|
||||
@ -32,13 +32,13 @@ namespace spine {
|
||||
#endif
|
||||
|
||||
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);
|
||||
} _AttachmentLoaderVtable;
|
||||
|
||||
void _AttachmentLoader_init (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);
|
||||
VTABLE(AttachmentLoader, self) ->dispose = dispose;
|
||||
VTABLE(AttachmentLoader, self) ->newAttachment = newAttachment;
|
||||
@ -54,12 +54,12 @@ void AttachmentLoader_dispose (AttachmentLoader* 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->error2);
|
||||
self->error1 = 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) {
|
||||
|
||||
@ -349,7 +349,7 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso
|
||||
return 0;
|
||||
}
|
||||
|
||||
Attachment* attachment = AttachmentLoader_newAttachment(self->attachmentLoader, type, attachmentName);
|
||||
Attachment* attachment = AttachmentLoader_newAttachment(self->attachmentLoader, skin, type, attachmentName);
|
||||
if (!attachment) {
|
||||
if (self->attachmentLoader->error1) {
|
||||
SkeletonData_dispose(skeletonData);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user