From f269d5a68e6a22676c49961c7529b9c00dc90649 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sun, 9 May 2010 14:31:43 -0600 Subject: Move target cursor management into ActorSprite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This simplifies handling of target cursors, centralizing their logic into a single class, instead of two. Also make them more flexible and move the image files outside of the theme so servers can can control them and give them better names. Reviewed-by: Thorbjørn Lindeijer --- src/actorsprite.h | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/actorsprite.h') diff --git a/src/actorsprite.h b/src/actorsprite.h index b5c402eb..a56be125 100644 --- a/src/actorsprite.h +++ b/src/actorsprite.h @@ -53,6 +53,14 @@ public: NUM_TC }; + enum TargetCursorType + { + TCT_NONE = -1, + TCT_NORMAL = 0, + TCT_IN_RANGE, + NUM_TCT + }; + ActorSprite(int id); ~ActorSprite(); @@ -73,6 +81,8 @@ public: virtual void logic(); + static void actorLogic(); + void setMap(Map* map); /** @@ -95,7 +105,7 @@ public: /** * Sets the target animation for this actor. */ - void setTargetAnimation(SimpleAnimation *animation); + void setTargetType(TargetCursorType type); /** * Untargets the actor. @@ -140,6 +150,10 @@ public: virtual float getAlpha() const { return CompoundSprite::getAlpha(); } + static void load(); + + static void unload(); + protected: /** * Trigger visual effect, with components @@ -185,6 +199,24 @@ private: /** Reset particle status effects on next redraw? */ bool mMustResetParticles; + /** Load the target cursors into memory */ + static void initTargetCursor(); + + /** Remove the target cursors from memory */ + static void cleanupTargetCursors(); + + /** + * Helper function for loading target cursors + */ + static void loadTargetCursor(const std::string &filename, + int width, int height, int type, int size); + + /** Images of the target cursor. */ + static ImageSet *targetCursorImages[NUM_TCT][NUM_TC]; + + /** Animated target cursors. */ + static SimpleAnimation *targetCursor[NUM_TCT][NUM_TC]; + /** Target cursor being used */ SimpleAnimation *mUsedTargetCursor; }; -- cgit v1.2.3-70-g09d2