From 435360d3ba7d979c7ed5c05e4ac07e113c6f2a0e Mon Sep 17 00:00:00 2001 From: Vladimir Menshakov Date: Sat, 12 Dec 2009 13:33:35 +0000 Subject: added z-ordering of the animation slots. svn-id: r46343 --- engines/teenagent/scene.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp index 463f1460e0..331e9dc483 100644 --- a/engines/teenagent/scene.cpp +++ b/engines/teenagent/scene.cpp @@ -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 @@ bool Scene::processEvent(const Common::Event &event) { } } +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 @@ bool Scene::render(OSystem *system) { s->render(surface); } } - + + Common::List z_order; + for (byte i = 0; i < 4; ++i) { Animation *a = custom_animation + i; Surface *s = a->currentFrame(); @@ -577,9 +586,9 @@ bool Scene::render(OSystem *system) { 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 @@ bool Scene::render(OSystem *system) { } } + Common::sort(z_order.begin(), z_order.end(), ZOrderCmp()); + Common::List::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 @@ bool Scene::render(OSystem *system) { } } + 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) { -- cgit v1.2.3