From d1d1c6a638d98ea49af5474abe097cc68126233b Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Tue, 14 May 2013 15:02:22 +0200 Subject: [PATCH] Added Skin_getAttachmentName to enumerate skin attachments for a slot. Thanks James Poag! --- spine-c/include/spine/Skin.h | 3 +++ spine-c/src/spine/Skin.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/spine-c/include/spine/Skin.h b/spine-c/include/spine/Skin.h index 649b15574..6fb3de156 100644 --- a/spine-c/include/spine/Skin.h +++ b/spine-c/include/spine/Skin.h @@ -46,6 +46,9 @@ void Skin_addAttachment (Skin* self, int slotIndex, const char* name, Attachment /* Returns 0 if the attachment was not found. */ Attachment* Skin_getAttachment (const Skin* self, int slotIndex, const char* name); +/* Returns 0 if the slot or attachment was not found. */ +const char* Skin_getAttachmentName (const Skin* self, int slotIndex, int attachmentIndex); + /** Attach each attachment in this skin if the corresponding attachment in oldSkin is currently attached. */ void Skin_attachAll (const Skin* self, struct Skeleton* skeleton, const Skin* oldSkin); diff --git a/spine-c/src/spine/Skin.c b/spine-c/src/spine/Skin.c index c91814d91..2cec61bf4 100644 --- a/spine-c/src/spine/Skin.c +++ b/spine-c/src/spine/Skin.c @@ -88,6 +88,19 @@ Attachment* Skin_getAttachment (const Skin* self, int slotIndex, const char* nam return 0; } +const char* Skin_getAttachmentName (const Skin* self, int slotIndex, int attachmentIndex) { + const _Entry* entry = SUB_CAST(_Internal, self) ->entries; + int i = 0; + while (entry) { + if (entry->slotIndex == slotIndex) { + if (i == attachmentIndex) return entry->name; + i++; + } + entry = entry->next; + } + return 0; +} + void Skin_attachAll (const Skin* self, Skeleton* skeleton, const Skin* oldSkin) { const _Entry *entry = SUB_CAST(_Internal, oldSkin) ->entries; while (entry) {