diff options
Diffstat (limited to 'engines/teenagent/scene.cpp')
-rw-r--r-- | engines/teenagent/scene.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
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<Surface *> 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<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 @@ 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) { |