mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-06 10:46:53 +08:00
[cpp] Updated CHANGELOG and clean-up.
This commit is contained in:
parent
4ac0a86193
commit
962aaa1c9f
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
## C++
|
## C++
|
||||||
* ** Additions **
|
* ** Additions **
|
||||||
|
* `AnimationState` and `TrackEntry` now also accept a subclass of `AnimationStateListenerObject` as a listener for animation events in the overloaded `setListener()` method.
|
||||||
|
|
||||||
* **Breaking changes**
|
* **Breaking changes**
|
||||||
|
|
||||||
|
|||||||
@ -60,11 +60,10 @@ namespace spine {
|
|||||||
typedef void (*AnimationStateListener) (AnimationState* state, EventType type, TrackEntry* entry, Event* event);
|
typedef void (*AnimationStateListener) (AnimationState* state, EventType type, TrackEntry* entry, Event* event);
|
||||||
|
|
||||||
/// Abstract class to inherit from to create a callback object
|
/// Abstract class to inherit from to create a callback object
|
||||||
class SP_API AnimationStateListenerClass
|
class SP_API AnimationStateListenerObject {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
AnimationStateListenerClass() = default;
|
AnimationStateListenerObject() = default;
|
||||||
virtual ~AnimationStateListenerClass() = default;
|
virtual ~AnimationStateListenerObject() = default;
|
||||||
public:
|
public:
|
||||||
/// The callback function to be called
|
/// The callback function to be called
|
||||||
virtual void callback(AnimationState* state, EventType type, TrackEntry* entry, Event* event) = 0;
|
virtual void callback(AnimationState* state, EventType type, TrackEntry* entry, Event* event) = 0;
|
||||||
@ -252,7 +251,7 @@ namespace spine {
|
|||||||
|
|
||||||
void setListener(AnimationStateListener listener);
|
void setListener(AnimationStateListener listener);
|
||||||
|
|
||||||
void setListener(AnimationStateListenerClass* listener);
|
void setListener(AnimationStateListenerObject* listener);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Animation* _animation;
|
Animation* _animation;
|
||||||
@ -272,7 +271,7 @@ namespace spine {
|
|||||||
Vector<TrackEntry*> _timelineHoldMix;
|
Vector<TrackEntry*> _timelineHoldMix;
|
||||||
Vector<float> _timelinesRotation;
|
Vector<float> _timelinesRotation;
|
||||||
AnimationStateListener _listener;
|
AnimationStateListener _listener;
|
||||||
AnimationStateListenerClass* _listenerObj;
|
AnimationStateListenerObject* _listenerObject;
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
};
|
};
|
||||||
@ -410,7 +409,7 @@ namespace spine {
|
|||||||
void setTimeScale(float inValue);
|
void setTimeScale(float inValue);
|
||||||
|
|
||||||
void setListener(AnimationStateListener listener);
|
void setListener(AnimationStateListener listener);
|
||||||
void setListener(AnimationStateListenerClass* listener);
|
void setListener(AnimationStateListenerObject* listener);
|
||||||
|
|
||||||
void disableQueue();
|
void disableQueue();
|
||||||
void enableQueue();
|
void enableQueue();
|
||||||
@ -428,7 +427,7 @@ namespace spine {
|
|||||||
bool _animationsChanged;
|
bool _animationsChanged;
|
||||||
|
|
||||||
AnimationStateListener _listener;
|
AnimationStateListener _listener;
|
||||||
AnimationStateListenerClass* _listenerObj;
|
AnimationStateListenerObject* _listenerObject;
|
||||||
|
|
||||||
float _timeScale;
|
float _timeScale;
|
||||||
|
|
||||||
|
|||||||
@ -59,7 +59,7 @@ TrackEntry::TrackEntry() : _animation(NULL), _next(NULL), _mixingFrom(NULL), _mi
|
|||||||
_animationEnd(0), _animationLast(0), _nextAnimationLast(0), _delay(0), _trackTime(0),
|
_animationEnd(0), _animationLast(0), _nextAnimationLast(0), _delay(0), _trackTime(0),
|
||||||
_trackLast(0), _nextTrackLast(0), _trackEnd(0), _timeScale(1.0f), _alpha(0), _mixTime(0),
|
_trackLast(0), _nextTrackLast(0), _trackEnd(0), _timeScale(1.0f), _alpha(0), _mixTime(0),
|
||||||
_mixDuration(0), _interruptAlpha(0), _totalAlpha(0), _mixBlend(MixBlend_Replace),
|
_mixDuration(0), _interruptAlpha(0), _totalAlpha(0), _mixBlend(MixBlend_Replace),
|
||||||
_listener(dummyOnAnimationEventFunc), _listenerObj(NULL) {
|
_listener(dummyOnAnimationEventFunc), _listenerObject(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry::~TrackEntry() { }
|
TrackEntry::~TrackEntry() { }
|
||||||
@ -164,12 +164,12 @@ void TrackEntry::resetRotationDirections() {
|
|||||||
|
|
||||||
void TrackEntry::setListener(AnimationStateListener inValue) {
|
void TrackEntry::setListener(AnimationStateListener inValue) {
|
||||||
_listener = inValue;
|
_listener = inValue;
|
||||||
_listenerObj = NULL;
|
_listenerObject = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackEntry::setListener(AnimationStateListenerClass* inValue) {
|
void TrackEntry::setListener(AnimationStateListenerObject* inValue) {
|
||||||
_listener = dummyOnAnimationEventFunc;
|
_listener = dummyOnAnimationEventFunc;
|
||||||
_listenerObj = inValue;
|
_listenerObject = inValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackEntry::reset() {
|
void TrackEntry::reset() {
|
||||||
@ -185,7 +185,7 @@ void TrackEntry::reset() {
|
|||||||
_timelinesRotation.clear();
|
_timelinesRotation.clear();
|
||||||
|
|
||||||
_listener = dummyOnAnimationEventFunc;
|
_listener = dummyOnAnimationEventFunc;
|
||||||
_listenerObj = NULL;
|
_listenerObject = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventQueueEntry::EventQueueEntry(EventType eventType, TrackEntry *trackEntry, Event *event) :
|
EventQueueEntry::EventQueueEntry(EventType eventType, TrackEntry *trackEntry, Event *event) :
|
||||||
@ -255,48 +255,32 @@ void EventQueue::drain() {
|
|||||||
case EventType_Start:
|
case EventType_Start:
|
||||||
case EventType_Interrupt:
|
case EventType_Interrupt:
|
||||||
case EventType_Complete:
|
case EventType_Complete:
|
||||||
if (NULL == trackEntry->_listenerObj)
|
if (!trackEntry->_listenerObject) trackEntry->_listener(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
trackEntry->_listener(&state, queueEntry->_type, trackEntry, NULL);
|
else trackEntry->_listenerObject->callback(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
else
|
if(!state._listenerObject) state._listener(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
trackEntry->_listenerObj->callback(&state, queueEntry->_type, trackEntry, NULL);
|
else state._listenerObject->callback(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
if (NULL == state._listenerObj)
|
|
||||||
state._listener(&state, queueEntry->_type, trackEntry, NULL);
|
|
||||||
else
|
|
||||||
state._listenerObj->callback(&state, queueEntry->_type, trackEntry, NULL);
|
|
||||||
break;
|
break;
|
||||||
case EventType_End:
|
case EventType_End:
|
||||||
if (NULL == trackEntry->_listenerObj)
|
if (!trackEntry->_listenerObject) trackEntry->_listener(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
trackEntry->_listener(&state, queueEntry->_type, trackEntry, NULL);
|
else trackEntry->_listenerObject->callback(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
else
|
if (!state._listenerObject) state._listener(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
trackEntry->_listenerObj->callback(&state, queueEntry->_type, trackEntry, NULL);
|
else state._listenerObject->callback(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
if (NULL == state._listenerObj)
|
|
||||||
state._listener(&state, queueEntry->_type, trackEntry, NULL);
|
|
||||||
else
|
|
||||||
state._listenerObj->callback(&state, queueEntry->_type, trackEntry, NULL);
|
|
||||||
/* Yes, we want to fall through here */
|
/* Yes, we want to fall through here */
|
||||||
case EventType_Dispose:
|
case EventType_Dispose:
|
||||||
|
|
||||||
if (NULL == trackEntry->_listenerObj)
|
if (!trackEntry->_listenerObject) trackEntry->_listener(&state, EventType_Dispose, trackEntry, NULL);
|
||||||
trackEntry->_listener(&state, EventType_Dispose, trackEntry, NULL);
|
else trackEntry->_listenerObject->callback(&state, EventType_Dispose, trackEntry, NULL);
|
||||||
else
|
if (!state._listenerObject) state._listener(&state, EventType_Dispose, trackEntry, NULL);
|
||||||
trackEntry->_listenerObj->callback(&state, EventType_Dispose, trackEntry, NULL);
|
else state._listenerObject->callback(&state, EventType_Dispose, trackEntry, NULL);
|
||||||
if (NULL == state._listenerObj)
|
|
||||||
state._listener(&state, EventType_Dispose, trackEntry, NULL);
|
|
||||||
else
|
|
||||||
state._listenerObj->callback(&state, EventType_Dispose, trackEntry, NULL);
|
|
||||||
|
|
||||||
trackEntry->reset();
|
trackEntry->reset();
|
||||||
_trackEntryPool.free(trackEntry);
|
_trackEntryPool.free(trackEntry);
|
||||||
break;
|
break;
|
||||||
case EventType_Event:
|
case EventType_Event:
|
||||||
if (NULL == trackEntry->_listenerObj)
|
if (!trackEntry->_listenerObject) trackEntry->_listener(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
||||||
trackEntry->_listener(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
else trackEntry->_listenerObject->callback(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
||||||
else
|
if (!state._listenerObject) state._listener(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
||||||
trackEntry->_listenerObj->callback(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
else state._listenerObject->callback(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
||||||
if (NULL == state._listenerObj)
|
|
||||||
state._listener(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
|
||||||
else
|
|
||||||
state._listenerObj->callback(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -316,7 +300,7 @@ AnimationState::AnimationState(AnimationStateData *data) :
|
|||||||
_queue(EventQueue::newEventQueue(*this, _trackEntryPool)),
|
_queue(EventQueue::newEventQueue(*this, _trackEntryPool)),
|
||||||
_animationsChanged(false),
|
_animationsChanged(false),
|
||||||
_listener(dummyOnAnimationEventFunc),
|
_listener(dummyOnAnimationEventFunc),
|
||||||
_listenerObj(NULL),
|
_listenerObject(NULL),
|
||||||
_timeScale(1) {
|
_timeScale(1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -652,12 +636,12 @@ void AnimationState::setTimeScale(float inValue) {
|
|||||||
|
|
||||||
void AnimationState::setListener(AnimationStateListener inValue) {
|
void AnimationState::setListener(AnimationStateListener inValue) {
|
||||||
_listener = inValue;
|
_listener = inValue;
|
||||||
_listenerObj = NULL;
|
_listenerObject = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationState::setListener(AnimationStateListenerClass* inValue) {
|
void AnimationState::setListener(AnimationStateListenerObject* inValue) {
|
||||||
_listener = dummyOnAnimationEventFunc;
|
_listener = dummyOnAnimationEventFunc;
|
||||||
_listenerObj = inValue;
|
_listenerObject = inValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationState::disableQueue() {
|
void AnimationState::disableQueue() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user