Skip to content

Commit d3921a5

Browse files
- Reldens - Tile Map Generator
1 parent 1153073 commit d3921a5

7 files changed

+268
-61
lines changed

examples/layer-elements-composite/generate-multiples-with-associations.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const execute = async () => {
1616
{mapFileName: 'town-001', mapTitle: 'Town 1'},
1717
{mapFileName: 'town-002', mapTitle: 'Town 2'},
1818
{mapFileName: 'town-003', mapTitle: 'Town 3'},
19-
{mapFileName: 'town-004', mapTitle: 'Town 4'},
19+
{mapFileName: 'town-004', mapTitle: 'Town 4'}
2020
];
2121
let i = 0;
2222
for(let mapInformation of mapsInformation){

examples/layer-elements-composite/house-composite.json

+18
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@
255255
"id":129,
256256
"name":"stairs-up-return-point",
257257
"opacity":1,
258+
"properties":[
259+
{
260+
"name":"position",
261+
"type":"string",
262+
"value":"down"
263+
}],
258264
"type":"tilelayer",
259265
"visible":true,
260266
"width":40,
@@ -477,6 +483,12 @@
477483
"id":130,
478484
"name":"stairs-down-return-point",
479485
"opacity":1,
486+
"properties":[
487+
{
488+
"name":"position",
489+
"type":"string",
490+
"value":"down"
491+
}],
480492
"type":"tilelayer",
481493
"visible":true,
482494
"width":40,
@@ -1923,6 +1935,12 @@
19231935
"nextlayerid":131,
19241936
"nextobjectid":1,
19251937
"orientation":"orthogonal",
1938+
"properties":[
1939+
{
1940+
"name":"position",
1941+
"type":"string",
1942+
"value":"down"
1943+
}],
19261944
"renderorder":"right-down",
19271945
"tiledversion":"1.10.2",
19281946
"tileheight":16,

examples/layer-elements-composite/reldens-town-composite-with-associations.json

+107-14
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,12 @@
863863
"id":107,
864864
"name":"house-01-return-point",
865865
"opacity":1,
866+
"properties":[
867+
{
868+
"name":"position",
869+
"type":"string",
870+
"value":"down"
871+
}],
866872
"type":"tilelayer",
867873
"visible":true,
868874
"width":48,
@@ -913,15 +919,10 @@
913919
"type":"string",
914920
"value":"house-composite"
915921
},
916-
{
917-
"name":"createWalls",
918-
"type":"bool",
919-
"value":true
920-
},
921922
{
922923
"name":"elementTitle",
923924
"type":"string",
924-
"value":"House"
925+
"value":"House 1"
925926
},
926927
{
927928
"name":"entryPosition",
@@ -1178,6 +1179,12 @@
11781179
"id":105,
11791180
"name":"house-02-return-point",
11801181
"opacity":1,
1182+
"properties":[
1183+
{
1184+
"name":"position",
1185+
"type":"string",
1186+
"value":"down"
1187+
}],
11811188
"type":"tilelayer",
11821189
"visible":true,
11831190
"width":48,
@@ -1228,15 +1235,10 @@
12281235
"type":"string",
12291236
"value":"house-composite"
12301237
},
1231-
{
1232-
"name":"createWalls",
1233-
"type":"bool",
1234-
"value":true
1235-
},
12361238
{
12371239
"name":"elementTitle",
12381240
"type":"string",
1239-
"value":"House"
1241+
"value":"House 2"
12401242
},
12411243
{
12421244
"name":"entryPosition",
@@ -1493,6 +1495,12 @@
14931495
"id":106,
14941496
"name":"house-03-return-point",
14951497
"opacity":1,
1498+
"properties":[
1499+
{
1500+
"name":"position",
1501+
"type":"string",
1502+
"value":"down"
1503+
}],
14961504
"type":"tilelayer",
14971505
"visible":true,
14981506
"width":48,
@@ -1532,6 +1540,91 @@
15321540
"id":100,
15331541
"name":"house-03-change-points",
15341542
"opacity":1,
1543+
"properties":[
1544+
{
1545+
"name":"blockMapBorder",
1546+
"type":"bool",
1547+
"value":true
1548+
},
1549+
{
1550+
"name":"compositeFileNames",
1551+
"type":"string",
1552+
"value":"house-composite"
1553+
},
1554+
{
1555+
"name":"downFloorCompositeFileNames",
1556+
"type":"string",
1557+
"value":"house-composite"
1558+
},
1559+
{
1560+
"name":"downFloors",
1561+
"type":"int",
1562+
"value":1
1563+
},
1564+
{
1565+
"name":"elementTitle",
1566+
"type":"string",
1567+
"value":"House 3"
1568+
},
1569+
{
1570+
"name":"entryPosition",
1571+
"type":"string",
1572+
"value":"down-right"
1573+
},
1574+
{
1575+
"name":"entryPositionSize",
1576+
"type":"int",
1577+
"value":2
1578+
},
1579+
{
1580+
"name":"upperFloorCompositeFileNames",
1581+
"type":"string",
1582+
"value":"house-composite"
1583+
},
1584+
{
1585+
"name":"upperFloors",
1586+
"type":"int",
1587+
"value":1
1588+
}],
1589+
"type":"tilelayer",
1590+
"visible":true,
1591+
"width":48,
1592+
"x":0,
1593+
"y":0
1594+
},
1595+
{
1596+
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1597+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1598+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1599+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1600+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1601+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1623+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
1624+
"height":28,
1625+
"id":108,
1626+
"name":"house-03-shadow",
1627+
"opacity":1,
15351628
"properties":[
15361629
{
15371630
"name":"blockMapBorder",
@@ -1606,7 +1699,7 @@
16061699
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16071700
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16081701
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3698, 3699, 3701, 3702, 3703, 3704, 3700, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1609-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3767, 3768, 3770, 3771, 3772, 3773, 3769, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1702+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3767, 3768, 3770, 0, 3772, 3773, 3769, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16101703
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16111704
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16121705
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -1701,7 +1794,7 @@
17011794
"x":0,
17021795
"y":0
17031796
}],
1704-
"nextlayerid":108,
1797+
"nextlayerid":109,
17051798
"nextobjectid":28,
17061799
"orientation":"orthogonal",
17071800
"renderorder":"right-down",

lib/generator/associated-maps.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class AssociatedMaps
5858
let downFloors = Number(mappedProperties['downFloors'] || 0);
5959
let upperFloors = Number(mappedProperties['upperFloors'] || 0);
6060
this.generators[subMapName] = new RandomMapGenerator();
61-
let subMapTitle = this.fetchSubMapTitle(mainMapGenerator, mappedProperties);
61+
let subMapTitle = this.fetchSubMapTitle(mainMapGenerator, mappedProperties, generatedChangePoint);
6262
if ('' !== subMapTitle) {
6363
this.generators[subMapName].addMapProperty('mapTitle', 'string', subMapTitle);
6464
}
@@ -109,11 +109,23 @@ class AssociatedMaps
109109
return this.generatedSubMaps;
110110
}
111111

112-
fetchSubMapTitle(mainMapGenerator, mappedProperties)
112+
fetchSubMapTitle(mainMapGenerator, mappedProperties, changePointData)
113113
{
114+
// @TODO - BETA - Make all the titles configurable.
114115
let mapTitle = (mainMapGenerator.fetchMapProperty('mapTitle')?.value || '').toString();
115116
let elementTitle = mappedProperties['elementTitle'] || '';
116-
return '' !== mapTitle && '' !== elementTitle ? mapTitle + ' - ' + elementTitle : '';
117+
let elementNumber = sc.get(changePointData, 'elementNumber', '');
118+
let fetchedTitle = '';
119+
if ('' !== mapTitle) {
120+
fetchedTitle = mapTitle;
121+
}
122+
if ('' !== elementTitle) {
123+
fetchedTitle = fetchedTitle + ('' !== fetchedTitle ? ' - ' : '') + elementTitle;
124+
}
125+
if ('' !== elementNumber) {
126+
fetchedTitle = fetchedTitle + ('' !== fetchedTitle ? '-' : '') + elementNumber;
127+
}
128+
return fetchedTitle;
117129
}
118130

119131
async generateFloors(

0 commit comments

Comments
 (0)