2011-07-22 00:26:32 +02:00
|
|
|
regionConstructors['Residence'] = function(dynmap, configuration) {
|
|
|
|
// Helper function.
|
|
|
|
function createBoxFromArea(area, boxCreator) {
|
|
|
|
return boxCreator(area.X1, area.X2, area.Y1, area.Y2, area.Z1, area.Z2);
|
|
|
|
}
|
2011-04-14 02:58:25 +02:00
|
|
|
|
2011-07-28 05:42:55 +02:00
|
|
|
$.getJSON('standalone/res_' + configuration.worldName + '.json', function(data) {
|
2011-07-22 00:26:32 +02:00
|
|
|
var boxLayers = [];
|
2011-07-21 02:16:00 +02:00
|
|
|
$.each(data, function(name, residence) {
|
2011-07-28 05:42:55 +02:00
|
|
|
if(configuration.worldName == residence.Permissions.World) {
|
2011-08-21 22:57:21 +02:00
|
|
|
$.each(residence.Areas, function(aname, area) {
|
2011-07-22 00:26:32 +02:00
|
|
|
var boxLayer = configuration.createBoxLayer(area.X1, area.X2, area.Y1, area.Y2, area.Z1, area.Z2);
|
|
|
|
|
|
|
|
boxLayer.bindPopup(configuration.createPopupContent(name, $.extend(residence, {
|
|
|
|
owners: { players: [residence.Permissions.Owner] },
|
2011-07-28 05:42:55 +02:00
|
|
|
flags: residence.Permissions.AreaFlags
|
2011-07-22 00:26:32 +02:00
|
|
|
})));
|
|
|
|
|
|
|
|
boxLayers.push(boxLayer);
|
2011-07-29 17:30:59 +02:00
|
|
|
});
|
|
|
|
$.each(residence.Subzones, function(szname, subzone) {
|
|
|
|
$.each(subzone.Areas, function(name2, area2) {
|
|
|
|
var subzoneLayer = configuration.createBoxLayer(area2.X1, area2.X2, area2.Y1, area2.Y2, area2.Z1, area2.Z2);
|
2011-08-21 22:57:21 +02:00
|
|
|
subzoneLayer.bindPopup(configuration.createPopupContent(name + '.' + szname, $.extend(subzone, {
|
2011-07-29 17:30:59 +02:00
|
|
|
owners: { players: [subzone.Permissions.Owner] },
|
|
|
|
flags: subzone.Permissions.AreaFlags
|
|
|
|
})));
|
|
|
|
boxLayers.push(subzoneLayer);
|
2011-07-29 16:50:50 +02:00
|
|
|
});
|
|
|
|
});
|
2011-07-21 02:16:00 +02:00
|
|
|
}
|
2011-04-14 02:58:25 +02:00
|
|
|
});
|
2011-07-22 00:26:32 +02:00
|
|
|
configuration.result(new L.LayerGroup(boxLayers));
|
2011-07-21 02:16:00 +02:00
|
|
|
|
2011-04-14 02:58:25 +02:00
|
|
|
});
|
2011-07-21 02:16:00 +02:00
|
|
|
};
|