First pass of Towny region support
This commit is contained in:
parent
1284a8a6ed
commit
d349a76660
6 changed files with 350 additions and 51 deletions
|
|
@ -115,8 +115,11 @@ componentconstructors['regions'] = function(dynmap, configuration) {
|
|||
popup = popup.replace('%regionname%', name);
|
||||
popup = popup.replace('%playerowners%', join(region.owners.players));
|
||||
popup = popup.replace('%groupowners%', join(region.owners.groups));
|
||||
popup = popup.replace('%playermanagers%', join(region.associates || ""));
|
||||
popup = popup.replace('%playermembers%', join(members.players));
|
||||
popup = popup.replace('%groupmembers%', join(members.groups));
|
||||
popup = popup.replace('%parent%', region.parent || "");
|
||||
popup = popup.replace('%priority%', region.priority || "");
|
||||
var regionflags = "";
|
||||
$.each(region.flags, function(name, value) {
|
||||
regionflags = regionflags + "<span>" + name + ": " + value + "</span><br>";
|
||||
|
|
|
|||
36
web/js/regions_Towny.js
Normal file
36
web/js/regions_Towny.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
regionConstructors['Towny'] = function(dynmap, configuration) {
|
||||
// Helper function.
|
||||
function createOutlineFromRegion(region, outCreator) {
|
||||
var xarray = [];
|
||||
var zarray = [];
|
||||
if(region.points) {
|
||||
var i;
|
||||
for(i = 0; i < region.points.length; i++) {
|
||||
xarray[i] = region.points[i].x;
|
||||
zarray[i] = region.points[i].z;
|
||||
}
|
||||
}
|
||||
var ymin = 64;
|
||||
var ymax = 65;
|
||||
|
||||
return outCreator(xarray, ymax, ymin, zarray);
|
||||
}
|
||||
|
||||
var regionFile = 'towny_'+configuration.worldName+'.json';
|
||||
$.getJSON('standalone/'+regionFile, function(data) {
|
||||
var boxLayers = [];
|
||||
$.each(data, function(name, region) {
|
||||
var outLayer = createOutlineFromRegion(region, configuration.createOutlineLayer);
|
||||
if (outLayer) {
|
||||
outLayer.bindPopup(configuration.createPopupContent(name,
|
||||
$.extend(region, {
|
||||
owners: { players: [region.mayor] },
|
||||
members: { players: [ region.residents ] }
|
||||
})));
|
||||
boxLayers.push(outLayer);
|
||||
}
|
||||
});
|
||||
configuration.result(new L.LayerGroup(boxLayers));
|
||||
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue