Updated tiled extension for entities.

This commit is contained in:
Ulysse Cura 2026-08-13 19:05:38 +02:00
parent d40f1943e5
commit 62a77dae6a
6 changed files with 574 additions and 40 deletions

View File

@ -106,7 +106,7 @@
0, 0, 0, 0, 0, 0, 0, 1821, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2323, 2324, 2325, 2326, 2327, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1867, 0, 0, 1870, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2372, 2373, 2374, 2375, 2376, 0, 0, 0, 0, 0
],
"HitBoxes": [
"Hitboxes": [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -131,5 +131,5 @@
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
]
],
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.12.1" orientation="orthogonal" renderorder="left-up" width="32" height="24" tilewidth="16" tileheight="16" infinite="0" nextlayerid="13" nextobjectid="12">
<map version="1.10" tiledversion="1.12.1" orientation="orthogonal" renderorder="left-up" width="32" height="24" tilewidth="16" tileheight="16" infinite="0" nextlayerid="14" nextobjectid="17">
<editorsettings>
<export target="dungeon_entry.json" format="custom"/>
</editorsettings>
@ -25,18 +25,10 @@
eJy9lr1Lw0AYh69JzIeTirZCQXDTxUlBdFKsVRDERfwbXEXQRakfrXbVQXAX7KDS+lHQSdDJQSdRBy212gpOnRQEfyEJvbZJTHK1w0NCkrvnzXt3752PEOKrAbcCIXcCez/9HCE7Dd7ach7bVTLLle5vatSnG3Yp/0+FP8jXN5YeUbtuwhsHAZMx3qpjjiIyIStgFayBdRAFMVl7L+vxNor/40/CkwLH4AScgjOQlkvfDMA9qPszHLvzEn0FFELaQRaeV5ADb+Ad5EFBNs9NUs9PVHbmovtQ2xfxsAj/GNzjirfcGPHFxepxM+ujk9P6MMutHXa5Ud+fw38hlsdmtN3mq/sw2k97GMMliZBlSc+pVP6Ojs14dgX/tcXajrn0H8B3CI4kd+2sSLv0P8P7AjK6P+swji7Ulm4QofKQh7vg0t+EvDaDFjDlcO7MVNS1FK/NU7q2OGUI3w+7aLNhsW/m+Or5z2MNCn+sQ5U5lzGb4RfK149KL9x9YNEiBrp+OPV8WPx/2OY8kaD8X7j/1mOia9AI8hdysF8GLfavBRP/AxyP4Mnk/xMV9Xne4V49YeHfd3GeMotpj+GsYNRKlvlzz3hW+WT0y4zn0Q6G+tmKsWgDfqW0dzuaC5RzksEfgm8UhBX7vfsXuP91rA==
</data>
</layer>
<layer id="12" name="HitBoxes" width="32" height="24" visible="0">
<properties>
<property name="2" type="list">
<item value="room_1"/>
<item type="list">
<item type="int" value="15"/>
<item type="int" value="22"/>
</item>
</property>
</properties>
<layer id="12" name="Hitboxes" width="32" height="24">
<data encoding="base64" compression="zlib">
eJwL52JgCB/Fo3gUj+IhhiOhmB52RWDBxMhRy25S5anpBnL9Rg03kGsGLfw/EHaTmg5oZTeutECrND+KR/Eopj0GAGrPIzU=
</data>
</layer>
<objectgroup id="13" name="Entities"/>
</map>

View File

@ -1,3 +0,0 @@
{
"Entities": []
}

View File

@ -0,0 +1,203 @@
{
"MapWidth": 14,
"MapHeight": 16,
"BackgroundLayer1": [
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, 50, 51, 51, 51, 51, 245, 247, 51, 51, 51, 51, 52, 156,
108, 196, 197, 197, 197, 197, 151, 150, 197, 197, 197, 197, 198, 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, 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, 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,
62, 107, 107, 107, 107, 107, 69, 70, 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, 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,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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, 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": [
{
"ID":1,
"Components": [
{
"Type": "TRANSFORM_COMPONENT",
"Attributes": [
96,
0,
32,
48
]
},
{
"Type": "SPRITE_COMPONENT",
"Attributes": [
"barred_door_sheet"
]
},
{
"Type": "ANIMATION_SYSTEM",
"Attributes": [
8,
0,
30,
false,
false,
false
]
},
{
"Type": "HITBOX_COMPONENT",
"Attributes": [
0,
0.8333333333333334,
1,
0.16666666666666666
]
},
{
"Type": "DOOR_COMPONENT",
"Attributes": [
"0",
false
]
}
]
},
{
"ID":2,
"Components": [
{
"Type": "TRANSFORM_COMPONENT",
"Attributes": [
88,
112,
48,
32
]
},
{
"Type": "SPRITE_COMPONENT",
"Attributes": [
"lever_sheet"
]
},
{
"Type": "ANIMATION_SYSTEM",
"Attributes": [
3,
0,
100,
false,
false,
false
]
},
{
"Type": "HITBOX_COMPONENT",
"Attributes": [
0.3333333333333333,
0.59375,
0.3333333333333333,
0.34375
]
},
{
"Type": "INTERACT_COMPONENT",
"Attributes": [
0.16666666666666666,
0.34375,
0.6666666666666666,
0.84375,
0,
0,
0
]
},
{
"Type": "LEVER_COMPONENT",
"Attributes": [
0,
false
]
}
]
}
]
}

View File

@ -0,0 +1,182 @@
<?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">
<editorsettings>
<export target="dungeon_room_1.json" format="custom"/>
</editorsettings>
<tileset firstgid="1" source="../tileset/tileset.tsx"/>
<tileset firstgid="2647" source="hiitboxes.tsx"/>
<layer id="1" name="BackgroundLayer1" width="14" height="16">
<data encoding="csv">
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,51,52,52,52,52,246,248,52,52,52,52,53,157,
109,197,198,198,198,198,152,151,198,198,198,198,199,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,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,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,
63,108,108,108,108,108,70,71,108,108,108,108,108,64
</data>
</layer>
<layer id="2" name="BackgroundLayer2" 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,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,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,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>
</layer>
<layer id="4" name="Foreground" width="14" height="16">
<data encoding="csv">
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,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,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,1,1,1,1,1,1,1,1
</data>
</layer>
<layer id="7" name="Hitboxes" width="14" height="16">
<data encoding="csv">
2647,2647,2647,2647,2647,2648,2650,2650,2648,2647,2647,2647,2647,2647,
2647,2647,2647,2647,2647,2648,2647,2647,2648,2647,2647,2647,2647,2647,
2648,2648,2648,2648,2648,2648,2647,2647,2648,2648,2648,2648,2648,2648,
2648,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2648,
2648,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2648,
2648,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2648,
2648,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2648,
2648,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2648,
2648,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2648,
2648,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2648,
2648,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2648,
2648,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2648,
2648,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2648,
2648,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2648,
2648,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2647,2648,
2648,2648,2648,2648,2648,2648,2649,2649,2648,2648,2648,2648,2648,2648
</data>
</layer>
<objectgroup id="8" name="Entities">
<object id="4" name="1" x="96" y="0" width="32" height="48">
<properties>
<property name="components" type="list">
<item type="list">
<item value="TRANSFORM_COMPONENT"/>
</item>
<item type="list">
<item value="SPRITE_COMPONENT"/>
<item value="barred_door_sheet"/>
</item>
<item type="list">
<item value="ANIMATION_SYSTEM"/>
<item type="int" value="8"/>
<item type="int" value="0"/>
<item type="float" value="30"/>
<item type="bool" value="false"/>
<item type="bool" value="false"/>
<item type="bool" value="false"/>
</item>
<item type="list">
<item value="HITBOX_COMPONENT"/>
<item type="object" value="5"/>
</item>
<item type="list">
<item value="DOOR_COMPONENT"/>
<item value="0"/>
<item type="bool" value="false"/>
</item>
</property>
</properties>
</object>
<object id="5" x="96" y="40" width="32" height="8"/>
<object id="8" name="2" x="88" y="112" width="48" height="32">
<properties>
<property name="components" type="list">
<item type="list">
<item value="TRANSFORM_COMPONENT"/>
</item>
<item type="list">
<item value="SPRITE_COMPONENT"/>
<item value="lever_sheet"/>
</item>
<item type="list">
<item value="ANIMATION_SYSTEM"/>
<item type="int" value="3"/>
<item type="int" value="0"/>
<item type="float" value="100"/>
<item type="bool" value="false"/>
<item type="bool" value="false"/>
<item type="bool" value="false"/>
</item>
<item type="list">
<item value="HITBOX_COMPONENT"/>
<item type="object" value="9"/>
</item>
<item type="list">
<item value="INTERACT_COMPONENT"/>
<item type="object" value="10"/>
<item type="int" value="0"/>
<item type="int" value="0"/>
<item type="int" value="0"/>
</item>
<item type="list">
<item value="LEVER_COMPONENT"/>
<item type="int" value="0"/>
<item type="bool" value="false"/>
</item>
</property>
</properties>
</object>
<object id="9" x="104" y="131" width="16" height="11"/>
<object id="10" x="96" y="123" width="32" height="27"/>
</objectgroup>
</map>

View File

@ -1,39 +1,199 @@
function writeTileLayer(tileLayer, file)
{
file.writeLine(" \"" + tileLayer.name + "\": [");
for(let cell_y = 0; cell_y < tileLayer.height; ++cell_y)
{
file.write(" ");
for(let cell_x = 0; cell_x < tileLayer.width; ++cell_x)
{
file.write(" " + tileLayer.cellAt(cell_x, cell_y).tileId)
if(cell_x < tileLayer.width - 1 || cell_y < tileLayer.height - 1)
file.write(",");
}
file.writeLine("");
}
file.writeLine(" ],");
}
function writeEntities(objectLayer, file)
{
file.writeLine(" \"Entities\": [");
let entities = [];
for(let i = 0; i < objectLayer.objectCount; i++)
{
let entity = objectLayer.objectAt(i);
if(entity.name)
{
entities.push(entity);
}
}
for(let i = 0; i < entities.length; i++)
{
let entity = entities[i];
file.writeLine(" {");
file.writeLine(" \"ID\":" + entity.name + ",");
file.writeLine(" \"Components\": [");
let components = entity.properties()["components"];
let nb_components = Object.keys(components).length;
for(let j = 0; j < nb_components; j++)
{
let component = components[j];
let component_type = component[0];
file.writeLine(" {");
file.write(" \"Type\": \"" + component_type + "\"");
if(component.length > 1)
{
file.writeLine(",");
file.writeLine(" \"Attributes\": [");
}
// Write atributes, speciale cases need speciale treatment.
if(component_type == "TRANSFORM_COMPONENT")
{
file.writeLine(",");
file.writeLine(" \"Attributes\": [");
file.writeLine(" " + entity.x + ",");
file.writeLine(" " + entity.y + ",");
file.writeLine(" " + entity.width + ",");
file.writeLine(" " + entity.height);
file.writeLine(" ]");
}
else if(component_type == "HITBOX_COMPONENT")
{
let hitbox;
for(let k = 0; k < objectLayer.objectCount; k++)
{
hitbox = objectLayer.objectAt(k);
if(hitbox.id === component[1].id)
break;
}
let x = (hitbox.x - entity.x) / entity.width;
let y = (hitbox.y - entity.y) / entity.height;
let width = hitbox.width / entity.width;
let height = hitbox.height / entity.height;
file.writeLine(" " + x + ",");
file.writeLine(" " + y + ",");
file.writeLine(" " + width + ",");
file.writeLine(" " + height);
}
else if(component_type == "INTERACT_COMPONENT")
{
let interact_box;
for(let k = 0; k < objectLayer.objectCount; k++)
{
interact_box = objectLayer.objectAt(k);
if(interact_box.id === component[1].id)
break;
}
let x = (interact_box.x - entity.x) / entity.width;
let y = (interact_box.y - entity.y) / entity.height;
let width = interact_box.width / entity.width;
let height = interact_box.height / entity.height;
file.writeLine(" " + x + ",");
file.writeLine(" " + y + ",");
file.writeLine(" " + width + ",");
file.writeLine(" " + height + ",");
file.writeLine(" " + component[2] + ",");
file.writeLine(" " + component[3] + ",");
file.writeLine(" " + component[4]);
}
else
{
if(component.length > 1)
{
for(let k = 1; k < component.length; k++)
{
file.write(" ");
switch(typeof(component[k]))
{
case typeof(Number()):
case typeof(Boolean()):
file.write(component[k]);
break;
case typeof(String()):
file.write("\"" + component[k] + "\"");
break;
default:
throw new Error("Attribute \"" + component[k] + "\", type not supported : " + typeof(component[k]));
}
if(k == component.length - 1)
file.writeLine("");
else
file.writeLine(",");
}
}
else
file.writeLine("");
}
if(component.length > 1)
file.writeLine(" ]");
if(j == nb_components - 1)
file.writeLine(" }");
else
file.writeLine(" },");
}
file.writeLine(" ]");
if(i == entities.length - 1)
file.writeLine(" }");
else
file.writeLine(" },");
}
file.writeLine(" ]");
}
var customMapFormat = {
name: "Custom map format",
extension: "custom",
name: "Custom JSON map format",
extension: "json",
write: function(map, fileName)
{
var file = new TextFile(fileName, TextFile.WriteOnly);
let file = new TextFile(fileName, TextFile.WriteOnly);
file.writeLine("{");
file.writeLine(" \"MapWidth\": " + map.width + ",");
file.writeLine(" \"MapHeight\": " + map.height + ",");
file.writeLine(" \"MapWidth\": " + map.width + ",");
file.writeLine(" \"MapHeight\": " + map.height + ",");
file.writeLine("");
for(var i = 0; i < map.layerCount; i++)
for(let i = 0; i < map.layerCount; i++)
{
var layer = map.layerAt(i);
let layer = map.layerAt(i);
if(layer.isTileLayer)
{
file.writeLine(" \"" + layer.name + "\": [");
for(var cell_y = 0; cell_y < layer.height; ++cell_y)
{
file.write(" ");
for (var cell_x = 0; cell_x < layer.width; ++cell_x)
{
file.write(" " + layer.cellAt(cell_x, cell_y).tileId)
if(cell_x < layer.width - 1 || cell_y < layer.height - 1)
file.write(",");
}
file.writeLine("");
}
file.writeLine(" ],");
writeTileLayer(layer, file);
}
else if(layer.isObjectLayer)
{
writeEntities(layer, file);
}
}