Mercurial > fife-parpg
diff engine/core/view/visual.h @ 356:ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
Added layer transparency support
Added layer transparency to map editor
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 24 Sep 2009 18:24:47 +0000 |
parents | 90005975cdbb |
children | 8fa2f3aa0cbd |
line wrap: on
line diff
--- a/engine/core/view/visual.h Tue Sep 22 19:03:53 2009 +0000 +++ b/engine/core/view/visual.h Thu Sep 24 18:24:47 2009 +0000 @@ -38,7 +38,7 @@ class Instance; class Action; class Image; - + /** Base class for all 2 dimensional visual classes * Visual classes are extensions to visualize the stuff in model (e.g. instances) * The reason why its separated is to keep model view-agnostic, so that we could @@ -49,35 +49,35 @@ /** Destructor */ virtual ~Visual2DGfx(); - + /** Sets transparency value for object to be visualized * @param stackposition new stack position */ void setTransparency(uint8_t transparency) { m_transparency = transparency; } - + /** Gets current transparency value (0-255) * @return current transparency value */ unsigned int getTransparency() { return m_transparency; } - + /** Sets visibility value for object to be visualized * @param visible is object visible or not */ void setVisible(bool visible) { m_visible = visible; } - + /** Is instance visible or not * @return is instance visible or not */ unsigned int isVisible() { return m_visible; } - + protected: /** Constructor */ Visual2DGfx(); - + uint8_t m_transparency; uint8_t m_visible; - + }; /** Object visual contains data that is needed for visualizing objects @@ -87,11 +87,11 @@ /** Constructs and assigns it to the passed item */ static ObjectVisual* create(Object* object); - + /** Destructor */ virtual ~ObjectVisual(); - + /** Adds new static image with given angle (degrees) * Static images are used in case there are no actions active in the instance * There can be several static images for different angles, that are used in @@ -102,26 +102,26 @@ @param image_index index of image to use for given degress */ void addStaticImage(unsigned int angle, int image_index); - + /** Returns closest matching static image for given angle * @return id for static image */ int getStaticImageIndexByAngle(int angle); - + /** Returns closest matching image angle for given angle * @return closest matching angle */ int getClosestMatchingAngle(int angle); - + /** Returns list of available static image angles for this object */ void getStaticImageAngles(std::vector<int>& angles); - + private: /** Constructor */ ObjectVisual(); - + type_angle2id m_angle2img; }; @@ -132,23 +132,23 @@ class InstanceVisualCacheItem { public: InstanceVisualCacheItem(); - + /** Returns closest matching static image for given angle * @return id for static image * @see ObjectVisual::getStaticImageIndexByAngle */ int getStaticImageIndexByAngle(unsigned int angle, Instance* instance); - + // point where instance was drawn during the previous render ScreenPoint screenpoint; - + // dimensions of this visual during the previous render Rect dimensions; - + // image used during previous render Image* image; - - // current facing angle + + // current facing angle int facing_angle; private: int m_cached_static_img_id; @@ -162,28 +162,28 @@ /** Constructs and assigns it to the passed item */ static InstanceVisual* create(Instance* instance); - + /** Destructor */ virtual ~InstanceVisual(); - + /** Sets stack position of the instance * Stack position is used to define the order in which instances residing * in the same location are drawn * @param stackposition new stack position */ void setStackPosition(int stackposition) { m_stackposition = stackposition; } - + /** Gets current stack position of instance * @return current stack position */ int getStackPosition() { return m_stackposition; } - + /** Get camera specific cache item for the visual * @return cache item */ inline InstanceVisualCacheItem& getCacheItem(Camera* cam) { return m_cache[cam]; } - + private: /** Constructor */ @@ -192,7 +192,7 @@ // there is separate cache item for each camera std::map<Camera*, InstanceVisualCacheItem> m_cache; }; - + /** Action visual contains data that is needed to visualize different actions on screen */ class ActionVisual: public Visual2DGfx { @@ -200,29 +200,29 @@ /** Constructs and assigns it to the passed item */ static ActionVisual* create(Action* action); - + /** Destructor */ virtual ~ActionVisual(); - + /** Adds new animation with given angle (degrees) */ void addAnimation(unsigned int angle, int animation_index); - + /** Gets index to animation closest to given angle * @return animation index, -1 if no animations available */ int getAnimationIndexByAngle(int angle); - + private: /** Constructor */ ActionVisual(); - + // animations associated with this action (handles to pool) // mapping = direction -> animation type_angle2id m_animations; }; - + } #endif