Documented changing map format and tiled export tool updated.

This commit is contained in:
Ulysse Cura 2026-08-20 01:08:02 +02:00
parent 66a0cf3df8
commit 1951d0bbca
6 changed files with 333 additions and 306 deletions

View File

@ -45,25 +45,25 @@ Convert from json to custom format.
### Maps asset data structure ### Maps asset data structure
| Description | Length | | Description | Length |
| :-------------------------- | :------------------------------------------------ | | :-------------------------- | :---------------------------------------------------- |
| Map width | unsigned int (32 bits) | | Map width | unsigned short (16 bits) |
| Map height | unsigned int (32 bits) | | Map height | unsigned short (16 bits) |
| Map background layer 1 data | depend on map size, tile short (16 bits) | | Map background layers nb | unsigned char (8 bits) |
| Map background layer 2 data | depend on map size, tile short (16 bits) | | Map background layers data | depends map size and layer count, tile short (16 bits)|
| Map background layer 3 data | depend on map size, tile short (16 bits) |
| Map foreground layer data | depend on map size, tile short (16 bits) | | Map foreground layer data | depend on map size, tile short (16 bits) |
| Tileset asset name | const char [] (variable length, ends with '\00') |
| Map hitboxes data | depend on map size, tile unsigned char (8 bits) | | Map hitboxes data | depend on map size, tile unsigned char (8 bits) |
| Entities number | unsigned int (32 bits) | | Entities number | unsigned short (16 bits) |
| ... | | | ... | |
| Entity ID | unsigned int (32 bits) | | Entity ID | unsigned int (32 bits) |
| Entity components number | unsigned int (32 bits) | | Entity components number | unsigned short (16 bits) |
| ... | | | ... | |
| Component type | int (32 bits) | | Component type | unsigned int (32 bits) |
| ... | | | ... | |
| Component attributes | depend on attribute type | | Component attributes | depend on attribute type |
| int | int (32 bits) | | int | unsigned int (32 bits) |
| float | float (32 bits) | | float | float (32 bits) |
| bool | bool (8 bits) | | bool | _Bool (8 bits) |
| str | const char [] (variable length, ends with '\00') | | str | const char [] (variable length, ends with '\00') |
| ... | | | ... | |
| ... | | | ... | |

View File

@ -2,7 +2,8 @@
"MapWidth": 32, "MapWidth": 32,
"MapHeight": 24, "MapHeight": 24,
"BackgroundLayer1": [ "BackgroundLayers": [
[
734, 733, 734, 734, 734, 732, 732, 733, 738, 707, 986, 987, 988, 648, 649, 650, 651, 652, 733, 732, 2069, 2070, 2071, 2072, 733, 734, 734, 734, 733, 1774, 1775, 1776, 734, 733, 734, 734, 734, 732, 732, 733, 738, 707, 986, 987, 988, 648, 649, 650, 651, 652, 733, 732, 2069, 2070, 2071, 2072, 733, 734, 734, 734, 733, 1774, 1775, 1776,
986, 987, 988, 734, 733, 734, 1432, 734, 733, 734, 1035, 1036, 1037, 697, 698, 699, 700, 701, 734, 2163, 2118, 2119, 2120, 2121, 732, 546, 733, 732, 943, 944, 945, 733, 986, 987, 988, 734, 733, 734, 1432, 734, 733, 734, 1035, 1036, 1037, 697, 698, 699, 700, 701, 734, 2163, 2118, 2119, 2120, 2121, 732, 546, 733, 732, 943, 944, 945, 733,
1035, 1036, 1037, 615, 1717, 732, 1481, 733, 732, 1083, 1084, 1085, 1086, 746, 747, 748, 749, 750, 733, 2166, 2167, 2168, 2169, 2170, 594, 595, 596, 991, 992, 993, 994, 995, 1035, 1036, 1037, 615, 1717, 732, 1481, 733, 732, 1083, 1084, 1085, 1086, 746, 747, 748, 749, 750, 733, 2166, 2167, 2168, 2169, 2170, 594, 595, 596, 991, 992, 993, 994, 995,
@ -28,7 +29,7 @@
734, 732, 734, 734, 734, 1819, 1820, 734, 733, 732, 732, 732, 734, 35, 35, 36, 35, 36, 732, 732, 734, 733, 732, 734, 734, 734, 732, 732, 734, 734, 733, 732, 734, 732, 734, 734, 734, 1819, 1820, 734, 733, 732, 732, 732, 734, 35, 35, 36, 35, 36, 732, 732, 734, 733, 732, 734, 734, 734, 732, 732, 734, 734, 733, 732,
732, 733, 733, 733, 733, 732, 732, 733, 732, 734, 733, 732, 734, 732, 85, 35, 36, 35, 734, 733, 733, 732, 734, 733, 734, 732, 733, 734, 732, 733, 733, 734 732, 733, 733, 733, 733, 732, 732, 733, 732, 734, 733, 732, 734, 732, 85, 35, 36, 35, 734, 733, 733, 732, 734, 733, 734, 732, 733, 734, 732, 733, 733, 734
], ],
"BackgroundLayer2": [ [
937, 938, 939, 940, 1127, 1128, 1621, 737, 706, 0, 708, 0, 647, 0, 2412, 0, 0, 2414, 2113, 2114, 1298, 1299, 1300, 1301, 496, 497, 1052, 1053, 1773, 895, 896, 0, 937, 938, 939, 940, 1127, 1128, 1621, 737, 706, 0, 708, 0, 647, 0, 2412, 0, 0, 2414, 2113, 2114, 1298, 1299, 1300, 1301, 496, 497, 1052, 1053, 1773, 895, 896, 0,
0, 0, 565, 989, 1176, 1177, 0, 786, 787, 1034, 757, 758, 696, 0, 0, 0, 2412, 0, 702, 2117, 1347, 1348, 1349, 544, 545, 1352, 1101, 1102, 0, 0, 0, 1825, 0, 0, 565, 989, 1176, 1177, 0, 786, 787, 1034, 757, 758, 696, 0, 0, 0, 2412, 0, 702, 2117, 1347, 1348, 1349, 544, 545, 1352, 1101, 1102, 0, 0, 0, 1825,
0, 613, 614, 0, 616, 1718, 618, 1482, 1081, 805, 806, 807, 745, 2411, 0, 0, 0, 2413, 751, 1330, 1396, 1397, 1398, 593, 1400, 1401, 990, 0, 0, 0, 0, 0, 0, 613, 614, 0, 616, 1718, 618, 1482, 1081, 805, 806, 807, 745, 2411, 0, 0, 0, 2413, 751, 1330, 1396, 1397, 1398, 593, 1400, 1401, 990, 0, 0, 0, 0, 0,
@ -54,7 +55,7 @@
1329, 1330, 1334, 1335, 1336, 0, 0, 2280, 1181, 0, 2462, 0, 0, 356, 306, 0, 354, 308, 0, 0, 2597, 2413, 892, 0, 1081, 980, 981, 805, 806, 1823, 1824, 1825, 1329, 1330, 1334, 1335, 1336, 0, 0, 2280, 1181, 0, 2462, 0, 0, 356, 306, 0, 354, 308, 0, 0, 2597, 2413, 892, 0, 1081, 980, 981, 805, 806, 1823, 1824, 1825,
1378, 1379, 1552, 1553, 2324, 2325, 2326, 2327, 0, 0, 843, 0, 0, 1000, 356, 306, 0, 358, 0, 793, 0, 0, 2414, 1080, 0, 1029, 1030, 854, 855, 856, 0, 0 1378, 1379, 1552, 1553, 2324, 2325, 2326, 2327, 0, 0, 843, 0, 0, 1000, 356, 306, 0, 358, 0, 793, 0, 0, 2414, 1080, 0, 1029, 1030, 854, 855, 856, 0, 0
], ],
"BackgroundLayer3": [ [
0, 0, 0, 0, 1619, 1620, 1383, 1384, 0, 0, 0, 0, 2415, 0, 0, 0, 0, 0, 653, 2068, 0, 0, 0, 0, 1302, 1303, 498, 893, 894, 0, 0, 0, 0, 0, 0, 0, 1619, 1620, 1383, 1384, 0, 0, 0, 0, 2415, 0, 0, 0, 0, 0, 653, 2068, 0, 0, 0, 0, 1302, 1303, 498, 893, 894, 0, 0, 0,
0, 0, 0, 566, 1668, 1669, 0, 1433, 755, 756, 0, 0, 0, 0, 0, 0, 0, 0, 1280, 2117, 0, 0, 0, 1350, 1351, 0, 547, 942, 0, 0, 0, 946, 0, 0, 0, 566, 1668, 1669, 0, 1433, 755, 756, 0, 0, 0, 0, 0, 0, 0, 0, 1280, 2117, 0, 0, 0, 1350, 1351, 0, 547, 942, 0, 0, 0, 946,
0, 0, 0, 0, 0, 1480, 0, 0, 804, 0, 0, 0, 0, 0, 0, 0, 0, 1328, 1329, 0, 0, 0, 0, 1399, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1480, 0, 0, 804, 0, 0, 0, 0, 0, 0, 0, 0, 1328, 1329, 0, 0, 0, 0, 1399, 0, 0, 0, 0, 0, 0, 0, 0,
@ -79,8 +80,9 @@
1452, 1453, 0, 1455, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2504, 0, 0, 0, 0, 0, 0, 0, 0, 931, 755, 0, 757, 758, 0, 0, 1452, 1453, 0, 1455, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2504, 0, 0, 0, 0, 0, 0, 0, 0, 931, 755, 0, 757, 758, 0, 0,
1501, 1502, 1503, 1504, 1818, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 804, 0, 0, 807, 0, 0, 1501, 1502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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
],
"Entities": [ "Entities": [
] ]
} }

View File

@ -30,5 +30,4 @@
eJwL52JgCB/Fo3gUj+IhhiOhmB52RWDBxMhRy25S5anpBnL9Rg03kGsGLfw/EHaTmg5oZTeutECrND+KR/Eopj0GAGrPIzU= eJwL52JgCB/Fo3gUj+IhhiOhmB52RWDBxMhRy25S5anpBnL9Rg03kGsGLfw/EHaTmg5oZTeutECrND+KR/Eopj0GAGrPIzU=
</data> </data>
</layer> </layer>
<objectgroup id="13" name="Entities"/>
</map> </map>

View File

@ -2,7 +2,8 @@
"MapWidth": 14, "MapWidth": 14,
"MapHeight": 16, "MapHeight": 16,
"BackgroundLayer1": [ "BackgroundLayers": [
[
13, 157, 157, 157, 157, 157, 245, 247, 157, 157, 157, 157, 157, 14, 13, 157, 157, 157, 157, 157, 245, 247, 157, 157, 157, 157, 157, 14,
108, 1, 2, 2, 2, 2, 245, 247, 2, 2, 2, 2, 3, 156, 108, 1, 2, 2, 2, 2, 245, 247, 2, 2, 2, 2, 3, 156,
108, 50, 51, 51, 51, 51, 245, 247, 51, 51, 51, 51, 52, 156, 108, 50, 51, 51, 51, 51, 245, 247, 51, 51, 51, 51, 52, 156,
@ -18,11 +19,11 @@
108, 245, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 247, 156, 108, 245, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 247, 156,
108, 245, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 247, 156, 108, 245, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 247, 156,
108, 294, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 296, 156, 108, 294, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 296, 156,
62, 107, 107, 107, 107, 107, 69, 70, 107, 107, 107, 107, 107, 63 62, 107, 107, 107, 107, 107, 0, 0, 107, 107, 107, 107, 107, 63
], ],
"BackgroundLayer2": [ [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 71, 72, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 120, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 121, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -37,28 +38,11 @@
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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,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1
], ],
"Entities": [ "Entities": [
{ {

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.12.1" orientation="orthogonal" renderorder="right-down" width="14" height="16" tilewidth="16" tileheight="16" infinite="0" nextlayerid="9" nextobjectid="13"> <map version="1.10" tiledversion="1.12.1" orientation="orthogonal" renderorder="right-down" width="14" height="16" tilewidth="16" tileheight="16" infinite="0" nextlayerid="10" nextobjectid="13">
<editorsettings> <editorsettings>
<export target="dungeon_room_1.json" format="custom"/> <export target="dungeon_room_1.map" format="custom"/>
</editorsettings> </editorsettings>
<tileset firstgid="1" source="../tileset/tileset.tsx"/> <tileset firstgid="1" source="../tileset/tileset.tsx"/>
<tileset firstgid="2647" source="hiitboxes.tsx"/> <tileset firstgid="2647" source="hiitboxes.tsx"/>
<layer id="1" name="BackgroundLayer1" width="14" height="16"> <layer id="1" name="Background1" width="14" height="16">
<data encoding="csv"> <data encoding="csv">
14,158,158,158,158,158,246,248,158,158,158,158,158,15, 14,158,158,158,158,158,246,248,158,158,158,158,158,15,
109,2,3,3,3,3,246,248,3,3,3,3,4,157, 109,2,3,3,3,3,246,248,3,3,3,3,4,157,
@ -22,13 +22,13 @@
109,246,247,247,247,247,247,247,247,247,247,247,248,157, 109,246,247,247,247,247,247,247,247,247,247,247,248,157,
109,246,247,247,247,247,247,247,247,247,247,247,248,157, 109,246,247,247,247,247,247,247,247,247,247,247,248,157,
109,295,296,296,296,296,296,296,296,296,296,296,297,157, 109,295,296,296,296,296,296,296,296,296,296,296,297,157,
63,108,108,108,108,108,70,71,108,108,108,108,108,64 63,108,108,108,108,108,1,1,108,108,108,108,108,64
</data> </data>
</layer> </layer>
<layer id="2" name="BackgroundLayer2" width="14" height="16"> <layer id="9" name="Background2" width="14" height="16">
<data encoding="csv"> <data encoding="csv">
1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,72,73,1,1,1,1,1,1,
1,1,1,1,1,1,121,122,1,1,1,1,1,1, 1,1,1,1,1,1,121,122,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,
@ -43,32 +43,12 @@
1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1 1,1,1,1,1,1,1,1,1,1,1,1,1,1
</data>
</layer>
<layer id="3" name="BackgroundLayer3" width="14" height="16">
<data encoding="csv">
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1
</data> </data>
</layer> </layer>
<layer id="4" name="Foreground" width="14" height="16"> <layer id="4" name="Foreground" width="14" height="16">
<data encoding="csv"> <data encoding="csv">
1,1,1,1,1,1,23,24,1,1,1,1,1,1, 1,1,1,1,1,1,23,24,1,1,1,1,1,1,
1,1,1,1,1,1,72,73,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,
@ -82,7 +62,7 @@
1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,21,22,1,1,1,1,1,1, 1,1,1,1,1,1,21,22,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1 1,1,1,1,1,1,70,71,1,1,1,1,1,1
</data> </data>
</layer> </layer>
<layer id="7" name="Hitboxes" width="14" height="16"> <layer id="7" name="Hitboxes" width="14" height="16">

View File

@ -5,37 +5,30 @@ function stringifyFloat(floatNumber)
return String(floatNumber); return String(floatNumber);
} }
function writeLayerContent(output_file, layer)
function writeTileLayer(tileLayer, file)
{ {
file.writeLine(" \"" + tileLayer.name + "\": ["); for(let cell_y = 0; cell_y < layer.height; ++cell_y)
for(let cell_y = 0; cell_y < tileLayer.height; ++cell_y)
{ {
file.write(" "); output_file.write(" ");
for(let cell_x = 0; cell_x < tileLayer.width; ++cell_x) for(let cell_x = 0; cell_x < layer.width; ++cell_x)
{ {
file.write(" " + tileLayer.cellAt(cell_x, cell_y).tileId) output_file.file.write(" " + layer.cellAt(cell_x, cell_y).tileId)
if(cell_x < tileLayer.width - 1 || cell_y < tileLayer.height - 1) if(cell_x < layer.width - 1 || cell_y < layer.height - 1)
file.write(","); output_file.file.write(",");
} }
file.writeLine(""); output_file.file.writeLine("");
} }
file.writeLine(" ],");
} }
function writeEntities(objectLayer, file) function writeEntities(output_file, entitieslayer)
{ {
file.writeLine(" \"Entities\": [");
let entities = []; let entities = [];
for(let i = 0; i < objectLayer.objectCount; i++) for(let i = 0; i < entitieslayer.objectCount; i++)
{ {
let entity = objectLayer.objectAt(i); let entity = entitieslayer.objectAt(i);
if(entity.name) if(entity.name)
{ {
@ -54,46 +47,51 @@ function writeEntities(objectLayer, file)
{ {
let entity = entities[i]; let entity = entities[i];
file.writeLine(" {"); output_file.writeLine("{");
file.writeLine(" \"ID\":" + entity.name + ",");
file.writeLine(" \"Components\": ["); output_file.indent_add(2);
output_file.writeLine("\"ID\":" + entity.name + ",");
output_file.writeLine("\"Components\": [");
let components = entity.properties()["components"]; let components = entity.properties()["components"];
let nb_components = Object.keys(components).length; let nb_components = Object.keys(components).length;
output_file.indent_add(2);
for(let j = 0; j < nb_components; j++) for(let j = 0; j < nb_components; j++)
{ {
let component = components[j]; let component = components[j];
let component_type = component[0]; let component_type = component[0];
file.writeLine(" {"); output_file.writeLine("{");
file.write(" \"Type\": \"" + component_type + "\""); output_file.indent_add(2);
output_file.write("\"Type\": \"" + component_type + "\"");
if(component.length > 1) if(component.length > 1)
{ {
file.writeLine(","); output_file.file.writeLine(",");
file.writeLine(" \"Attributes\": ["); output_file.writeLine("\"Attributes\": [");
} }
// Write atributes, speciale cases need speciale treatment. // Write atributes, speciale cases need speciale treatment.
if(component_type == "TRANSFORM_COMPONENT") if(component_type == "TRANSFORM_COMPONENT")
{ {
file.writeLine(","); output_file.file.writeLine(",");
file.writeLine(" \"Attributes\": ["); output_file.writeLine("\"Attributes\": [");
file.writeLine(" " + stringifyFloat(entity.x) + ","); output_file.writeLine(" " + stringifyFloat(entity.x) + ",");
file.writeLine(" " + stringifyFloat(entity.y) + ","); output_file.writeLine(" " + stringifyFloat(entity.y) + ",");
file.writeLine(" " + stringifyFloat(entity.width) + ","); output_file.writeLine(" " + stringifyFloat(entity.width) + ",");
file.writeLine(" " + stringifyFloat(entity.height)); output_file.writeLine(" " + stringifyFloat(entity.height));
file.writeLine(" ]"); output_file.writeLine("]");
} }
else if(component_type == "HITBOX_COMPONENT") else if(component_type == "HITBOX_COMPONENT")
{ {
let hitbox; let hitbox;
for(let k = 0; k < objectLayer.objectCount; k++) for(let k = 0; k < entitieslayer.objectCount; k++)
{ {
hitbox = objectLayer.objectAt(k); hitbox = entitieslayer.objectAt(k);
if(hitbox.id === component[1].id) if(hitbox.id === component[1].id)
break; break;
} }
@ -103,18 +101,18 @@ function writeEntities(objectLayer, file)
let width = hitbox.width / entity.width; let width = hitbox.width / entity.width;
let height = hitbox.height / entity.height; let height = hitbox.height / entity.height;
file.writeLine(" " + stringifyFloat(x) + ","); output_file.writeLine(" " + stringifyFloat(x) + ",");
file.writeLine(" " + stringifyFloat(y) + ","); output_file.writeLine(" " + stringifyFloat(y) + ",");
file.writeLine(" " + stringifyFloat(width) + ","); output_file.writeLine(" " + stringifyFloat(width) + ",");
file.writeLine(" " + stringifyFloat(height)); output_file.writeLine(" " + stringifyFloat(height));
} }
else if(component_type == "INTERACT_COMPONENT") else if(component_type == "INTERACT_COMPONENT")
{ {
let interact_box; let interact_box;
for(let k = 0; k < objectLayer.objectCount; k++) for(let k = 0; k < entitieslayer.objectCount; k++)
{ {
interact_box = objectLayer.objectAt(k); interact_box = entitieslayer.objectAt(k);
if(interact_box.id === component[1].id) if(interact_box.id === component[1].id)
break; break;
} }
@ -124,37 +122,37 @@ function writeEntities(objectLayer, file)
let width = interact_box.width / entity.width; let width = interact_box.width / entity.width;
let height = interact_box.height / entity.height; let height = interact_box.height / entity.height;
file.writeLine(" " + stringifyFloat(x) + ","); output_file.writeLine(" " + stringifyFloat(x) + ",");
file.writeLine(" " + stringifyFloat(y) + ","); output_file.writeLine(" " + stringifyFloat(y) + ",");
file.writeLine(" " + stringifyFloat(width) + ","); output_file.writeLine(" " + stringifyFloat(width) + ",");
file.writeLine(" " + stringifyFloat(height) + ","); output_file.writeLine(" " + stringifyFloat(height) + ",");
file.writeLine(" " + component[2] + ","); output_file.writeLine(" " + component[2] + ",");
file.writeLine(" " + component[3] + ","); output_file.writeLine(" " + component[3] + ",");
file.writeLine(" " + component[4]); output_file.writeLine(" " + component[4]);
} }
else if(component_type == "SPRITE_COMPONENT") else if(component_type == "SPRITE_COMPONENT")
{ {
file.writeLine(" \"" + component[1] + "\""); output_file.writeLine(" \"" + component[1] + "\"");
} }
else if(component_type == "ANIMATION_SYSTEM") else if(component_type == "ANIMATION_SYSTEM")
{ {
file.writeLine(" " + component[1] + ","); output_file.writeLine(" " + component[1] + ",");
file.writeLine(" " + component[2] + ","); output_file.writeLine(" " + component[2] + ",");
file.writeLine(" " + stringifyFloat(component[3]) + ","); output_file.writeLine(" " + stringifyFloat(component[3]) + ",");
file.writeLine(" " + component[4] + ","); output_file.writeLine(" " + component[4] + ",");
file.writeLine(" " + component[5] + ","); output_file.writeLine(" " + component[5] + ",");
file.writeLine(" " + component[6]); output_file.writeLine(" " + component[6]);
} }
else if(component_type == "LEVER_COMPONENT") else if(component_type == "LEVER_COMPONENT")
{ {
file.writeLine(" " + component[1] + ","); output_file.writeLine(" " + component[1] + ",");
file.writeLine(" " + component[2]); output_file.writeLine(" " + component[2]);
} }
else if(component_type == "DOOR_COMPONENT") else if(component_type == "DOOR_COMPONENT")
{ {
file.writeLine(" " + component[1] + ","); output_file.writeLine(" " + component[1] + ",");
file.writeLine(" " + component[2]); output_file.writeLine(" " + component[2]);
} }
else else
{ {
@ -162,23 +160,27 @@ function writeEntities(objectLayer, file)
} }
if(component.length > 1) if(component.length > 1)
file.writeLine(" ]"); output_file.writeLine("]");
output_file.indent_remove(2);
if(j == nb_components - 1) if(j == nb_components - 1)
file.writeLine(" }"); output_file.writeLine("}");
else else
file.writeLine(" },"); output_file.writeLine("},");
} }
file.writeLine(" ]"); output_file.indent_remove(2);
output_file.writeLine("]");
output_file.indent_remove(2);
if(i == entities.length - 1) if(i == entities.length - 1)
file.writeLine(" }"); output_file.writeLine("}");
else else
file.writeLine(" },"); output_file.writeLine("},");
} }
file.writeLine(" ]");
} }
var customMapFormat = { var customMapFormat = {
@ -187,12 +189,44 @@ var customMapFormat = {
write: function(map, fileName) write: function(map, fileName)
{ {
let file = new TextFile(fileName, TextFile.WriteOnly); let output_file = {
file: new TextFile(fileName, TextFile.WriteOnly),
indent: "",
indent_add: function(nb)
{
this.indent += " ".repeat(nb);
},
indent_remove: function(nb)
{
this.indent = this.indent.substring(0, this.indent.length - nb);
},
file.writeLine("{"); write: function(content)
file.writeLine(" \"MapWidth\": " + map.width + ","); {
file.writeLine(" \"MapHeight\": " + map.height + ","); this.file.write(this.indent);
file.writeLine(""); this.file.write(content);
},
writeLine: function(content)
{
this.file.write(this.indent);
this.file.writeLine(content);
},
commit: function()
{
this.file.commit();
}
};
output_file.file.writeLine("{");
output_file.indent_add(2);
output_file.writeLine("\"MapWidth\": " + map.width + ",");
output_file.writeLine("\"MapHeight\": " + map.height + ",");
output_file.file.writeLine("");
let backgroundlayers = [];
let foregroundlayer = null;
let hitboxes = null;
let entitieslayer = null;
for(let i = 0; i < map.layerCount; i++) for(let i = 0; i < map.layerCount; i++)
{ {
@ -200,17 +234,89 @@ var customMapFormat = {
if(layer.isTileLayer) if(layer.isTileLayer)
{ {
writeTileLayer(layer, file); if(layer.name.startsWith("Background"))
{
backgroundlayers.push(layer);
}
else if(layer.name.startsWith("Foreground"))
{
foregroundlayer = layer;
}
else if(layer.name == "Hitboxes")
{
hitboxes = layer;
}
else
{
throw new Error("Invalid layer name for a tile layer : " + layer.name);
}
} }
else if(layer.isObjectLayer) else if(layer.isObjectLayer)
{ {
writeEntities(layer, file); if(layer.name == "Entities")
{
if(entitieslayer)
throw new Error("There cannot be multiple entity layers.");
entitieslayer = layer;
}
else
{
throw new Error("Invalid layer name for an object layer : " + layer.name);
}
} }
} }
file.write("}"); if(backgroundlayers.length == 0)
file.commit(); {
}, throw new Error("At least one background layer is needed.");
}
if(foregroundlayer == null)
{
throw new Error("A foreground layer is needed.");
}
backgroundlayers.sort((a, b) => {
if(Number(a.name[a.name.length - 1]) > Number(b.name[b.name.length - 1]))
return 1;
return -1;
});
output_file.writeLine("\"BackgroundLayers\": [");
output_file.indent_add(2);
for(let i = 0; i < backgroundlayers.length; i++)
{
const layer = backgroundlayers[i];
output_file.writeLine("[");
writeLayerContent(output_file, layer);
if(i == backgroundlayers.length - 1)
output_file.writeLine("]");
else
output_file.writeLine("],");
};
output_file.indent_remove(2);
output_file.writeLine("],");
output_file.writeLine("\"ForegroundLayer\": [");
writeLayerContent(output_file, foregroundlayer);
output_file.writeLine("],");
output_file.writeLine("\"Entities\": [");
output_file.indent_add(2);
if(entitieslayer)
writeEntities(output_file, entitieslayer);
output_file.indent_remove(2);
output_file.writeLine("]");
output_file.indent_remove(2);
output_file.write("}");
output_file.commit();
}
} }
tiled.registerMapFormat("custom", customMapFormat) tiled.registerMapFormat("custom", customMapFormat)