changeset 397:8fa2f3aa0cbd

Added the ActionVisual::getActionImageAngles() function.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 27 Jan 2010 20:43:03 +0000
parents 81641655bc38
children 7b1de5e31834
files engine/core/view/visual.cpp engine/core/view/visual.h engine/core/view/visual.i
diffstat 3 files changed, 33 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- 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<ObjectVisual>()) {
 			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<int>& 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<ObjectVisual>()->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<InstanceVisual>()) {
 			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<ActionVisual>()) {
 			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<int>& angles) {
+		angles.clear();
+		type_angle2id::const_iterator i(m_animations.begin());
+		while (i != m_animations.end()) {
+			angles.push_back(i->first);
+			++i;
+		}
+	}
 }
--- 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<int>& angles);
+
 	private:
 		/** Constructor
 		 */
--- 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<InstanceVisual>;
 	
+	%apply std::vector<int> &OUTPUT { std::vector<int>& 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<int>& angles);
 	private:
 		ActionVisual();
 	};