From b0167b595a952e1decc48c239c95c52e1bc057d7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 26 Oct 2013 21:40:47 +0300 Subject: show main layers based on map mask. --- src/map.cpp | 10 ++++++++++ src/map.h | 1 + 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/map.cpp b/src/map.cpp index 362693722..3c0c9f4a4 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -172,6 +172,7 @@ Map::Map(const int width, const int height, mDrawY(-1), mDrawScrollX(-1), mDrawScrollY(-1), + mMask(1), mAtlas(nullptr), mHeights(nullptr), mRedrawMap(true), @@ -430,6 +431,9 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY) layeri != layeri_end && !overFringe; ++ layeri) { MapLayer *const layer = *layeri; + if (!(layer->mMask & mMask)) + continue; + if (layer->isFringeLayer()) { layer->setSpecialLayer(mSpecialLayer); @@ -597,6 +601,8 @@ void Map::updateAmbientLayers(const float scrollX, const float scrollY) const float dy = scrollY - mLastAScrollY; const int timePassed = get_elapsed_time(lastTick); + // need check mask to update or not to update + FOR_EACH (AmbientLayerVectorCIter, i, mBackgrounds) (*i)->update(timePassed, dx, dy); @@ -637,6 +643,7 @@ void Map::drawAmbientLayers(Graphics *const graphics, const LayerType type, // Draw overlays FOR_EACHP (AmbientLayerVectorCIter, i, layers) { + // need check mask to draw or not to draw if (*i) (*i)->draw(graphics, graphics->mWidth, graphics->mHeight); @@ -1603,4 +1610,7 @@ uint8_t Map::getHeightOffset(const int x, const int y) const void Map::setMask(const int mask) { + if (mask != mMask) + mRedrawMap = true; + mMask = mask; } diff --git a/src/map.h b/src/map.h index 89e62e4fc..49662c919 100644 --- a/src/map.h +++ b/src/map.h @@ -547,6 +547,7 @@ class Map final : public Properties, public ConfigListener int mDrawY; int mDrawScrollX; int mDrawScrollY; + int mMask; Resource *mAtlas; MapHeights *mHeights; bool mRedrawMap; -- cgit v1.2.3-70-g09d2