diff --git a/spine-c/example/main.c b/spine-c/example/main.c index 10d983029..f58517632 100644 --- a/spine-c/example/main.c +++ b/spine-c/example/main.c @@ -9,47 +9,47 @@ /**/ -void _AtlasPage_createTexture (AtlasPage* self, const char* path) { +void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) { self->rendererObject = 0; self->width = 123; self->height = 456; } -void _AtlasPage_disposeTexture (AtlasPage* self) { +void _spAtlasPage_disposeTexture (spAtlasPage* self) { } -char* _Util_readFile (const char* path, int* length) { +char* _spUtil_readFile (const char* path, int* length) { return _readFile(path, length); } /**/ int main (void) { - Atlas* atlas = Atlas_readAtlasFile("data/spineboy.atlas"); + spAtlas* atlas = spAtlas_readAtlasFile("data/spineboy.atlas"); printf("First region name: %s, x: %d, y: %d\n", atlas->regions->name, atlas->regions->x, atlas->regions->y); printf("First page name: %s, size: %d, %d\n", atlas->pages->name, atlas->pages->width, atlas->pages->height); - SkeletonJson* json = SkeletonJson_create(atlas); - SkeletonData *skeletonData = SkeletonJson_readSkeletonDataFile(json, "data/spineboy.json"); + spSkeletonJson* json = spSkeletonJson_create(atlas); + spSkeletonData *skeletonData = spSkeletonJson_readSkeletonDataFile(json, "data/spineboy.json"); if (!skeletonData) { printf("Error: %s\n", json->error); exit(0); } printf("Default skin name: %s\n", skeletonData->defaultSkin->name); - Skeleton* skeleton = Skeleton_create(skeletonData); + spSkeleton* skeleton = spSkeleton_create(skeletonData); - Animation* animation = SkeletonData_findAnimation(skeletonData, "walk"); + spAnimation* animation = spSkeletonData_findAnimation(skeletonData, "walk"); if (!animation) { printf("Error: Animation not found: walk\n"); exit(0); } printf("Animation timelineCount: %d\n", animation->timelineCount); - Skeleton_dispose(skeleton); - SkeletonData_dispose(skeletonData); - SkeletonJson_dispose(json); - Atlas_dispose(atlas); + spSkeleton_dispose(skeleton); + spSkeletonData_dispose(skeletonData); + spSkeletonJson_dispose(json); + spAtlas_dispose(atlas); return 0; -} \ No newline at end of file +} diff --git a/spine-c/include/spine/Animation.h b/spine-c/include/spine/Animation.h index 1f2cab812..1f9781e7f 100644 --- a/spine-c/include/spine/Animation.h +++ b/spine-c/include/spine/Animation.h @@ -40,142 +40,206 @@ extern "C" { #endif -typedef struct Timeline Timeline; -struct Skeleton; +typedef struct spTimeline spTimeline; +struct spSkeleton; typedef struct { const char* const name; float duration; int timelineCount; - Timeline** timelines; -} Animation; + spTimeline** timelines; +} spAnimation; -Animation* Animation_create (const char* name, int timelineCount); -void Animation_dispose (Animation* self); +spAnimation* spAnimation_create (const char* name, int timelineCount); +void spAnimation_dispose (spAnimation* self); /** Poses the skeleton at the specified time for this animation. * @param lastTime The last time the animation was applied. * @param events Any triggered events are added. */ -void Animation_apply (const Animation* self, struct Skeleton* skeleton, float lastTime, float time, int loop, - Event** events, int* eventCount); +void spAnimation_apply (const spAnimation* self, struct spSkeleton* skeleton, float lastTime, float time, int loop, + spEvent** events, int* eventCount); /** Poses the skeleton at the specified time for this animation mixed with the current pose. * @param lastTime The last time the animation was applied. * @param events Any triggered events are added. * @param alpha The amount of this animation that affects the current pose. */ -void Animation_mix (const Animation* self, struct Skeleton* skeleton, float lastTime, float time, int loop, Event** events, +void spAnimation_mix (const spAnimation* self, struct spSkeleton* skeleton, float lastTime, float time, int loop, spEvent** events, int* eventCount, float alpha); +#ifdef SPINE_SHORT_NAMES +typedef spAnimation Animation; +#define Animation_create(...) spAnimation_create(__VA_ARGS__) +#define Animation_dispose(...) spAnimation_dispose(__VA_ARGS__) +#define Animation_apply(...) spAnimation_apply(__VA_ARGS__) +#define Animation_mix(...) spAnimation_mix(__VA_ARGS__) +#endif + /**/ -struct Timeline { +struct spTimeline { const void* const vtable; }; -void Timeline_dispose (Timeline* self); -void Timeline_apply (const Timeline* self, struct Skeleton* skeleton, float lastTime, float time, Event** firedEvents, +void spTimeline_dispose (spTimeline* self); +void spTimeline_apply (const spTimeline* self, struct spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha); +#ifdef SPINE_SHORT_NAMES +typedef spTimeline Timeline; +#define Timeline_dispose(...) spTimeline_dispose(__VA_ARGS__) +#define Timeline_apply(...) spTimeline_apply(__VA_ARGS__) +#endif + /**/ typedef struct { - Timeline super; + spTimeline super; float* curves; /* dfx, dfy, ddfx, ddfy, dddfx, dddfy, ... */ -} CurveTimeline; +} spCurveTimeline; -void CurveTimeline_setLinear (CurveTimeline* self, int frameIndex); -void CurveTimeline_setStepped (CurveTimeline* self, int frameIndex); +void spCurveTimeline_setLinear (spCurveTimeline* self, int frameIndex); +void spCurveTimeline_setStepped (spCurveTimeline* self, int frameIndex); /* Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next. * cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of * the difference between the keyframe's values. */ -void CurveTimeline_setCurve (CurveTimeline* self, int frameIndex, float cx1, float cy1, float cx2, float cy2); -float CurveTimeline_getCurvePercent (const CurveTimeline* self, int frameIndex, float percent); +void spCurveTimeline_setCurve (spCurveTimeline* self, int frameIndex, float cx1, float cy1, float cx2, float cy2); +float spCurveTimeline_getCurvePercent (const spCurveTimeline* self, int frameIndex, float percent); + +#ifdef SPINE_SHORT_NAMES +typedef spCurveTimeline CurveTimeline; +#define CurveTimeline_setLinear(...) spCurveTimeline_setLinear(__VA_ARGS__) +#define CurveTimeline_setStepped(...) spCurveTimeline_setStepped(__VA_ARGS__) +#define CurveTimeline_setCurve(...) spCurveTimeline_setCurve(__VA_ARGS__) +#define CurveTimeline_getCurvePercent(...) spCurveTimeline_getCurvePercent(__VA_ARGS__) +#endif /**/ -typedef struct BaseTimeline { - CurveTimeline super; +typedef struct spBaseTimeline { + spCurveTimeline super; int const framesLength; float* const frames; /* time, angle, ... for rotate. time, x, y, ... for translate and scale. */ int boneIndex; -} RotateTimeline; +} spRotateTimeline; -RotateTimeline* RotateTimeline_create (int frameCount); +spRotateTimeline* spRotateTimeline_create (int frameCount); -void RotateTimeline_setFrame (RotateTimeline* self, int frameIndex, float time, float angle); +void spRotateTimeline_setFrame (spRotateTimeline* self, int frameIndex, float time, float angle); + +#ifdef SPINE_SHORT_NAMES +typedef spRotateTimeline RotateTimeline; +#define RotateTimeline_create(...) spRotateTimeline_create(__VA_ARGS__) +#define RotateTimeline_setFrame(...) spRotateTimeline_setFrame(__VA_ARGS__) +#endif /**/ -typedef struct BaseTimeline TranslateTimeline; +typedef struct spBaseTimeline spTranslateTimeline; -TranslateTimeline* TranslateTimeline_create (int frameCount); +spTranslateTimeline* spTranslateTimeline_create (int frameCount); -void TranslateTimeline_setFrame (TranslateTimeline* self, int frameIndex, float time, float x, float y); +void spTranslateTimeline_setFrame (spTranslateTimeline* self, int frameIndex, float time, float x, float y); + +#ifdef SPINE_SHORT_NAMES +typedef spTranslateTimeline TranslateTimeline; +#define TranslateTimeline_create(...) spTranslateTimeline_create(__VA_ARGS__) +#define TranslateTimeline_setFrame(...) spTranslateTimeline_setFrame(__VA_ARGS__) +#endif /**/ -typedef struct BaseTimeline ScaleTimeline; +typedef struct spBaseTimeline spScaleTimeline; -ScaleTimeline* ScaleTimeline_create (int frameCount); +spScaleTimeline* spScaleTimeline_create (int frameCount); -void ScaleTimeline_setFrame (ScaleTimeline* self, int frameIndex, float time, float x, float y); +void spScaleTimeline_setFrame (spScaleTimeline* self, int frameIndex, float time, float x, float y); + +#ifdef SPINE_SHORT_NAMES +typedef spScaleTimeline ScaleTimeline; +#define ScaleTimeline_create(...) spScaleTimeline_create(__VA_ARGS__) +#define ScaleTimeline_setFrame(...) spScaleTimeline_setFrame(__VA_ARGS__) +#endif /**/ typedef struct { - CurveTimeline super; + spCurveTimeline super; int const framesLength; float* const frames; /* time, r, g, b, a, ... */ int slotIndex; -} ColorTimeline; +} spColorTimeline; -ColorTimeline* ColorTimeline_create (int frameCount); +spColorTimeline* spColorTimeline_create (int frameCount); -void ColorTimeline_setFrame (ColorTimeline* self, int frameIndex, float time, float r, float g, float b, float a); +void spColorTimeline_setFrame (spColorTimeline* self, int frameIndex, float time, float r, float g, float b, float a); + +#ifdef SPINE_SHORT_NAMES +typedef spColorTimeline ColorTimeline; +#define ColorTimeline_create(...) spColorTimeline_create(__VA_ARGS__) +#define ColorTimeline_setFrame(...) spColorTimeline_setFrame(__VA_ARGS__) +#endif /**/ typedef struct { - Timeline super; + spTimeline super; int const framesLength; float* const frames; /* time, ... */ int slotIndex; const char** const attachmentNames; -} AttachmentTimeline; +} spAttachmentTimeline; -AttachmentTimeline* AttachmentTimeline_create (int frameCount); +spAttachmentTimeline* spAttachmentTimeline_create (int frameCount); /* @param attachmentName May be 0. */ -void AttachmentTimeline_setFrame (AttachmentTimeline* self, int frameIndex, float time, const char* attachmentName); +void spAttachmentTimeline_setFrame (spAttachmentTimeline* self, int frameIndex, float time, const char* attachmentName); + +#ifdef SPINE_SHORT_NAMES +typedef spAttachmentTimeline AttachmentTimeline; +#define AttachmentTimeline_create(...) spAttachmentTimeline_create(__VA_ARGS__) +#define AttachmentTimeline_setFrame(...) spAttachmentTimeline_setFrame(__VA_ARGS__) +#endif /**/ typedef struct { - Timeline super; + spTimeline super; int const framesLength; float* const frames; /* time, ... */ - Event** const events; -} EventTimeline; + spEvent** const events; +} spEventTimeline; -EventTimeline* EventTimeline_create (int frameCount); +spEventTimeline* spEventTimeline_create (int frameCount); -void EventTimeline_setFrame (EventTimeline* self, int frameIndex, float time, Event* event); +void spEventTimeline_setFrame (spEventTimeline* self, int frameIndex, float time, spEvent* event); + +#ifdef SPINE_SHORT_NAMES +typedef spEventTimeline EventTimeline; +#define EventTimeline_create(...) spEventTimeline_create(__VA_ARGS__) +#define EventTimeline_setFrame(...) spEventTimeline_setFrame(__VA_ARGS__) +#endif /**/ typedef struct { - Timeline super; + spTimeline super; int const framesLength; float* const frames; /* time, ... */ const int** const drawOrders; int const slotCount; -} DrawOrderTimeline; +} spDrawOrderTimeline; -DrawOrderTimeline* DrawOrderTimeline_create (int frameCount, int slotCount); +spDrawOrderTimeline* spDrawOrderTimeline_create (int frameCount, int slotCount); -void DrawOrderTimeline_setFrame (DrawOrderTimeline* self, int frameIndex, float time, const int* drawOrder); +void spDrawOrderTimeline_setFrame (spDrawOrderTimeline* self, int frameIndex, float time, const int* drawOrder); + +#ifdef SPINE_SHORT_NAMES +typedef spDrawOrderTimeline DrawOrderTimeline; +#define DrawOrderTimeline_create(...) spDrawOrderTimeline_create(__VA_ARGS__) +#define DrawOrderTimeline_setFrame(...) spDrawOrderTimeline_setFrame(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/AnimationState.h b/spine-c/include/spine/AnimationState.h index 8a3912a03..990dbe75e 100644 --- a/spine-c/include/spine/AnimationState.h +++ b/spine-c/include/spine/AnimationState.h @@ -34,6 +34,7 @@ #ifndef SPINE_ANIMATIONSTATE_H_ #define SPINE_ANIMATIONSTATE_H_ +#include #include #include @@ -43,55 +44,75 @@ extern "C" { typedef enum { ANIMATION_START, ANIMATION_END, ANIMATION_COMPLETE, ANIMATION_EVENT -} EventType; +} spEventType; -typedef struct AnimationState AnimationState; +typedef struct spAnimationState spAnimationState; -typedef void (*AnimationStateListener) (AnimationState* state, int trackIndex, EventType type, Event* event, int loopCount); +typedef void (*spAnimationStateListener) (spAnimationState* state, int trackIndex, spEventType type, spEvent* event, + int loopCount); -typedef struct TrackEntry TrackEntry; -struct TrackEntry { - TrackEntry* next; - TrackEntry* previous; - Animation* animation; +typedef struct spTrackEntry spTrackEntry; +struct spTrackEntry { + spTrackEntry* next; + spTrackEntry* previous; + spAnimation* animation; int/*bool*/loop; float delay, time, lastTime, endTime, timeScale; - AnimationStateListener listener; + spAnimationStateListener listener; float mixTime, mixDuration; }; -struct AnimationState { - AnimationStateData* const data; +struct spAnimationState { + spAnimationStateData* const data; float timeScale; - AnimationStateListener listener; + spAnimationStateListener listener; void* context; int trackCount; - TrackEntry** tracks; + spTrackEntry** tracks; }; /* @param data May be 0 for no mixing. */ -AnimationState* AnimationState_create (AnimationStateData* data); -void AnimationState_dispose (AnimationState* self); +spAnimationState* spAnimationState_create (spAnimationStateData* data); +void spAnimationState_dispose (spAnimationState* self); -void AnimationState_update (AnimationState* self, float delta); -void AnimationState_apply (AnimationState* self, struct Skeleton* skeleton); +void spAnimationState_update (spAnimationState* self, float delta); +void spAnimationState_apply (spAnimationState* self, struct spSkeleton* skeleton); -void AnimationState_clearTracks (AnimationState* self); -void AnimationState_clearTrack (AnimationState* self, int trackIndex); +void spAnimationState_clearTracks (spAnimationState* self); +void spAnimationState_clearTrack (spAnimationState* self, int trackIndex); /** Set the current animation. Any queued animations are cleared. */ -TrackEntry* AnimationState_setAnimationByName (AnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop); -TrackEntry* AnimationState_setAnimation (AnimationState* self, int trackIndex, Animation* animation, int/*bool*/loop); +spTrackEntry* spAnimationState_setAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, + int/*bool*/loop); +spTrackEntry* spAnimationState_setAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop); /** Adds an animation to be played delay seconds after the current or last queued animation, taking into account any mix * duration. */ -TrackEntry* AnimationState_addAnimationByName (AnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop, - float delay); -TrackEntry* AnimationState_addAnimation (AnimationState* self, int trackIndex, Animation* animation, int/*bool*/loop, +spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, + int/*bool*/loop, float delay); +spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop, float delay); -TrackEntry* AnimationState_getCurrent (AnimationState* self, int trackIndex); +spTrackEntry* spAnimationState_getCurrent (spAnimationState* self, int trackIndex); + +#ifdef SPINE_SHORT_NAMES +typedef spEventType EventType; +typedef spAnimationStateListener AnimationStateListener; +typedef spTrackEntry TrackEntry; +typedef spAnimationState AnimationState; +#define AnimationState_create(...) spAnimationState_create(__VA_ARGS__) +#define AnimationState_dispose(...) spAnimationState_dispose(__VA_ARGS__) +#define AnimationState_update(...) spAnimationState_update(__VA_ARGS__) +#define AnimationState_apply(...) spAnimationState_apply(__VA_ARGS__) +#define AnimationState_clearTracks(...) spAnimationState_clearTracks(__VA_ARGS__) +#define AnimationState_clearTrack(...) spAnimationState_clearTrack(__VA_ARGS__) +#define AnimationState_setAnimationByName(...) spAnimationState_setAnimationByName(__VA_ARGS__) +#define AnimationState_setAnimation(...) spAnimationState_setAnimation(__VA_ARGS__) +#define AnimationState_addAnimationByName(...) spAnimationState_addAnimationByName(__VA_ARGS__) +#define AnimationState_addAnimation(...) spAnimationState_addAnimation(__VA_ARGS__) +#define AnimationState_getCurrent(...) spAnimationState_getCurrent(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/AnimationStateData.h b/spine-c/include/spine/AnimationStateData.h index 03f5f6b64..aed175429 100644 --- a/spine-c/include/spine/AnimationStateData.h +++ b/spine-c/include/spine/AnimationStateData.h @@ -42,18 +42,27 @@ extern "C" { #endif typedef struct { - SkeletonData* const skeletonData; + spSkeletonData* const skeletonData; float defaultMix; const void* const entries; -} AnimationStateData; +} spAnimationStateData; -AnimationStateData* AnimationStateData_create (SkeletonData* skeletonData); -void AnimationStateData_dispose (AnimationStateData* self); +spAnimationStateData* spAnimationStateData_create (spSkeletonData* skeletonData); +void spAnimationStateData_dispose (spAnimationStateData* self); -void AnimationStateData_setMixByName (AnimationStateData* self, const char* fromName, const char* toName, float duration); -void AnimationStateData_setMix (AnimationStateData* self, Animation* from, Animation* to, float duration); +void spAnimationStateData_setMixByName (spAnimationStateData* self, const char* fromName, const char* toName, float duration); +void spAnimationStateData_setMix (spAnimationStateData* self, spAnimation* from, spAnimation* to, float duration); /* Returns 0 if there is no mixing between the animations. */ -float AnimationStateData_getMix (AnimationStateData* self, Animation* from, Animation* to); +float spAnimationStateData_getMix (spAnimationStateData* self, spAnimation* from, spAnimation* to); + +#ifdef SPINE_SHORT_NAMES +typedef spAnimationStateData AnimationStateData; +#define AnimationStateData_create(...) spAnimationStateData_create(__VA_ARGS__) +#define AnimationStateData_dispose(...) spAnimationStateData_dispose(__VA_ARGS__) +#define AnimationStateData_setMixByName(...) spAnimationStateData_setMixByName(__VA_ARGS__) +#define AnimationStateData_setMix(...) spAnimationStateData_setMix(__VA_ARGS__) +#define AnimationStateData_getMix(...) spAnimationStateData_getMix(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/Atlas.h b/spine-c/include/spine/Atlas.h index d4db8f6d0..77da6d147 100644 --- a/spine-c/include/spine/Atlas.h +++ b/spine-c/include/spine/Atlas.h @@ -40,7 +40,7 @@ extern "C" { typedef enum { ATLAS_ALPHA, ATLAS_INTENSITY, ATLAS_LUMINANCE_ALPHA, ATLAS_RGB565, ATLAS_RGBA4444, ATLAS_RGB888, ATLAS_RGBA8888 -} AtlasFormat; +} spAtlasFormat; typedef enum { ATLAS_NEAREST, @@ -50,32 +50,41 @@ typedef enum { ATLAS_MIPMAP_LINEAR_NEAREST, ATLAS_MIPMAP_NEAREST_LINEAR, ATLAS_MIPMAP_LINEAR_LINEAR -} AtlasFilter; +} spAtlasFilter; typedef enum { ATLAS_MIRROREDREPEAT, ATLAS_CLAMPTOEDGE, ATLAS_REPEAT -} AtlasWrap; +} spAtlasWrap; -typedef struct AtlasPage AtlasPage; -struct AtlasPage { +typedef struct spAtlasPage spAtlasPage; +struct spAtlasPage { const char* name; - AtlasFormat format; - AtlasFilter minFilter, magFilter; - AtlasWrap uWrap, vWrap; + spAtlasFormat format; + spAtlasFilter minFilter, magFilter; + spAtlasWrap uWrap, vWrap; void* rendererObject; int width, height; - AtlasPage* next; + spAtlasPage* next; }; -AtlasPage* AtlasPage_create (const char* name); -void AtlasPage_dispose (AtlasPage* self); +spAtlasPage* spAtlasPage_create (const char* name); +void spAtlasPage_dispose (spAtlasPage* self); + +#ifdef SPINE_SHORT_NAMES +typedef spAtlasFormat AtlasFormat; +typedef spAtlasFilter AtlasFilter; +typedef spAtlasWrap AtlasWrap; +typedef spAtlasPage AtlasPage; +#define AtlasPage_create(...) spAtlasPage_create(__VA_ARGS__) +#define AtlasPage_dispose(...) spAtlasPage_dispose(__VA_ARGS__) +#endif /**/ -typedef struct AtlasRegion AtlasRegion; -struct AtlasRegion { +typedef struct spAtlasRegion spAtlasRegion; +struct spAtlasRegion { const char* name; int x, y, width, height; float u, v, u2, v2; @@ -87,29 +96,43 @@ struct AtlasRegion { int* splits; int* pads; - AtlasPage* page; + spAtlasPage* page; - AtlasRegion* next; + spAtlasRegion* next; }; -AtlasRegion* AtlasRegion_create (); -void AtlasRegion_dispose (AtlasRegion* self); +spAtlasRegion* spAtlasRegion_create (); +void spAtlasRegion_dispose (spAtlasRegion* self); + +#ifdef SPINE_SHORT_NAMES +typedef spAtlasRegion AtlasRegion; +#define AtlasRegion_create(...) spAtlasRegion_create(__VA_ARGS__) +#define AtlasRegion_dispose(...) spAtlasRegion_dispose(__VA_ARGS__) +#endif /**/ typedef struct { - AtlasPage* pages; - AtlasRegion* regions; -} Atlas; + spAtlasPage* pages; + spAtlasRegion* regions; +} spAtlas; /* Image files referenced in the atlas file will be prefixed with dir. */ -Atlas* Atlas_readAtlas (const char* data, int length, const char* dir); +spAtlas* spAtlas_readAtlas (const char* data, int length, const char* dir); /* Image files referenced in the atlas file will be prefixed with the directory containing the atlas file. */ -Atlas* Atlas_readAtlasFile (const char* path); -void Atlas_dispose (Atlas* atlas); +spAtlas* spAtlas_readAtlasFile (const char* path); +void spAtlas_dispose (spAtlas* atlas); /* Returns 0 if the region was not found. */ -AtlasRegion* Atlas_findRegion (const Atlas* self, const char* name); +spAtlasRegion* spAtlas_findRegion (const spAtlas* self, const char* name); + +#ifdef SPINE_SHORT_NAMES +typedef spAtlas Atlas; +#define Atlas_readAtlas(...) spAtlas_readAtlas(__VA_ARGS__) +#define Atlas_readAtlasFile(...) spAtlas_readAtlasFile(__VA_ARGS__) +#define Atlas_dispose(...) spAtlas_dispose(__VA_ARGS__) +#define Atlas_findRegion(...) spAtlas_findRegion(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/AtlasAttachmentLoader.h b/spine-c/include/spine/AtlasAttachmentLoader.h index 02af0def8..09303f567 100644 --- a/spine-c/include/spine/AtlasAttachmentLoader.h +++ b/spine-c/include/spine/AtlasAttachmentLoader.h @@ -42,11 +42,16 @@ extern "C" { #endif typedef struct { - AttachmentLoader super; - Atlas* atlas; -} AtlasAttachmentLoader; + spAttachmentLoader super; + spAtlas* atlas; +} spAtlasAttachmentLoader; -AtlasAttachmentLoader* AtlasAttachmentLoader_create (Atlas* atlas); +spAtlasAttachmentLoader* spAtlasAttachmentLoader_create (spAtlas* atlas); + +#ifdef SPINE_SHORT_NAMES +typedef spAtlasAttachmentLoader AtlasAttachmentLoader; +#define AtlasAttachmentLoader_create(...) spAtlasAttachmentLoader_create(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/Attachment.h b/spine-c/include/spine/Attachment.h index 36d216357..8ef9d64bb 100644 --- a/spine-c/include/spine/Attachment.h +++ b/spine-c/include/spine/Attachment.h @@ -38,21 +38,27 @@ extern "C" { #endif -struct Slot; +struct spSlot; typedef enum { ATTACHMENT_REGION, ATTACHMENT_REGION_SEQUENCE, ATTACHMENT_BOUNDING_BOX -} AttachmentType; +} spAttachmentType; -typedef struct Attachment Attachment; -struct Attachment { +typedef struct spAttachment spAttachment; +struct spAttachment { const char* const name; - AttachmentType type; + spAttachmentType type; const void* const vtable; }; -void Attachment_dispose (Attachment* self); +void spAttachment_dispose (spAttachment* self); + +#ifdef SPINE_SHORT_NAMES +typedef spAttachmentType AttachmentType; +typedef spAttachment Attachment; +#define Attachment_dispose(...) spAttachment_dispose(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/AttachmentLoader.h b/spine-c/include/spine/AttachmentLoader.h index d9e246d3e..fdea26df7 100644 --- a/spine-c/include/spine/AttachmentLoader.h +++ b/spine-c/include/spine/AttachmentLoader.h @@ -41,21 +41,31 @@ extern "C" { #endif -typedef struct AttachmentLoader AttachmentLoader; -struct AttachmentLoader { +typedef struct spAttachmentLoader spAttachmentLoader; +struct spAttachmentLoader { const char* error1; const char* error2; const void* const vtable; #ifdef __cplusplus - AttachmentLoader () : error1(0), error2(0), vtable(0) {} + spAttachmentLoader () : + error1(0), + error2(0), + vtable(0) { + } #endif }; -void AttachmentLoader_dispose (AttachmentLoader* self); +void spAttachmentLoader_dispose (spAttachmentLoader* 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, Skin* skin, AttachmentType type, const char* name); +/* 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); + +#ifdef SPINE_SHORT_NAMES +typedef spAttachmentLoader AttachmentLoader; +#define AttachmentLoader_dispose(...) spAttachmentLoader_dispose(__VA_ARGS__) +#define AttachmentLoader_newAttachment(...) spAttachmentLoader_newAttachment(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/Bone.h b/spine-c/include/spine/Bone.h index 713ef1f1f..844eeebd8 100644 --- a/spine-c/include/spine/Bone.h +++ b/spine-c/include/spine/Bone.h @@ -40,10 +40,10 @@ extern "C" { #endif -typedef struct Bone Bone; -struct Bone { - BoneData* const data; - Bone* const parent; +typedef struct spBone spBone; +struct spBone { + spBoneData* const data; + spBone* const parent; float x, y; float rotation; float scaleX, scaleY; @@ -54,15 +54,24 @@ struct Bone { float const worldScaleX, worldScaleY; }; -void Bone_setYDown (int/*bool*/yDown); +void spBone_setYDown (int/*bool*/yDown); /* @param parent May be 0. */ -Bone* Bone_create (BoneData* data, Bone* parent); -void Bone_dispose (Bone* self); +spBone* spBone_create (spBoneData* data, spBone* parent); +void spBone_dispose (spBone* self); -void Bone_setToSetupPose (Bone* self); +void spBone_setToSetupPose (spBone* self); -void Bone_updateWorldTransform (Bone* self, int/*bool*/flipX, int/*bool*/flipY); +void spBone_updateWorldTransform (spBone* self, int/*bool*/flipX, int/*bool*/flipY); + +#ifdef SPINE_SHORT_NAMES +typedef spBone Bone; +#define Bone_setYDown(...) spBone_setYDown(__VA_ARGS__) +#define Bone_create(...) spBone_create(__VA_ARGS__) +#define Bone_dispose(...) spBone_dispose(__VA_ARGS__) +#define Bone_setToSetupPose(...) spBone_setToSetupPose(__VA_ARGS__) +#define Bone_updateWorldTransform(...) spBone_updateWorldTransform(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/BoneData.h b/spine-c/include/spine/BoneData.h index d5d73acbf..1af8b56c4 100644 --- a/spine-c/include/spine/BoneData.h +++ b/spine-c/include/spine/BoneData.h @@ -38,10 +38,10 @@ extern "C" { #endif -typedef struct BoneData BoneData; -struct BoneData { +typedef struct spBoneData spBoneData; +struct spBoneData { const char* const name; - BoneData* const parent; + spBoneData* const parent; float length; float x, y; float rotation; @@ -49,8 +49,14 @@ struct BoneData { int/*bool*/inheritScale, inheritRotation; }; -BoneData* BoneData_create (const char* name, BoneData* parent); -void BoneData_dispose (BoneData* self); +spBoneData* spBoneData_create (const char* name, spBoneData* parent); +void spBoneData_dispose (spBoneData* self); + +#ifdef SPINE_SHORT_NAMES +typedef spBoneData BoneData; +#define BoneData_create(...) spBoneData_create(__VA_ARGS__) +#define BoneData_dispose(...) spBoneData_dispose(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/BoundingBoxAttachment.h b/spine-c/include/spine/BoundingBoxAttachment.h index 0a75b8b9a..606089389 100644 --- a/spine-c/include/spine/BoundingBoxAttachment.h +++ b/spine-c/include/spine/BoundingBoxAttachment.h @@ -42,15 +42,21 @@ extern "C" { #endif -typedef struct BoundingBoxAttachment BoundingBoxAttachment; -struct BoundingBoxAttachment { - Attachment super; +typedef struct spBoundingBoxAttachment spBoundingBoxAttachment; +struct spBoundingBoxAttachment { + spAttachment super; int verticesCount; float* vertices; }; -BoundingBoxAttachment* BoundingBoxAttachment_create (const char* name); -void BoundingBoxAttachment_computeWorldVertices (BoundingBoxAttachment* self, float x, float y, Bone* bone, float* vertices); +spBoundingBoxAttachment* spBoundingBoxAttachment_create (const char* name); +void spBoundingBoxAttachment_computeWorldVertices (spBoundingBoxAttachment* self, float x, float y, spBone* bone, float* vertices); + +#ifdef SPINE_SHORT_NAMES +typedef spBoundingBoxAttachment BoundingBoxAttachment; +#define BoundingBoxAttachment_create(...) spBoundingBoxAttachment_create(__VA_ARGS__) +#define BoundingBoxAttachment_computeWorldVertices(...) spBoundingBoxAttachment_computeWorldVertices(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/Event.h b/spine-c/include/spine/Event.h index a967baba7..147457fe4 100644 --- a/spine-c/include/spine/Event.h +++ b/spine-c/include/spine/Event.h @@ -40,16 +40,22 @@ extern "C" { #endif -typedef struct Event Event; -struct Event { - EventData* const data; +typedef struct spEvent spEvent; +struct spEvent { + spEventData* const data; int intValue; float floatValue; const char* stringValue; }; -Event* Event_create (EventData* data); -void Event_dispose (Event* self); +spEvent* spEvent_create (spEventData* data); +void spEvent_dispose (spEvent* self); + +#ifdef SPINE_SHORT_NAMES +typedef spEvent Event; +#define Event_create(...) spEvent_create(__VA_ARGS__) +#define Event_dispose(...) spEvent_dispose(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/EventData.h b/spine-c/include/spine/EventData.h index 5eca03da0..3672de7b4 100644 --- a/spine-c/include/spine/EventData.h +++ b/spine-c/include/spine/EventData.h @@ -38,16 +38,22 @@ extern "C" { #endif -typedef struct EventData EventData; -struct EventData { +typedef struct spEventData spEventData; +struct spEventData { const char* const name; int intValue; float floatValue; const char* stringValue; }; -EventData* EventData_create (const char* name); -void EventData_dispose (EventData* self); +spEventData* spEventData_create (const char* name); +void spEventData_dispose (spEventData* self); + +#ifdef SPINE_SHORT_NAMES +typedef spEventData EventData; +#define EventData_create(...) spEventData_create(__VA_ARGS__) +#define EventData_dispose(...) spEventData_dispose(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/RegionAttachment.h b/spine-c/include/spine/RegionAttachment.h index 912bd368b..6f1e96b3d 100644 --- a/spine-c/include/spine/RegionAttachment.h +++ b/spine-c/include/spine/RegionAttachment.h @@ -44,11 +44,11 @@ extern "C" { typedef enum { VERTEX_X1 = 0, VERTEX_Y1, VERTEX_X2, VERTEX_Y2, VERTEX_X3, VERTEX_Y3, VERTEX_X4, VERTEX_Y4 -} VertexIndex; +} spVertexIndex; -typedef struct RegionAttachment RegionAttachment; -struct RegionAttachment { - Attachment super; +typedef struct spRegionAttachment spRegionAttachment; +struct spRegionAttachment { + spAttachment super; float x, y, scaleX, scaleY, rotation, width, height; void* rendererObject; @@ -60,10 +60,19 @@ struct RegionAttachment { float uvs[8]; }; -RegionAttachment* RegionAttachment_create (const char* name); -void RegionAttachment_setUVs (RegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate); -void RegionAttachment_updateOffset (RegionAttachment* self); -void RegionAttachment_computeWorldVertices (RegionAttachment* self, float x, float y, Bone* bone, float* vertices); +spRegionAttachment* spRegionAttachment_create (const char* name); +void spRegionAttachment_setUVs (spRegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate); +void spRegionAttachment_updateOffset (spRegionAttachment* self); +void spRegionAttachment_computeWorldVertices (spRegionAttachment* self, float x, float y, spBone* bone, float* vertices); + +#ifdef SPINE_SHORT_NAMES +typedef spVertexIndex VertexIndex; +typedef spRegionAttachment RegionAttachment; +#define RegionAttachment_create(...) spRegionAttachment_create(__VA_ARGS__) +#define RegionAttachment_setUVs(...) spRegionAttachment_setUVs(__VA_ARGS__) +#define RegionAttachment_updateOffset(...) spRegionAttachment_updateOffset(__VA_ARGS__) +#define RegionAttachment_computeWorldVertices(...) spRegionAttachment_computeWorldVertices(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/Skeleton.h b/spine-c/include/spine/Skeleton.h index ad9bfc4f0..070d4b0fe 100644 --- a/spine-c/include/spine/Skeleton.h +++ b/spine-c/include/spine/Skeleton.h @@ -42,60 +42,80 @@ extern "C" { #endif -typedef struct Skeleton Skeleton; -struct Skeleton { - SkeletonData* const data; +typedef struct spSkeleton spSkeleton; +struct spSkeleton { + spSkeletonData* const data; int boneCount; - Bone** bones; - Bone* const root; + spBone** bones; + spBone* const root; int slotCount; - Slot** slots; - Slot** drawOrder; + spSlot** slots; + spSlot** drawOrder; - Skin* const skin; + spSkin* const skin; float r, g, b, a; float time; int/*bool*/flipX, flipY; float x, y; }; -Skeleton* Skeleton_create (SkeletonData* data); -void Skeleton_dispose (Skeleton* self); +spSkeleton* spSkeleton_create (spSkeletonData* data); +void spSkeleton_dispose (spSkeleton* self); -void Skeleton_updateWorldTransform (const Skeleton* self); +void spSkeleton_updateWorldTransform (const spSkeleton* self); -void Skeleton_setToSetupPose (const Skeleton* self); -void Skeleton_setBonesToSetupPose (const Skeleton* self); -void Skeleton_setSlotsToSetupPose (const Skeleton* self); +void spSkeleton_setToSetupPose (const spSkeleton* self); +void spSkeleton_setBonesToSetupPose (const spSkeleton* self); +void spSkeleton_setSlotsToSetupPose (const spSkeleton* self); /* Returns 0 if the bone was not found. */ -Bone* Skeleton_findBone (const Skeleton* self, const char* boneName); +spBone* spSkeleton_findBone (const spSkeleton* self, const char* boneName); /* Returns -1 if the bone was not found. */ -int Skeleton_findBoneIndex (const Skeleton* self, const char* boneName); +int spSkeleton_findBoneIndex (const spSkeleton* self, const char* boneName); /* Returns 0 if the slot was not found. */ -Slot* Skeleton_findSlot (const Skeleton* self, const char* slotName); +spSlot* spSkeleton_findSlot (const spSkeleton* self, const char* slotName); /* Returns -1 if the slot was not found. */ -int Skeleton_findSlotIndex (const Skeleton* self, const char* slotName); +int spSkeleton_findSlotIndex (const spSkeleton* self, const char* slotName); /* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are * attached if the corresponding attachment from the old skin was attached. * @param skin May be 0.*/ -void Skeleton_setSkin (Skeleton* self, Skin* skin); -/* Returns 0 if the skin was not found. See Skeleton_setSkin. +void spSkeleton_setSkin (spSkeleton* self, spSkin* skin); +/* Returns 0 if the skin was not found. See spSkeleton_setSkin. * @param skinName May be 0. */ -int Skeleton_setSkinByName (Skeleton* self, const char* skinName); +int spSkeleton_setSkinByName (spSkeleton* self, const char* skinName); /* Returns 0 if the slot or attachment was not found. */ -Attachment* Skeleton_getAttachmentForSlotName (const Skeleton* self, const char* slotName, const char* attachmentName); +spAttachment* spSkeleton_getAttachmentForSlotName (const spSkeleton* self, const char* slotName, const char* attachmentName); /* Returns 0 if the slot or attachment was not found. */ -Attachment* Skeleton_getAttachmentForSlotIndex (const Skeleton* self, int slotIndex, const char* attachmentName); +spAttachment* spSkeleton_getAttachmentForSlotIndex (const spSkeleton* self, int slotIndex, const char* attachmentName); /* Returns 0 if the slot or attachment was not found. */ -int Skeleton_setAttachment (Skeleton* self, const char* slotName, const char* attachmentName); +int spSkeleton_setAttachment (spSkeleton* self, const char* slotName, const char* attachmentName); -void Skeleton_update (Skeleton* self, float deltaTime); +void spSkeleton_update (spSkeleton* self, float deltaTime); + +#ifdef SPINE_SHORT_NAMES +typedef spSkeleton Skeleton; +#define Skeleton_create(...) spSkeleton_create(__VA_ARGS__) +#define Skeleton_dispose(...) spSkeleton_dispose(__VA_ARGS__) +#define Skeleton_updateWorldTransform(...) spSkeleton_updateWorldTransform(__VA_ARGS__) +#define Skeleton_setToSetupPose(...) spSkeleton_setToSetupPose(__VA_ARGS__) +#define Skeleton_setBonesToSetupPose(...) spSkeleton_setBonesToSetupPose(__VA_ARGS__) +#define Skeleton_setSlotsToSetupPose(...) spSkeleton_setSlotsToSetupPose(__VA_ARGS__) +#define Skeleton_findBone(...) spSkeleton_findBone(__VA_ARGS__) +#define Skeleton_findBoneIndex(...) spSkeleton_findBoneIndex(__VA_ARGS__) +#define Skeleton_findSlot(...) spSkeleton_findSlot(__VA_ARGS__) +#define Skeleton_findSlotIndex(...) spSkeleton_findSlotIndex(__VA_ARGS__) +#define Skeleton_setSkin(...) spSkeleton_setSkin(__VA_ARGS__) +#define Skeleton_setSkinByName(...) spSkeleton_setSkinByName(__VA_ARGS__) +#define Skeleton_getAttachmentForSlotName(...) spSkeleton_getAttachmentForSlotName(__VA_ARGS__) +#define Skeleton_getAttachmentForSlotIndex(...) spSkeleton_getAttachmentForSlotIndex(__VA_ARGS__) +#define Skeleton_setAttachment(...) spSkeleton_setAttachment(__VA_ARGS__) +#define Skeleton_update(...) spSkeleton_update(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/SkeletonBounds.h b/spine-c/include/spine/SkeletonBounds.h index 484b5920e..498f7ce0f 100644 --- a/spine-c/include/spine/SkeletonBounds.h +++ b/spine-c/include/spine/SkeletonBounds.h @@ -45,47 +45,68 @@ typedef struct { float* const vertices; int count; int capacity; -} BoundingPolygon; +} spBoundingPolygon; -BoundingPolygon* BoundingPolygon_create (int capacity); -void BoundingPolygon_dispose (BoundingPolygon* self); +spBoundingPolygon* spBoundingPolygon_create (int capacity); +void spBoundingPolygon_dispose (spBoundingPolygon* self); -int/*bool*/BoundingPolygon_containsPoint (BoundingPolygon* polygon, float x, float y); -int/*bool*/BoundingPolygon_intersectsSegment (BoundingPolygon* polygon, float x1, float y1, float x2, float y2); +int/*bool*/spBoundingPolygon_containsPoint (spBoundingPolygon* polygon, float x, float y); +int/*bool*/spBoundingPolygon_intersectsSegment (spBoundingPolygon* polygon, float x1, float y1, float x2, float y2); + +#ifdef SPINE_SHORT_NAMES +typedef spBoundingPolygon BoundingPolygon; +#define BoundingPolygon_create(...) spBoundingPolygon_create(__VA_ARGS__) +#define BoundingPolygon_dispose(...) spBoundingPolygon_dispose(__VA_ARGS__) +#define BoundingPolygon_containsPoint(...) spBoundingPolygon_containsPoint(__VA_ARGS__) +#define BoundingPolygon_intersectsSegment(...) spBoundingPolygon_intersectsSegment(__VA_ARGS__) +#endif /**/ typedef struct { int count; - BoundingBoxAttachment** boundingBoxes; - BoundingPolygon** polygons; + spBoundingBoxAttachment** boundingBoxes; + spBoundingPolygon** polygons; float minX, minY, maxX, maxY; -} SkeletonBounds; +} spSkeletonBounds; -SkeletonBounds* SkeletonBounds_create (); -void SkeletonBounds_dispose (SkeletonBounds* self); -void SkeletonBounds_update (SkeletonBounds* self, Skeleton* skeleton, int/*bool*/updateAabb); +spSkeletonBounds* spSkeletonBounds_create (); +void spSkeletonBounds_dispose (spSkeletonBounds* self); +void spSkeletonBounds_update (spSkeletonBounds* self, spSkeleton* skeleton, int/*bool*/updateAabb); /** Returns true if the axis aligned bounding box contains the point. */ -int/*bool*/SkeletonBounds_aabbContainsPoint (SkeletonBounds* self, float x, float y); +int/*bool*/spSkeletonBounds_aabbContainsPoint (spSkeletonBounds* self, float x, float y); /** Returns true if the axis aligned bounding box intersects the line segment. */ -int/*bool*/SkeletonBounds_aabbIntersectsSegment (SkeletonBounds* self, float x1, float y1, float x2, float y2); +int/*bool*/spSkeletonBounds_aabbIntersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2); /** Returns true if the axis aligned bounding box intersects the axis aligned bounding box of the specified bounds. */ -int/*bool*/SkeletonBounds_aabbIntersectsSkeleton (SkeletonBounds* self, SkeletonBounds* bounds); +int/*bool*/spSkeletonBounds_aabbIntersectsSkeleton (spSkeletonBounds* self, spSkeletonBounds* bounds); /** Returns the first bounding box attachment that contains the point, or null. When doing many checks, it is usually more - * efficient to only call this method if SkeletonBounds_aabbContainsPoint returns true. */ -BoundingBoxAttachment* SkeletonBounds_containsPoint (SkeletonBounds* self, float x, float y); + * efficient to only call this method if spSkeletonBounds_aabbContainsPoint returns true. */ +spBoundingBoxAttachment* spSkeletonBounds_containsPoint (spSkeletonBounds* self, float x, float y); /** Returns the first bounding box attachment that contains the line segment, or null. When doing many checks, it is usually - * more efficient to only call this method if SkeletonBounds_aabbIntersectsSegment returns true. */ -BoundingBoxAttachment* SkeletonBounds_intersectsSegment (SkeletonBounds* self, float x1, float y1, float x2, float y2); + * more efficient to only call this method if spSkeletonBounds_aabbIntersectsSegment returns true. */ +spBoundingBoxAttachment* spSkeletonBounds_intersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2); /** Returns the polygon for the specified bounding box, or null. */ -BoundingPolygon* SkeletonBounds_getPolygon (SkeletonBounds* self, BoundingBoxAttachment* boundingBox); +spBoundingPolygon* spSkeletonBounds_getPolygon (spSkeletonBounds* self, spBoundingBoxAttachment* boundingBox); + +#ifdef SPINE_SHORT_NAMES +typedef spSkeletonBounds SkeletonBounds; +#define SkeletonBounds_create(...) spSkeletonBounds_create(__VA_ARGS__) +#define SkeletonBounds_dispose(...) spSkeletonBounds_dispose(__VA_ARGS__) +#define SkeletonBounds_update(...) spSkeletonBounds_update(__VA_ARGS__) +#define SkeletonBounds_aabbContainsPoint(...) spSkeletonBounds_aabbContainsPoint(__VA_ARGS__) +#define SkeletonBounds_aabbIntersectsSegment(...) spSkeletonBounds_aabbIntersectsSegment(__VA_ARGS__) +#define SkeletonBounds_aabbIntersectsSkeleton(...) spSkeletonBounds_aabbIntersectsSkeleton(__VA_ARGS__) +#define SkeletonBounds_containsPoint(...) spSkeletonBounds_containsPoint(__VA_ARGS__) +#define SkeletonBounds_intersectsSegment(...) spSkeletonBounds_intersectsSegment(__VA_ARGS__) +#define SkeletonBounds_getPolygon(...) spSkeletonBounds_getPolygon(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/SkeletonData.h b/spine-c/include/spine/SkeletonData.h index 17de3b535..c23879efb 100644 --- a/spine-c/include/spine/SkeletonData.h +++ b/spine-c/include/spine/SkeletonData.h @@ -46,36 +46,49 @@ extern "C" { typedef struct { int boneCount; - BoneData** bones; + spBoneData** bones; int slotCount; - SlotData** slots; + spSlotData** slots; int skinCount; - Skin** skins; - Skin* defaultSkin; + spSkin** skins; + spSkin* defaultSkin; int eventCount; - EventData** events; + spEventData** events; int animationCount; - Animation** animations; -} SkeletonData; + spAnimation** animations; +} spSkeletonData; -SkeletonData* SkeletonData_create (); -void SkeletonData_dispose (SkeletonData* self); +spSkeletonData* spSkeletonData_create (); +void spSkeletonData_dispose (spSkeletonData* self); -BoneData* SkeletonData_findBone (const SkeletonData* self, const char* boneName); -int SkeletonData_findBoneIndex (const SkeletonData* self, const char* boneName); +spBoneData* spSkeletonData_findBone (const spSkeletonData* self, const char* boneName); +int spSkeletonData_findBoneIndex (const spSkeletonData* self, const char* boneName); -SlotData* SkeletonData_findSlot (const SkeletonData* self, const char* slotName); -int SkeletonData_findSlotIndex (const SkeletonData* self, const char* slotName); +spSlotData* spSkeletonData_findSlot (const spSkeletonData* self, const char* slotName); +int spSkeletonData_findSlotIndex (const spSkeletonData* self, const char* slotName); -Skin* SkeletonData_findSkin (const SkeletonData* self, const char* skinName); +spSkin* spSkeletonData_findSkin (const spSkeletonData* self, const char* skinName); -EventData* SkeletonData_findEvent (const SkeletonData* self, const char* eventName); +spEventData* spSkeletonData_findEvent (const spSkeletonData* self, const char* eventName); -Animation* SkeletonData_findAnimation (const SkeletonData* self, const char* animationName); +spAnimation* spSkeletonData_findAnimation (const spSkeletonData* self, const char* animationName); + +#ifdef SPINE_SHORT_NAMES +typedef spSkeletonData SkeletonData; +#define SkeletonData_create(...) spSkeletonData_create(__VA_ARGS__) +#define SkeletonData_dispose(...) spSkeletonData_dispose(__VA_ARGS__) +#define SkeletonData_findBone(...) spSkeletonData_findBone(__VA_ARGS__) +#define SkeletonData_findBoneIndex(...) spSkeletonData_findBoneIndex(__VA_ARGS__) +#define SkeletonData_findSlot(...) spSkeletonData_findSlot(__VA_ARGS__) +#define SkeletonData_findSlotIndex(...) spSkeletonData_findSlotIndex(__VA_ARGS__) +#define SkeletonData_findSkin(...) spSkeletonData_findSkin(__VA_ARGS__) +#define SkeletonData_findEvent(...) spSkeletonData_findEvent(__VA_ARGS__) +#define SkeletonData_findAnimation(...) spSkeletonData_findAnimation(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/SkeletonJson.h b/spine-c/include/spine/SkeletonJson.h index 341ac1faa..672f8d72a 100644 --- a/spine-c/include/spine/SkeletonJson.h +++ b/spine-c/include/spine/SkeletonJson.h @@ -46,16 +46,25 @@ extern "C" { typedef struct { float scale; - AttachmentLoader* attachmentLoader; + spAttachmentLoader* attachmentLoader; const char* const error; -} SkeletonJson; +} spSkeletonJson; -SkeletonJson* SkeletonJson_createWithLoader (AttachmentLoader* attachmentLoader); -SkeletonJson* SkeletonJson_create (Atlas* atlas); -void SkeletonJson_dispose (SkeletonJson* self); +spSkeletonJson* spSkeletonJson_createWithLoader (spAttachmentLoader* attachmentLoader); +spSkeletonJson* spSkeletonJson_create (spAtlas* atlas); +void spSkeletonJson_dispose (spSkeletonJson* self); -SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* json); -SkeletonData* SkeletonJson_readSkeletonDataFile (SkeletonJson* self, const char* path); +spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const char* json); +spSkeletonData* spSkeletonJson_readSkeletonDataFile (spSkeletonJson* self, const char* path); + +#ifdef SPINE_SHORT_NAMES +typedef spSkeletonJson SkeletonJson; +#define SkeletonJson_createWithLoader(...) spSkeletonJson_createWithLoader(__VA_ARGS__) +#define SkeletonJson_create(...) spSkeletonJson_create(__VA_ARGS__) +#define SkeletonJson_dispose(...) spSkeletonJson_dispose(__VA_ARGS__) +#define SkeletonJson_readSkeletonData(...) spSkeletonJson_readSkeletonData(__VA_ARGS__) +#define SkeletonJson_readSkeletonDataFile(...) spSkeletonJson_readSkeletonDataFile(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/Skin.h b/spine-c/include/spine/Skin.h index c82fe650f..da4080340 100644 --- a/spine-c/include/spine/Skin.h +++ b/spine-c/include/spine/Skin.h @@ -40,25 +40,35 @@ extern "C" { #endif -struct Skeleton; +struct spSkeleton; typedef struct { const char* const name; -} Skin; +} spSkin; -Skin* Skin_create (const char* name); -void Skin_dispose (Skin* self); +spSkin* spSkin_create (const char* name); +void spSkin_dispose (spSkin* self); /* The Skin owns the attachment. */ -void Skin_addAttachment (Skin* self, int slotIndex, const char* name, Attachment* attachment); +void spSkin_addAttachment (spSkin* self, int slotIndex, const char* name, spAttachment* attachment); /* Returns 0 if the attachment was not found. */ -Attachment* Skin_getAttachment (const Skin* self, int slotIndex, const char* name); +spAttachment* spSkin_getAttachment (const spSkin* 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); +const char* spSkin_getAttachmentName (const spSkin* 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); +void spSkin_attachAll (const spSkin* self, struct spSkeleton* skeleton, const spSkin* oldspSkin); + +#ifdef SPINE_SHORT_NAMES +typedef spSkin Skin; +#define Skin_create(...) spSkin_create(__VA_ARGS__) +#define Skin_dispose(...) spSkin_dispose(__VA_ARGS__) +#define Skin_addAttachment(...) spSkin_addAttachment(__VA_ARGS__) +#define Skin_getAttachment(...) spSkin_getAttachment(__VA_ARGS__) +#define Skin_getAttachmentName(...) spSkin_getAttachmentName(__VA_ARGS__) +#define Skin_attachAll(...) spSkin_attachAll(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/Slot.h b/spine-c/include/spine/Slot.h index ffb3e34e5..9f7094db1 100644 --- a/spine-c/include/spine/Slot.h +++ b/spine-c/include/spine/Slot.h @@ -42,26 +42,36 @@ extern "C" { #endif -struct Skeleton; +struct spSkeleton; -typedef struct Slot { - SlotData* const data; - struct Skeleton* const skeleton; - Bone* const bone; +typedef struct spSlot { + spSlotData* const data; + struct spSkeleton* const skeleton; + spBone* const bone; float r, g, b, a; - Attachment* const attachment; -} Slot; + spAttachment* const attachment; +} spSlot; -Slot* Slot_create (SlotData* data, struct Skeleton* skeleton, Bone* bone); -void Slot_dispose (Slot* self); +spSlot* spSlot_create (spSlotData* data, struct spSkeleton* skeleton, spBone* bone); +void spSlot_dispose (spSlot* self); /* @param attachment May be 0 to clear the attachment for the slot. */ -void Slot_setAttachment (Slot* self, Attachment* attachment); +void spSlot_setAttachment (spSlot* self, spAttachment* attachment); -void Slot_setAttachmentTime (Slot* self, float time); -float Slot_getAttachmentTime (const Slot* self); +void spSlot_setAttachmentTime (spSlot* self, float time); +float spSlot_getAttachmentTime (const spSlot* self); -void Slot_setToSetupPose (Slot* self); +void spSlot_setToSetupPose (spSlot* self); + +#ifdef SPINE_SHORT_NAMES +typedef spSlot Slot; +#define Slot_create(...) spSlot_create(__VA_ARGS__) +#define Slot_dispose(...) spSlot_dispose(__VA_ARGS__) +#define Slot_setAttachment(...) spSlot_setAttachment(__VA_ARGS__) +#define Slot_setAttachmentTime(...) spSlot_setAttachmentTime(__VA_ARGS__) +#define Slot_getAttachmentTime(...) spSlot_getAttachmentTime(__VA_ARGS__) +#define Slot_setToSetupPose(...) spSlot_setToSetupPose(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/SlotData.h b/spine-c/include/spine/SlotData.h index 056ec3235..7f00bfed3 100644 --- a/spine-c/include/spine/SlotData.h +++ b/spine-c/include/spine/SlotData.h @@ -42,17 +42,24 @@ extern "C" { typedef struct { const char* const name; - const BoneData* const boneData; + const spBoneData* const boneData; const char* const attachmentName; float r, g, b, a; int/*bool*/additiveBlending; -} SlotData; +} spSlotData; -SlotData* SlotData_create (const char* name, BoneData* boneData); -void SlotData_dispose (SlotData* self); +spSlotData* spSlotData_create (const char* name, spBoneData* boneData); +void spSlotData_dispose (spSlotData* self); /* @param attachmentName May be 0 for no setup pose attachment. */ -void SlotData_setAttachmentName (SlotData* self, const char* attachmentName); +void spSlotData_setAttachmentName (spSlotData* self, const char* attachmentName); + +#ifdef SPINE_SHORT_NAMES +typedef spSlotData SlotData; +#define SlotData_create(...) spSlotData_create(__VA_ARGS__) +#define SlotData_dispose(...) spSlotData_dispose(__VA_ARGS__) +#define SlotData_setAttachmentName(...) spSlotData_setAttachmentName(__VA_ARGS__) +#endif #ifdef __cplusplus } diff --git a/spine-c/include/spine/extension.h b/spine-c/include/spine/extension.h index cfd1a9e1e..14dc9aba5 100644 --- a/spine-c/include/spine/extension.h +++ b/spine-c/include/spine/extension.h @@ -1,5 +1,4 @@ - /* Implementation notes: @@ -58,9 +57,9 @@ #define MALLOC_STR(TO,FROM) strcpy(CONST_CAST(char*, TO) = (char*)malloc(strlen(FROM) + 1), FROM) #ifdef __STDC_VERSION__ - #define FMOD(A,B) fmodf(A, B) +#define FMOD(A,B) fmodf(A, B) #else - #define FMOD(A,B) (float)fmod(A, B) +#define FMOD(A,B) (float)fmod(A, B) #endif #include @@ -81,9 +80,15 @@ extern "C" { * Functions that must be implemented: */ -void _AtlasPage_createTexture (AtlasPage* self, const char* path); -void _AtlasPage_disposeTexture (AtlasPage* self); -char* _Util_readFile (const char* path, int* length); +void _spAtlasPage_createTexture (spAtlasPage* self, const char* path); +void _spAtlasPage_disposeTexture (spAtlasPage* self); +char* _spUtil_readFile (const char* path, int* length); + +#ifdef SPINE_SHORT_NAMES +#define _AtlasPage_createTexture(...) _spAtlasPage_createTexture(__VA_ARGS__) +#define _AtlasPage_disposeTexture(...) _spAtlasPage_disposeTexture(__VA_ARGS__) +#define _Util_readFile(...) _spUtil_readFile(__VA_ARGS__) +#endif /* * Internal API available for extension: @@ -100,37 +105,59 @@ char* _readFile (const char* path, int* length); /**/ -void _AttachmentLoader_init (AttachmentLoader* self, /**/ - void (*dispose) (AttachmentLoader* self), /**/ - 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); +void _spAttachmentLoader_init (spAttachmentLoader* self, /**/ +void (*dispose) (spAttachmentLoader* self), /**/ +spAttachment* (*newAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name)); +void _spAttachmentLoader_deinit (spAttachmentLoader* self); +void _spAttachmentLoader_setError (spAttachmentLoader* self, const char* error1, const char* error2); +void _spAttachmentLoader_setUnknownTypeError (spAttachmentLoader* self, spAttachmentType type); + +#ifdef SPINE_SHORT_NAMES +#define _AttachmentLoader_init(...) _spAttachmentLoader_init(__VA_ARGS__) +#define _AttachmentLoader_deinit(...) _spAttachmentLoader_deinit(__VA_ARGS__) +#define _AttachmentLoader_setError(...) _spAttachmentLoader_setError(__VA_ARGS__) +#define _AttachmentLoader_setUnknownTypeError(...) _spAttachmentLoader_setUnknownTypeError(__VA_ARGS__) +#endif /**/ -void _Attachment_init (Attachment* self, const char* name, AttachmentType type, /**/ - void (*dispose) (Attachment* self)); -void _Attachment_deinit (Attachment* self); +void _spAttachment_init (spAttachment* self, const char* name, spAttachmentType type, /**/ +void (*dispose) (spAttachment* self)); +void _spAttachment_deinit (spAttachment* self); + +#ifdef SPINE_SHORT_NAMES +#define _Attachment_init(...) _spAttachment_init(__VA_ARGS__) +#define _Attachment_deinit(...) _spAttachment_deinit(__VA_ARGS__) +#endif /**/ -void _Timeline_init (Timeline* self, /**/ - void (*dispose) (Timeline* self), /**/ - void (*apply) (const Timeline* self, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, int* eventCount, - float alpha)); -void _Timeline_deinit (Timeline* self); +void _spTimeline_init (spTimeline* self, /**/ +void (*dispose) (spTimeline* self), /**/ + void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, + int* eventCount, float alpha)); +void _spTimeline_deinit (spTimeline* self); + +#ifdef SPINE_SHORT_NAMES +#define _Timeline_init(...) _spTimeline_init(__VA_ARGS__) +#define _Timeline_deinit(...) _spTimeline_deinit(__VA_ARGS__) +#endif /**/ -void _CurveTimeline_init (CurveTimeline* self, int frameCount, /**/ - void (*dispose) (Timeline* self), /**/ - void (*apply) (const Timeline* self, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, int* eventCount, - float alpha)); -void _CurveTimeline_deinit (CurveTimeline* self); +void _spCurveTimeline_init (spCurveTimeline* self, int frameCount, /**/ +void (*dispose) (spTimeline* self), /**/ + void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, + int* eventCount, float alpha)); +void _spCurveTimeline_deinit (spCurveTimeline* self); + +#ifdef SPINE_SHORT_NAMES +#define _CurveTimeline_init(...) _spCurveTimeline_init(__VA_ARGS__) +#define _CurveTimeline_deinit(...) _spCurveTimeline_deinit(__VA_ARGS__) +#endif #ifdef __cplusplus } #endif -#endif /* SPINE_EXTENSION_H_ */ \ No newline at end of file +#endif /* SPINE_EXTENSION_H_ */ diff --git a/spine-c/spine-c.vcxproj b/spine-c/spine-c.vcxproj index b3f4c1bae..c393bf8c0 100644 --- a/spine-c/spine-c.vcxproj +++ b/spine-c/spine-c.vcxproj @@ -71,53 +71,53 @@ - - - + + + - + - - - - - - + + + + + + - + - - - - - - + + + + + + - - - + + + - + - - - - - - + + + + + + - + - - - - - - + + + + + + diff --git a/spine-c/spine-c.vcxproj.filters b/spine-c/spine-c.vcxproj.filters index b8134c757..178cbbf8f 100644 --- a/spine-c/spine-c.vcxproj.filters +++ b/spine-c/spine-c.vcxproj.filters @@ -15,55 +15,55 @@ - + Header Files - + Header Files - + Header Files Header Files - + Header Files Header Files - + Header Files - + Header Files - + Header Files Header Files - + Header Files Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files @@ -72,45 +72,45 @@ Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Source Files - + Source Files - + Source Files Source Files - + Source Files Source Files - + Source Files - + Source Files - + Source Files @@ -119,37 +119,37 @@ Source Files - + Source Files Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files diff --git a/spine-c/src/spine/Animation.c b/spine-c/src/spine/Animation.c index 822cb0746..6a6186c3d 100644 --- a/spine-c/src/spine/Animation.c +++ b/spine-c/src/spine/Animation.c @@ -35,24 +35,24 @@ #include #include -Animation* Animation_create (const char* name, int timelineCount) { - Animation* self = NEW(Animation); +spAnimation* spAnimation_create (const char* name, int timelineCount) { + spAnimation* self = NEW(spAnimation); MALLOC_STR(self->name, name); self->timelineCount = timelineCount; - self->timelines = MALLOC(Timeline*, timelineCount); + self->timelines = MALLOC(spTimeline*, timelineCount); return self; } -void Animation_dispose (Animation* self) { +void spAnimation_dispose (spAnimation* self) { int i; for (i = 0; i < self->timelineCount; ++i) - Timeline_dispose(self->timelines[i]); + spTimeline_dispose(self->timelines[i]); FREE(self->timelines); FREE(self->name); FREE(self); } -void Animation_apply (const Animation* self, Skeleton* skeleton, float lastTime, float time, int loop, Event** events, +void spAnimation_apply (const spAnimation* self, spSkeleton* skeleton, float lastTime, float time, int loop, spEvent** events, int* eventCount) { int i, n = self->timelineCount; @@ -62,10 +62,10 @@ void Animation_apply (const Animation* self, Skeleton* skeleton, float lastTime, } for (i = 0; i < n; ++i) - Timeline_apply(self->timelines[i], skeleton, lastTime, time, events, eventCount, 1); + spTimeline_apply(self->timelines[i], skeleton, lastTime, time, events, eventCount, 1); } -void Animation_mix (const Animation* self, Skeleton* skeleton, float lastTime, float time, int loop, Event** events, +void spAnimation_mix (const spAnimation* self, spSkeleton* skeleton, float lastTime, float time, int loop, spEvent** events, int* eventCount, float alpha) { int i, n = self->timelineCount; @@ -75,37 +75,37 @@ void Animation_mix (const Animation* self, Skeleton* skeleton, float lastTime, f } for (i = 0; i < n; ++i) - Timeline_apply(self->timelines[i], skeleton, lastTime, time, events, eventCount, alpha); + spTimeline_apply(self->timelines[i], skeleton, lastTime, time, events, eventCount, alpha); } /**/ -typedef struct _TimelineVtable { - void (*apply) (const Timeline* self, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, int* eventCount, +typedef struct _spTimelineVtable { + void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha); - void (*dispose) (Timeline* self); -} _TimelineVtable; + void (*dispose) (spTimeline* self); +} _spTimelineVtable; -void _Timeline_init (Timeline* self, /**/ -void (*dispose) (Timeline* self), /**/ - void (*apply) (const Timeline* self, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, int* eventCount, - float alpha)) { - CONST_CAST(_TimelineVtable*, self->vtable) = NEW(_TimelineVtable); - VTABLE(Timeline, self)->dispose = dispose; - VTABLE(Timeline, self)->apply = apply; +void _spTimeline_init (spTimeline* self, /**/ +void (*dispose) (spTimeline* self), /**/ + void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, + int* eventCount, float alpha)) { + CONST_CAST(_spTimelineVtable*, self->vtable) = NEW(_spTimelineVtable); + VTABLE(spTimeline, self)->dispose = dispose; + VTABLE(spTimeline, self)->apply = apply; } -void _Timeline_deinit (Timeline* self) { +void _spTimeline_deinit (spTimeline* self) { FREE(self->vtable); } -void Timeline_dispose (Timeline* self) { - VTABLE(Timeline, self)->dispose(self); +void spTimeline_dispose (spTimeline* self) { + VTABLE(spTimeline, self)->dispose(self); } -void Timeline_apply (const Timeline* self, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, int* eventCount, - float alpha) { - VTABLE(Timeline, self)->apply(self, skeleton, lastTime, time, firedEvents, eventCount, alpha); +void spTimeline_apply (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, + int* eventCount, float alpha) { + VTABLE(spTimeline, self)->apply(self, skeleton, lastTime, time, firedEvents, eventCount, alpha); } /**/ @@ -114,28 +114,28 @@ static const float CURVE_LINEAR = 0; static const float CURVE_STEPPED = -1; static const int CURVE_SEGMENTS = 10; -void _CurveTimeline_init (CurveTimeline* self, int frameCount, /**/ -void (*dispose) (Timeline* self), /**/ - void (*apply) (const Timeline* self, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, int* eventCount, - float alpha)) { - _Timeline_init(SUPER(self), dispose, apply); +void _spCurveTimeline_init (spCurveTimeline* self, int frameCount, /**/ +void (*dispose) (spTimeline* self), /**/ + void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, + int* eventCount, float alpha)) { + _spTimeline_init(SUPER(self), dispose, apply); self->curves = CALLOC(float, (frameCount - 1) * 6); } -void _CurveTimeline_deinit (CurveTimeline* self) { - _Timeline_deinit(SUPER(self)); +void _spCurveTimeline_deinit (spCurveTimeline* self) { + _spTimeline_deinit(SUPER(self)); FREE(self->curves); } -void CurveTimeline_setLinear (CurveTimeline* self, int frameIndex) { +void spCurveTimeline_setLinear (spCurveTimeline* self, int frameIndex) { self->curves[frameIndex * 6] = CURVE_LINEAR; } -void CurveTimeline_setStepped (CurveTimeline* self, int frameIndex) { +void spCurveTimeline_setStepped (spCurveTimeline* self, int frameIndex) { self->curves[frameIndex * 6] = CURVE_STEPPED; } -void CurveTimeline_setCurve (CurveTimeline* self, int frameIndex, float cx1, float cy1, float cx2, float cy2) { +void spCurveTimeline_setCurve (spCurveTimeline* self, int frameIndex, float cx1, float cy1, float cx2, float cy2) { float subdiv_step = 1.0f / CURVE_SEGMENTS; float subdiv_step2 = subdiv_step * subdiv_step; float subdiv_step3 = subdiv_step2 * subdiv_step; @@ -156,7 +156,7 @@ void CurveTimeline_setCurve (CurveTimeline* self, int frameIndex, float cx1, flo self->curves[i + 5] = tmp2y * pre5; } -float CurveTimeline_getCurvePercent (const CurveTimeline* self, int frameIndex, float percent) { +float spCurveTimeline_getCurvePercent (const spCurveTimeline* self, int frameIndex, float percent) { float dfy; float ddfx; float ddfy; @@ -221,19 +221,19 @@ static int binarySearch (float *values, int valuesLength, float target, int step /**/ -void _BaseTimeline_dispose (Timeline* timeline) { - struct BaseTimeline* self = SUB_CAST(struct BaseTimeline, timeline); - _CurveTimeline_deinit(SUPER(self)); +void _spBaseTimeline_dispose (spTimeline* timeline) { + struct spBaseTimeline* self = SUB_CAST(struct spBaseTimeline, timeline); + _spCurveTimeline_deinit(SUPER(self)); FREE(self->frames); FREE(self); } -/* Many timelines have structure identical to struct BaseTimeline and extend CurveTimeline. **/ -struct BaseTimeline* _BaseTimeline_create (int frameCount, int frameSize, /**/ - void (*apply) (const Timeline* self, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, int* eventCount, - float alpha)) { - struct BaseTimeline* self = NEW(struct BaseTimeline); - _CurveTimeline_init(SUPER(self), frameCount, _BaseTimeline_dispose, apply); +/* Many timelines have structure identical to struct spBaseTimeline and extend spCurveTimeline. **/ +struct spBaseTimeline* _spBaseTimeline_create (int frameCount, int frameSize, /**/ + void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, + int* eventCount, float alpha)) { + struct spBaseTimeline* self = NEW(struct spBaseTimeline); + _spCurveTimeline_init(SUPER(self), frameCount, _spBaseTimeline_dispose, apply); CONST_CAST(int, self->framesLength) = frameCount * frameSize; CONST_CAST(float*, self->frames) = CALLOC(float, self->framesLength); @@ -246,13 +246,13 @@ struct BaseTimeline* _BaseTimeline_create (int frameCount, int frameSize, /**/ static const int ROTATE_LAST_FRAME_TIME = -2; static const int ROTATE_FRAME_VALUE = 1; -void _RotateTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, +void _spRotateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha) { - Bone *bone; + spBone *bone; int frameIndex; float lastFrameValue, frameTime, percent, amount; - RotateTimeline* self = SUB_CAST(RotateTimeline, timeline); + spRotateTimeline* self = SUB_CAST(spRotateTimeline, timeline); if (time < self->frames[0]) return; /* Time is before first frame. */ @@ -273,7 +273,7 @@ void _RotateTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float lastFrameValue = self->frames[frameIndex - 1]; frameTime = self->frames[frameIndex]; percent = 1 - (time - frameTime) / (self->frames[frameIndex + ROTATE_LAST_FRAME_TIME] - frameTime); - percent = CurveTimeline_getCurvePercent(SUPER(self), frameIndex / 2 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent)); + percent = spCurveTimeline_getCurvePercent(SUPER(self), frameIndex / 2 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent)); amount = self->frames[frameIndex + ROTATE_FRAME_VALUE] - lastFrameValue; while (amount > 180) @@ -288,11 +288,11 @@ void _RotateTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float bone->rotation += amount * alpha; } -RotateTimeline* RotateTimeline_create (int frameCount) { - return _BaseTimeline_create(frameCount, 2, _RotateTimeline_apply); +spRotateTimeline* spRotateTimeline_create (int frameCount) { + return _spBaseTimeline_create(frameCount, 2, _spRotateTimeline_apply); } -void RotateTimeline_setFrame (RotateTimeline* self, int frameIndex, float time, float angle) { +void spRotateTimeline_setFrame (spRotateTimeline* self, int frameIndex, float time, float angle) { frameIndex *= 2; self->frames[frameIndex] = time; self->frames[frameIndex + 1] = angle; @@ -304,13 +304,13 @@ static const int TRANSLATE_LAST_FRAME_TIME = -3; static const int TRANSLATE_FRAME_X = 1; static const int TRANSLATE_FRAME_Y = 2; -void _TranslateTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, +void _spTranslateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha) { - Bone *bone; + spBone *bone; int frameIndex; float lastFrameX, lastFrameY, frameTime, percent; - TranslateTimeline* self = SUB_CAST(TranslateTimeline, timeline); + spTranslateTimeline* self = SUB_CAST(spTranslateTimeline, timeline); if (time < self->frames[0]) return; /* Time is before first frame. */ @@ -328,7 +328,7 @@ void _TranslateTimeline_apply (const Timeline* timeline, Skeleton* skeleton, flo lastFrameY = self->frames[frameIndex - 1]; frameTime = self->frames[frameIndex]; percent = 1 - (time - frameTime) / (self->frames[frameIndex + TRANSLATE_LAST_FRAME_TIME] - frameTime); - percent = CurveTimeline_getCurvePercent(SUPER(self), frameIndex / 3 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent)); + percent = spCurveTimeline_getCurvePercent(SUPER(self), frameIndex / 3 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent)); bone->x += (bone->data->x + lastFrameX + (self->frames[frameIndex + TRANSLATE_FRAME_X] - lastFrameX) * percent - bone->x) * alpha; @@ -336,11 +336,11 @@ void _TranslateTimeline_apply (const Timeline* timeline, Skeleton* skeleton, flo * alpha; } -TranslateTimeline* TranslateTimeline_create (int frameCount) { - return _BaseTimeline_create(frameCount, 3, _TranslateTimeline_apply); +spTranslateTimeline* spTranslateTimeline_create (int frameCount) { + return _spBaseTimeline_create(frameCount, 3, _spTranslateTimeline_apply); } -void TranslateTimeline_setFrame (TranslateTimeline* self, int frameIndex, float time, float x, float y) { +void spTranslateTimeline_setFrame (spTranslateTimeline* self, int frameIndex, float time, float x, float y) { frameIndex *= 3; self->frames[frameIndex] = time; self->frames[frameIndex + 1] = x; @@ -349,13 +349,13 @@ void TranslateTimeline_setFrame (TranslateTimeline* self, int frameIndex, float /**/ -void _ScaleTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, +void _spScaleTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha) { - Bone *bone; + spBone *bone; int frameIndex; float lastFrameX, lastFrameY, frameTime, percent; - ScaleTimeline* self = SUB_CAST(ScaleTimeline, timeline); + spScaleTimeline* self = SUB_CAST(spScaleTimeline, timeline); if (time < self->frames[0]) return; /* Time is before first frame. */ @@ -372,7 +372,7 @@ void _ScaleTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float l lastFrameY = self->frames[frameIndex - 1]; frameTime = self->frames[frameIndex]; percent = 1 - (time - frameTime) / (self->frames[frameIndex + TRANSLATE_LAST_FRAME_TIME] - frameTime); - percent = CurveTimeline_getCurvePercent(SUPER(self), frameIndex / 3 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent)); + percent = spCurveTimeline_getCurvePercent(SUPER(self), frameIndex / 3 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent)); bone->scaleX += (bone->data->scaleX - 1 + lastFrameX + (self->frames[frameIndex + TRANSLATE_FRAME_X] - lastFrameX) * percent - bone->scaleX) * alpha; @@ -380,12 +380,12 @@ void _ScaleTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float l - bone->scaleY) * alpha; } -ScaleTimeline* ScaleTimeline_create (int frameCount) { - return _BaseTimeline_create(frameCount, 3, _ScaleTimeline_apply); +spScaleTimeline* spScaleTimeline_create (int frameCount) { + return _spBaseTimeline_create(frameCount, 3, _spScaleTimeline_apply); } -void ScaleTimeline_setFrame (ScaleTimeline* self, int frameIndex, float time, float x, float y) { - TranslateTimeline_setFrame(self, frameIndex, time, x, y); +void spScaleTimeline_setFrame (spScaleTimeline* self, int frameIndex, float time, float x, float y) { + spTranslateTimeline_setFrame(self, frameIndex, time, x, y); } /**/ @@ -396,13 +396,13 @@ static const int COLOR_FRAME_G = 2; static const int COLOR_FRAME_B = 3; static const int COLOR_FRAME_A = 4; -void _ColorTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, +void _spColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha) { - Slot *slot; + spSlot *slot; int frameIndex; float lastFrameR, lastFrameG, lastFrameB, lastFrameA, percent, frameTime; float r, g, b, a; - ColorTimeline* self = (ColorTimeline*)timeline; + spColorTimeline* self = (spColorTimeline*)timeline; if (time < self->frames[0]) return; /* Time is before first frame. */ @@ -425,7 +425,7 @@ void _ColorTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float l lastFrameA = self->frames[frameIndex - 1]; frameTime = self->frames[frameIndex]; percent = 1 - (time - frameTime) / (self->frames[frameIndex + COLOR_LAST_FRAME_TIME] - frameTime); - percent = CurveTimeline_getCurvePercent(SUPER(self), frameIndex / 5 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent)); + percent = spCurveTimeline_getCurvePercent(SUPER(self), frameIndex / 5 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent)); r = lastFrameR + (self->frames[frameIndex + COLOR_FRAME_R] - lastFrameR) * percent; g = lastFrameG + (self->frames[frameIndex + COLOR_FRAME_G] - lastFrameG) * percent; @@ -444,11 +444,11 @@ void _ColorTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float l } } -ColorTimeline* ColorTimeline_create (int frameCount) { - return (ColorTimeline*)_BaseTimeline_create(frameCount, 5, _ColorTimeline_apply); +spColorTimeline* spColorTimeline_create (int frameCount) { + return (spColorTimeline*)_spBaseTimeline_create(frameCount, 5, _spColorTimeline_apply); } -void ColorTimeline_setFrame (ColorTimeline* self, int frameIndex, float time, float r, float g, float b, float a) { +void spColorTimeline_setFrame (spColorTimeline* self, int frameIndex, float time, float r, float g, float b, float a) { frameIndex *= 5; self->frames[frameIndex] = time; self->frames[frameIndex + 1] = r; @@ -459,11 +459,11 @@ void ColorTimeline_setFrame (ColorTimeline* self, int frameIndex, float time, fl /**/ -void _AttachmentTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, +void _spAttachmentTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha) { int frameIndex; const char* attachmentName; - AttachmentTimeline* self = (AttachmentTimeline*)timeline; + spAttachmentTimeline* self = (spAttachmentTimeline*)timeline; if (time < self->frames[0]) return; /* Time is before first frame. */ @@ -473,15 +473,15 @@ void _AttachmentTimeline_apply (const Timeline* timeline, Skeleton* skeleton, fl frameIndex = binarySearch(self->frames, self->framesLength, time, 1) - 1; attachmentName = self->attachmentNames[frameIndex]; - Slot_setAttachment(skeleton->slots[self->slotIndex], - attachmentName ? Skeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0); + spSlot_setAttachment(skeleton->slots[self->slotIndex], + attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0); } -void _AttachmentTimeline_dispose (Timeline* timeline) { - AttachmentTimeline* self = SUB_CAST(AttachmentTimeline, timeline); +void _spAttachmentTimeline_dispose (spTimeline* timeline) { + spAttachmentTimeline* self = SUB_CAST(spAttachmentTimeline, timeline); int i; - _Timeline_deinit(timeline); + _spTimeline_deinit(timeline); for (i = 0; i < self->framesLength; ++i) FREE(self->attachmentNames[i]); @@ -490,9 +490,9 @@ void _AttachmentTimeline_dispose (Timeline* timeline) { FREE(self); } -AttachmentTimeline* AttachmentTimeline_create (int frameCount) { - AttachmentTimeline* self = NEW(AttachmentTimeline); - _Timeline_init(SUPER(self), _AttachmentTimeline_dispose, _AttachmentTimeline_apply); +spAttachmentTimeline* spAttachmentTimeline_create (int frameCount) { + spAttachmentTimeline* self = NEW(spAttachmentTimeline); + _spTimeline_init(SUPER(self), _spAttachmentTimeline_dispose, _spAttachmentTimeline_apply); CONST_CAST(int, self->framesLength) = frameCount; CONST_CAST(float*, self->frames) = CALLOC(float, frameCount); @@ -501,7 +501,7 @@ AttachmentTimeline* AttachmentTimeline_create (int frameCount) { return self; } -void AttachmentTimeline_setFrame (AttachmentTimeline* self, int frameIndex, float time, const char* attachmentName) { +void spAttachmentTimeline_setFrame (spAttachmentTimeline* self, int frameIndex, float time, const char* attachmentName) { self->frames[frameIndex] = time; FREE(self->attachmentNames[frameIndex]); @@ -513,17 +513,17 @@ void AttachmentTimeline_setFrame (AttachmentTimeline* self, int frameIndex, floa /**/ -void _EventTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, +void _spEventTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha) { if (!firedEvents) return; - EventTimeline* self = (EventTimeline*)timeline; + spEventTimeline* self = (spEventTimeline*)timeline; int frameIndex; if (lastTime >= self->frames[self->framesLength - 1]) return; /* Last time is after last frame. */ if (lastTime > time) { /* Fire events after last time for looped animations. */ - _EventTimeline_apply(timeline, skeleton, lastTime, (float)INT_MAX, firedEvents, eventCount, alpha); + _spEventTimeline_apply(timeline, skeleton, lastTime, (float)INT_MAX, firedEvents, eventCount, alpha); lastTime = 0; } @@ -544,11 +544,11 @@ void _EventTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float l } } -void _EventTimeline_dispose (Timeline* timeline) { - EventTimeline* self = SUB_CAST(EventTimeline, timeline); +void _spEventTimeline_dispose (spTimeline* timeline) { + spEventTimeline* self = SUB_CAST(spEventTimeline, timeline); int i; - _Timeline_deinit(timeline); + _spTimeline_deinit(timeline); for (i = 0; i < self->framesLength; ++i) FREE(self->events[i]); @@ -557,18 +557,18 @@ void _EventTimeline_dispose (Timeline* timeline) { FREE(self); } -EventTimeline* EventTimeline_create (int frameCount) { - EventTimeline* self = NEW(EventTimeline); - _Timeline_init(SUPER(self), _EventTimeline_dispose, _EventTimeline_apply); +spEventTimeline* spEventTimeline_create (int frameCount) { + spEventTimeline* self = NEW(spEventTimeline); + _spTimeline_init(SUPER(self), _spEventTimeline_dispose, _spEventTimeline_apply); CONST_CAST(int, self->framesLength) = frameCount; CONST_CAST(float*, self->frames) = CALLOC(float, frameCount); - CONST_CAST(Event**, self->events) = CALLOC(Event*, frameCount); + CONST_CAST(spEvent**, self->events) = CALLOC(spEvent*, frameCount); return self; } -void EventTimeline_setFrame (EventTimeline* self, int frameIndex, float time, Event* event) { +void spEventTimeline_setFrame (spEventTimeline* self, int frameIndex, float time, spEvent* event) { self->frames[frameIndex] = time; FREE(self->events[frameIndex]); @@ -577,12 +577,12 @@ void EventTimeline_setFrame (EventTimeline* self, int frameIndex, float time, Ev /**/ -void _DrawOrderTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, +void _spDrawOrderTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha) { int i; int frameIndex; const int* drawOrderToSetupIndex; - DrawOrderTimeline* self = (DrawOrderTimeline*)timeline; + spDrawOrderTimeline* self = (spDrawOrderTimeline*)timeline; if (time < self->frames[0]) return; /* Time is before first frame. */ @@ -600,11 +600,11 @@ void _DrawOrderTimeline_apply (const Timeline* timeline, Skeleton* skeleton, flo } } -void _DrawOrderTimeline_dispose (Timeline* timeline) { - DrawOrderTimeline* self = SUB_CAST(DrawOrderTimeline, timeline); +void _spDrawOrderTimeline_dispose (spTimeline* timeline) { + spDrawOrderTimeline* self = SUB_CAST(spDrawOrderTimeline, timeline); int i; - _Timeline_deinit(timeline); + _spTimeline_deinit(timeline); for (i = 0; i < self->framesLength; ++i) FREE(self->drawOrders[i]); @@ -613,9 +613,9 @@ void _DrawOrderTimeline_dispose (Timeline* timeline) { FREE(self); } -DrawOrderTimeline* DrawOrderTimeline_create (int frameCount, int slotCount) { - DrawOrderTimeline* self = NEW(DrawOrderTimeline); - _Timeline_init(SUPER(self), _DrawOrderTimeline_dispose, _DrawOrderTimeline_apply); +spDrawOrderTimeline* spDrawOrderTimeline_create (int frameCount, int slotCount) { + spDrawOrderTimeline* self = NEW(spDrawOrderTimeline); + _spTimeline_init(SUPER(self), _spDrawOrderTimeline_dispose, _spDrawOrderTimeline_apply); CONST_CAST(int, self->framesLength) = frameCount; CONST_CAST(float*, self->frames) = CALLOC(float, frameCount); @@ -625,7 +625,7 @@ DrawOrderTimeline* DrawOrderTimeline_create (int frameCount, int slotCount) { return self; } -void DrawOrderTimeline_setFrame (DrawOrderTimeline* self, int frameIndex, float time, const int* drawOrder) { +void spDrawOrderTimeline_setFrame (spDrawOrderTimeline* self, int frameIndex, float time, const int* drawOrder) { self->frames[frameIndex] = time; FREE(self->drawOrders[frameIndex]); diff --git a/spine-c/src/spine/AnimationState.c b/spine-c/src/spine/AnimationState.c index d3fad3901..3ca35b3da 100644 --- a/spine-c/src/spine/AnimationState.c +++ b/spine-c/src/spine/AnimationState.c @@ -40,20 +40,20 @@ #include #include -TrackEntry* _TrackEntry_create () { - TrackEntry* entry = NEW(TrackEntry); +spTrackEntry* _spTrackEntry_create () { + spTrackEntry* entry = NEW(spTrackEntry); entry->timeScale = 1; return entry; } -void _TrackEntry_dispose (TrackEntry* entry) { +void _spTrackEntry_dispose (spTrackEntry* entry) { FREE(entry); } -void _TrackEntry_disposeAll (TrackEntry* entry) { +void _spTrackEntry_disposeAll (spTrackEntry* entry) { while (entry) { - TrackEntry* next = entry->next; - _TrackEntry_dispose(entry); + spTrackEntry* next = entry->next; + _spTrackEntry_dispose(entry); entry = next; } } @@ -61,34 +61,34 @@ void _TrackEntry_disposeAll (TrackEntry* entry) { /**/ typedef struct { - AnimationState super; - Event** events; -} _AnimationState; + spAnimationState super; + spEvent** events; +} _spAnimationState; -void _AnimationState_setCurrent (AnimationState* self, int index, TrackEntry* entry); +void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEntry* entry); -AnimationState* AnimationState_create (AnimationStateData* data) { - _AnimationState* internal = NEW(_AnimationState); - AnimationState* self = SUPER(internal); - internal->events = MALLOC(Event*, 64); +spAnimationState* spAnimationState_create (spAnimationStateData* data) { + _spAnimationState* internal = NEW(_spAnimationState); + spAnimationState* self = SUPER(internal); + internal->events = MALLOC(spEvent*, 64); self->timeScale = 1; - CONST_CAST(AnimationStateData*, self->data) = data; + CONST_CAST(spAnimationStateData*, self->data) = data; return self; } -void AnimationState_dispose (AnimationState* self) { +void spAnimationState_dispose (spAnimationState* self) { int i; for (i = 0; i < self->trackCount; i++) - _TrackEntry_disposeAll(self->tracks[i]); + _spTrackEntry_disposeAll(self->tracks[i]); FREE(self); } -void AnimationState_update (AnimationState* self, float delta) { +void spAnimationState_update (spAnimationState* self, float delta) { int i; float time, endTime, trackDelta; delta *= self->timeScale; for (i = 0; i < self->trackCount; i++) { - TrackEntry* current = self->tracks[i]; + spTrackEntry* current = self->tracks[i]; if (!current) continue; trackDelta = delta * current->timeScale; @@ -110,23 +110,23 @@ void AnimationState_update (AnimationState* self, float delta) { } if (current->next) { - if (time - trackDelta >= current->next->delay) _AnimationState_setCurrent(self, i, current->next); + if (time - trackDelta >= current->next->delay) _spAnimationState_setCurrent(self, i, current->next); } else { /* End non-looping animation when it reaches its end time and there is no next entry. */ - if (!current->loop && current->lastTime >= current->endTime) AnimationState_clearTrack(self, i); + if (!current->loop && current->lastTime >= current->endTime) spAnimationState_clearTrack(self, i); } } } -void AnimationState_apply (AnimationState* self, Skeleton* skeleton) { - _AnimationState* internal = SUB_CAST(_AnimationState, self); +void spAnimationState_apply (spAnimationState* self, spSkeleton* skeleton) { + _spAnimationState* internal = SUB_CAST(_spAnimationState, self); int i, ii; int eventCount; float time; - TrackEntry* previous; + spTrackEntry* previous; for (i = 0; i < self->trackCount; i++) { - TrackEntry* current = self->tracks[i]; + spTrackEntry* current = self->tracks[i]; if (!current) continue; eventCount = 0; @@ -136,26 +136,26 @@ void AnimationState_apply (AnimationState* self, Skeleton* skeleton) { previous = current->previous; if (!previous) { - Animation_apply(current->animation, skeleton, current->lastTime, time, current->loop, internal->events, + spAnimation_apply(current->animation, skeleton, current->lastTime, time, current->loop, internal->events, &eventCount); } else { float alpha = current->mixTime / current->mixDuration; float previousTime = previous->time; if (!previous->loop && previousTime > previous->endTime) previousTime = previous->endTime; - Animation_apply(previous->animation, skeleton, previousTime, previousTime, previous->loop, 0, 0); + spAnimation_apply(previous->animation, skeleton, previousTime, previousTime, previous->loop, 0, 0); if (alpha >= 1) { alpha = 1; - _TrackEntry_dispose(current->previous); + _spTrackEntry_dispose(current->previous); current->previous = 0; } - Animation_mix(current->animation, skeleton, current->lastTime, time, current->loop, internal->events, + spAnimation_mix(current->animation, skeleton, current->lastTime, time, current->loop, internal->events, &eventCount, alpha); } for (ii = 0; ii < eventCount; ii++) { - Event* event = internal->events[ii]; + spEvent* event = internal->events[ii]; if (current->listener) current->listener(self, i, ANIMATION_EVENT, event, 0); if (self->listener) self->listener(self, i, ANIMATION_EVENT, event, 0); } @@ -164,15 +164,15 @@ void AnimationState_apply (AnimationState* self, Skeleton* skeleton) { } } -void AnimationState_clearTracks (AnimationState* self) { +void spAnimationState_clearTracks (spAnimationState* self) { int i; for (i = 0; i < self->trackCount; i++) - AnimationState_clearTrack(self, i); + spAnimationState_clearTrack(self, i); self->trackCount = 0; } -void AnimationState_clearTrack (AnimationState* self, int trackIndex) { - TrackEntry* current; +void spAnimationState_clearTrack (spAnimationState* self, int trackIndex) { + spTrackEntry* current; if (trackIndex >= self->trackCount) return; current = self->tracks[trackIndex]; if (!current) return; @@ -181,37 +181,37 @@ void AnimationState_clearTrack (AnimationState* self, int trackIndex) { if (self->listener) self->listener(self, trackIndex, ANIMATION_END, 0, 0); self->tracks[trackIndex] = 0; - if (current->previous) _TrackEntry_dispose(current->previous); - _TrackEntry_disposeAll(current); + if (current->previous) _spTrackEntry_dispose(current->previous); + _spTrackEntry_disposeAll(current); } -TrackEntry* _AnimationState_expandToIndex (AnimationState* self, int index) { - TrackEntry** newTracks; +spTrackEntry* _spAnimationState_expandToIndex (spAnimationState* self, int index) { + spTrackEntry** newTracks; if (index < self->trackCount) return self->tracks[index]; - newTracks = CALLOC(TrackEntry*, index + 1); - memcpy(newTracks, self->tracks, self->trackCount * sizeof(TrackEntry*)); + newTracks = CALLOC(spTrackEntry*, index + 1); + memcpy(newTracks, self->tracks, self->trackCount * sizeof(spTrackEntry*)); self->tracks = newTracks; self->trackCount = index + 1; return 0; } -void _AnimationState_setCurrent (AnimationState* self, int index, TrackEntry* entry) { - TrackEntry* current = _AnimationState_expandToIndex(self, index); +void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEntry* entry) { + spTrackEntry* current = _spAnimationState_expandToIndex(self, index); if (current) { if (current->previous) { - _TrackEntry_dispose(current->previous); + _spTrackEntry_dispose(current->previous); current->previous = 0; } if (current->listener) current->listener(self, index, ANIMATION_END, 0, 0); if (self->listener) self->listener(self, index, ANIMATION_END, 0, 0); - entry->mixDuration = AnimationStateData_getMix(self->data, current->animation, entry->animation); + entry->mixDuration = spAnimationStateData_getMix(self->data, current->animation, entry->animation); if (entry->mixDuration > 0) { entry->mixTime = 0; entry->previous = current; } else - _TrackEntry_dispose(current); + _spTrackEntry_dispose(current); } self->tracks[index] = entry; @@ -220,41 +220,41 @@ void _AnimationState_setCurrent (AnimationState* self, int index, TrackEntry* en if (self->listener) self->listener(self, index, ANIMATION_START, 0, 0); } -TrackEntry* AnimationState_setAnimationByName (AnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop) { - Animation* animation = SkeletonData_findAnimation(self->data->skeletonData, animationName); - return AnimationState_setAnimation(self, trackIndex, animation, loop); +spTrackEntry* spAnimationState_setAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop) { + spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName); + return spAnimationState_setAnimation(self, trackIndex, animation, loop); } -TrackEntry* AnimationState_setAnimation (AnimationState* self, int trackIndex, Animation* animation, int/*bool*/loop) { - TrackEntry* entry; - TrackEntry* current = _AnimationState_expandToIndex(self, trackIndex); - if (current) _TrackEntry_disposeAll(current->next); +spTrackEntry* spAnimationState_setAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop) { + spTrackEntry* entry; + spTrackEntry* current = _spAnimationState_expandToIndex(self, trackIndex); + if (current) _spTrackEntry_disposeAll(current->next); - entry = _TrackEntry_create(); + entry = _spTrackEntry_create(); entry->animation = animation; entry->loop = loop; entry->time = 0; entry->endTime = animation->duration; - _AnimationState_setCurrent(self, trackIndex, entry); + _spAnimationState_setCurrent(self, trackIndex, entry); return entry; } -TrackEntry* AnimationState_addAnimationByName (AnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop, +spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop, float delay) { - Animation* animation = SkeletonData_findAnimation(self->data->skeletonData, animationName); - return AnimationState_addAnimation(self, trackIndex, animation, loop, delay); + spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName); + return spAnimationState_addAnimation(self, trackIndex, animation, loop, delay); } -TrackEntry* AnimationState_addAnimation (AnimationState* self, int trackIndex, Animation* animation, int/*bool*/loop, float delay) { - TrackEntry* last; +spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop, float delay) { + spTrackEntry* last; - TrackEntry* entry = _TrackEntry_create(); + spTrackEntry* entry = _spTrackEntry_create(); entry->animation = animation; entry->loop = loop; entry->time = 0; entry->endTime = animation->duration; - last = _AnimationState_expandToIndex(self, trackIndex); + last = _spAnimationState_expandToIndex(self, trackIndex); if (last) { while (last->next) last = last->next; @@ -265,7 +265,7 @@ TrackEntry* AnimationState_addAnimation (AnimationState* self, int trackIndex, A if (delay <= 0) { if (last) { delay += last->endTime; - if (animation) delay -= AnimationStateData_getMix(self->data, last->animation, animation); + if (animation) delay -= spAnimationStateData_getMix(self->data, last->animation, animation); } else delay = 0; } @@ -274,7 +274,7 @@ TrackEntry* AnimationState_addAnimation (AnimationState* self, int trackIndex, A return entry; } -TrackEntry* AnimationState_getCurrent (AnimationState* self, int trackIndex) { +spTrackEntry* spAnimationState_getCurrent (spAnimationState* self, int trackIndex) { if (trackIndex >= self->trackCount) return 0; return self->tracks[trackIndex]; } diff --git a/spine-c/src/spine/AnimationStateData.c b/spine-c/src/spine/AnimationStateData.c index 84442e63a..d479dbf5f 100644 --- a/spine-c/src/spine/AnimationStateData.c +++ b/spine-c/src/spine/AnimationStateData.c @@ -36,12 +36,12 @@ typedef struct _ToEntry _ToEntry; struct _ToEntry { - Animation* animation; + spAnimation* animation; float duration; _ToEntry* next; }; -_ToEntry* _ToEntry_create (Animation* to, float duration) { +_ToEntry* _ToEntry_create (spAnimation* to, float duration) { _ToEntry* self = NEW(_ToEntry); self->animation = to; self->duration = duration; @@ -56,12 +56,12 @@ void _ToEntry_dispose (_ToEntry* self) { typedef struct _FromEntry _FromEntry; struct _FromEntry { - Animation* animation; + spAnimation* animation; _ToEntry* toEntries; _FromEntry* next; }; -_FromEntry* _FromEntry_create (Animation* from) { +_FromEntry* _FromEntry_create (spAnimation* from) { _FromEntry* self = NEW(_FromEntry); self->animation = from; return self; @@ -73,13 +73,13 @@ void _FromEntry_dispose (_FromEntry* self) { /**/ -AnimationStateData* AnimationStateData_create (SkeletonData* skeletonData) { - AnimationStateData* self = NEW(AnimationStateData); - CONST_CAST(SkeletonData*, self->skeletonData) = skeletonData; +spAnimationStateData* spAnimationStateData_create (spSkeletonData* skeletonData) { + spAnimationStateData* self = NEW(spAnimationStateData); + CONST_CAST(spSkeletonData*, self->skeletonData) = skeletonData; return self; } -void AnimationStateData_dispose (AnimationStateData* self) { +void spAnimationStateData_dispose (spAnimationStateData* self) { _ToEntry* toEntry; _ToEntry* nextToEntry; _FromEntry* nextFromEntry; @@ -100,16 +100,16 @@ void AnimationStateData_dispose (AnimationStateData* self) { FREE(self); } -void AnimationStateData_setMixByName (AnimationStateData* self, const char* fromName, const char* toName, float duration) { - Animation* to; - Animation* from = SkeletonData_findAnimation(self->skeletonData, fromName); +void spAnimationStateData_setMixByName (spAnimationStateData* self, const char* fromName, const char* toName, float duration) { + spAnimation* to; + spAnimation* from = spSkeletonData_findAnimation(self->skeletonData, fromName); if (!from) return; - to = SkeletonData_findAnimation(self->skeletonData, toName); + to = spSkeletonData_findAnimation(self->skeletonData, toName); if (!to) return; - AnimationStateData_setMix(self, from, to, duration); + spAnimationStateData_setMix(self, from, to, duration); } -void AnimationStateData_setMix (AnimationStateData* self, Animation* from, Animation* to, float duration) { +void spAnimationStateData_setMix (spAnimationStateData* self, spAnimation* from, spAnimation* to, float duration) { /* Find existing FromEntry. */ _ToEntry* toEntry; _FromEntry* fromEntry = (_FromEntry*)self->entries; @@ -138,7 +138,7 @@ void AnimationStateData_setMix (AnimationStateData* self, Animation* from, Anima fromEntry->toEntries = toEntry; } -float AnimationStateData_getMix (AnimationStateData* self, Animation* from, Animation* to) { +float spAnimationStateData_getMix (spAnimationStateData* self, spAnimation* from, spAnimation* to) { _FromEntry* fromEntry = (_FromEntry*)self->entries; while (fromEntry) { if (fromEntry->animation == from) { diff --git a/spine-c/src/spine/Atlas.c b/spine-c/src/spine/Atlas.c index 91f5154ad..b63c92361 100644 --- a/spine-c/src/spine/Atlas.c +++ b/spine-c/src/spine/Atlas.c @@ -35,25 +35,25 @@ #include #include -AtlasPage* AtlasPage_create (const char* name) { - AtlasPage* self = NEW(AtlasPage); +spAtlasPage* spAtlasPage_create (const char* name) { + spAtlasPage* self = NEW(spAtlasPage); MALLOC_STR(self->name, name); return self; } -void AtlasPage_dispose (AtlasPage* self) { - _AtlasPage_disposeTexture(self); +void spAtlasPage_dispose (spAtlasPage* self) { + _spAtlasPage_disposeTexture(self); FREE(self->name); FREE(self); } /**/ -AtlasRegion* AtlasRegion_create () { - return NEW(AtlasRegion) ; +spAtlasRegion* spAtlasRegion_create () { + return NEW(spAtlasRegion) ; } -void AtlasRegion_dispose (AtlasRegion* self) { +void spAtlasRegion_dispose (spAtlasRegion* self) { FREE(self->name); FREE(self->splits); FREE(self->pads); @@ -165,8 +165,8 @@ static int toInt (Str* str) { return strtol(str->begin, (char**)&str->end, 10); } -static Atlas* abortAtlas (Atlas* self) { - Atlas_dispose(self); +static spAtlas* abortAtlas (spAtlas* self) { + spAtlas_dispose(self); return 0; } @@ -174,17 +174,17 @@ static const char* formatNames[] = {"Alpha", "Intensity", "LuminanceAlpha", "RGB static const char* textureFilterNames[] = {"Nearest", "Linear", "MipMap", "MipMapNearestNearest", "MipMapLinearNearest", "MipMapNearestLinear", "MipMapLinearLinear"}; -Atlas* Atlas_readAtlas (const char* begin, int length, const char* dir) { +spAtlas* spAtlas_readAtlas (const char* begin, int length, const char* dir) { int count; const char* end = begin + length; int dirLength = strlen(dir); int needsSlash = dirLength > 0 && dir[dirLength - 1] != '/' && dir[dirLength - 1] != '\\'; - Atlas* self = NEW(Atlas); + spAtlas* self = NEW(spAtlas); - AtlasPage *page = 0; - AtlasPage *lastPage = 0; - AtlasRegion *lastRegion = 0; + spAtlasPage *page = 0; + spAtlasPage *lastPage = 0; + spAtlasRegion *lastRegion = 0; Str str; Str tuple[4]; readLine(begin, 0, 0); @@ -198,7 +198,7 @@ Atlas* Atlas_readAtlas (const char* begin, int length, const char* dir) { if (needsSlash) path[dirLength] = '/'; strcpy(path + dirLength + needsSlash, name); - page = AtlasPage_create(name); + page = spAtlasPage_create(name); FREE(name); if (lastPage) lastPage->next = page; @@ -207,11 +207,11 @@ Atlas* Atlas_readAtlas (const char* begin, int length, const char* dir) { lastPage = page; if (!readValue(end, &str)) return abortAtlas(self); - page->format = (AtlasFormat)indexOf(formatNames, 7, &str); + page->format = (spAtlasFormat)indexOf(formatNames, 7, &str); if (!readTuple(end, tuple)) return abortAtlas(self); - page->minFilter = (AtlasFilter)indexOf(textureFilterNames, 7, tuple); - page->magFilter = (AtlasFilter)indexOf(textureFilterNames, 7, tuple + 1); + page->minFilter = (spAtlasFilter)indexOf(textureFilterNames, 7, tuple); + page->magFilter = (spAtlasFilter)indexOf(textureFilterNames, 7, tuple + 1); if (!readValue(end, &str)) return abortAtlas(self); if (!equals(&str, "none")) { @@ -219,10 +219,10 @@ Atlas* Atlas_readAtlas (const char* begin, int length, const char* dir) { page->vWrap = *str.begin == 'x' ? ATLAS_CLAMPTOEDGE : (*str.begin == 'y' ? ATLAS_REPEAT : ATLAS_REPEAT); } - _AtlasPage_createTexture(page, path); + _spAtlasPage_createTexture(page, path); FREE(path); } else { - AtlasRegion *region = AtlasRegion_create(); + spAtlasRegion *region = spAtlasRegion_create(); if (lastRegion) lastRegion->next = region; else @@ -288,13 +288,13 @@ Atlas* Atlas_readAtlas (const char* begin, int length, const char* dir) { return self; } -Atlas* Atlas_readAtlasFile (const char* path) { +spAtlas* spAtlas_readAtlasFile (const char* path) { int dirLength; char *dir; int length; const char* data; - Atlas* atlas = 0; + spAtlas* atlas = 0; /* Get directory from atlas path. */ const char* lastForwardSlash = strrchr(path, '/'); @@ -306,35 +306,35 @@ Atlas* Atlas_readAtlasFile (const char* path) { memcpy(dir, path, dirLength); dir[dirLength] = '\0'; - data = _Util_readFile(path, &length); - if (data) atlas = Atlas_readAtlas(data, length, dir); + data = _spUtil_readFile(path, &length); + if (data) atlas = spAtlas_readAtlas(data, length, dir); FREE(data); FREE(dir); return atlas; } -void Atlas_dispose (Atlas* self) { - AtlasRegion* region, *nextRegion; - AtlasPage* page = self->pages; +void spAtlas_dispose (spAtlas* self) { + spAtlasRegion* region, *nextRegion; + spAtlasPage* page = self->pages; while (page) { - AtlasPage* nextPage = page->next; - AtlasPage_dispose(page); + spAtlasPage* nextPage = page->next; + spAtlasPage_dispose(page); page = nextPage; } region = self->regions; while (region) { nextRegion = region->next; - AtlasRegion_dispose(region); + spAtlasRegion_dispose(region); region = nextRegion; } FREE(self); } -AtlasRegion* Atlas_findRegion (const Atlas* self, const char* name) { - AtlasRegion* region = self->regions; +spAtlasRegion* spAtlas_findRegion (const spAtlas* self, const char* name) { + spAtlasRegion* region = self->regions; while (region) { if (strcmp(region->name, name) == 0) return region; region = region->next; diff --git a/spine-c/src/spine/AtlasAttachmentLoader.c b/spine-c/src/spine/AtlasAttachmentLoader.c index 1858b7d9d..23b9171a8 100644 --- a/spine-c/src/spine/AtlasAttachmentLoader.c +++ b/spine-c/src/spine/AtlasAttachmentLoader.c @@ -34,19 +34,20 @@ #include #include -Attachment* _AtlasAttachmentLoader_newAttachment (AttachmentLoader* loader, Skin* skin, AttachmentType type, const char* name) { - AtlasAttachmentLoader* self = SUB_CAST(AtlasAttachmentLoader, loader); +spAttachment* _spAtlasAttachmentLoader_newAttachment (spAttachmentLoader* loader, spSkin* skin, spAttachmentType type, + const char* name) { + spAtlasAttachmentLoader* self = SUB_CAST(spAtlasAttachmentLoader, loader); switch (type) { case ATTACHMENT_REGION: { - RegionAttachment* attachment; - AtlasRegion* region = Atlas_findRegion(self->atlas, name); + spRegionAttachment* attachment; + spAtlasRegion* region = spAtlas_findRegion(self->atlas, name); if (!region) { - _AttachmentLoader_setError(loader, "Region not found: ", name); + _spAttachmentLoader_setError(loader, "Region not found: ", name); return 0; } - attachment = RegionAttachment_create(name); + attachment = spRegionAttachment_create(name); attachment->rendererObject = region; - RegionAttachment_setUVs(attachment, region->u, region->v, region->u2, region->v2, region->rotate); + spRegionAttachment_setUVs(attachment, region->u, region->v, region->u2, region->v2, region->rotate); attachment->regionOffsetX = region->offsetX; attachment->regionOffsetY = region->offsetY; attachment->regionWidth = region->width; @@ -56,16 +57,16 @@ Attachment* _AtlasAttachmentLoader_newAttachment (AttachmentLoader* loader, Skin return SUPER(attachment); } case ATTACHMENT_BOUNDING_BOX: - return SUPER(BoundingBoxAttachment_create(name)); + return SUPER(spBoundingBoxAttachment_create(name)); default: - _AttachmentLoader_setUnknownTypeError(loader, type); + _spAttachmentLoader_setUnknownTypeError(loader, type); return 0; } } -AtlasAttachmentLoader* AtlasAttachmentLoader_create (Atlas* atlas) { - AtlasAttachmentLoader* self = NEW(AtlasAttachmentLoader); - _AttachmentLoader_init(SUPER(self), _AttachmentLoader_deinit, _AtlasAttachmentLoader_newAttachment); +spAtlasAttachmentLoader* spAtlasAttachmentLoader_create (spAtlas* atlas) { + spAtlasAttachmentLoader* self = NEW(spAtlasAttachmentLoader); + _spAttachmentLoader_init(SUPER(self), _spAttachmentLoader_deinit, _spAtlasAttachmentLoader_newAttachment); self->atlas = atlas; return self; } diff --git a/spine-c/src/spine/Attachment.c b/spine-c/src/spine/Attachment.c index e7f5d05a2..81ed3d670 100644 --- a/spine-c/src/spine/Attachment.c +++ b/spine-c/src/spine/Attachment.c @@ -35,26 +35,26 @@ #include #include -typedef struct _AttachmentVtable { - void (*dispose) (Attachment* self); -} _AttachmentVtable; +typedef struct _spAttachmentVtable { + void (*dispose) (spAttachment* self); +} _spAttachmentVtable; -void _Attachment_init (Attachment* self, const char* name, AttachmentType type, /**/ - void (*dispose) (Attachment* self)) { +void _spAttachment_init (spAttachment* self, const char* name, spAttachmentType type, /**/ + void (*dispose) (spAttachment* self)) { - CONST_CAST(_AttachmentVtable*, self->vtable) = NEW(_AttachmentVtable); - VTABLE(Attachment, self) ->dispose = dispose; + CONST_CAST(_spAttachmentVtable*, self->vtable) = NEW(_spAttachmentVtable); + VTABLE(spAttachment, self) ->dispose = dispose; MALLOC_STR(self->name, name); self->type = type; } -void _Attachment_deinit (Attachment* self) { +void _spAttachment_deinit (spAttachment* self) { FREE(self->vtable); FREE(self->name); } -void Attachment_dispose (Attachment* self) { - VTABLE(Attachment, self) ->dispose(self); +void spAttachment_dispose (spAttachment* self) { + VTABLE(spAttachment, self) ->dispose(self); FREE(self); } diff --git a/spine-c/src/spine/AttachmentLoader.c b/spine-c/src/spine/AttachmentLoader.c index 44d7c9114..18fad267c 100644 --- a/spine-c/src/spine/AttachmentLoader.c +++ b/spine-c/src/spine/AttachmentLoader.c @@ -35,47 +35,47 @@ #include #include -typedef struct _AttachmentLoaderVtable { - Attachment* (*newAttachment) (AttachmentLoader* self, Skin* skin, AttachmentType type, const char* name); - void (*dispose) (AttachmentLoader* self); -} _AttachmentLoaderVtable; +typedef struct _spAttachmentLoaderVtable { + spAttachment* (*newAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name); + void (*dispose) (spAttachmentLoader* self); +} _spAttachmentLoaderVtable; -void _AttachmentLoader_init (AttachmentLoader* self, /**/ - void (*dispose) (AttachmentLoader* self), /**/ - 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; +void _spAttachmentLoader_init (spAttachmentLoader* self, /**/ +void (*dispose) (spAttachmentLoader* self), /**/ +spAttachment* (*newAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name)) { + CONST_CAST(_spAttachmentLoaderVtable*, self->vtable) = NEW(_spAttachmentLoaderVtable); + VTABLE(spAttachmentLoader, self)->dispose = dispose; + VTABLE(spAttachmentLoader, self)->newAttachment = newAttachment; } -void _AttachmentLoader_deinit (AttachmentLoader* self) { +void _spAttachmentLoader_deinit (spAttachmentLoader* self) { FREE(self->vtable); FREE(self->error1); FREE(self->error2); } -void AttachmentLoader_dispose (AttachmentLoader* self) { - VTABLE(AttachmentLoader, self) ->dispose(self); +void spAttachmentLoader_dispose (spAttachmentLoader* self) { + VTABLE(spAttachmentLoader, self)->dispose(self); FREE(self); } -Attachment* AttachmentLoader_newAttachment (AttachmentLoader* self, Skin* skin, AttachmentType type, const char* name) { +spAttachment* spAttachmentLoader_newAttachment (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name) { FREE(self->error1); FREE(self->error2); self->error1 = 0; self->error2 = 0; - return VTABLE(AttachmentLoader, self) ->newAttachment(self, skin, type, name); + return VTABLE(spAttachmentLoader, self)->newAttachment(self, skin, type, name); } -void _AttachmentLoader_setError (AttachmentLoader* self, const char* error1, const char* error2) { +void _spAttachmentLoader_setError (spAttachmentLoader* self, const char* error1, const char* error2) { FREE(self->error1); FREE(self->error2); MALLOC_STR(self->error1, error1); MALLOC_STR(self->error2, error2); } -void _AttachmentLoader_setUnknownTypeError (AttachmentLoader* self, AttachmentType type) { +void _spAttachmentLoader_setUnknownTypeError (spAttachmentLoader* self, spAttachmentType type) { char buffer[16]; sprintf(buffer, "%d", type); - _AttachmentLoader_setError(self, "Unknown attachment type: ", buffer); + _spAttachmentLoader_setError(self, "Unknown attachment type: ", buffer); } diff --git a/spine-c/src/spine/Bone.c b/spine-c/src/spine/Bone.c index 8e62fcff7..c322ff1c9 100644 --- a/spine-c/src/spine/Bone.c +++ b/spine-c/src/spine/Bone.c @@ -36,23 +36,23 @@ static int yDown; -void Bone_setYDown (int value) { +void spBone_setYDown (int value) { yDown = value; } -Bone* Bone_create (BoneData* data, Bone* parent) { - Bone* self = NEW(Bone); - CONST_CAST(BoneData*, self->data) = data; - CONST_CAST(Bone*, self->parent) = parent; - Bone_setToSetupPose(self); +spBone* spBone_create (spBoneData* data, spBone* parent) { + spBone* self = NEW(spBone); + CONST_CAST(spBoneData*, self->data) = data; + CONST_CAST(spBone*, self->parent) = parent; + spBone_setToSetupPose(self); return self; } -void Bone_dispose (Bone* self) { +void spBone_dispose (spBone* self) { FREE(self); } -void Bone_setToSetupPose (Bone* self) { +void spBone_setToSetupPose (spBone* self) { self->x = self->data->x; self->y = self->data->y; self->rotation = self->data->rotation; @@ -60,7 +60,7 @@ void Bone_setToSetupPose (Bone* self) { self->scaleY = self->data->scaleY; } -void Bone_updateWorldTransform (Bone* self, int flipX, int flipY) { +void spBone_updateWorldTransform (spBone* self, int flipX, int flipY) { float radians, cosine, sine; if (self->parent) { CONST_CAST(float, self->worldX) = self->x * self->parent->m00 + self->y * self->parent->m01 + self->parent->worldX; diff --git a/spine-c/src/spine/BoneData.c b/spine-c/src/spine/BoneData.c index 75932ce2f..8a17348d0 100644 --- a/spine-c/src/spine/BoneData.c +++ b/spine-c/src/spine/BoneData.c @@ -34,10 +34,10 @@ #include #include -BoneData* BoneData_create (const char* name, BoneData* parent) { - BoneData* self = NEW(BoneData); +spBoneData* spBoneData_create (const char* name, spBoneData* parent) { + spBoneData* self = NEW(spBoneData); MALLOC_STR(self->name, name); - CONST_CAST(BoneData*, self->parent) = parent; + CONST_CAST(spBoneData*, self->parent) = parent; self->scaleX = 1; self->scaleY = 1; self->inheritScale = 1; @@ -45,7 +45,7 @@ BoneData* BoneData_create (const char* name, BoneData* parent) { return self; } -void BoneData_dispose (BoneData* self) { +void spBoneData_dispose (spBoneData* self) { FREE(self->name); FREE(self); } diff --git a/spine-c/src/spine/BoundingBoxAttachment.c b/spine-c/src/spine/BoundingBoxAttachment.c index 520e8f960..215ac056f 100644 --- a/spine-c/src/spine/BoundingBoxAttachment.c +++ b/spine-c/src/spine/BoundingBoxAttachment.c @@ -34,13 +34,13 @@ #include #include -BoundingBoxAttachment* BoundingBoxAttachment_create (const char* name) { - BoundingBoxAttachment* self = NEW(BoundingBoxAttachment); - _Attachment_init(SUPER(self), name, ATTACHMENT_BOUNDING_BOX, _Attachment_deinit); +spBoundingBoxAttachment* spBoundingBoxAttachment_create (const char* name) { + spBoundingBoxAttachment* self = NEW(spBoundingBoxAttachment); + _spAttachment_init(SUPER(self), name, ATTACHMENT_BOUNDING_BOX, _spAttachment_deinit); return self; } -void BoundingBoxAttachment_computeWorldVertices (BoundingBoxAttachment* self, float x, float y, Bone* bone, float* worldVertices) { +void spBoundingBoxAttachment_computeWorldVertices (spBoundingBoxAttachment* self, float x, float y, spBone* bone, float* worldVertices) { int i; float px, py; float* vertices = self->vertices; diff --git a/spine-c/src/spine/Event.c b/spine-c/src/spine/Event.c index 022e42bf5..0f77b6506 100644 --- a/spine-c/src/spine/Event.c +++ b/spine-c/src/spine/Event.c @@ -34,13 +34,13 @@ #include #include -Event* Event_create (EventData* data) { - Event* self = NEW(Event); - CONST_CAST(EventData*, self->data) = data; +spEvent* spEvent_create (spEventData* data) { + spEvent* self = NEW(spEvent); + CONST_CAST(spEventData*, self->data) = data; return self; } -void Event_dispose (Event* self) { +void spEvent_dispose (spEvent* self) { FREE(self->stringValue); FREE(self); } diff --git a/spine-c/src/spine/EventData.c b/spine-c/src/spine/EventData.c index 9b0d3e933..85d304410 100644 --- a/spine-c/src/spine/EventData.c +++ b/spine-c/src/spine/EventData.c @@ -34,13 +34,13 @@ #include #include -EventData* EventData_create (const char* name) { - EventData* self = NEW(EventData); +spEventData* spEventData_create (const char* name) { + spEventData* self = NEW(spEventData); MALLOC_STR(self->name, name); return self; } -void EventData_dispose (EventData* self) { +void spEventData_dispose (spEventData* self) { FREE(self->stringValue); FREE(self->name); FREE(self); diff --git a/spine-c/src/spine/RegionAttachment.c b/spine-c/src/spine/RegionAttachment.c index 431173a3d..04f27bf9f 100644 --- a/spine-c/src/spine/RegionAttachment.c +++ b/spine-c/src/spine/RegionAttachment.c @@ -34,15 +34,15 @@ #include #include -RegionAttachment* RegionAttachment_create (const char* name) { - RegionAttachment* self = NEW(RegionAttachment); +spRegionAttachment* spRegionAttachment_create (const char* name) { + spRegionAttachment* self = NEW(spRegionAttachment); self->scaleX = 1; self->scaleY = 1; - _Attachment_init(SUPER(self), name, ATTACHMENT_REGION, _Attachment_deinit); + _spAttachment_init(SUPER(self), name, ATTACHMENT_REGION, _spAttachment_deinit); return self; } -void RegionAttachment_setUVs (RegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate) { +void spRegionAttachment_setUVs (spRegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate) { if (rotate) { self->uvs[VERTEX_X2] = u; self->uvs[VERTEX_Y2] = v2; @@ -64,7 +64,7 @@ void RegionAttachment_setUVs (RegionAttachment* self, float u, float v, float u2 } } -void RegionAttachment_updateOffset (RegionAttachment* self) { +void spRegionAttachment_updateOffset (spRegionAttachment* self) { float regionScaleX = self->width / self->regionOriginalWidth * self->scaleX; float regionScaleY = self->height / self->regionOriginalHeight * self->scaleY; float localX = -self->width / 2 * self->scaleX + self->regionOffsetX * regionScaleX; @@ -97,7 +97,7 @@ void RegionAttachment_updateOffset (RegionAttachment* self) { self->offset[VERTEX_Y4] = localYCos + localX2Sin; } -void RegionAttachment_computeWorldVertices (RegionAttachment* self, float x, float y, Bone* bone, float* vertices) { +void spRegionAttachment_computeWorldVertices (spRegionAttachment* self, float x, float y, spBone* bone, float* vertices) { float* offset = self->offset; x += bone->worldX; y += bone->worldY; diff --git a/spine-c/src/spine/Skeleton.c b/spine-c/src/spine/Skeleton.c index 797b305ef..9c6ea3075 100644 --- a/spine-c/src/spine/Skeleton.c +++ b/spine-c/src/spine/Skeleton.c @@ -35,18 +35,18 @@ #include #include -Skeleton* Skeleton_create (SkeletonData* data) { +spSkeleton* spSkeleton_create (spSkeletonData* data) { int i, ii; - Skeleton* self = NEW(Skeleton); - CONST_CAST(SkeletonData*, self->data) = data; + spSkeleton* self = NEW(spSkeleton); + CONST_CAST(spSkeletonData*, self->data) = data; self->boneCount = self->data->boneCount; - self->bones = MALLOC(Bone*, self->boneCount); + self->bones = MALLOC(spBone*, self->boneCount); for (i = 0; i < self->boneCount; ++i) { - BoneData* boneData = self->data->bones[i]; - Bone* parent = 0; + spBoneData* boneData = self->data->bones[i]; + spBone* parent = 0; if (boneData->parent) { /* Find parent bone. */ for (ii = 0; ii < self->boneCount; ++ii) { @@ -56,28 +56,28 @@ Skeleton* Skeleton_create (SkeletonData* data) { } } } - self->bones[i] = Bone_create(boneData, parent); + self->bones[i] = spBone_create(boneData, parent); } - CONST_CAST(Bone*, self->root) = self->bones[0]; + CONST_CAST(spBone*, self->root) = self->bones[0]; self->slotCount = data->slotCount; - self->slots = MALLOC(Slot*, self->slotCount); + self->slots = MALLOC(spSlot*, self->slotCount); for (i = 0; i < self->slotCount; ++i) { - SlotData *slotData = data->slots[i]; + spSlotData *slotData = data->slots[i]; /* Find bone for the slotData's boneData. */ - Bone* bone = 0; + spBone* bone = 0; for (ii = 0; ii < self->boneCount; ++ii) { if (data->bones[ii] == slotData->boneData) { bone = self->bones[ii]; break; } } - self->slots[i] = Slot_create(slotData, self, bone); + self->slots[i] = spSlot_create(slotData, self, bone); } - self->drawOrder = MALLOC(Slot*, self->slotCount); - memcpy(self->drawOrder, self->slots, sizeof(Slot*) * self->slotCount); + self->drawOrder = MALLOC(spSlot*, self->slotCount); + memcpy(self->drawOrder, self->slots, sizeof(spSlot*) * self->slotCount); self->r = 1; self->g = 1; @@ -87,118 +87,118 @@ Skeleton* Skeleton_create (SkeletonData* data) { return self; } -void Skeleton_dispose (Skeleton* self) { +void spSkeleton_dispose (spSkeleton* self) { int i; for (i = 0; i < self->boneCount; ++i) - Bone_dispose(self->bones[i]); + spBone_dispose(self->bones[i]); FREE(self->bones); for (i = 0; i < self->slotCount; ++i) - Slot_dispose(self->slots[i]); + spSlot_dispose(self->slots[i]); FREE(self->slots); FREE(self->drawOrder); FREE(self); } -void Skeleton_updateWorldTransform (const Skeleton* self) { +void spSkeleton_updateWorldTransform (const spSkeleton* self) { int i; for (i = 0; i < self->boneCount; ++i) - Bone_updateWorldTransform(self->bones[i], self->flipX, self->flipY); + spBone_updateWorldTransform(self->bones[i], self->flipX, self->flipY); } -void Skeleton_setToSetupPose (const Skeleton* self) { - Skeleton_setBonesToSetupPose(self); - Skeleton_setSlotsToSetupPose(self); +void spSkeleton_setToSetupPose (const spSkeleton* self) { + spSkeleton_setBonesToSetupPose(self); + spSkeleton_setSlotsToSetupPose(self); } -void Skeleton_setBonesToSetupPose (const Skeleton* self) { +void spSkeleton_setBonesToSetupPose (const spSkeleton* self) { int i; for (i = 0; i < self->boneCount; ++i) - Bone_setToSetupPose(self->bones[i]); + spBone_setToSetupPose(self->bones[i]); } -void Skeleton_setSlotsToSetupPose (const Skeleton* self) { +void spSkeleton_setSlotsToSetupPose (const spSkeleton* self) { int i; memcpy(self->drawOrder, self->slots, self->slotCount * sizeof(int)); for (i = 0; i < self->slotCount; ++i) - Slot_setToSetupPose(self->slots[i]); + spSlot_setToSetupPose(self->slots[i]); } -Bone* Skeleton_findBone (const Skeleton* self, const char* boneName) { +spBone* spSkeleton_findBone (const spSkeleton* self, const char* boneName) { int i; for (i = 0; i < self->boneCount; ++i) if (strcmp(self->data->bones[i]->name, boneName) == 0) return self->bones[i]; return 0; } -int Skeleton_findBoneIndex (const Skeleton* self, const char* boneName) { +int spSkeleton_findBoneIndex (const spSkeleton* self, const char* boneName) { int i; for (i = 0; i < self->boneCount; ++i) if (strcmp(self->data->bones[i]->name, boneName) == 0) return i; return -1; } -Slot* Skeleton_findSlot (const Skeleton* self, const char* slotName) { +spSlot* spSkeleton_findSlot (const spSkeleton* self, const char* slotName) { int i; for (i = 0; i < self->slotCount; ++i) if (strcmp(self->data->slots[i]->name, slotName) == 0) return self->slots[i]; return 0; } -int Skeleton_findSlotIndex (const Skeleton* self, const char* slotName) { +int spSkeleton_findSlotIndex (const spSkeleton* self, const char* slotName) { int i; for (i = 0; i < self->slotCount; ++i) if (strcmp(self->data->slots[i]->name, slotName) == 0) return i; return -1; } -int Skeleton_setSkinByName (Skeleton* self, const char* skinName) { - Skin *skin; +int spSkeleton_setSkinByName (spSkeleton* self, const char* skinName) { + spSkin *skin; if (!skinName) { - Skeleton_setSkin(self, 0); + spSkeleton_setSkin(self, 0); return 1; } - skin = SkeletonData_findSkin(self->data, skinName); + skin = spSkeletonData_findSkin(self->data, skinName); if (!skin) return 0; - Skeleton_setSkin(self, skin); + spSkeleton_setSkin(self, skin); return 1; } -void Skeleton_setSkin (Skeleton* self, Skin* newSkin) { - if (self->skin && newSkin) Skin_attachAll(newSkin, self, self->skin); - CONST_CAST(Skin*, self->skin) = newSkin; +void spSkeleton_setSkin (spSkeleton* self, spSkin* newSkin) { + if (self->skin && newSkin) spSkin_attachAll(newSkin, self, self->skin); + CONST_CAST(spSkin*, self->skin) = newSkin; } -Attachment* Skeleton_getAttachmentForSlotName (const Skeleton* self, const char* slotName, const char* attachmentName) { - int slotIndex = SkeletonData_findSlotIndex(self->data, slotName); - return Skeleton_getAttachmentForSlotIndex(self, slotIndex, attachmentName); +spAttachment* spSkeleton_getAttachmentForSlotName (const spSkeleton* self, const char* slotName, const char* attachmentName) { + int slotIndex = spSkeletonData_findSlotIndex(self->data, slotName); + return spSkeleton_getAttachmentForSlotIndex(self, slotIndex, attachmentName); } -Attachment* Skeleton_getAttachmentForSlotIndex (const Skeleton* self, int slotIndex, const char* attachmentName) { +spAttachment* spSkeleton_getAttachmentForSlotIndex (const spSkeleton* self, int slotIndex, const char* attachmentName) { if (slotIndex == -1) return 0; if (self->skin) { - Attachment *attachment = Skin_getAttachment(self->skin, slotIndex, attachmentName); + spAttachment *attachment = spSkin_getAttachment(self->skin, slotIndex, attachmentName); if (attachment) return attachment; } if (self->data->defaultSkin) { - Attachment *attachment = Skin_getAttachment(self->data->defaultSkin, slotIndex, attachmentName); + spAttachment *attachment = spSkin_getAttachment(self->data->defaultSkin, slotIndex, attachmentName); if (attachment) return attachment; } return 0; } -int Skeleton_setAttachment (Skeleton* self, const char* slotName, const char* attachmentName) { +int spSkeleton_setAttachment (spSkeleton* self, const char* slotName, const char* attachmentName) { int i; for (i = 0; i < self->slotCount; ++i) { - Slot *slot = self->slots[i]; + spSlot *slot = self->slots[i]; if (strcmp(slot->data->name, slotName) == 0) { if (!attachmentName) - Slot_setAttachment(slot, 0); + spSlot_setAttachment(slot, 0); else { - Attachment* attachment = Skeleton_getAttachmentForSlotIndex(self, i, attachmentName); + spAttachment* attachment = spSkeleton_getAttachmentForSlotIndex(self, i, attachmentName); if (!attachment) return 0; - Slot_setAttachment(slot, attachment); + spSlot_setAttachment(slot, attachment); } return 1; } @@ -206,6 +206,6 @@ int Skeleton_setAttachment (Skeleton* self, const char* slotName, const char* at return 0; } -void Skeleton_update (Skeleton* self, float deltaTime) { +void spSkeleton_update (spSkeleton* self, float deltaTime) { self->time += deltaTime; } diff --git a/spine-c/src/spine/SkeletonBounds.c b/spine-c/src/spine/SkeletonBounds.c index 90f44f605..68eeaa742 100644 --- a/spine-c/src/spine/SkeletonBounds.c +++ b/spine-c/src/spine/SkeletonBounds.c @@ -35,19 +35,19 @@ #include #include -BoundingPolygon* BoundingPolygon_create (int capacity) { - BoundingPolygon* self = NEW(BoundingPolygon); +spBoundingPolygon* spBoundingPolygon_create (int capacity) { + spBoundingPolygon* self = NEW(spBoundingPolygon); self->capacity = capacity; CONST_CAST(float*, self->vertices) = MALLOC(float, capacity); return self; } -void BoundingPolygon_dispose (BoundingPolygon* self) { +void spBoundingPolygon_dispose (spBoundingPolygon* self) { FREE(self->vertices); FREE(self); } -int/*bool*/BoundingPolygon_containsPoint (BoundingPolygon* self, float x, float y) { +int/*bool*/spBoundingPolygon_containsPoint (spBoundingPolygon* self, float x, float y) { int prevIndex = self->count - 2; int inside = 0; int i; @@ -63,7 +63,7 @@ int/*bool*/BoundingPolygon_containsPoint (BoundingPolygon* self, float x, float return inside; } -int/*bool*/BoundingPolygon_intersectsSegment (BoundingPolygon* self, float x1, float y1, float x2, float y2) { +int/*bool*/spBoundingPolygon_intersectsSegment (spBoundingPolygon* self, float x1, float y1, float x2, float y2) { float width12 = x1 - x2, height12 = y1 - y2; float det1 = x1 * y2 - y1 * x2; float x3 = self->vertices[self->count - 2], y3 = self->vertices[self->count - 1]; @@ -87,34 +87,34 @@ int/*bool*/BoundingPolygon_intersectsSegment (BoundingPolygon* self, float x1, f /**/ typedef struct { - SkeletonBounds super; + spSkeletonBounds super; int capacity; -} _SkeletonBounds; +} _spSkeletonBounds; -SkeletonBounds* SkeletonBounds_create () { - return SUPER(NEW(_SkeletonBounds)); +spSkeletonBounds* spSkeletonBounds_create () { + return SUPER(NEW(_spSkeletonBounds)); } -void SkeletonBounds_dispose (SkeletonBounds* self) { +void spSkeletonBounds_dispose (spSkeletonBounds* self) { int i; - for (i = 0; i < SUB_CAST(_SkeletonBounds, self)->capacity; ++i) - if (self->polygons[i]) BoundingPolygon_dispose(self->polygons[i]); + for (i = 0; i < SUB_CAST(_spSkeletonBounds, self)->capacity; ++i) + if (self->polygons[i]) spBoundingPolygon_dispose(self->polygons[i]); FREE(self->polygons); FREE(self->boundingBoxes); FREE(self); } -void SkeletonBounds_update (SkeletonBounds* self, Skeleton* skeleton, int/*bool*/updateAabb) { +void spSkeletonBounds_update (spSkeletonBounds* self, spSkeleton* skeleton, int/*bool*/updateAabb) { int i; - _SkeletonBounds* internal = SUB_CAST(_SkeletonBounds, self); + _spSkeletonBounds* internal = SUB_CAST(_spSkeletonBounds, self); if (internal->capacity < skeleton->slotCount) { - BoundingPolygon** newPolygons; + spBoundingPolygon** newPolygons; FREE(self->boundingBoxes); - self->boundingBoxes = MALLOC(BoundingBoxAttachment*, skeleton->slotCount); + self->boundingBoxes = MALLOC(spBoundingBoxAttachment*, skeleton->slotCount); - newPolygons = CALLOC(BoundingPolygon*, skeleton->slotCount); + newPolygons = CALLOC(spBoundingPolygon*, skeleton->slotCount); memcpy(newPolygons, self->polygons, internal->capacity); FREE(self->polygons); self->polygons = newPolygons; @@ -129,22 +129,22 @@ void SkeletonBounds_update (SkeletonBounds* self, Skeleton* skeleton, int/*bool* self->count = 0; for (i = 0; i < skeleton->slotCount; ++i) { - BoundingPolygon* polygon; - BoundingBoxAttachment* boundingBox; + spBoundingPolygon* polygon; + spBoundingBoxAttachment* boundingBox; - Slot* slot = skeleton->slots[i]; - Attachment* attachment = slot->attachment; + spSlot* slot = skeleton->slots[i]; + spAttachment* attachment = slot->attachment; if (!attachment || attachment->type != ATTACHMENT_BOUNDING_BOX) continue; - boundingBox = (BoundingBoxAttachment*)attachment; + boundingBox = (spBoundingBoxAttachment*)attachment; self->boundingBoxes[self->count] = boundingBox; polygon = self->polygons[self->count]; if (!polygon || polygon->capacity < boundingBox->verticesCount) { - if (polygon) BoundingPolygon_dispose(polygon); - self->polygons[self->count] = polygon = BoundingPolygon_create(boundingBox->verticesCount); + if (polygon) spBoundingPolygon_dispose(polygon); + self->polygons[self->count] = polygon = spBoundingPolygon_create(boundingBox->verticesCount); } polygon->count = boundingBox->verticesCount; - BoundingBoxAttachment_computeWorldVertices(boundingBox, skeleton->x, skeleton->y, slot->bone, polygon->vertices); + spBoundingBoxAttachment_computeWorldVertices(boundingBox, skeleton->x, skeleton->y, slot->bone, polygon->vertices); if (updateAabb) { int ii = 0; @@ -162,11 +162,11 @@ void SkeletonBounds_update (SkeletonBounds* self, Skeleton* skeleton, int/*bool* } } -int/*bool*/SkeletonBounds_aabbContainsPoint (SkeletonBounds* self, float x, float y) { +int/*bool*/spSkeletonBounds_aabbContainsPoint (spSkeletonBounds* self, float x, float y) { return x >= self->minX && x <= self->maxX && y >= self->minY && y <= self->maxY; } -int/*bool*/SkeletonBounds_aabbIntersectsSegment (SkeletonBounds* self, float x1, float y1, float x2, float y2) { +int/*bool*/spSkeletonBounds_aabbIntersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2) { float m, x, y; if ((x1 <= self->minX && x2 <= self->minX) || (y1 <= self->minY && y2 <= self->minY) || (x1 >= self->maxX && x2 >= self->maxX) || (y1 >= self->maxY && y2 >= self->maxY)) return 0; @@ -182,25 +182,25 @@ int/*bool*/SkeletonBounds_aabbIntersectsSegment (SkeletonBounds* self, float x1, return 0; } -int/*bool*/SkeletonBounds_aabbIntersectsSkeleton (SkeletonBounds* self, SkeletonBounds* bounds) { +int/*bool*/spSkeletonBounds_aabbIntersectsSkeleton (spSkeletonBounds* self, spSkeletonBounds* bounds) { return self->minX < bounds->maxX && self->maxX > bounds->minX && self->minY < bounds->maxY && self->maxY > bounds->minY; } -BoundingBoxAttachment* SkeletonBounds_containsPoint (SkeletonBounds* self, float x, float y) { +spBoundingBoxAttachment* spSkeletonBounds_containsPoint (spSkeletonBounds* self, float x, float y) { int i; for (i = 0; i < self->count; ++i) - if (BoundingPolygon_containsPoint(self->polygons[i], x, y)) return self->boundingBoxes[i]; + if (spBoundingPolygon_containsPoint(self->polygons[i], x, y)) return self->boundingBoxes[i]; return 0; } -BoundingBoxAttachment* SkeletonBounds_intersectsSegment (SkeletonBounds* self, float x1, float y1, float x2, float y2) { +spBoundingBoxAttachment* spSkeletonBounds_intersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2) { int i; for (i = 0; i < self->count; ++i) - if (BoundingPolygon_intersectsSegment(self->polygons[i], x1, y1, x2, y2)) return self->boundingBoxes[i]; + if (spBoundingPolygon_intersectsSegment(self->polygons[i], x1, y1, x2, y2)) return self->boundingBoxes[i]; return 0; } -BoundingPolygon* SkeletonBounds_getPolygon (SkeletonBounds* self, BoundingBoxAttachment* boundingBox) { +spBoundingPolygon* spSkeletonBounds_getPolygon (spSkeletonBounds* self, spBoundingBoxAttachment* boundingBox) { int i; for (i = 0; i < self->count; ++i) if (self->boundingBoxes[i] == boundingBox) return self->polygons[i]; diff --git a/spine-c/src/spine/SkeletonData.c b/spine-c/src/spine/SkeletonData.c index b601d6bca..c1a78c992 100644 --- a/spine-c/src/spine/SkeletonData.c +++ b/spine-c/src/spine/SkeletonData.c @@ -35,74 +35,74 @@ #include #include -SkeletonData* SkeletonData_create () { - return NEW(SkeletonData); +spSkeletonData* spSkeletonData_create () { + return NEW(spSkeletonData); } -void SkeletonData_dispose (SkeletonData* self) { +void spSkeletonData_dispose (spSkeletonData* self) { int i; for (i = 0; i < self->boneCount; ++i) - BoneData_dispose(self->bones[i]); + spBoneData_dispose(self->bones[i]); FREE(self->bones); for (i = 0; i < self->slotCount; ++i) - SlotData_dispose(self->slots[i]); + spSlotData_dispose(self->slots[i]); FREE(self->slots); for (i = 0; i < self->skinCount; ++i) - Skin_dispose(self->skins[i]); + spSkin_dispose(self->skins[i]); FREE(self->skins); for (i = 0; i < self->animationCount; ++i) - Animation_dispose(self->animations[i]); + spAnimation_dispose(self->animations[i]); FREE(self->animations); FREE(self); } -BoneData* SkeletonData_findBone (const SkeletonData* self, const char* boneName) { +spBoneData* spSkeletonData_findBone (const spSkeletonData* self, const char* boneName) { int i; for (i = 0; i < self->boneCount; ++i) if (strcmp(self->bones[i]->name, boneName) == 0) return self->bones[i]; return 0; } -int SkeletonData_findBoneIndex (const SkeletonData* self, const char* boneName) { +int spSkeletonData_findBoneIndex (const spSkeletonData* self, const char* boneName) { int i; for (i = 0; i < self->boneCount; ++i) if (strcmp(self->bones[i]->name, boneName) == 0) return i; return 0; } -SlotData* SkeletonData_findSlot (const SkeletonData* self, const char* slotName) { +spSlotData* spSkeletonData_findSlot (const spSkeletonData* self, const char* slotName) { int i; for (i = 0; i < self->slotCount; ++i) if (strcmp(self->slots[i]->name, slotName) == 0) return self->slots[i]; return 0; } -int SkeletonData_findSlotIndex (const SkeletonData* self, const char* slotName) { +int spSkeletonData_findSlotIndex (const spSkeletonData* self, const char* slotName) { int i; for (i = 0; i < self->slotCount; ++i) if (strcmp(self->slots[i]->name, slotName) == 0) return i; return 0; } -Skin* SkeletonData_findSkin (const SkeletonData* self, const char* skinName) { +spSkin* spSkeletonData_findSkin (const spSkeletonData* self, const char* skinName) { int i; for (i = 0; i < self->skinCount; ++i) if (strcmp(self->skins[i]->name, skinName) == 0) return self->skins[i]; return 0; } -EventData* SkeletonData_findEvent (const SkeletonData* self, const char* eventName) { +spEventData* spSkeletonData_findEvent (const spSkeletonData* self, const char* eventName) { int i; for (i = 0; i < self->eventCount; ++i) if (strcmp(self->events[i]->name, eventName) == 0) return self->events[i]; return 0; } -Animation* SkeletonData_findAnimation (const SkeletonData* self, const char* animationName) { +spAnimation* spSkeletonData_findAnimation (const spSkeletonData* self, const char* animationName) { int i; for (i = 0; i < self->animationCount; ++i) if (strcmp(self->animations[i]->name, animationName) == 0) return self->animations[i]; diff --git a/spine-c/src/spine/SkeletonJson.c b/spine-c/src/spine/SkeletonJson.c index 0f4fdd424..ade30dcb6 100644 --- a/spine-c/src/spine/SkeletonJson.c +++ b/spine-c/src/spine/SkeletonJson.c @@ -39,31 +39,31 @@ #include typedef struct { - SkeletonJson super; + spSkeletonJson super; int ownsLoader; -} _SkeletonJson; +} _spSkeletonJson; -SkeletonJson* SkeletonJson_createWithLoader (AttachmentLoader* attachmentLoader) { - SkeletonJson* self = SUPER(NEW(_SkeletonJson)); +spSkeletonJson* spSkeletonJson_createWithLoader (spAttachmentLoader* attachmentLoader) { + spSkeletonJson* self = SUPER(NEW(_spSkeletonJson)); self->scale = 1; self->attachmentLoader = attachmentLoader; return self; } -SkeletonJson* SkeletonJson_create (Atlas* atlas) { - AtlasAttachmentLoader* attachmentLoader = AtlasAttachmentLoader_create(atlas); - SkeletonJson* self = SkeletonJson_createWithLoader(SUPER(attachmentLoader)); - SUB_CAST(_SkeletonJson, self)->ownsLoader = 1; +spSkeletonJson* spSkeletonJson_create (spAtlas* atlas) { + spAtlasAttachmentLoader* attachmentLoader = spAtlasAttachmentLoader_create(atlas); + spSkeletonJson* self = spSkeletonJson_createWithLoader(SUPER(attachmentLoader)); + SUB_CAST(_spSkeletonJson, self)->ownsLoader = 1; return self; } -void SkeletonJson_dispose (SkeletonJson* self) { - if (SUB_CAST(_SkeletonJson, self)->ownsLoader) AttachmentLoader_dispose(self->attachmentLoader); +void spSkeletonJson_dispose (spSkeletonJson* self) { + if (SUB_CAST(_spSkeletonJson, self)->ownsLoader) spAttachmentLoader_dispose(self->attachmentLoader); FREE(self->error); FREE(self); } -void _SkeletonJson_setError (SkeletonJson* self, Json* root, const char* value1, const char* value2) { +void _spSkeletonJson_setError (spSkeletonJson* self, Json* root, const char* value1, const char* value2) { char message[256]; int length; FREE(self->error); @@ -90,24 +90,24 @@ static float toColor (const char* value, int index) { return color / (float)255; } -static void readCurve (CurveTimeline* timeline, int frameIndex, Json* frame) { +static void readCurve (spCurveTimeline* timeline, int frameIndex, Json* frame) { Json* curve = Json_getItem(frame, "curve"); if (!curve) return; if (curve->type == Json_String && strcmp(curve->valueString, "stepped") == 0) - CurveTimeline_setStepped(timeline, frameIndex); + spCurveTimeline_setStepped(timeline, frameIndex); else if (curve->type == Json_Array) { Json* child0 = curve->child; Json* child1 = child0->next; Json* child2 = child1->next; Json* child3 = child2->next; - CurveTimeline_setCurve(timeline, frameIndex, child0->valueFloat, child1->valueFloat, child2->valueFloat, + spCurveTimeline_setCurve(timeline, frameIndex, child0->valueFloat, child1->valueFloat, child2->valueFloat, child3->valueFloat); } } -static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, SkeletonData *skeletonData) { +static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* root, spSkeletonData *skeletonData) { int i; - Animation* animation; + spAnimation* animation; Json* bones = Json_getItem(root, "bones"); Json* slots = Json_getItem(root, "slots"); @@ -123,7 +123,7 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S if (events) ++timelineCount; if (drawOrder) ++timelineCount; - animation = Animation_create(root->name, timelineCount); + animation = spAnimation_create(root->name, timelineCount); animation->timelineCount = 0; skeletonData->animations[skeletonData->animationCount] = animation; ++skeletonData->animationCount; @@ -131,10 +131,10 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S for (boneMap = bones ? bones->child : 0; boneMap; boneMap = boneMap->next) { Json *timelineArray; - int boneIndex = SkeletonData_findBoneIndex(skeletonData, boneMap->name); + int boneIndex = spSkeletonData_findBoneIndex(skeletonData, boneMap->name); if (boneIndex == -1) { - Animation_dispose(animation); - _SkeletonJson_setError(self, root, "Bone not found: ", boneMap->name); + spAnimation_dispose(animation); + _spSkeletonJson_setError(self, root, "spBone not found: ", boneMap->name); return 0; } @@ -143,13 +143,13 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S float duration; if (strcmp(timelineArray->name, "rotate") == 0) { - RotateTimeline *timeline = RotateTimeline_create(timelineArray->size); + spRotateTimeline *timeline = spRotateTimeline_create(timelineArray->size); timeline->boneIndex = boneIndex; for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) { - RotateTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), Json_getFloat(frame, "angle", 0)); + spRotateTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), Json_getFloat(frame, "angle", 0)); readCurve(SUPER(timeline), i, frame); } - animation->timelines[animation->timelineCount++] = (Timeline*)timeline; + animation->timelines[animation->timelineCount++] = (spTimeline*)timeline; duration = timeline->frames[timelineArray->size * 2 - 2]; if (duration > animation->duration) animation->duration = duration; @@ -157,20 +157,20 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S int isScale = strcmp(timelineArray->name, "scale") == 0; if (isScale || strcmp(timelineArray->name, "translate") == 0) { float scale = isScale ? 1 : self->scale; - TranslateTimeline *timeline = - isScale ? ScaleTimeline_create(timelineArray->size) : TranslateTimeline_create(timelineArray->size); + spTranslateTimeline *timeline = + isScale ? spScaleTimeline_create(timelineArray->size) : spTranslateTimeline_create(timelineArray->size); timeline->boneIndex = boneIndex; for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) { - TranslateTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), Json_getFloat(frame, "x", 0) * scale, + spTranslateTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), Json_getFloat(frame, "x", 0) * scale, Json_getFloat(frame, "y", 0) * scale); readCurve(SUPER(timeline), i, frame); } - animation->timelines[animation->timelineCount++] = (Timeline*)timeline; + animation->timelines[animation->timelineCount++] = (spTimeline*)timeline; duration = timeline->frames[timelineArray->size * 3 - 3]; if (duration > animation->duration) animation->duration = duration; } else { - Animation_dispose(animation); - _SkeletonJson_setError(self, 0, "Invalid timeline type for a bone: ", timelineArray->name); + spAnimation_dispose(animation); + _spSkeletonJson_setError(self, 0, "Invalid timeline type for a bone: ", timelineArray->name); return 0; } } @@ -180,10 +180,10 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S for (slotMap = slots ? slots->child : 0; slotMap; slotMap = slotMap->next) { Json *timelineArray; - int slotIndex = SkeletonData_findSlotIndex(skeletonData, slotMap->name); + int slotIndex = spSkeletonData_findSlotIndex(skeletonData, slotMap->name); if (slotIndex == -1) { - Animation_dispose(animation); - _SkeletonJson_setError(self, root, "Slot not found: ", slotMap->name); + spAnimation_dispose(animation); + _spSkeletonJson_setError(self, root, "Slot not found: ", slotMap->name); return 0; } @@ -192,33 +192,33 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S float duration; if (strcmp(timelineArray->name, "color") == 0) { - ColorTimeline *timeline = ColorTimeline_create(timelineArray->size); + spColorTimeline *timeline = spColorTimeline_create(timelineArray->size); timeline->slotIndex = slotIndex; for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) { const char* s = Json_getString(frame, "color", 0); - ColorTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), toColor(s, 0), toColor(s, 1), toColor(s, 2), + spColorTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), toColor(s, 0), toColor(s, 1), toColor(s, 2), toColor(s, 3)); readCurve(SUPER(timeline), i, frame); } - animation->timelines[animation->timelineCount++] = (Timeline*)timeline; + animation->timelines[animation->timelineCount++] = (spTimeline*)timeline; duration = timeline->frames[timelineArray->size * 5 - 5]; if (duration > animation->duration) animation->duration = duration; } else if (strcmp(timelineArray->name, "attachment") == 0) { - AttachmentTimeline *timeline = AttachmentTimeline_create(timelineArray->size); + spAttachmentTimeline *timeline = spAttachmentTimeline_create(timelineArray->size); timeline->slotIndex = slotIndex; for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) { Json* name = Json_getItem(frame, "name"); - AttachmentTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), + spAttachmentTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), name->type == Json_NULL ? 0 : name->valueString); } - animation->timelines[animation->timelineCount++] = (Timeline*)timeline; + animation->timelines[animation->timelineCount++] = (spTimeline*)timeline; duration = timeline->frames[timelineArray->size - 1]; if (duration > animation->duration) animation->duration = duration; } else { - Animation_dispose(animation); - _SkeletonJson_setError(self, 0, "Invalid timeline type for a slot: ", timelineArray->name); + spAnimation_dispose(animation); + _spSkeletonJson_setError(self, 0, "Invalid timeline type for a slot: ", timelineArray->name); return 0; } } @@ -228,24 +228,24 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S Json* frame; float duration; - EventTimeline* timeline = EventTimeline_create(events->size); + spEventTimeline* timeline = spEventTimeline_create(events->size); for (frame = events->child, i = 0; frame; frame = frame->next, ++i) { - Event* event; + spEvent* event; const char* stringValue; - EventData* eventData = SkeletonData_findEvent(skeletonData, Json_getString(frame, "name", 0)); + spEventData* eventData = spSkeletonData_findEvent(skeletonData, Json_getString(frame, "name", 0)); if (!eventData) { - Animation_dispose(animation); - _SkeletonJson_setError(self, 0, "Event not found: ", Json_getString(frame, "name", 0)); + spAnimation_dispose(animation); + _spSkeletonJson_setError(self, 0, "Event not found: ", Json_getString(frame, "name", 0)); return 0; } - event = Event_create(eventData); + event = spEvent_create(eventData); event->intValue = Json_getInt(frame, "int", eventData->intValue); event->floatValue = Json_getFloat(frame, "float", eventData->floatValue); stringValue = Json_getString(frame, "string", eventData->stringValue); if (stringValue) MALLOC_STR(event->stringValue, stringValue); - EventTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), event); + spEventTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), event); } - animation->timelines[animation->timelineCount++] = (Timeline*)timeline; + animation->timelines[animation->timelineCount++] = (spTimeline*)timeline; duration = timeline->frames[events->size - 1]; if (duration > animation->duration) animation->duration = duration; } @@ -254,7 +254,7 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S Json* frame; float duration; - DrawOrderTimeline* timeline = DrawOrderTimeline_create(drawOrder->size, skeletonData->slotCount); + spDrawOrderTimeline* timeline = spDrawOrderTimeline_create(drawOrder->size, skeletonData->slotCount); for (frame = drawOrder->child, i = 0; frame; frame = frame->next, ++i) { int ii; int* drawOrder = 0; @@ -269,10 +269,10 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S drawOrder[ii] = -1; for (offsetMap = offsets->child; offsetMap; offsetMap = offsetMap->next) { - int slotIndex = SkeletonData_findSlotIndex(skeletonData, Json_getString(offsetMap, "slot", 0)); + int slotIndex = spSkeletonData_findSlotIndex(skeletonData, Json_getString(offsetMap, "slot", 0)); if (slotIndex == -1) { - Animation_dispose(animation); - _SkeletonJson_setError(self, 0, "Slot not found: ", Json_getString(offsetMap, "slot", 0)); + spAnimation_dispose(animation); + _spSkeletonJson_setError(self, 0, "Slot not found: ", Json_getString(offsetMap, "slot", 0)); return 0; } /* Collect unchanged items. */ @@ -290,10 +290,10 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S if (drawOrder[ii] == -1) drawOrder[ii] = unchanged[--unchangedIndex]; FREE(unchanged); } - DrawOrderTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), drawOrder); + spDrawOrderTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), drawOrder); FREE(drawOrder); } - animation->timelines[animation->timelineCount++] = (Timeline*)timeline; + animation->timelines[animation->timelineCount++] = (spTimeline*)timeline; duration = timeline->frames[drawOrder->size - 1]; if (duration > animation->duration) animation->duration = duration; } @@ -301,22 +301,22 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S return animation; } -SkeletonData* SkeletonJson_readSkeletonDataFile (SkeletonJson* self, const char* path) { +spSkeletonData* spSkeletonJson_readSkeletonDataFile (spSkeletonJson* self, const char* path) { int length; - SkeletonData* skeletonData; - const char* json = _Util_readFile(path, &length); + spSkeletonData* skeletonData; + const char* json = _spUtil_readFile(path, &length); if (!json) { - _SkeletonJson_setError(self, 0, "Unable to read skeleton file: ", path); + _spSkeletonJson_setError(self, 0, "Unable to read skeleton file: ", path); return 0; } - skeletonData = SkeletonJson_readSkeletonData(self, json); + skeletonData = spSkeletonJson_readSkeletonData(self, json); FREE(json); return skeletonData; } -SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* json) { +spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const char* json) { int i; - SkeletonData* skeletonData; + spSkeletonData* skeletonData; Json *root, *bones, *boneMap, *slots, *skins, *animations, *events; FREE(self->error); @@ -324,29 +324,29 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso root = Json_create(json); if (!root) { - _SkeletonJson_setError(self, 0, "Invalid skeleton JSON: ", Json_getError()); + _spSkeletonJson_setError(self, 0, "Invalid skeleton JSON: ", Json_getError()); return 0; } - skeletonData = SkeletonData_create(); + skeletonData = spSkeletonData_create(); bones = Json_getItem(root, "bones"); - skeletonData->bones = MALLOC(BoneData*, bones->size); + skeletonData->bones = MALLOC(spBoneData*, bones->size); for (boneMap = bones->child, i = 0; boneMap; boneMap = boneMap->next, ++i) { - BoneData* boneData; + spBoneData* boneData; - BoneData* parent = 0; + spBoneData* parent = 0; const char* parentName = Json_getString(boneMap, "parent", 0); if (parentName) { - parent = SkeletonData_findBone(skeletonData, parentName); + parent = spSkeletonData_findBone(skeletonData, parentName); if (!parent) { - SkeletonData_dispose(skeletonData); - _SkeletonJson_setError(self, root, "Parent bone not found: ", parentName); + spSkeletonData_dispose(skeletonData); + _spSkeletonJson_setError(self, root, "Parent bone not found: ", parentName); return 0; } } - boneData = BoneData_create(Json_getString(boneMap, "name", 0), parent); + boneData = spBoneData_create(Json_getString(boneMap, "name", 0), parent); boneData->length = Json_getFloat(boneMap, "length", 0) * self->scale; boneData->x = Json_getFloat(boneMap, "x", 0) * self->scale; boneData->y = Json_getFloat(boneMap, "y", 0) * self->scale; @@ -363,21 +363,21 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso slots = Json_getItem(root, "slots"); if (slots) { Json *slotMap; - skeletonData->slots = MALLOC(SlotData*, slots->size); + skeletonData->slots = MALLOC(spSlotData*, slots->size); for (slotMap = slots->child, i = 0; slotMap; slotMap = slotMap->next, ++i) { - SlotData* slotData; + spSlotData* slotData; const char* color; Json *attachmentItem; const char* boneName = Json_getString(slotMap, "bone", 0); - BoneData* boneData = SkeletonData_findBone(skeletonData, boneName); + spBoneData* boneData = spSkeletonData_findBone(skeletonData, boneName); if (!boneData) { - SkeletonData_dispose(skeletonData); - _SkeletonJson_setError(self, root, "Slot bone not found: ", boneName); + spSkeletonData_dispose(skeletonData); + _spSkeletonJson_setError(self, root, "spSlot bone not found: ", boneName); return 0; } - slotData = SlotData_create(Json_getString(slotMap, "name", 0), boneData); + slotData = spSlotData_create(Json_getString(slotMap, "name", 0), boneData); color = Json_getString(slotMap, "color", 0); if (color) { @@ -388,7 +388,7 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso } attachmentItem = Json_getItem(slotMap, "attachment"); - if (attachmentItem) SlotData_setAttachmentName(slotData, attachmentItem->valueString); + if (attachmentItem) spSlotData_setAttachmentName(slotData, attachmentItem->valueString); slotData->additiveBlending = Json_getInt(slotMap, "additive", 0); @@ -400,26 +400,26 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso skins = Json_getItem(root, "skins"); if (skins) { Json *slotMap; - skeletonData->skins = MALLOC(Skin*, skins->size); + skeletonData->skins = MALLOC(spSkin*, skins->size); for (slotMap = skins->child, i = 0; slotMap; slotMap = slotMap->next, ++i) { Json *attachmentsMap; - Skin *skin = Skin_create(slotMap->name); + spSkin *skin = spSkin_create(slotMap->name); skeletonData->skins[i] = skin; ++skeletonData->skinCount; if (strcmp(slotMap->name, "default") == 0) skeletonData->defaultSkin = skin; for (attachmentsMap = slotMap->child; attachmentsMap; attachmentsMap = attachmentsMap->next) { - int slotIndex = SkeletonData_findSlotIndex(skeletonData, attachmentsMap->name); + int slotIndex = spSkeletonData_findSlotIndex(skeletonData, attachmentsMap->name); Json *attachmentMap; for (attachmentMap = attachmentsMap->child; attachmentMap; attachmentMap = attachmentMap->next) { - Attachment* attachment; + spAttachment* attachment; const char* skinAttachmentName = attachmentMap->name; const char* attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName); const char* typeString = Json_getString(attachmentMap, "type", "region"); - AttachmentType type; + spAttachmentType type; if (strcmp(typeString, "region") == 0) type = ATTACHMENT_REGION; else if (strcmp(typeString, "boundingbox") == 0) @@ -427,16 +427,16 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso else if (strcmp(typeString, "regionsequence") == 0) type = ATTACHMENT_REGION_SEQUENCE; else { - SkeletonData_dispose(skeletonData); - _SkeletonJson_setError(self, root, "Unknown attachment type: ", typeString); + spSkeletonData_dispose(skeletonData); + _spSkeletonJson_setError(self, root, "Unknown attachment type: ", typeString); return 0; } - attachment = AttachmentLoader_newAttachment(self->attachmentLoader, skin, type, attachmentName); + attachment = spAttachmentLoader_newAttachment(self->attachmentLoader, skin, type, attachmentName); if (!attachment) { if (self->attachmentLoader->error1) { - SkeletonData_dispose(skeletonData); - _SkeletonJson_setError(self, root, self->attachmentLoader->error1, self->attachmentLoader->error2); + spSkeletonData_dispose(skeletonData); + _spSkeletonJson_setError(self, root, self->attachmentLoader->error1, self->attachmentLoader->error2); return 0; } continue; @@ -445,7 +445,7 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso switch (attachment->type) { case ATTACHMENT_REGION: case ATTACHMENT_REGION_SEQUENCE: { - RegionAttachment* regionAttachment = (RegionAttachment*)attachment; + spRegionAttachment* regionAttachment = (spRegionAttachment*)attachment; regionAttachment->x = Json_getFloat(attachmentMap, "x", 0) * self->scale; regionAttachment->y = Json_getFloat(attachmentMap, "y", 0) * self->scale; regionAttachment->scaleX = Json_getFloat(attachmentMap, "scaleX", 1); @@ -453,11 +453,11 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso regionAttachment->rotation = Json_getFloat(attachmentMap, "rotation", 0); regionAttachment->width = Json_getFloat(attachmentMap, "width", 32) * self->scale; regionAttachment->height = Json_getFloat(attachmentMap, "height", 32) * self->scale; - RegionAttachment_updateOffset(regionAttachment); + spRegionAttachment_updateOffset(regionAttachment); break; } case ATTACHMENT_BOUNDING_BOX: { - BoundingBoxAttachment* box = (BoundingBoxAttachment*)attachment; + spBoundingBoxAttachment* box = (spBoundingBoxAttachment*)attachment; Json* verticesArray = Json_getItem(attachmentMap, "vertices"); Json* vertex; int i; @@ -469,7 +469,7 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso } } - Skin_addAttachment(skin, slotIndex, skinAttachmentName, attachment); + spSkin_addAttachment(skin, slotIndex, skinAttachmentName, attachment); } } } @@ -480,9 +480,9 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso if (events) { Json *eventMap; const char* stringValue; - skeletonData->events = MALLOC(EventData*, events->size); + skeletonData->events = MALLOC(spEventData*, events->size); for (eventMap = events->child; eventMap; eventMap = eventMap->next) { - EventData* eventData = EventData_create(eventMap->name); + spEventData* eventData = spEventData_create(eventMap->name); eventData->intValue = Json_getInt(eventMap, "int", 0); eventData->floatValue = Json_getFloat(eventMap, "float", 0); stringValue = Json_getString(eventMap, "string", 0); @@ -495,9 +495,9 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso animations = Json_getItem(root, "animations"); if (animations) { Json *animationMap; - skeletonData->animations = MALLOC(Animation*, animations->size); + skeletonData->animations = MALLOC(spAnimation*, animations->size); for (animationMap = animations->child; animationMap; animationMap = animationMap->next) - _SkeletonJson_readAnimation(self, animationMap, skeletonData); + _spSkeletonJson_readAnimation(self, animationMap, skeletonData); } Json_dispose(root); diff --git a/spine-c/src/spine/Skin.c b/spine-c/src/spine/Skin.c index 27b50d325..081288827 100644 --- a/spine-c/src/spine/Skin.c +++ b/spine-c/src/spine/Skin.c @@ -38,11 +38,11 @@ typedef struct _Entry _Entry; struct _Entry { int slotIndex; const char* name; - Attachment* attachment; + spAttachment* attachment; _Entry* next; }; -_Entry* _Entry_create (int slotIndex, const char* name, Attachment* attachment) { +_Entry* _Entry_create (int slotIndex, const char* name, spAttachment* attachment) { _Entry* self = NEW(_Entry); self->slotIndex = slotIndex; MALLOC_STR(self->name, name); @@ -51,7 +51,7 @@ _Entry* _Entry_create (int slotIndex, const char* name, Attachment* attachment) } void _Entry_dispose (_Entry* self) { - Attachment_dispose(self->attachment); + spAttachment_dispose(self->attachment); FREE(self->name); FREE(self); } @@ -59,18 +59,18 @@ void _Entry_dispose (_Entry* self) { /**/ typedef struct { - Skin super; + spSkin super; _Entry* entries; -} _Skin; +} _spSkin; -Skin* Skin_create (const char* name) { - Skin* self = SUPER(NEW(_Skin)); +spSkin* spSkin_create (const char* name) { + spSkin* self = SUPER(NEW(_spSkin)); MALLOC_STR(self->name, name); return self; } -void Skin_dispose (Skin* self) { - _Entry* entry = SUB_CAST(_Skin, self)->entries; +void spSkin_dispose (spSkin* self) { + _Entry* entry = SUB_CAST(_spSkin, self)->entries; while (entry) { _Entry* nextEntry = entry->next; _Entry_dispose(entry); @@ -81,14 +81,14 @@ void Skin_dispose (Skin* self) { FREE(self); } -void Skin_addAttachment (Skin* self, int slotIndex, const char* name, Attachment* attachment) { +void spSkin_addAttachment (spSkin* self, int slotIndex, const char* name, spAttachment* attachment) { _Entry* newEntry = _Entry_create(slotIndex, name, attachment); - newEntry->next = SUB_CAST(_Skin, self)->entries; - SUB_CAST(_Skin, self)->entries = newEntry; + newEntry->next = SUB_CAST(_spSkin, self)->entries; + SUB_CAST(_spSkin, self)->entries = newEntry; } -Attachment* Skin_getAttachment (const Skin* self, int slotIndex, const char* name) { - const _Entry* entry = SUB_CAST(_Skin, self)->entries; +spAttachment* spSkin_getAttachment (const spSkin* self, int slotIndex, const char* name) { + const _Entry* entry = SUB_CAST(_spSkin, self)->entries; while (entry) { if (entry->slotIndex == slotIndex && strcmp(entry->name, name) == 0) return entry->attachment; entry = entry->next; @@ -96,8 +96,8 @@ 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(_Skin, self)->entries; +const char* spSkin_getAttachmentName (const spSkin* self, int slotIndex, int attachmentIndex) { + const _Entry* entry = SUB_CAST(_spSkin, self)->entries; int i = 0; while (entry) { if (entry->slotIndex == slotIndex) { @@ -109,13 +109,13 @@ const char* Skin_getAttachmentName (const Skin* self, int slotIndex, int attachm return 0; } -void Skin_attachAll (const Skin* self, Skeleton* skeleton, const Skin* oldSkin) { - const _Entry *entry = SUB_CAST(_Skin, oldSkin)->entries; +void spSkin_attachAll (const spSkin* self, spSkeleton* skeleton, const spSkin* oldSkin) { + const _Entry *entry = SUB_CAST(_spSkin, oldSkin)->entries; while (entry) { - Slot *slot = skeleton->slots[entry->slotIndex]; + spSlot *slot = skeleton->slots[entry->slotIndex]; if (slot->attachment == entry->attachment) { - Attachment *attachment = Skin_getAttachment(self, entry->slotIndex, entry->name); - if (attachment) Slot_setAttachment(slot, attachment); + spAttachment *attachment = spSkin_getAttachment(self, entry->slotIndex, entry->name); + if (attachment) spSlot_setAttachment(slot, attachment); } entry = entry->next; } diff --git a/spine-c/src/spine/Slot.c b/spine-c/src/spine/Slot.c index e12a21b1a..3dd572446 100644 --- a/spine-c/src/spine/Slot.c +++ b/spine-c/src/spine/Slot.c @@ -36,38 +36,38 @@ #include typedef struct { - Slot super; + spSlot super; float attachmentTime; -} _Slot; +} _spSlot; -Slot* Slot_create (SlotData* data, Skeleton* skeleton, Bone* bone) { - Slot* self = SUPER(NEW(_Slot)); - CONST_CAST(SlotData*, self->data) = data; - CONST_CAST(Skeleton*, self->skeleton) = skeleton; - CONST_CAST(Bone*, self->bone) = bone; - Slot_setToSetupPose(self); +spSlot* spSlot_create (spSlotData* data, spSkeleton* skeleton, spBone* bone) { + spSlot* self = SUPER(NEW(_spSlot)); + CONST_CAST(spSlotData*, self->data) = data; + CONST_CAST(spSkeleton*, self->skeleton) = skeleton; + CONST_CAST(spBone*, self->bone) = bone; + spSlot_setToSetupPose(self); return self; } -void Slot_dispose (Slot* self) { +void spSlot_dispose (spSlot* self) { FREE(self); } -void Slot_setAttachment (Slot* self, Attachment* attachment) { - CONST_CAST(Attachment*, self->attachment) = attachment; - SUB_CAST(_Slot, self) ->attachmentTime = self->skeleton->time; +void spSlot_setAttachment (spSlot* self, spAttachment* attachment) { + CONST_CAST(spAttachment*, self->attachment) = attachment; + SUB_CAST(_spSlot, self) ->attachmentTime = self->skeleton->time; } -void Slot_setAttachmentTime (Slot* self, float time) { - SUB_CAST(_Slot, self) ->attachmentTime = self->skeleton->time - time; +void spSlot_setAttachmentTime (spSlot* self, float time) { + SUB_CAST(_spSlot, self) ->attachmentTime = self->skeleton->time - time; } -float Slot_getAttachmentTime (const Slot* self) { - return self->skeleton->time - SUB_CAST(_Slot, self) ->attachmentTime; +float spSlot_getAttachmentTime (const spSlot* self) { + return self->skeleton->time - SUB_CAST(_spSlot, self) ->attachmentTime; } -void Slot_setToSetupPose (Slot* self) { - Attachment* attachment = 0; +void spSlot_setToSetupPose (spSlot* self) { + spAttachment* attachment = 0; self->r = self->data->r; self->g = self->data->g; self->b = self->data->b; @@ -78,10 +78,10 @@ void Slot_setToSetupPose (Slot* self) { int i; for (i = 0; i < self->skeleton->data->slotCount; ++i) { if (self->data == self->skeleton->data->slots[i]) { - attachment = Skeleton_getAttachmentForSlotIndex(self->skeleton, i, self->data->attachmentName); + attachment = spSkeleton_getAttachmentForSlotIndex(self->skeleton, i, self->data->attachmentName); break; } } } - Slot_setAttachment(self, attachment); + spSlot_setAttachment(self, attachment); } diff --git a/spine-c/src/spine/SlotData.c b/spine-c/src/spine/SlotData.c index af05ca287..15d7a4ab0 100644 --- a/spine-c/src/spine/SlotData.c +++ b/spine-c/src/spine/SlotData.c @@ -34,10 +34,10 @@ #include #include -SlotData* SlotData_create (const char* name, BoneData* boneData) { - SlotData* self = NEW(SlotData); +spSlotData* spSlotData_create (const char* name, spBoneData* boneData) { + spSlotData* self = NEW(spSlotData); MALLOC_STR(self->name, name); - CONST_CAST(BoneData*, self->boneData) = boneData; + CONST_CAST(spBoneData*, self->boneData) = boneData; self->r = 1; self->g = 1; self->b = 1; @@ -45,13 +45,13 @@ SlotData* SlotData_create (const char* name, BoneData* boneData) { return self; } -void SlotData_dispose (SlotData* self) { +void spSlotData_dispose (spSlotData* self) { FREE(self->name); FREE(self->attachmentName); FREE(self); } -void SlotData_setAttachmentName (SlotData* self, const char* attachmentName) { +void spSlotData_setAttachmentName (spSlotData* self, const char* attachmentName) { FREE(self->attachmentName); if (attachmentName) MALLOC_STR(self->attachmentName, attachmentName); diff --git a/spine-cocos2d-iphone/src/spine/CCSkeleton.h b/spine-cocos2d-iphone/src/spine/CCSkeleton.h index 16187e255..6d64994dc 100644 --- a/spine-cocos2d-iphone/src/spine/CCSkeleton.h +++ b/spine-cocos2d-iphone/src/spine/CCSkeleton.h @@ -31,6 +31,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#define SPINE_SHORT_NAMES #import #import "cocos2d.h" diff --git a/spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.h b/spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.h index e28db0639..782ba128a 100644 --- a/spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.h +++ b/spine-cocos2d-iphone/src/spine/CCSkeletonAnimation.h @@ -31,6 +31,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#define SPINE_SHORT_NAMES #import #import #import "cocos2d.h" diff --git a/spine-cocos2d-iphone/src/spine/spine-cocos2d-iphone.h b/spine-cocos2d-iphone/src/spine/spine-cocos2d-iphone.h index 8ad4e990c..05ddfb610 100644 --- a/spine-cocos2d-iphone/src/spine/spine-cocos2d-iphone.h +++ b/spine-cocos2d-iphone/src/spine/spine-cocos2d-iphone.h @@ -31,6 +31,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#define SPINE_SHORT_NAMES #import #import "cocos2d.h" #import "CCSkeleton.h" diff --git a/spine-cocos2dx/example/Classes/ExampleLayer.cpp b/spine-cocos2dx/example/Classes/ExampleLayer.cpp index d553bbbec..f5abd3c2d 100644 --- a/spine-cocos2dx/example/Classes/ExampleLayer.cpp +++ b/spine-cocos2dx/example/Classes/ExampleLayer.cpp @@ -51,8 +51,8 @@ void ExampleLayer::update (float deltaTime) { // if (entry->time > 0.1) CCDirector::sharedDirector()->replaceScene(ExampleLayer::scene()); } -void ExampleLayer::animationStateEvent (CCSkeletonAnimation* node, int trackIndex, EventType type, Event* event, int loopCount) { - TrackEntry* entry = AnimationState_getCurrent(node->state, trackIndex); +void ExampleLayer::animationStateEvent (CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount) { + spTrackEntry* entry = spAnimationState_getCurrent(node->state, trackIndex); const char* animationName = (entry && entry->animation) ? entry->animation->name : 0; switch (type) { diff --git a/spine-cocos2dx/example/Classes/ExampleLayer.h b/spine-cocos2dx/example/Classes/ExampleLayer.h index 8f9c708b1..f1d9e1f6a 100644 --- a/spine-cocos2dx/example/Classes/ExampleLayer.h +++ b/spine-cocos2dx/example/Classes/ExampleLayer.h @@ -17,7 +17,7 @@ public: private: spine::CCSkeletonAnimation* skeletonNode; - void animationStateEvent (spine::CCSkeletonAnimation* node, int trackIndex, EventType type, Event* event, int loopCount); + void animationStateEvent (spine::CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount); }; #endif // _EXAMPLELAYER_H_ \ No newline at end of file diff --git a/spine-cocos2dx/src/spine/CCSkeleton.cpp b/spine-cocos2dx/src/spine/CCSkeleton.cpp index 278487a7d..d112abfcf 100644 --- a/spine-cocos2dx/src/spine/CCSkeleton.cpp +++ b/spine-cocos2dx/src/spine/CCSkeleton.cpp @@ -40,13 +40,13 @@ using std::max; namespace spine { -CCSkeleton* CCSkeleton::createWithData (SkeletonData* skeletonData, bool ownsSkeletonData) { +CCSkeleton* CCSkeleton::createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData) { CCSkeleton* node = new CCSkeleton(skeletonData, ownsSkeletonData); node->autorelease(); return node; } -CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale) { +CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) { CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlas, scale); node->autorelease(); return node; @@ -72,8 +72,8 @@ void CCSkeleton::initialize () { scheduleUpdate(); } -void CCSkeleton::setSkeletonData (SkeletonData *skeletonData, bool ownsSkeletonData) { - skeleton = Skeleton_create(skeletonData); +void CCSkeleton::setSkeletonData (spSkeletonData *skeletonData, bool ownsSkeletonData) { + skeleton = spSkeleton_create(skeletonData); rootBone = skeleton->bones[0]; this->ownsSkeletonData = ownsSkeletonData; } @@ -82,20 +82,20 @@ CCSkeleton::CCSkeleton () { initialize(); } -CCSkeleton::CCSkeleton (SkeletonData *skeletonData, bool ownsSkeletonData) { +CCSkeleton::CCSkeleton (spSkeletonData *skeletonData, bool ownsSkeletonData) { initialize(); setSkeletonData(skeletonData, ownsSkeletonData); } -CCSkeleton::CCSkeleton (const char* skeletonDataFile, Atlas* atlas, float scale) { +CCSkeleton::CCSkeleton (const char* skeletonDataFile, spAtlas* atlas, float scale) { initialize(); - SkeletonJson* json = SkeletonJson_create(atlas); + spSkeletonJson* json = spSkeletonJson_create(atlas); json->scale = scale; - SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile); + spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile); CCAssert(skeletonData, json->error ? json->error : "Error reading skeleton data."); - SkeletonJson_dispose(json); + spSkeletonJson_dispose(json); setSkeletonData(skeletonData, true); } @@ -103,26 +103,26 @@ CCSkeleton::CCSkeleton (const char* skeletonDataFile, Atlas* atlas, float scale) CCSkeleton::CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale) { initialize(); - atlas = Atlas_readAtlasFile(atlasFile); + atlas = spAtlas_readAtlasFile(atlasFile); CCAssert(atlas, "Error reading atlas file."); - SkeletonJson* json = SkeletonJson_create(atlas); + spSkeletonJson* json = spSkeletonJson_create(atlas); json->scale = scale; - SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile); + spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile); CCAssert(skeletonData, json->error ? json->error : "Error reading skeleton data file."); - SkeletonJson_dispose(json); + spSkeletonJson_dispose(json); setSkeletonData(skeletonData, true); } CCSkeleton::~CCSkeleton () { - if (ownsSkeletonData) SkeletonData_dispose(skeleton->data); - if (atlas) Atlas_dispose(atlas); - Skeleton_dispose(skeleton); + if (ownsSkeletonData) spSkeletonData_dispose(skeleton->data); + if (atlas) spAtlas_dispose(atlas); + spSkeleton_dispose(skeleton); } void CCSkeleton::update (float deltaTime) { - Skeleton_update(skeleton, deltaTime * timeScale); + spSkeleton_update(skeleton, deltaTime * timeScale); } void CCSkeleton::draw () { @@ -148,9 +148,9 @@ void CCSkeleton::draw () { quad.bl.vertices.z = 0; quad.br.vertices.z = 0; for (int i = 0, n = skeleton->slotCount; i < n; i++) { - Slot* slot = skeleton->drawOrder[i]; + spSlot* slot = skeleton->drawOrder[i]; if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue; - RegionAttachment* attachment = (RegionAttachment*)slot->attachment; + spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; CCTextureAtlas* regionTextureAtlas = getTextureAtlas(attachment); if (slot->data->additiveBlending != additive) { @@ -173,7 +173,7 @@ void CCSkeleton::draw () { if (!textureAtlas->resizeCapacity(textureAtlas->getCapacity() * 2)) return; } - RegionAttachment_updateQuad(attachment, slot, &quad, premultipliedAlpha); + spRegionAttachment_updateQuad(attachment, slot, &quad, premultipliedAlpha); textureAtlas->updateQuad(&quad, quadCount); } if (textureAtlas) { @@ -188,10 +188,10 @@ void CCSkeleton::draw () { CCPoint points[4]; ccV3F_C4B_T2F_Quad quad; for (int i = 0, n = skeleton->slotCount; i < n; i++) { - Slot* slot = skeleton->drawOrder[i]; + spSlot* slot = skeleton->drawOrder[i]; if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue; - RegionAttachment* attachment = (RegionAttachment*)slot->attachment; - RegionAttachment_updateQuad(attachment, slot, &quad); + spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; + spRegionAttachment_updateQuad(attachment, slot, &quad); points[0] = ccp(quad.bl.vertices.x, quad.bl.vertices.y); points[1] = ccp(quad.br.vertices.x, quad.br.vertices.y); points[2] = ccp(quad.tr.vertices.x, quad.tr.vertices.y); @@ -204,7 +204,7 @@ void CCSkeleton::draw () { glLineWidth(2); ccDrawColor4B(255, 0, 0, 255); for (int i = 0, n = skeleton->boneCount; i < n; i++) { - Bone *bone = skeleton->bones[i]; + spBone *bone = skeleton->bones[i]; float x = bone->data->length * bone->m00 + bone->worldX; float y = bone->data->length * bone->m10 + bone->worldY; ccDrawLine(ccp(bone->worldX, bone->worldY), ccp(x, y)); @@ -213,15 +213,15 @@ void CCSkeleton::draw () { ccPointSize(4); ccDrawColor4B(0, 0, 255, 255); // Root bone is blue. for (int i = 0, n = skeleton->boneCount; i < n; i++) { - Bone *bone = skeleton->bones[i]; + spBone *bone = skeleton->bones[i]; ccDrawPoint(ccp(bone->worldX, bone->worldY)); if (i == 0) ccDrawColor4B(0, 255, 0, 255); } } } -CCTextureAtlas* CCSkeleton::getTextureAtlas (RegionAttachment* regionAttachment) const { - return (CCTextureAtlas*)((AtlasRegion*)regionAttachment->rendererObject)->page->rendererObject; +CCTextureAtlas* CCSkeleton::getTextureAtlas (spRegionAttachment* regionAttachment) const { + return (CCTextureAtlas*)((spAtlasRegion*)regionAttachment->rendererObject)->page->rendererObject; } CCRect CCSkeleton::boundingBox () { @@ -230,10 +230,10 @@ CCRect CCSkeleton::boundingBox () { float scaleY = getScaleY(); float vertices[8]; for (int i = 0; i < skeleton->slotCount; ++i) { - Slot* slot = skeleton->slots[i]; + spSlot* slot = skeleton->slots[i]; if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue; - RegionAttachment* attachment = (RegionAttachment*)slot->attachment; - RegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices); + spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; + spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices); minX = min(minX, vertices[VERTEX_X1] * scaleX); minY = min(minY, vertices[VERTEX_Y1] * scaleY); maxX = max(maxX, vertices[VERTEX_X1] * scaleX); @@ -258,36 +258,36 @@ CCRect CCSkeleton::boundingBox () { // --- Convenience methods for Skeleton_* functions. void CCSkeleton::updateWorldTransform () { - Skeleton_updateWorldTransform(skeleton); + spSkeleton_updateWorldTransform(skeleton); } void CCSkeleton::setToSetupPose () { - Skeleton_setToSetupPose(skeleton); + spSkeleton_setToSetupPose(skeleton); } void CCSkeleton::setBonesToSetupPose () { - Skeleton_setBonesToSetupPose(skeleton); + spSkeleton_setBonesToSetupPose(skeleton); } void CCSkeleton::setSlotsToSetupPose () { - Skeleton_setSlotsToSetupPose(skeleton); + spSkeleton_setSlotsToSetupPose(skeleton); } -Bone* CCSkeleton::findBone (const char* boneName) const { - return Skeleton_findBone(skeleton, boneName); +spBone* CCSkeleton::findBone (const char* boneName) const { + return spSkeleton_findBone(skeleton, boneName); } -Slot* CCSkeleton::findSlot (const char* slotName) const { - return Skeleton_findSlot(skeleton, slotName); +spSlot* CCSkeleton::findSlot (const char* slotName) const { + return spSkeleton_findSlot(skeleton, slotName); } bool CCSkeleton::setSkin (const char* skinName) { - return Skeleton_setSkinByName(skeleton, skinName) ? true : false; + return spSkeleton_setSkinByName(skeleton, skinName) ? true : false; } -Attachment* CCSkeleton::getAttachment (const char* slotName, const char* attachmentName) const { - return Skeleton_getAttachmentForSlotName(skeleton, slotName, attachmentName); +spAttachment* CCSkeleton::getAttachment (const char* slotName, const char* attachmentName) const { + return spSkeleton_getAttachmentForSlotName(skeleton, slotName, attachmentName); } bool CCSkeleton::setAttachment (const char* slotName, const char* attachmentName) { - return Skeleton_setAttachment(skeleton, slotName, attachmentName) ? true : false; + return spSkeleton_setAttachment(skeleton, slotName, attachmentName) ? true : false; } // --- CCBlendProtocol diff --git a/spine-cocos2dx/src/spine/CCSkeleton.h b/spine-cocos2dx/src/spine/CCSkeleton.h index 5d9d84004..0b65a4333 100644 --- a/spine-cocos2dx/src/spine/CCSkeleton.h +++ b/spine-cocos2dx/src/spine/CCSkeleton.h @@ -42,19 +42,19 @@ namespace spine { /** Draws a skeleton. */ class CCSkeleton: public cocos2d::CCNodeRGBA, public cocos2d::CCBlendProtocol { public: - Skeleton* skeleton; - Bone* rootBone; + spSkeleton* skeleton; + spBone* rootBone; float timeScale; bool debugSlots; bool debugBones; bool premultipliedAlpha; - static CCSkeleton* createWithData (SkeletonData* skeletonData, bool ownsSkeletonData = false); - static CCSkeleton* createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale = 1); + static CCSkeleton* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false); + static CCSkeleton* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 1); static CCSkeleton* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 1); - CCSkeleton (SkeletonData* skeletonData, bool ownsSkeletonData = false); - CCSkeleton (const char* skeletonDataFile, Atlas* atlas, float scale = 1); + CCSkeleton (spSkeletonData* skeletonData, bool ownsSkeletonData = false); + CCSkeleton (const char* skeletonDataFile, spAtlas* atlas, float scale = 1); CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale = 1); virtual ~CCSkeleton (); @@ -71,9 +71,9 @@ public: void setSlotsToSetupPose (); /* Returns 0 if the bone was not found. */ - Bone* findBone (const char* boneName) const; + spBone* findBone (const char* boneName) const; /* Returns 0 if the slot was not found. */ - Slot* findSlot (const char* slotName) const; + spSlot* findSlot (const char* slotName) const; /* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are * attached if the corresponding attachment from the old skin was attached. Returns false if the skin was not found. @@ -81,7 +81,7 @@ public: bool setSkin (const char* skinName); /* Returns 0 if the slot or attachment was not found. */ - Attachment* getAttachment (const char* slotName, const char* attachmentName) const; + spAttachment* getAttachment (const char* slotName, const char* attachmentName) const; /* Returns false if the slot or attachment was not found. */ bool setAttachment (const char* slotName, const char* attachmentName); @@ -92,12 +92,12 @@ public: protected: CCSkeleton (); - void setSkeletonData (SkeletonData* skeletonData, bool ownsSkeletonData); - cocos2d::CCTextureAtlas* getTextureAtlas (RegionAttachment* regionAttachment) const; + void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData); + cocos2d::CCTextureAtlas* getTextureAtlas (spRegionAttachment* regionAttachment) const; private: bool ownsSkeletonData; - Atlas* atlas; + spAtlas* atlas; void initialize (); }; diff --git a/spine-cocos2dx/src/spine/CCSkeletonAnimation.cpp b/spine-cocos2dx/src/spine/CCSkeletonAnimation.cpp index aff464a79..624f5d113 100644 --- a/spine-cocos2dx/src/spine/CCSkeletonAnimation.cpp +++ b/spine-cocos2dx/src/spine/CCSkeletonAnimation.cpp @@ -42,17 +42,17 @@ using std::vector; namespace spine { -static void callback (AnimationState* state, int trackIndex, EventType type, Event* event, int loopCount) { +static void callback (spAnimationState* state, int trackIndex, spEventType type, spEvent* event, int loopCount) { ((CCSkeletonAnimation*)state->context)->onAnimationStateEvent(trackIndex, type, event, loopCount); } -CCSkeletonAnimation* CCSkeletonAnimation::createWithData (SkeletonData* skeletonData) { +CCSkeletonAnimation* CCSkeletonAnimation::createWithData (spSkeletonData* skeletonData) { CCSkeletonAnimation* node = new CCSkeletonAnimation(skeletonData); node->autorelease(); return node; } -CCSkeletonAnimation* CCSkeletonAnimation::createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale) { +CCSkeletonAnimation* CCSkeletonAnimation::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) { CCSkeletonAnimation* node = new CCSkeletonAnimation(skeletonDataFile, atlas, scale); node->autorelease(); return node; @@ -68,17 +68,17 @@ void CCSkeletonAnimation::initialize () { listenerInstance = 0; listenerMethod = 0; - state = AnimationState_create(AnimationStateData_create(skeleton->data)); + state = spAnimationState_create(spAnimationStateData_create(skeleton->data)); state->context = this; state->listener = callback; } -CCSkeletonAnimation::CCSkeletonAnimation (SkeletonData *skeletonData) +CCSkeletonAnimation::CCSkeletonAnimation (spSkeletonData *skeletonData) : CCSkeleton(skeletonData) { initialize(); } -CCSkeletonAnimation::CCSkeletonAnimation (const char* skeletonDataFile, Atlas* atlas, float scale) +CCSkeletonAnimation::CCSkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale) : CCSkeleton(skeletonDataFile, atlas, scale) { initialize(); } @@ -89,33 +89,33 @@ CCSkeletonAnimation::CCSkeletonAnimation (const char* skeletonDataFile, const ch } CCSkeletonAnimation::~CCSkeletonAnimation () { - if (ownsAnimationStateData) AnimationStateData_dispose(state->data); - AnimationState_dispose(state); + if (ownsAnimationStateData) spAnimationStateData_dispose(state->data); + spAnimationState_dispose(state); } void CCSkeletonAnimation::update (float deltaTime) { super::update(deltaTime); deltaTime *= timeScale; - AnimationState_update(state, deltaTime); - AnimationState_apply(state, skeleton); - Skeleton_updateWorldTransform(skeleton); + spAnimationState_update(state, deltaTime); + spAnimationState_apply(state, skeleton); + spSkeleton_updateWorldTransform(skeleton); } -void CCSkeletonAnimation::setAnimationStateData (AnimationStateData* stateData) { +void CCSkeletonAnimation::setAnimationStateData (spAnimationStateData* stateData) { CCAssert(stateData, "stateData cannot be null."); - if (ownsAnimationStateData) AnimationStateData_dispose(state->data); - AnimationState_dispose(state); + if (ownsAnimationStateData) spAnimationStateData_dispose(state->data); + spAnimationState_dispose(state); ownsAnimationStateData = true; - state = AnimationState_create(stateData); + state = spAnimationState_create(stateData); state->context = this; state->listener = callback; } void CCSkeletonAnimation::setMix (const char* fromAnimation, const char* toAnimation, float duration) { - AnimationStateData_setMixByName(state->data, fromAnimation, toAnimation, duration); + spAnimationStateData_setMixByName(state->data, fromAnimation, toAnimation, duration); } void CCSkeletonAnimation::setAnimationListener (CCObject* instance, SEL_AnimationStateEvent method) { @@ -123,37 +123,37 @@ void CCSkeletonAnimation::setAnimationListener (CCObject* instance, SEL_Animatio listenerMethod = method; } -TrackEntry* CCSkeletonAnimation::setAnimation (int trackIndex, const char* name, bool loop) { - Animation* animation = SkeletonData_findAnimation(skeleton->data, name); +spTrackEntry* CCSkeletonAnimation::setAnimation (int trackIndex, const char* name, bool loop) { + spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name); if (!animation) { CCLog("Spine: Animation not found: %s", name); return 0; } - return AnimationState_setAnimation(state, trackIndex, animation, loop); + return spAnimationState_setAnimation(state, trackIndex, animation, loop); } -TrackEntry* CCSkeletonAnimation::addAnimation (int trackIndex, const char* name, bool loop, float delay) { - Animation* animation = SkeletonData_findAnimation(skeleton->data, name); +spTrackEntry* CCSkeletonAnimation::addAnimation (int trackIndex, const char* name, bool loop, float delay) { + spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name); if (!animation) { CCLog("Spine: Animation not found: %s", name); return 0; } - return AnimationState_addAnimation(state, trackIndex, animation, loop, delay); + return spAnimationState_addAnimation(state, trackIndex, animation, loop, delay); } -TrackEntry* CCSkeletonAnimation::getCurrent (int trackIndex) { - return AnimationState_getCurrent(state, trackIndex); +spTrackEntry* CCSkeletonAnimation::getCurrent (int trackIndex) { + return spAnimationState_getCurrent(state, trackIndex); } void CCSkeletonAnimation::clearTracks () { - AnimationState_clearTracks(state); + spAnimationState_clearTracks(state); } void CCSkeletonAnimation::clearTrack (int trackIndex) { - AnimationState_clearTrack(state, trackIndex); + spAnimationState_clearTrack(state, trackIndex); } -void CCSkeletonAnimation::onAnimationStateEvent (int trackIndex, EventType type, Event* event, int loopCount) { +void CCSkeletonAnimation::onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount) { if (listenerInstance) (listenerInstance->*listenerMethod)(this, trackIndex, type, event, loopCount); } diff --git a/spine-cocos2dx/src/spine/CCSkeletonAnimation.h b/spine-cocos2dx/src/spine/CCSkeletonAnimation.h index bd3e1a5e0..5f7682ae8 100644 --- a/spine-cocos2dx/src/spine/CCSkeletonAnimation.h +++ b/spine-cocos2dx/src/spine/CCSkeletonAnimation.h @@ -41,38 +41,38 @@ namespace spine { class CCSkeletonAnimation; -typedef void (cocos2d::CCObject::*SEL_AnimationStateEvent)(spine::CCSkeletonAnimation* node, int trackIndex, EventType type, Event* event, int loopCount); +typedef void (cocos2d::CCObject::*SEL_AnimationStateEvent)(spine::CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount); #define animationStateEvent_selector(_SELECTOR) (SEL_AnimationStateEvent)(&_SELECTOR) /** Draws an animated skeleton, providing an AnimationState for applying one or more animations and queuing animations to be * played later. */ class CCSkeletonAnimation: public CCSkeleton { public: - AnimationState* state; + spAnimationState* state; - static CCSkeletonAnimation* createWithData (SkeletonData* skeletonData); - static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale = 1); + static CCSkeletonAnimation* createWithData (spSkeletonData* skeletonData); + static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 1); static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 1); - CCSkeletonAnimation (SkeletonData* skeletonData); - CCSkeletonAnimation (const char* skeletonDataFile, Atlas* atlas, float scale = 1); + CCSkeletonAnimation (spSkeletonData* skeletonData); + CCSkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale = 1); CCSkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale = 1); virtual ~CCSkeletonAnimation (); virtual void update (float deltaTime); - void setAnimationStateData (AnimationStateData* stateData); + void setAnimationStateData (spAnimationStateData* stateData); void setMix (const char* fromAnimation, const char* toAnimation, float duration); void setAnimationListener (CCObject* instance, SEL_AnimationStateEvent method); - TrackEntry* setAnimation (int trackIndex, const char* name, bool loop); - TrackEntry* addAnimation (int trackIndex, const char* name, bool loop, float delay = 0); - TrackEntry* getCurrent (int trackIndex = 0); + spTrackEntry* setAnimation (int trackIndex, const char* name, bool loop); + spTrackEntry* addAnimation (int trackIndex, const char* name, bool loop, float delay = 0); + spTrackEntry* getCurrent (int trackIndex = 0); void clearTracks (); void clearTrack (int trackIndex = 0); - void onAnimationStateEvent (int trackIndex, EventType type, Event* event, int loopCount); + void onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount); protected: CCSkeletonAnimation (); diff --git a/spine-cocos2dx/src/spine/spine-cocos2dx.cpp b/spine-cocos2dx/src/spine/spine-cocos2dx.cpp index 76beebe13..907e5941c 100644 --- a/spine-cocos2dx/src/spine/spine-cocos2dx.cpp +++ b/spine-cocos2dx/src/spine/spine-cocos2dx.cpp @@ -36,7 +36,7 @@ USING_NS_CC; -void _AtlasPage_createTexture (AtlasPage* self, const char* path) { +void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) { CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage(path); CCTextureAtlas* textureAtlas = CCTextureAtlas::createWithTexture(texture, 128); textureAtlas->retain(); @@ -45,11 +45,11 @@ void _AtlasPage_createTexture (AtlasPage* self, const char* path) { self->height = texture->getPixelsHigh(); } -void _AtlasPage_disposeTexture (AtlasPage* self) { +void _spAtlasPage_disposeTexture (spAtlasPage* self) { ((CCTextureAtlas*)self->rendererObject)->release(); } -char* _Util_readFile (const char* path, int* length) { +char* _spUtil_readFile (const char* path, int* length) { unsigned long size; char* data = reinterpret_cast(CCFileUtils::sharedFileUtils()->getFileData( CCFileUtils::sharedFileUtils()->fullPathForFilename(path).c_str(), "r", &size)); @@ -59,9 +59,9 @@ char* _Util_readFile (const char* path, int* length) { /**/ -void RegionAttachment_updateQuad (RegionAttachment* self, Slot* slot, ccV3F_C4B_T2F_Quad* quad, bool premultipliedAlpha) { +void spRegionAttachment_updateQuad (spRegionAttachment* self, spSlot* slot, ccV3F_C4B_T2F_Quad* quad, bool premultipliedAlpha) { float vertices[8]; - RegionAttachment_computeWorldVertices(self, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices); + spRegionAttachment_computeWorldVertices(self, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices); GLubyte r = slot->skeleton->r * slot->r * 255; GLubyte g = slot->skeleton->g * slot->g * 255; diff --git a/spine-cocos2dx/src/spine/spine-cocos2dx.h b/spine-cocos2dx/src/spine/spine-cocos2dx.h index 30d3da3ca..c4e01fe5b 100644 --- a/spine-cocos2dx/src/spine/spine-cocos2dx.h +++ b/spine-cocos2dx/src/spine/spine-cocos2dx.h @@ -39,6 +39,6 @@ #include #include -void RegionAttachment_updateQuad (RegionAttachment* self, Slot* slot, cocos2d::ccV3F_C4B_T2F_Quad* quad, bool premultiplied = false); +void spRegionAttachment_updateQuad (spRegionAttachment* self, spSlot* slot, cocos2d::ccV3F_C4B_T2F_Quad* quad, bool premultiplied = false); #endif /* SPINE_COCOS2DX_H_ */ diff --git a/spine-sfml/src/spine/spine-sfml.h b/spine-sfml/src/spine/spine-sfml.h index a51921ece..c5941b8e1 100644 --- a/spine-sfml/src/spine/spine-sfml.h +++ b/spine-sfml/src/spine/spine-sfml.h @@ -34,6 +34,7 @@ #ifndef SPINE_SFML_H_ #define SPINE_SFML_H_ +#define SPINE_SHORT_NAMES #include #include #include