2011-08-22 08:17:28 +02:00
|
|
|
regionConstructors['Towny'] = function(dynmap, configuration) {
|
|
|
|
// Helper function.
|
2011-08-25 05:11:31 +02:00
|
|
|
function createOutlineFromRegion(name, region, points, outCreator) {
|
2011-08-22 08:17:28 +02:00
|
|
|
var xarray = [];
|
|
|
|
var zarray = [];
|
2011-08-25 05:11:31 +02:00
|
|
|
var i;
|
|
|
|
for(i = 0; i < points.length; i++) {
|
|
|
|
xarray[i] = points[i].x;
|
|
|
|
zarray[i] = points[i].z;
|
2011-08-22 08:17:28 +02:00
|
|
|
}
|
|
|
|
var ymin = 64;
|
|
|
|
var ymax = 65;
|
|
|
|
|
2011-08-23 05:16:38 +02:00
|
|
|
return outCreator(xarray, ymax, ymin, zarray, configuration.getStyle(name, region.nation));
|
2011-08-22 08:17:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var regionFile = 'towny_'+configuration.worldName+'.json';
|
|
|
|
$.getJSON('standalone/'+regionFile, function(data) {
|
|
|
|
var boxLayers = [];
|
|
|
|
$.each(data, function(name, region) {
|
2011-08-25 05:11:31 +02:00
|
|
|
var i;
|
|
|
|
for(i = 0; i < region.points.length; i++) {
|
|
|
|
var outLayer = createOutlineFromRegion(name, region, region.points[i], configuration.createOutlineLayer);
|
|
|
|
if (outLayer) {
|
|
|
|
outLayer.bindPopup(configuration.createPopupContent(name,
|
|
|
|
$.extend(region, {
|
|
|
|
owners: { players: [region.mayor] },
|
|
|
|
members: { players: [ region.residents ] }
|
|
|
|
})));
|
|
|
|
boxLayers.push(outLayer);
|
|
|
|
}
|
2011-08-22 08:17:28 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
configuration.result(new L.LayerGroup(boxLayers));
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|