diff --git a/app/data/testmap3S/data.js b/app/data/testmap3S/data.js index 4a6eb06..b3f3dbe 100644 --- a/app/data/testmap3S/data.js +++ b/app/data/testmap3S/data.js @@ -93,6 +93,19 @@ ec && ec.loadMap({ "material": "brick", "image": "elements/wall.png" }, + { + "name": "little floor", + "mapType": "parallax", + "x": 169, + "y": 887, + "z": 0, + "width": 259, + "height": 70, + "depth": 0, + "regX": 0, + "regY": 0, + "image": "elements/little_floor.png" + }, { "name": "floor", "mapType": "floor", diff --git a/app/data/testmap3S/elements/big_box.png b/app/data/testmap3S/elements/big_box.png index 0095e0a..52cefdb 100644 Binary files a/app/data/testmap3S/elements/big_box.png and b/app/data/testmap3S/elements/big_box.png differ diff --git a/app/data/testmap3S/elements/full_area.png b/app/data/testmap3S/elements/full_area.png index 3339959..ef924de 100644 Binary files a/app/data/testmap3S/elements/full_area.png and b/app/data/testmap3S/elements/full_area.png differ diff --git a/app/data/testmap3S/elements/little_box.png b/app/data/testmap3S/elements/little_box.png index 51a7ae8..e23108d 100644 Binary files a/app/data/testmap3S/elements/little_box.png and b/app/data/testmap3S/elements/little_box.png differ diff --git a/app/data/testmap3S/elements/little_floor.png b/app/data/testmap3S/elements/little_floor.png new file mode 100644 index 0000000..d551bbb Binary files /dev/null and b/app/data/testmap3S/elements/little_floor.png differ diff --git a/dev/maps/Scripts/Export Map.jsx b/dev/maps/Scripts/Export Map.jsx index 710c981..dbd09ba 100644 --- a/dev/maps/Scripts/Export Map.jsx +++ b/dev/maps/Scripts/Export Map.jsx @@ -251,6 +251,8 @@ function main() { function parseLayers(layers, mapLayer) { log('>', layers.length, 'Layers'); + var elementCount = 0; + for (var i = layers.length; i-- > 0;) { var layer = layers[i]; @@ -275,12 +277,18 @@ function parseLayers(layers, mapLayer) { } if (layer.typename === 'ArtLayer') { - parseArtLayer(layer, mapLayer); + elementCount += parseArtLayer(layer, mapLayer); } else if (layer.typename === 'LayerSet') { - parseLayerSet(layer, mapLayer); + var elementsFound = parseLayerSet(layer, mapLayer); + elementCount += elementsFound; + if (elementsFound === 0) { + log('- FOUND NO ELEMENTS IN', quote(layer.name)); + } } } + + return elementCount; } //----------- @@ -291,10 +299,12 @@ function parseArtLayer(layer, mapLayer) { /* LayerKind.NORMAL, <--- export image? LayerKind.PATTERNFILL, <--- - LayerKind.SMARTOBJECT, <--- + LayerKind.SMARTOBJECT, <--- return 1 or more LayerKind.SOLIDFILL, <--- (Paths) LayerKind.TEXT <--- Data? */ + + return 0; } function parseLayerSet(layerSet, mapLayer) { @@ -332,7 +342,6 @@ function parseLayerSet(layerSet, mapLayer) { var elementData = getElementData(layerSet); if (elementData.shapes.length) { log('\t+ new element'); - // Get the other stuff (images, childres, etc...) elements.push(elementData); //reg point @@ -356,43 +365,65 @@ function parseLayerSet(layerSet, mapLayer) { height: getLayerHeight(layerSet) }); - // TODO: determine if this set will be exported as one image, or if we export sub layers: - //var otherLayers = elementData.layers; - delete elementData.layers; - //parseLayers(otherLayers, mapLayer, elementData); + exportElement(elementData, layerSet); - // export PNG - var filename = getLayerImageName(layerSet) +'.png'; - var filepath = exports.elementsFolder.toString() +'/'+ filename; - exportLayer(layerSet, filepath); - elementData.image = 'elements/'+filename; + return 1; + } - } else { - parseLayers(layerSet.layers, mapLayer); - } // else add children, if (!mapType) mapType = 'container' - - //------------- - // var layerContainer = { - // mapType: 'container',//'parallax' - // children: [] - // }; - // var layerFrameElements = [];//layerSet.frames[0].elements; - // for (var j=0; j 0;) { var layer = layers[i]; - var shapes; var name = layer.name.toLowerCase(); var width; var height; @@ -582,17 +612,17 @@ function getPathData(layer, offsetX, offsetY) { var poly = []; polygons.push(poly); - + var points = path.subPathItems[b].pathPoints; for (var c = 0; c < points.length; c++) { //points[c].kind //PointKind.SMOOTHPOINT (elipse?) //PointKind.CORNERPOINT var point = points[c].anchor;//.slice(0); - poly[c] = [ + poly.push([ Math.round((point[0]-offsetX)*10)/10, Math.round((point[1]-offsetY)*10)/10 - ]; + ]); // points[c].leftDirection // points[c].rightDirection // points[c].kind