summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-10-26 22:09:03 +0300
committerAndrei Karas <akaras@inbox.ru>2013-10-26 23:49:56 +0300
commit91998bfc4631cd305062bf9bedd56083a2b2cbde (patch)
tree68b9924a69d4ee27ae41eb0d5f2ec4af2a86fb4e /src/map.cpp
parentb0167b595a952e1decc48c239c95c52e1bc057d7 (diff)
downloadmanaplus-91998bfc4631cd305062bf9bedd56083a2b2cbde.tar.gz
manaplus-91998bfc4631cd305062bf9bedd56083a2b2cbde.tar.bz2
manaplus-91998bfc4631cd305062bf9bedd56083a2b2cbde.tar.xz
manaplus-91998bfc4631cd305062bf9bedd56083a2b2cbde.zip
allow load and use mask in ambient layers.
default layer mask is 1.
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 3c0c9f4a4..5188da985 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -281,11 +281,15 @@ void Map::initializeAmbientLayers()
Image *const img = resman->getImage(getProperty(name + "image"));
if (img)
{
+ int mask = atoi(getProperty(name + "mask").c_str());
+ if (!mask)
+ mask = 1;
mForegrounds.push_back(new AmbientLayer(img,
getFloatProperty(name + "parallax"),
getFloatProperty(name + "scrollX"),
getFloatProperty(name + "scrollY"),
- getBoolProperty(name + "keepratio")));
+ getBoolProperty(name + "keepratio"),
+ mask));
// The AmbientLayer takes control over the image.
img->decRef();
@@ -301,11 +305,15 @@ void Map::initializeAmbientLayers()
if (img)
{
+ int mask = atoi(getProperty(name + "mask").c_str());
+ if (!mask)
+ mask = 1;
mBackgrounds.push_back(new AmbientLayer(img,
getFloatProperty(name + "parallax"),
getFloatProperty(name + "scrollX"),
getFloatProperty(name + "scrollY"),
- getBoolProperty(name + "keepratio")));
+ getBoolProperty(name + "keepratio"),
+ mask));
// The AmbientLayer takes control over the image.
img->decRef();
@@ -603,11 +611,19 @@ void Map::updateAmbientLayers(const float scrollX, const float scrollY)
// need check mask to update or not to update
- FOR_EACH (AmbientLayerVectorCIter, i, mBackgrounds)
- (*i)->update(timePassed, dx, dy);
+ FOR_EACH (AmbientLayerVectorIter, i, mBackgrounds)
+ {
+ AmbientLayer *const layer = *i;
+ if (layer && (layer->mMask & mMask))
+ layer->update(timePassed, dx, dy);
+ }
- FOR_EACH (AmbientLayerVectorCIter, i, mForegrounds)
- (*i)->update(timePassed, dx, dy);
+ FOR_EACH (AmbientLayerVectorIter, i, mForegrounds)
+ {
+ AmbientLayer *const layer = *i;
+ if (layer && (layer->mMask & mMask))
+ layer->update(timePassed, dx, dy);
+ }
mLastAScrollX = scrollX;
mLastAScrollY = scrollY;
@@ -643,9 +659,10 @@ void Map::drawAmbientLayers(Graphics *const graphics, const LayerType type,
// Draw overlays
FOR_EACHP (AmbientLayerVectorCIter, i, layers)
{
+ const AmbientLayer *const layer = *i;
// need check mask to draw or not to draw
- if (*i)
- (*i)->draw(graphics, graphics->mWidth, graphics->mHeight);
+ if (layer && (layer->mMask & mMask))
+ (layer)->draw(graphics, graphics->mWidth, graphics->mHeight);
// Detail 1: only one overlay, higher: all overlays
if (detail == 1)