mirror of
https://github.com/webbukkit/dynmap.git
synced 2025-02-27 17:21:46 +01:00
Handle bigmap versus bigworld, allows HDMap to be big-map-style independent of bigworld setting. Add bigmap setting on KzedMap and FlatMap too.
This commit is contained in:
parent
02fa9384ac
commit
898f4a6740
@ -37,7 +37,7 @@ public class ClientConfigurationComponent extends Component {
|
||||
a(t, "worlds", wo);
|
||||
|
||||
for(MapType mt : world.maps) {
|
||||
mt.buildClientConfiguration(wo);
|
||||
mt.buildClientConfiguration(wo, world);
|
||||
}
|
||||
}
|
||||
s(t, "defaultworld", c.getString("defaultworld", defaultWorld == null ? "world" : defaultWorld.world.getName()));
|
||||
|
@ -114,6 +114,7 @@ public class DynmapWorld {
|
||||
String fnprefix;
|
||||
String zfnprefix;
|
||||
int bigworldshift;
|
||||
boolean isbigworld;
|
||||
}
|
||||
|
||||
public void freshenZoomOutFilesByLevel(int zoomlevel) {
|
||||
@ -123,10 +124,10 @@ public class DynmapWorld {
|
||||
return;
|
||||
HashMap<String, PrefixData> maptab = buildPrefixData(zoomlevel);
|
||||
|
||||
if(bigworld) { /* If big world, next directories are map name specific */
|
||||
DirFilter df = new DirFilter();
|
||||
for(String pfx : maptab.keySet()) { /* Walk through prefixes, as directories */
|
||||
PrefixData pd = maptab.get(pfx);
|
||||
DirFilter df = new DirFilter();
|
||||
for(String pfx : maptab.keySet()) { /* Walk through prefixes */
|
||||
PrefixData pd = maptab.get(pfx);
|
||||
if(pd.isbigworld) { /* If big world, next directories are map name specific */
|
||||
File dname = new File(worldtilepath, pfx);
|
||||
/* Now, go through subdirectories under this one, and process them */
|
||||
String[] subdir = dname.list(df);
|
||||
@ -136,9 +137,7 @@ public class DynmapWorld {
|
||||
cnt += processZoomDirectory(sdname, pd);
|
||||
}
|
||||
}
|
||||
}
|
||||
else { /* Else, classic file layout */
|
||||
for(String pfx : maptab.keySet()) { /* Walk through prefixes, as directories */
|
||||
else { /* Else, classic file layout */
|
||||
cnt += processZoomDirectory(worldtilepath, maptab.get(pfx));
|
||||
}
|
||||
}
|
||||
@ -178,7 +177,8 @@ public class DynmapWorld {
|
||||
pd.zoomlevel = zoomlevel;
|
||||
pd.zoomprefix = "zzzzzzzzzzzz".substring(0, zoomlevel);
|
||||
pd.bigworldshift = bigworldshift;
|
||||
if(bigworld) {
|
||||
pd.isbigworld = mt.isBigWorldMap(this);
|
||||
if(pd.isbigworld) {
|
||||
if(zoomlevel > 0) {
|
||||
pd.zoomprefix += "_";
|
||||
pd.zfnprefix = "z" + pd.zoomprefix;
|
||||
@ -206,7 +206,7 @@ public class DynmapWorld {
|
||||
}
|
||||
|
||||
private String makeFilePath(PrefixData pd, int x, int y, boolean zoomed) {
|
||||
if(bigworld)
|
||||
if(pd.isbigworld)
|
||||
return pd.baseprefix + "/" + (x >> pd.bigworldshift) + "_" + (y >> pd.bigworldshift) + "/" + (zoomed?pd.zfnprefix:pd.fnprefix) + x + "_" + y + ".png";
|
||||
else
|
||||
return (zoomed?pd.zfnprefix:pd.fnprefix) + "_" + x + "_" + y + ".png";
|
||||
|
@ -16,7 +16,7 @@ public abstract class MapType {
|
||||
|
||||
public abstract boolean render(MapChunkCache cache, MapTile tile, File outputFile);
|
||||
|
||||
public void buildClientConfiguration(JSONObject worldObject) {
|
||||
public void buildClientConfiguration(JSONObject worldObject, DynmapWorld w) {
|
||||
}
|
||||
|
||||
public abstract String getName();
|
||||
@ -32,6 +32,8 @@ public abstract class MapType {
|
||||
public abstract int baseZoomFileStepSize();
|
||||
/* How many bits of coordinate are shifted off to make big world directory name */
|
||||
public abstract int getBigWorldShift();
|
||||
/* Returns true if big world file structure is in effect for this map */
|
||||
public abstract boolean isBigWorldMap(DynmapWorld w);
|
||||
|
||||
/**
|
||||
* Step sequence for creating zoomed file: first index is top-left, second top-right, third bottom-left, forth bottom-right
|
||||
|
@ -42,6 +42,7 @@ public class FlatMap extends MapType {
|
||||
protected boolean transparency;
|
||||
private enum Texture { NONE, SMOOTH, DITHER };
|
||||
private Texture textured = Texture.NONE;
|
||||
private boolean isbigmap;
|
||||
|
||||
public FlatMap(ConfigurationNode configuration) {
|
||||
this.configuration = configuration;
|
||||
@ -81,6 +82,7 @@ public class FlatMap extends MapType {
|
||||
textured = Texture.DITHER;
|
||||
else
|
||||
textured = Texture.SMOOTH;
|
||||
isbigmap = configuration.getBoolean("isbigmap", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -429,6 +431,12 @@ public class FlatMap extends MapType {
|
||||
/* How many bits of coordinate are shifted off to make big world directory name */
|
||||
public int getBigWorldShift() { return 5; }
|
||||
|
||||
/* Returns true if big world file structure is in effect for this map */
|
||||
@Override
|
||||
public boolean isBigWorldMap(DynmapWorld w) {
|
||||
return w.bigworld || isbigmap;
|
||||
}
|
||||
|
||||
public static class FlatMapTile extends MapTile {
|
||||
FlatMap map;
|
||||
public int x;
|
||||
@ -494,7 +502,7 @@ public class FlatMap extends MapType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildClientConfiguration(JSONObject worldObject) {
|
||||
public void buildClientConfiguration(JSONObject worldObject, DynmapWorld world) {
|
||||
ConfigurationNode c = configuration;
|
||||
JSONObject o = new JSONObject();
|
||||
s(o, "type", "FlatMapType");
|
||||
@ -506,6 +514,7 @@ public class FlatMap extends MapType {
|
||||
s(o, "nightandday", c.getBoolean("night-and-day",false));
|
||||
s(o, "backgroundday", c.getString("backgroundday"));
|
||||
s(o, "backgroundnight", c.getString("backgroundnight"));
|
||||
s(o, "bigmap", this.isBigWorldMap(world));
|
||||
a(worldObject, "maps", o);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.MapTile;
|
||||
@ -102,6 +103,10 @@ public class HDMap extends MapType {
|
||||
/* How many bits of coordinate are shifted off to make big world directory name */
|
||||
public int getBigWorldShift() { return 5; }
|
||||
|
||||
/* Returns true if big world file structure is in effect for this map */
|
||||
@Override
|
||||
public boolean isBigWorldMap(DynmapWorld w) { return true; } /* We always use it on these maps */
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
@ -112,7 +117,7 @@ public class HDMap extends MapType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildClientConfiguration(JSONObject worldObject) {
|
||||
public void buildClientConfiguration(JSONObject worldObject, DynmapWorld world) {
|
||||
ConfigurationNode c = configuration;
|
||||
JSONObject o = new JSONObject();
|
||||
s(o, "type", "HDMapType");
|
||||
@ -123,7 +128,7 @@ public class HDMap extends MapType {
|
||||
s(o, "background", c.getString("background"));
|
||||
s(o, "backgroundday", c.getString("backgroundday"));
|
||||
s(o, "backgroundnight", c.getString("backgroundnight"));
|
||||
|
||||
s(o, "bigmap", true);
|
||||
perspective.addClientConfiguration(o);
|
||||
shader.addClientConfiguration(o);
|
||||
lighting.addClientConfiguration(o);
|
||||
|
@ -16,6 +16,7 @@ import org.dynmap.Client;
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ColorScheme;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.TileHashManager;
|
||||
import org.dynmap.debug.Debug;
|
||||
@ -586,7 +587,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildClientConfiguration(JSONObject worldObject) {
|
||||
public void buildClientConfiguration(JSONObject worldObject, DynmapWorld world, KzedMap map) {
|
||||
ConfigurationNode c = configuration;
|
||||
JSONObject o = new JSONObject();
|
||||
s(o, "type", "KzedMapType");
|
||||
@ -598,6 +599,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
||||
s(o, "nightandday", c.getBoolean("night-and-day", false));
|
||||
s(o, "backgroundday", c.getString("backgroundday"));
|
||||
s(o, "backgroundnight", c.getString("backgroundnight"));
|
||||
s(o, "bigmap", map.isBigWorldMap(world));
|
||||
a(worldObject, "maps", o);
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ public class KzedMap extends MapType {
|
||||
public static final int anchorz = 0;
|
||||
|
||||
MapTileRenderer[] renderers;
|
||||
private boolean isbigmap;
|
||||
|
||||
/* BufferedImage with direct access to its ARGB-formatted data buffer */
|
||||
public static class KzedBufferedImage {
|
||||
@ -68,6 +69,7 @@ public class KzedMap extends MapType {
|
||||
this.renderers = new MapTileRenderer[renderers.size()];
|
||||
renderers.toArray(this.renderers);
|
||||
Log.verboseinfo("Loaded " + renderers.size() + " renderers for map '" + getClass().toString() + "'.");
|
||||
isbigmap = configuration.getBoolean("isbigmap", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -342,14 +344,20 @@ public class KzedMap extends MapType {
|
||||
/* How many bits of coordinate are shifted off to make big world directory name */
|
||||
public int getBigWorldShift() { return 12; }
|
||||
|
||||
/* Returns true if big world file structure is in effect for this map */
|
||||
@Override
|
||||
public boolean isBigWorldMap(DynmapWorld w) {
|
||||
return w.bigworld || isbigmap;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "KzedMap";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildClientConfiguration(JSONObject worldObject) {
|
||||
public void buildClientConfiguration(JSONObject worldObject, DynmapWorld world) {
|
||||
for(MapTileRenderer renderer : renderers) {
|
||||
renderer.buildClientConfiguration(worldObject);
|
||||
renderer.buildClientConfiguration(worldObject, world, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class KzedMapTile extends MapTile {
|
||||
@Override
|
||||
public String getFilename() {
|
||||
if(fname == null) {
|
||||
if(world.bigworld)
|
||||
if(map.isBigWorldMap(world))
|
||||
fname = renderer.getName() + "/" + (px >> 12) + '_' + (py >> 12) + '/' + px + "_" + py + ".png";
|
||||
else
|
||||
fname = renderer.getName() + "_" + px + "_" + py + ".png";
|
||||
@ -42,7 +42,7 @@ public class KzedMapTile extends MapTile {
|
||||
@Override
|
||||
public String getDayFilename() {
|
||||
if(fname_day == null) {
|
||||
if(world.bigworld)
|
||||
if(map.isBigWorldMap(world))
|
||||
fname_day = renderer.getName() + "_day/" + (px >> 12) + '_' + (py >> 12) + '/' + px + "_" + py + ".png";
|
||||
else
|
||||
fname_day = renderer.getName() + "_day_" + px + "_" + py + ".png";
|
||||
|
@ -2,6 +2,7 @@ package org.dynmap.kzedmap;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
@ -11,7 +12,7 @@ public interface MapTileRenderer {
|
||||
|
||||
boolean render(MapChunkCache cache, KzedMapTile tile, File outputFile);
|
||||
|
||||
void buildClientConfiguration(JSONObject worldObject);
|
||||
void buildClientConfiguration(JSONObject worldObject, DynmapWorld w, KzedMap map);
|
||||
|
||||
boolean isBiomeDataNeeded();
|
||||
boolean isRawBiomeDataNeeded();
|
||||
|
@ -33,7 +33,7 @@ FlatMapType.prototype = $.extend(new DynMapType(), {
|
||||
if(zoom < extrazoom) {
|
||||
var scale = 1 << (extrazoom-zoom);
|
||||
var zprefix = "zzzzzzzzzzzz".substring(0, extrazoom-zoom);
|
||||
if(this.dynmap.world.bigworld)
|
||||
if(this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].bigmap)
|
||||
tileName = this.prefix + dnprefix + '_128/' + ((scale*coord.x) >> 5) + '_' + ((scale*coord.y) >> 5) +
|
||||
'/' + zprefix + "_" + (scale*coord.x) + '_' + (scale*coord.y) + '.png';
|
||||
else
|
||||
@ -41,7 +41,7 @@ FlatMapType.prototype = $.extend(new DynMapType(), {
|
||||
imgSize = 128;
|
||||
}
|
||||
else {
|
||||
if(this.dynmap.world.bigworld)
|
||||
if(this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].bigmap)
|
||||
tileName = this.prefix + dnprefix + '_128/' + (coord.x >> 5) + '_' + (coord.y >> 5) +
|
||||
'/' + coord.x + '_' + coord.y + '.png';
|
||||
else
|
||||
|
@ -55,7 +55,7 @@ KzedMapType.prototype = $.extend(new DynMapType(), {
|
||||
tileSize = 128;
|
||||
imgSize = tileSize;
|
||||
var tilescale = 2 << (extrazoom-zoom);
|
||||
if (this.dynmap.world.bigworld) {
|
||||
if (this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].bigmap) {
|
||||
if(zoom < extrazoom) zpre = zpre + '_';
|
||||
tileName = 'z' + this.prefix + dnprefix + '/' + ((-coord.x * tileSize*tilescale)>>12) +
|
||||
'_' + ((coord.y * tileSize*tilescale) >> 12) + '/' + zpre +
|
||||
@ -69,7 +69,7 @@ KzedMapType.prototype = $.extend(new DynMapType(), {
|
||||
tileSize = 128;
|
||||
|
||||
imgSize = Math.pow(2, 6+zoom-extrazoom);
|
||||
if(this.dynmap.world.bigworld) {
|
||||
if(this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].bigmap) {
|
||||
tileName = this.prefix + dnprefix + '/' + ((-coord.x*tileSize) >> 12) + '_' +
|
||||
((coord.y*tileSize)>>12) + '/' +
|
||||
(-coord.x*tileSize) + '_' + (coord.y*tileSize) + '.png';
|
||||
|
Loading…
Reference in New Issue
Block a user