# HG changeset patch # User prock@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1264624983 0 # Node ID 8fa2f3aa0cbd8afdef868ab20fd895bf9517b3e6 # Parent 81641655bc389484f15e2f608124e589f806de0b Added the ActionVisual::getActionImageAngles() function. diff -r 81641655bc38 -r 8fa2f3aa0cbd engine/core/view/visual.cpp --- a/engine/core/view/visual.cpp Wed Jan 27 15:58:49 2010 +0000 +++ b/engine/core/view/visual.cpp Wed Jan 27 20:43:03 2010 +0000 @@ -40,16 +40,16 @@ namespace FIFE { static Logger _log(LM_VIEW); - + Visual2DGfx::Visual2DGfx(): m_transparency(0), m_visible(true) { } - + Visual2DGfx::~Visual2DGfx() { } - + ObjectVisual::ObjectVisual() { } - + ObjectVisual* ObjectVisual::create(Object* object) { if (object->getVisual()) { throw Duplicate("Object already contains visualization"); @@ -58,25 +58,25 @@ object->adoptVisual(v); return v; } - + ObjectVisual::~ObjectVisual() { } - + void ObjectVisual::addStaticImage(unsigned int angle, int image_index) { m_angle2img[angle % 360] = image_index; } - + int ObjectVisual::getStaticImageIndexByAngle(int angle) { int closestMatch = 0; return getIndexByAngle(angle, m_angle2img, closestMatch); } - + int ObjectVisual::getClosestMatchingAngle(int angle) { int closestMatch = 0; getIndexByAngle(angle, m_angle2img, closestMatch); return closestMatch; } - + void ObjectVisual::getStaticImageAngles(std::vector& angles) { angles.clear(); type_angle2id::const_iterator i(m_angle2img.begin()); @@ -85,7 +85,7 @@ ++i; } } - + const int STATIC_IMAGE_NOT_INITIALIZED = -2; const int STATIC_IMAGE_NOT_FOUND = -1; @@ -107,12 +107,12 @@ m_cached_static_img_id = instance->getObject()->getVisual()->getStaticImageIndexByAngle(angle); m_cached_static_img_angle = angle; return m_cached_static_img_id; - } - - InstanceVisual::InstanceVisual(): + } + + InstanceVisual::InstanceVisual(): m_stackposition(0) { } - + InstanceVisual* InstanceVisual::create(Instance* instance) { if (instance->getVisual()) { throw Duplicate("Instance already contains visualization"); @@ -121,13 +121,13 @@ instance->setVisual(v); return v; } - + InstanceVisual::~InstanceVisual() { } - + ActionVisual::ActionVisual(): m_animations() { } - + ActionVisual* ActionVisual::create(Action* action) { if (action->getVisual()) { throw Duplicate("Action already contains visualization"); @@ -136,7 +136,7 @@ action->adoptVisual(v); return v; } - + ActionVisual::~ActionVisual() { } @@ -148,4 +148,13 @@ int closestMatch = 0; return getIndexByAngle(angle, m_animations, closestMatch); } + + void ActionVisual::getActionImageAngles(std::vector& angles) { + angles.clear(); + type_angle2id::const_iterator i(m_animations.begin()); + while (i != m_animations.end()) { + angles.push_back(i->first); + ++i; + } + } } diff -r 81641655bc38 -r 8fa2f3aa0cbd engine/core/view/visual.h --- a/engine/core/view/visual.h Wed Jan 27 15:58:49 2010 +0000 +++ b/engine/core/view/visual.h Wed Jan 27 20:43:03 2010 +0000 @@ -214,6 +214,10 @@ */ int getAnimationIndexByAngle(int angle); + /** Returns list of available angles for this Action + */ + void getActionImageAngles(std::vector& angles); + private: /** Constructor */ diff -r 81641655bc38 -r 8fa2f3aa0cbd engine/core/view/visual.i --- a/engine/core/view/visual.i Wed Jan 27 15:58:49 2010 +0000 +++ b/engine/core/view/visual.i Wed Jan 27 20:43:03 2010 +0000 @@ -62,12 +62,14 @@ }; %template(get2dGfxVisual) Instance::getVisual; + %apply std::vector &OUTPUT { std::vector& angles }; class ActionVisual: public Visual2DGfx { public: static ActionVisual* create(Action* action); virtual ~ActionVisual(); void addAnimation(unsigned int angle, int animation_index); int getAnimationIndexByAngle(int angle); + void getActionImageAngles(std::vector& angles); private: ActionVisual(); };