Added Skin_getAttachmentName to enumerate skin attachments for a slot. Thanks James Poag!

This commit is contained in:
NathanSweet 2013-05-14 15:02:22 +02:00 committed by Dgizusse
parent 69f37c2a48
commit d1d1c6a638
2 changed files with 16 additions and 0 deletions

View File

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

View File

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