[Scummvm-cvs-logs] SF.net SVN: scummvm:[46343] scummvm/trunk/engines/teenagent/scene.cpp

megath at users.sourceforge.net megath at users.sourceforge.net
Sat Dec 12 14:33:35 CET 2009


Revision: 46343
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46343&view=rev
Author:   megath
Date:     2009-12-12 13:33:35 +0000 (Sat, 12 Dec 2009)

Log Message:
-----------
added z-ordering of the animation slots.

Modified Paths:
--------------
    scummvm/trunk/engines/teenagent/scene.cpp

Modified: scummvm/trunk/engines/teenagent/scene.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/scene.cpp	2009-12-12 13:12:30 UTC (rev 46342)
+++ scummvm/trunk/engines/teenagent/scene.cpp	2009-12-12 13:33:35 UTC (rev 46343)
@@ -26,6 +26,7 @@
 #include "teenagent/resources.h"
 #include "teenagent/surface.h"
 #include "common/debug.h"
+#include "common/algorithm.h"
 #include "teenagent/objects.h"
 #include "teenagent/teenagent.h"
 #include "teenagent/dialog.h"
@@ -483,6 +484,12 @@
 	}
 }
 
+struct ZOrderCmp {
+	inline bool operator()(const Surface *a, const Surface *b) const {
+		return a->y + a->h < b->y + b->h;
+	}
+};
+
 bool Scene::render(OSystem *system) {
 	Resources *res = Resources::instance();
 	bool busy;
@@ -542,7 +549,9 @@
 					s->render(surface);
 			}
 		}
-
+		
+		Common::List<Surface *> z_order;
+		
 		for (byte i = 0; i < 4; ++i) {
 			Animation *a = custom_animation + i;
 			Surface *s = a->currentFrame();
@@ -577,9 +586,9 @@
 			
 			if (s == NULL)
 				continue;
-
+			
 			if (debug_features.feature[DebugFeatures::kShowLan])
-				animation_position[i] = s->render(surface);
+				z_order.push_back(s);
 
 			if (a->id == 0)
 				continue;
@@ -595,6 +604,16 @@
 			}
 		}
 
+		Common::sort(z_order.begin(), z_order.end(), ZOrderCmp());
+		Common::List<Surface *>::iterator z_order_it;
+
+		for(z_order_it = z_order.begin(); z_order_it != z_order.end(); ++z_order_it) {
+			Surface *s = *z_order_it;
+			if (s->y + s->h > position.y)
+				break;
+			s->render(surface);
+		}
+
 		{
 			Surface *mark = actor_animation.currentFrame();
 			if (mark != NULL) {
@@ -659,6 +678,11 @@
 			}
 		}
 
+		for(; z_order_it != z_order.end(); ++z_order_it) {
+			Surface *s = *z_order_it;
+			s->render(surface);
+		}
+
 		if (!message.empty()) {
 			bool visible = true;
 			if (message_first_frame != 0 && message_animation != NULL) {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list