summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-10-26 21:18:45 +0300
committerAndrei Karas <akaras@inbox.ru>2013-10-26 23:23:32 +0300
commit0380eec2d9d03a2541e4f89640f452fb96a7914a (patch)
tree78d28c04511d26956fe5dad1bff30063cd755a88 /src
parent344fc37de3bbc385e04ee4109600625f9aefbeba (diff)
downloadmv-0380eec2d9d03a2541e4f89640f452fb96a7914a.tar.gz
mv-0380eec2d9d03a2541e4f89640f452fb96a7914a.tar.bz2
mv-0380eec2d9d03a2541e4f89640f452fb96a7914a.tar.xz
mv-0380eec2d9d03a2541e4f89640f452fb96a7914a.zip
Loading map layer masks from layer properties.
Diffstat (limited to 'src')
-rw-r--r--src/maplayer.cpp3
-rw-r--r--src/maplayer.h3
-rw-r--r--src/resources/mapreader.cpp32
3 files changed, 27 insertions, 11 deletions
diff --git a/src/maplayer.cpp b/src/maplayer.cpp
index 67df3930b..84514cdaa 100644
--- a/src/maplayer.cpp
+++ b/src/maplayer.cpp
@@ -43,7 +43,7 @@
#include "debug.h"
MapLayer::MapLayer(const int x, const int y, const int width, const int height,
- const bool fringeLayer):
+ const bool fringeLayer, const int mask):
mX(x),
mY(y),
mWidth(width),
@@ -52,6 +52,7 @@ MapLayer::MapLayer(const int x, const int y, const int width, const int height,
mSpecialLayer(nullptr),
mTempLayer(nullptr),
mTempRows(),
+ mMask(mask),
mIsFringeLayer(fringeLayer),
mHighlightAttackRange(config.getBoolValue("highlightAttackRange"))
{
diff --git a/src/maplayer.h b/src/maplayer.h
index f5b4c88a8..0706e438e 100644
--- a/src/maplayer.h
+++ b/src/maplayer.h
@@ -102,7 +102,7 @@ class MapLayer final: public ConfigListener
* There can be only one fringe layer per map.
*/
MapLayer(const int x, const int y, const int width, const int height,
- const bool isFringeLayer);
+ const bool isFringeLayer, const int mask);
A_DELETE_COPY(MapLayer)
@@ -190,6 +190,7 @@ class MapLayer final: public ConfigListener
SpecialLayer *mTempLayer;
typedef std::vector<MapRowVertexes*> MapRows;
MapRows mTempRows;
+ int mMask;
bool mIsFringeLayer; /**< Whether the actors are drawn. */
bool mHighlightAttackRange;
};
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 95da2ae36..a1b087102 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -666,6 +666,7 @@ void MapReader::readLayer(const XmlNodePtr node, Map *const map)
const bool isFringeLayer = (name.substr(0, 6) == "fringe");
const bool isCollisionLayer = (name.substr(0, 9) == "collision");
const bool isHeightLayer = (name.substr(0, 7) == "heights");
+ int mask = 1;
MapLayer::Type layerType = MapLayer::TILES;
if (isCollisionLayer)
@@ -694,12 +695,25 @@ void MapReader::readLayer(const XmlNodePtr node, Map *const map)
const std::string pname = XML::getProperty(prop, "name", "");
const std::string value = XML::getProperty(prop, "value", "");
// ignoring any layer if property Hidden is 1
- if (pname == "Hidden" && value == "1")
- return;
- if (pname == "Version" && value > CHECK_VERSION)
- return;
- if (pname == "NotVersion" && value <= CHECK_VERSION)
- return;
+ if (pname == "Hidden")
+ {
+ if (value == "1")
+ return;
+ }
+ else if (pname == "Version")
+ {
+ if (value > CHECK_VERSION)
+ return;
+ }
+ else if (pname == "NotVersion")
+ {
+ if (value <= CHECK_VERSION)
+ return;
+ }
+ else if (pname == "Mask")
+ {
+ mask = atoi(value.c_str());
+ }
}
}
@@ -708,7 +722,7 @@ void MapReader::readLayer(const XmlNodePtr node, Map *const map)
if (layerType == MapLayer::TILES)
{
- layer = new MapLayer(offsetX, offsetY, w, h, isFringeLayer);
+ layer = new MapLayer(offsetX, offsetY, w, h, isFringeLayer, mask);
map->addLayer(layer);
}
else if (layerType == MapLayer::HEIGHTS)
@@ -939,9 +953,9 @@ Map *MapReader::createEmptyMap(const std::string &filename,
map->setProperty("_realfilename", filename);
updateMusic(map);
map->setCustom(true);
- MapLayer *layer = new MapLayer(0, 0, 300, 300, false);
+ MapLayer *layer = new MapLayer(0, 0, 300, 300, false, 1);
map->addLayer(layer);
- layer = new MapLayer(0, 0, 300, 300, true);
+ layer = new MapLayer(0, 0, 300, 300, true, 1);
map->addLayer(layer);
return map;