| 48 | : _owner(owner) { } |
| 49 | |
| 50 | void Spine::SpineListener::callback(spine::AnimationState* state, spine::EventType type, spine::TrackEntry* entry, spine::Event* event) { |
| 51 | spine::String empty; |
| 52 | const spine::String& name = entry ? entry->getAnimation().getName() : empty; |
| 53 | Slice animationName{name.buffer(), name.length()}; |
| 54 | switch (type) { |
| 55 | case spine::EventType_End: |
| 56 | if (_owner->_currentAnimationName == animationName) { |
| 57 | _owner->_currentAnimationName.clear(); |
| 58 | } |
| 59 | break; |
| 60 | case spine::EventType_Event: { |
| 61 | const auto& name = event->getData().getName(); |
| 62 | _owner->emit(Slice{name.buffer(), name.length()}, s_cast<Playable*>(_owner)); |
| 63 | break; |
| 64 | } |
| 65 | case spine::EventType_Complete: |
| 66 | _owner->emit("AnimationEnd"_slice, animationName.toString(), s_cast<Playable*>(_owner)); |
| 67 | _owner->_lastCompletedAnimationName = animationName.toString(); |
| 68 | if (_owner->_currentAnimationName == animationName) { |
| 69 | _owner->_currentAnimationName.clear(); |
| 70 | } |
| 71 | break; |
| 72 | case spine::EventType_Interrupt: |
| 73 | _owner->_lastCompletedAnimationName.clear(); |
| 74 | if (_owner->_currentAnimationName == animationName) { |
| 75 | _owner->_currentAnimationName.clear(); |
| 76 | } |
| 77 | break; |
| 78 | case spine::EventType_Start: |
| 79 | case spine::EventType_Dispose: |
| 80 | break; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | Spine::Spine(String spineStr) |
| 85 | : _skeletonData(SharedSkeletonCache.load(spineStr)) |
no test coverage detected