From e2ca397e63861b256d50ba5ea9550db3ac4421e5 Mon Sep 17 00:00:00 2001 From: Robert Špalek Date: Tue, 10 Nov 2009 05:16:34 +0000 Subject: Huge refactoring of data structures. Replaced IDs of objects by pointers, which saves many lookups, each of which is horribly ineffective. Moved a lot of code into methods of structs now turned into objects. Tested the new code a lot and seems to work as well as the old code. svn-id: r45799 --- engines/draci/animation.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'engines/draci/animation.h') diff --git a/engines/draci/animation.h b/engines/draci/animation.h index aff2680c37..b669d53272 100644 --- a/engines/draci/animation.h +++ b/engines/draci/animation.h @@ -62,7 +62,7 @@ class Animation { typedef void (Animation::* AnimationCallback)(); public: - Animation(DraciEngine *v, int index); + Animation(DraciEngine *v, int id, uint z, bool playing); ~Animation(); uint getZ() const { return _z; } @@ -120,10 +120,13 @@ public: void registerCallback(AnimationCallback callback) { _callback = callback; } void doNothing() {} - void stopAnimation(); void exitGameLoop(); void tellWalkingState(); + void play(); + void stop(); + void del(); + private: uint nextFrameNum() const; void deleteFrames(); @@ -174,17 +177,13 @@ public: AnimationManager(DraciEngine *vm) : _vm(vm), _lastIndex(-1) {} ~AnimationManager() { deleteAll(); } - Animation *addAnimation(int id, uint z, bool playing); - Animation *addText(int id, bool playing); - Animation *addItem(int id, bool playing); - void addOverlay(Drawable *overlay, uint z); + void insert(Animation *anim, bool allocateIndex); + Animation *load(uint animNum); - void play(int id); - void stop(int id); void pauseAnimations(); void unpauseAnimations(); - void deleteAnimation(int id); + void deleteAnimation(Animation *anim); void deleteOverlays(); void deleteAll(); @@ -195,11 +194,10 @@ public: int getLastIndex() const { return _lastIndex; } void deleteAfterIndex(int index); - int getTopAnimationID(int x, int y) const; + const Animation *getTopAnimation(int x, int y) const; private: void sortAnimations(); - void insertAnimation(Animation *anim); DraciEngine *_vm; -- cgit v1.2.3