changeset 591:378b588216d6

* Improved addTransparentArea(). Now you can set a list with namespaces.
author helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 13 Aug 2010 20:28:52 +0000
parents 59c92d10d7bc
children fc5a781adf2a
files engine/core/view/renderers/instancerenderer.cpp engine/core/view/renderers/instancerenderer.h engine/core/view/renderers/instancerenderer.i
diffstat 3 files changed, 23 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/engine/core/view/renderers/instancerenderer.cpp	Fri Aug 13 16:42:09 2010 +0000
+++ b/engine/core/view/renderers/instancerenderer.cpp	Fri Aug 13 20:28:52 2010 +0000
@@ -162,16 +162,19 @@
 					}
 
 					std::string str_name = instance->getObject()->getNamespace();
-					if(str_name.find(infoa.groups) != -1) {
-						ScreenPoint p;
-						Rect rec;
-						p = cam->toScreenCoordinates(infoa.instance->getLocation().getMapCoordinates());
-						rec.x = p.x - infoa.w / 2;
-						rec.y = p.y - infoa.h / 2;
-						rec.w = infoa.w;
-						rec.h = infoa.h;
-						if(infoa.instance != instance && vc.dimensions.intersects(rec)) {
-							vc.transparency = 255 - infoa.trans;
+					std::list<std::string>::iterator group_it = infoa.groups.begin();
+					for(;group_it != infoa.groups.end(); ++group_it) {
+						if(str_name.find((*group_it)) != -1) {
+							ScreenPoint p;
+							Rect rec;
+							p = cam->toScreenCoordinates(infoa.instance->getLocation().getMapCoordinates());
+							rec.x = p.x - infoa.w / 2;
+							rec.y = p.y - infoa.h / 2;
+							rec.w = infoa.w;
+							rec.h = infoa.h;
+							if(infoa.instance != instance && vc.dimensions.intersects(rec)) {
+								vc.transparency = 255 - infoa.trans;
+							}
 						}
 					}
 				}
@@ -371,10 +374,11 @@
 		}
 	}
 
-	void InstanceRenderer::addTransparentArea(Instance* instance, const std::string &groups, unsigned int w, unsigned int h, unsigned char trans, bool front) {
+	void InstanceRenderer::addTransparentArea(Instance* instance, const std::list<std::string> &groups, unsigned int w, unsigned int h, unsigned char trans, bool front) {
 		AreaInfo newinfo;
 		newinfo.instance = instance;
 		newinfo.groups = groups;
+
 		newinfo.w = w;
 		newinfo.h = h;
 		newinfo.trans = trans;
--- a/engine/core/view/renderers/instancerenderer.h	Fri Aug 13 16:42:09 2010 +0000
+++ b/engine/core/view/renderers/instancerenderer.h	Fri Aug 13 20:28:52 2010 +0000
@@ -24,6 +24,7 @@
 
 // Standard C++ library includes
 #include <string>
+#include <list>
 
 // 3rd party library includes
 
@@ -68,7 +69,7 @@
 
 		/** Marks given instance to have an transparent area with given paramters
 		 */
-		void addTransparentArea(Instance* instance, const std::string &groups, unsigned int w, unsigned int h, unsigned char trans, bool front = true);
+		void addTransparentArea(Instance* instance, const std::list<std::string> &groups, unsigned int w, unsigned int h, unsigned char trans, bool front = true);
 		
 		/** Removes instance from outlining list
 		 */
@@ -133,7 +134,8 @@
 		class AreaInfo {
 		public:
 			Instance* instance;
-			std::string groups;
+			//std::string groups;
+			std::list<std::string> groups;
 			unsigned int w;
 			unsigned int h;
 			unsigned char trans;
--- a/engine/core/view/renderers/instancerenderer.i	Fri Aug 13 16:42:09 2010 +0000
+++ b/engine/core/view/renderers/instancerenderer.i	Fri Aug 13 20:28:52 2010 +0000
@@ -25,6 +25,8 @@
 %}
 
 namespace FIFE {
+	%apply const std::list<std::string> &OUTPUT {std::list<std::string> &groups};
+	
 	class Location;
 	class RenderBackend;
 	class ImagePool;
@@ -40,11 +42,12 @@
 		void addColored(Instance* instance, int r, int g, int b);
 		void removeColored(Instance* instance);
 		void removeAllColored();
-		void addTransparentArea(Instance* instance, const std::string &groups, unsigned int w, unsigned int h, unsigned char trans, bool front = true);
+		void addTransparentArea(Instance* instance, const std::list<std::string> &groups, unsigned int w, unsigned int h, unsigned char trans, bool front = true);
 		void removeTransparentArea(Instance* instance);
 		void removeAllTransparentAreas();
 		static InstanceRenderer* getInstance(IRendererContainer* cnt);
 	private:
 		InstanceRenderer(RenderBackend* renderbackend, int position, ImagePool* imagepool, AnimationPool* animpool);
 	};
+	%clear std::list<std::string> &groups;
 }