Added showchatballoons, showplayerfacesonmap and showplayerfacesinmenu to configuration.
This commit is contained in:
parent
4014a21d0b
commit
ed67225a9e
4 changed files with 158 additions and 409 deletions
|
|
@ -15,6 +15,7 @@ webserver-bindaddress: 0.0.0.0
|
||||||
# The TCP-port the webserver will listen on.
|
# The TCP-port the webserver will listen on.
|
||||||
webserver-port: 8123
|
webserver-port: 8123
|
||||||
|
|
||||||
|
# The maptypes Dynmap will use to render.
|
||||||
maps:
|
maps:
|
||||||
- class: org.dynmap.kzedmap.KzedMap
|
- class: org.dynmap.kzedmap.KzedMap
|
||||||
renderers:
|
renderers:
|
||||||
|
|
@ -27,7 +28,14 @@ web:
|
||||||
# Interval the browser should poll for updates.
|
# Interval the browser should poll for updates.
|
||||||
updaterate: 2000
|
updaterate: 2000
|
||||||
|
|
||||||
|
showchatballoons: true
|
||||||
|
showplayerfacesonmap: true
|
||||||
|
showplayerfacesinmenu: true
|
||||||
|
|
||||||
|
# The name of the map shown when opening Dynmap's page (must be in menu).
|
||||||
defaultmap: defaultmap
|
defaultmap: defaultmap
|
||||||
|
|
||||||
|
# The maps shown in the menu.
|
||||||
shownmaps:
|
shownmaps:
|
||||||
- type: KzedMapType
|
- type: KzedMapType
|
||||||
name: defaultmap
|
name: defaultmap
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
|
@ -21,7 +22,6 @@ import org.dynmap.ChatQueue;
|
||||||
import org.dynmap.MapManager;
|
import org.dynmap.MapManager;
|
||||||
import org.dynmap.PlayerList;
|
import org.dynmap.PlayerList;
|
||||||
import org.dynmap.TileUpdate;
|
import org.dynmap.TileUpdate;
|
||||||
import org.dynmap.ChatQueue.ChatMessage;
|
|
||||||
import org.dynmap.debug.Debugger;
|
import org.dynmap.debug.Debugger;
|
||||||
|
|
||||||
public class WebServerRequest extends Thread {
|
public class WebServerRequest extends Thread {
|
||||||
|
|
@ -112,11 +112,14 @@ public class WebServerRequest extends Thread {
|
||||||
public String stringifyJson(Object o) {
|
public String stringifyJson(Object o) {
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
return "null";
|
return "null";
|
||||||
|
} else if (o instanceof Boolean) {
|
||||||
|
return ((Boolean)o) ? "true" : "false";
|
||||||
} else if (o instanceof String) {
|
} else if (o instanceof String) {
|
||||||
return "\"" + o + "\"";
|
return "\"" + o + "\"";
|
||||||
} else if (o instanceof Integer || o instanceof Long || o instanceof Float || o instanceof Double) {
|
} else if (o instanceof Integer || o instanceof Long || o instanceof Float || o instanceof Double) {
|
||||||
return o.toString();
|
return o.toString();
|
||||||
} else if (o instanceof LinkedHashMap<?, ?>) {
|
} else if (o instanceof LinkedHashMap<?, ?>) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
LinkedHashMap<String, Object> m = (LinkedHashMap<String, Object>)o;
|
LinkedHashMap<String, Object> m = (LinkedHashMap<String, Object>)o;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("{");
|
sb.append("{");
|
||||||
|
|
@ -131,6 +134,17 @@ public class WebServerRequest extends Thread {
|
||||||
}
|
}
|
||||||
sb.append("}");
|
sb.append("}");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
} else if (o instanceof ArrayList<?>) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
ArrayList<Object> l = (ArrayList<Object>)o;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
int count = 0;
|
||||||
|
for(int i=0;i<l.size();i++) {
|
||||||
|
sb.append(count++ == 0 ? "[" : ",");
|
||||||
|
sb.append(stringifyJson(l.get(i)));
|
||||||
|
}
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
} else {
|
} else {
|
||||||
return "undefined";
|
return "undefined";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
490
web/kzedmaps.js
490
web/kzedmaps.js
|
|
@ -1,392 +1,116 @@
|
||||||
package org.dynmap.kzedmap;
|
function KzedProjection() {}
|
||||||
|
KzedProjection.prototype = {
|
||||||
|
fromLatLngToPoint: function(latLng) {
|
||||||
|
var x = (latLng.lng() * config.tileWidth)|0;
|
||||||
|
var y = (latLng.lat() * config.tileHeight)|0;
|
||||||
|
|
||||||
import java.awt.Color;
|
return new google.maps.Point(x, y);
|
||||||
import java.io.File;
|
},
|
||||||
import java.io.FileInputStream;
|
fromPointToLatLng: function(point) {
|
||||||
import java.io.InputStream;
|
var lng = point.x / config.tileWidth;
|
||||||
import java.lang.reflect.Constructor;
|
var lat = point.y / config.tileHeight;
|
||||||
import java.util.ArrayList;
|
return new google.maps.LatLng(lat, lng);
|
||||||
import java.util.HashMap;
|
},
|
||||||
import java.util.List;
|
fromWorldToLatLng: function(x, y, z)
|
||||||
import java.util.Map;
|
{
|
||||||
import java.util.Scanner;
|
var dx = +x;
|
||||||
import java.util.logging.Logger;
|
var dy = +y - 127;
|
||||||
|
var dz = +z;
|
||||||
|
var px = dx + dz;
|
||||||
|
var py = dx - dz - dy;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
var lng = -px / config.tileWidth / 2 + 0.5;
|
||||||
import org.bukkit.World;
|
var lat = py / config.tileHeight / 2;
|
||||||
import org.dynmap.MapManager;
|
|
||||||
import org.dynmap.MapTile;
|
|
||||||
import org.dynmap.MapType;
|
|
||||||
import org.dynmap.debug.Debugger;
|
|
||||||
|
|
||||||
public class KzedMap extends MapType {
|
return new google.maps.LatLng(lat, lng);
|
||||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
|
||||||
|
|
||||||
/* dimensions of a map tile */
|
|
||||||
public static final int tileWidth = 128;
|
|
||||||
public static final int tileHeight = 128;
|
|
||||||
|
|
||||||
/* (logical!) dimensions of a zoomed out map tile
|
|
||||||
* must be twice the size of the normal tile */
|
|
||||||
public static final int zTileWidth = 256;
|
|
||||||
public static final int zTileHeight = 256;
|
|
||||||
|
|
||||||
/* map x, y, z for projection origin */
|
|
||||||
public static final int anchorx = 0;
|
|
||||||
public static final int anchory = 127;
|
|
||||||
public static final int anchorz = 0;
|
|
||||||
|
|
||||||
public static java.util.Map<Integer, Color[]> colors;
|
|
||||||
MapTileRenderer[] renderers;
|
|
||||||
ZoomedTileRenderer zoomrenderer;
|
|
||||||
|
|
||||||
public KzedMap(MapManager manager, World world, Debugger debugger, Map<String, Object> configuration) {
|
|
||||||
super(manager, world, debugger);
|
|
||||||
if (colors == null) {
|
|
||||||
colors = loadColorSet("colors.txt");
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
renderers = loadRenderers(configuration);
|
function KzedMapType(configuration) { $.extend(this, configuration); }
|
||||||
zoomrenderer = new ZoomedTileRenderer(debugger, configuration);
|
KzedMapType.prototype = $.extend(new DynMapType(), {
|
||||||
}
|
constructor: KzedMapType,
|
||||||
|
projection: new KzedProjection(),
|
||||||
|
tileSize: new google.maps.Size(128, 128),
|
||||||
|
minZoom: 0,
|
||||||
|
maxZoom: 3,
|
||||||
|
prefix: null,
|
||||||
|
getTile: function(coord, zoom, doc) {
|
||||||
|
var tileDebugText = null;
|
||||||
|
var tileSize = 128;
|
||||||
|
var tileName;
|
||||||
|
var imgSize;
|
||||||
|
var offset = {x: 0, y: 0};
|
||||||
|
|
||||||
private MapTileRenderer[] loadRenderers(Map<String, Object> configuration) {
|
var debugred;
|
||||||
List<?> configuredRenderers = (List<?>)configuration.get("renderers");
|
var debugblue;
|
||||||
ArrayList<MapTileRenderer> renderers = new ArrayList<MapTileRenderer>();
|
|
||||||
for(Object configuredRendererObj : configuredRenderers) {
|
if (zoom == 0) {
|
||||||
try {
|
// Most zoomed out tiles.
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Map<String, Object> configuredRenderer = (Map<String, Object>)configuredRendererObj;
|
tileSize = 128;
|
||||||
String typeName = (String)configuredRenderer.get("class");
|
imgSize = tileSize;
|
||||||
log.info("Loading renderer '" + typeName.toString() + "'...");
|
tileName = 'z' + this.prefix + '_' + (-coord.x * tileSize*2) + '_' + (coord.y * tileSize*2);
|
||||||
Class<?> mapTypeClass = Class.forName(typeName);
|
} else {
|
||||||
Constructor<?> constructor = mapTypeClass.getConstructor(Debugger.class, Map.class);
|
// Other zoom levels.
|
||||||
MapTileRenderer mapTileRenderer = (MapTileRenderer)constructor.newInstance(getDebugger(), configuredRenderer);
|
tileSize = 128;
|
||||||
renderers.add(mapTileRenderer);
|
|
||||||
} catch (Exception e) {
|
// Helper functions.
|
||||||
getDebugger().error("Error loading renderer", e);
|
var floor = Math.floor;
|
||||||
|
var div = function(x,y){return floor(x/y);}
|
||||||
|
var mod = function(x,y){return ((x%y)+y)%y;};
|
||||||
|
|
||||||
|
// Split the image up in ... segments (1*1 for zoom 1, 2*2 for zoom 2, 4*4 for zoom 3, etc).
|
||||||
|
var segments = Math.pow(2,zoom-1);
|
||||||
|
imgSize = segments*tileSize;
|
||||||
|
|
||||||
|
// Calculate the location relative to the world of this segment.
|
||||||
|
var mapcoord = {x: div(coord.x,segments)*tileSize, y: div(coord.y,segments)*tileSize};
|
||||||
|
// Calculate the location relative to the image of this segment.
|
||||||
|
offset = {x: mod(coord.x,segments)*-tileSize, y: mod(coord.y,segments)*-tileSize};
|
||||||
|
|
||||||
|
// The next couple of lines are somewhat of a hack, but makes it faster to render zoomed in tiles:
|
||||||
|
tileSize = imgSize;
|
||||||
|
|
||||||
|
if (offset.x == 0 && offset.y == 0) {
|
||||||
|
tileName = this.prefix + '_' + (-mapcoord.x) + '_' + mapcoord.y;
|
||||||
}
|
}
|
||||||
|
offset = {x: 0, y: 0};
|
||||||
|
// The next line is not:
|
||||||
|
//tileName = this.prefix + '_' + (-mapcoord.x) + '_' + mapcoord.y;
|
||||||
}
|
}
|
||||||
MapTileRenderer[] result = new MapTileRenderer[renderers.size()];
|
var img;
|
||||||
renderers.toArray(result);
|
var tile = $('<div/>')
|
||||||
return result;
|
.addClass('tile')
|
||||||
|
.css({
|
||||||
|
overflow: 'hidden',
|
||||||
|
width: tileSize + 'px',
|
||||||
|
height: tileSize + 'px'
|
||||||
|
});
|
||||||
|
if (tileDebugText) {
|
||||||
|
$('<span/>')
|
||||||
|
.text(tileDebugText)
|
||||||
|
.css({
|
||||||
|
position: 'absolute',
|
||||||
|
color: 'red'
|
||||||
|
})
|
||||||
|
.appendTo(tile);
|
||||||
|
}
|
||||||
|
if (tileName) {
|
||||||
|
img = $('<img/>')
|
||||||
|
.attr('src', this.dynmap.getTileUrl(tileName))
|
||||||
|
.error(function() { img.hide(); })
|
||||||
|
.css({
|
||||||
|
width: imgSize + 'px',
|
||||||
|
height: imgSize + 'px',
|
||||||
|
borderStyle: 'none',
|
||||||
|
marginLeft: offset.x + 'px',
|
||||||
|
marginTop: offset.y + 'px'
|
||||||
|
})
|
||||||
|
.appendTo(tile);
|
||||||
|
this.dynmap.registerTile(this, tileName, img);
|
||||||
|
} else {
|
||||||
|
this.dynmap.unregisterTile(this, tileName);
|
||||||
|
}
|
||||||
|
return tile.get(0);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
@Override
|
|
||||||
public void touch(Location l) {
|
|
||||||
int x = l.getBlockX();
|
|
||||||
int y = l.getBlockY();
|
|
||||||
int z = l.getBlockZ();
|
|
||||||
|
|
||||||
int dx = x - anchorx;
|
|
||||||
int dy = y - anchory;
|
|
||||||
int dz = z - anchorz;
|
|
||||||
int px = dx + dz;
|
|
||||||
int py = dx - dz - dy;
|
|
||||||
|
|
||||||
int tx = tilex(px);
|
|
||||||
int ty = tiley(py);
|
|
||||||
|
|
||||||
invalidateTile(tx, ty);
|
|
||||||
|
|
||||||
boolean ledge = tilex(px - 4) != tx;
|
|
||||||
boolean tedge = tiley(py - 4) != ty;
|
|
||||||
boolean redge = tilex(px + 4) != tx;
|
|
||||||
boolean bedge = tiley(py + 4) != ty;
|
|
||||||
|
|
||||||
if(ledge) invalidateTile(tx - tileWidth, ty);
|
|
||||||
if(redge) invalidateTile(tx + tileWidth, ty);
|
|
||||||
if(tedge) invalidateTile(tx, ty - tileHeight);
|
|
||||||
if(bedge) invalidateTile(tx, ty + tileHeight);
|
|
||||||
|
|
||||||
if(ledge && tedge) invalidateTile(tx - tileWidth, ty - tileHeight);
|
|
||||||
if(ledge && bedge) invalidateTile(tx - tileWidth, ty + tileHeight);
|
|
||||||
if(redge && tedge) invalidateTile(tx + tileWidth, ty - tileHeight);
|
|
||||||
if(redge && bedge) invalidateTile(tx + tileWidth, ty + tileHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void invalidateTile(int px, int py) {
|
|
||||||
for(MapTileRenderer renderer : renderers) {
|
|
||||||
invalidateTile(new KzedMapTile(this, renderer, px, py));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(MapTile tile) {
|
|
||||||
if (tile instanceof KzedZoomedMapTile) {
|
|
||||||
zoomrenderer.render((KzedZoomedMapTile)tile, getMapManager().tileDirectory.getAbsolutePath());
|
|
||||||
} else if (tile instanceof KzedMapTile) {
|
|
||||||
((KzedMapTile)tile).renderer.render((KzedMapTile)tile, getMapManager().tileDirectory.getAbsolutePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* tile X for position x */
|
|
||||||
static int tilex(int x)
|
|
||||||
{
|
|
||||||
if(x < 0)
|
|
||||||
return x - (tileWidth + (x % tileWidth));
|
|
||||||
else
|
|
||||||
return x - (x % tileWidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* tile Y for position y */
|
|
||||||
static int tiley(int y)
|
|
||||||
{
|
|
||||||
if(y < 0)
|
|
||||||
return y - (tileHeight + (y % tileHeight));
|
|
||||||
else
|
|
||||||
return y - (y % tileHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* zoomed-out tile X for tile position x */
|
|
||||||
static int ztilex(int x)
|
|
||||||
{
|
|
||||||
if(x < 0)
|
|
||||||
return x + x % zTileWidth;
|
|
||||||
else
|
|
||||||
return x - (x % zTileWidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* zoomed-out tile Y for tile position y */
|
|
||||||
static int ztiley(int y)
|
|
||||||
{
|
|
||||||
if(y < 0)
|
|
||||||
return y + y % zTileHeight;
|
|
||||||
//return y - (zTileHeight + (y % zTileHeight));
|
|
||||||
else
|
|
||||||
return y - (y % zTileHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
// regenerate the entire map, starting at position
|
|
||||||
public void regenerate(int x, int y, int z)
|
|
||||||
{
|
|
||||||
int dx = x - anchorx;
|
|
||||||
int dy = y - anchory;
|
|
||||||
int dz = z - anchorz;
|
|
||||||
int px = dx + dz;
|
|
||||||
int py = dx - dz - dy;
|
|
||||||
|
|
||||||
int tx = tilex(px);
|
|
||||||
int ty = tiley(py);
|
|
||||||
|
|
||||||
MapTile first = getTileByPosition(tx, ty);
|
|
||||||
|
|
||||||
Vector<MapTile> open = new Vector<MapTile>();
|
|
||||||
open.add(first);
|
|
||||||
|
|
||||||
while(open.size() > 0) {
|
|
||||||
MapTile t = open.remove(open.size() - 1);
|
|
||||||
if(t.stale) continue;
|
|
||||||
int h = world.getHighestBlockYAt(t.mx, t.mz);
|
|
||||||
|
|
||||||
log.info("walking: " + t.mx + ", " + t.mz + ", h = " + h);
|
|
||||||
if(h < 1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
pushStaleTile(t);
|
|
||||||
|
|
||||||
open.add(getTileByPosition(t.px + tileWidth, t.py));
|
|
||||||
open.add(getTileByPosition(t.px - tileWidth, t.py));
|
|
||||||
open.add(getTileByPosition(t.px, t.py + tileHeight));
|
|
||||||
open.add(getTileByPosition(t.px, t.py - tileHeight));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// regenerate all zoom tiles, starting at position
|
|
||||||
public void regenerateZoom(int x, int y, int z)
|
|
||||||
{
|
|
||||||
int dx = x - anchorx;
|
|
||||||
int dy = y - anchory;
|
|
||||||
int dz = z - anchorz;
|
|
||||||
int px = dx + dz;
|
|
||||||
int py = dx - dz - dy;
|
|
||||||
|
|
||||||
int fzpx = ztilex(tilex(px));
|
|
||||||
int fzpy = ztiley(tiley(py));
|
|
||||||
|
|
||||||
class Pair implements Comparator {
|
|
||||||
public int x;
|
|
||||||
public int y;
|
|
||||||
public Pair(int x, int y)
|
|
||||||
{
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
return (x << 16) ^ y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object o)
|
|
||||||
{
|
|
||||||
Pair p = (Pair) o;
|
|
||||||
return x == p.x && y == p.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compare(Object o1, Object o2)
|
|
||||||
{
|
|
||||||
Pair p1 = (Pair) o1;
|
|
||||||
Pair p2 = (Pair) o2;
|
|
||||||
if(p1.x < p1.x) return -1;
|
|
||||||
if(p1.x > p1.x) return 1;
|
|
||||||
if(p1.y < p1.y) return -1;
|
|
||||||
if(p1.y > p1.y) return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HashSet<Pair> visited = new HashSet<Pair>();
|
|
||||||
Vector<Pair> open = new Vector<Pair>();
|
|
||||||
|
|
||||||
Pair fp = new Pair(fzpx, fzpy);
|
|
||||||
open.add(fp);
|
|
||||||
visited.add(fp);
|
|
||||||
|
|
||||||
while(open.size() > 0) {
|
|
||||||
Pair p = open.remove(open.size() - 1);
|
|
||||||
|
|
||||||
int zpx = p.x;
|
|
||||||
int zpy = p.y;
|
|
||||||
|
|
||||||
log.info("Regenerating zoom tile " + zpx + "," + zpy);
|
|
||||||
|
|
||||||
int g = regenZoomTile(zpx, zpy);
|
|
||||||
|
|
||||||
if(g > 0) {
|
|
||||||
Pair[] np = new Pair[4];
|
|
||||||
np[0] = new Pair(zpx-zTileWidth, zpy);
|
|
||||||
np[1] = new Pair(zpx+zTileWidth, zpy);
|
|
||||||
np[2] = new Pair(zpx, zpy-zTileHeight);
|
|
||||||
np[3] = new Pair(zpx, zpy+zTileHeight);
|
|
||||||
|
|
||||||
for(int i=0; i<4; i++) {
|
|
||||||
if(!visited.contains(np[i])) {
|
|
||||||
visited.add(np[i]);
|
|
||||||
open.add(np[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// regenerate zoom-out tile
|
|
||||||
// returns number of valid subtiles
|
|
||||||
public int regenZoomTile(int zpx, int zpy)
|
|
||||||
{
|
|
||||||
int px1 = zpx + tileWidth;
|
|
||||||
int py1 = zpy;
|
|
||||||
int px2 = zpx;
|
|
||||||
int py2 = py1 + tileHeight;
|
|
||||||
|
|
||||||
MapTile t1 = getTileByPosition(px1, py1);
|
|
||||||
MapTile t2 = getTileByPosition(px2, py1);
|
|
||||||
MapTile t3 = getTileByPosition(px1, py2);
|
|
||||||
MapTile t4 = getTileByPosition(px2, py2);
|
|
||||||
|
|
||||||
BufferedImage im1 = t1.loadTile(this);
|
|
||||||
BufferedImage im2 = t2.loadTile(this);
|
|
||||||
BufferedImage im3 = t3.loadTile(this);
|
|
||||||
BufferedImage im4 = t4.loadTile(this);
|
|
||||||
|
|
||||||
BufferedImage zIm = new BufferedImage(MapManager.tileWidth, MapManager.tileHeight, BufferedImage.TYPE_INT_RGB);
|
|
||||||
WritableRaster zr = zIm.getRaster();
|
|
||||||
Graphics2D g2 = zIm.createGraphics();
|
|
||||||
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
|
||||||
|
|
||||||
int scw = tileWidth / 2;
|
|
||||||
int sch = tileHeight / 2;
|
|
||||||
|
|
||||||
int good = 0;
|
|
||||||
|
|
||||||
if(im1 != null) {
|
|
||||||
g2.drawImage(im1, 0, 0, scw, sch, null);
|
|
||||||
good ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(im2 != null) {
|
|
||||||
g2.drawImage(im2, scw, 0, scw, sch, null);
|
|
||||||
good ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(im3 != null) {
|
|
||||||
g2.drawImage(im3, 0, sch, scw, sch, null);
|
|
||||||
good ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(im4 != null) {
|
|
||||||
g2.drawImage(im4, scw, sch, scw, sch, null);
|
|
||||||
good ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(good == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
String zPath = t1.getZoomPath(this);
|
|
||||||
// save zoom-out tile
|
|
||||||
try {
|
|
||||||
File file = new File(zPath);
|
|
||||||
ImageIO.write(zIm, "png", file);
|
|
||||||
log.info("regenZoomTile saved zoom-out tile at " + zPath);
|
|
||||||
} catch(IOException e) {
|
|
||||||
log.log(Level.SEVERE, "Failed to save zoom-out tile: " + zPath, e);
|
|
||||||
} catch(java.lang.NullPointerException e) {
|
|
||||||
log.log(Level.SEVERE, "Failed to save zoom-out tile (NullPointerException): " + zPath, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return good;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public java.util.Map<Integer, Color[]> loadColorSet(String colorsetpath) {
|
|
||||||
java.util.Map<Integer, Color[]> colors = new HashMap<Integer, Color[]>();
|
|
||||||
|
|
||||||
InputStream stream;
|
|
||||||
|
|
||||||
try {
|
|
||||||
/* load colorset */
|
|
||||||
File cfile = new File(colorsetpath);
|
|
||||||
if (cfile.isFile()) {
|
|
||||||
getDebugger().debug("Loading colors from '" + colorsetpath + "'...");
|
|
||||||
stream = new FileInputStream(cfile);
|
|
||||||
} else {
|
|
||||||
getDebugger().debug("Loading colors from jar...");
|
|
||||||
stream = KzedMap.class.getResourceAsStream("/colors.txt");
|
|
||||||
}
|
|
||||||
|
|
||||||
Scanner scanner = new Scanner(stream);
|
|
||||||
int nc = 0;
|
|
||||||
while(scanner.hasNextLine()) {
|
|
||||||
String line = scanner.nextLine();
|
|
||||||
if (line.startsWith("#") || line.equals("")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] split = line.split("\t");
|
|
||||||
if (split.length < 17) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer id = new Integer(split[0]);
|
|
||||||
|
|
||||||
Color[] c = new Color[4];
|
|
||||||
|
|
||||||
/* store colors by raycast sequence number */
|
|
||||||
c[0] = new Color(Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]), Integer.parseInt(split[4]));
|
|
||||||
c[3] = new Color(Integer.parseInt(split[5]), Integer.parseInt(split[6]), Integer.parseInt(split[7]), Integer.parseInt(split[8]));
|
|
||||||
c[1] = new Color(Integer.parseInt(split[9]), Integer.parseInt(split[10]), Integer.parseInt(split[11]), Integer.parseInt(split[12]));
|
|
||||||
c[2] = new Color(Integer.parseInt(split[13]), Integer.parseInt(split[14]), Integer.parseInt(split[15]), Integer.parseInt(split[16]));
|
|
||||||
|
|
||||||
colors.put(id, c);
|
|
||||||
nc += 1;
|
|
||||||
}
|
|
||||||
scanner.close();
|
|
||||||
} catch(Exception e) {
|
|
||||||
getDebugger().error("Could not load colors", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return colors;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
57
web/map.js
57
web/map.js
|
|
@ -68,11 +68,11 @@ MinecraftClock.prototype = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function DynMap(options) {
|
function DynMap(options) {
|
||||||
var self = this;
|
var me = this;
|
||||||
self.options = options;
|
me.options = options;
|
||||||
$.getJSON(self.options.updateUrl + 'configuration', function(configuration) {
|
$.getJSON(me.options.updateUrl + 'configuration', function(configuration) {
|
||||||
self.configure(configuration);
|
me.configure(configuration);
|
||||||
self.initialize();
|
me.initialize();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
DynMap.prototype = {
|
DynMap.prototype = {
|
||||||
|
|
@ -83,14 +83,12 @@ DynMap.prototype = {
|
||||||
lasttimestamp: '0',
|
lasttimestamp: '0',
|
||||||
followingPlayer: '',
|
followingPlayer: '',
|
||||||
configure: function(configuration) {
|
configure: function(configuration) {
|
||||||
var self = this;
|
var me = this;
|
||||||
$.extend(this.options, configuration);
|
$.extend(me.options, configuration);
|
||||||
if (!self.options.maps) self.options.maps = {};
|
if (!me.options.maps) me.options.maps = {};
|
||||||
$.each(self.options.shownmaps, function(index, mapentry) {
|
$.each(me.options.shownmaps, function(index, mapentry) {
|
||||||
var mapconstructor = eval(mapentry.type);
|
var mapconstructor = eval(mapentry.type);
|
||||||
var mapname = mapentry.name;
|
me.options.maps[mapentry.name] = new mapconstructor(mapentry);
|
||||||
var mapconfiguration = mapentry;
|
|
||||||
self.options.maps[mapname] = new mapconstructor(mapconfiguration);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
|
@ -192,7 +190,7 @@ DynMap.prototype = {
|
||||||
.addClass('alertbox')
|
.addClass('alertbox')
|
||||||
.appendTo(container);
|
.appendTo(container);
|
||||||
|
|
||||||
setTimeout(function() { me.update(); }, me.options.updateRate);
|
setTimeout(function() { me.update(); }, me.options.updaterate);
|
||||||
},
|
},
|
||||||
update: function() {
|
update: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
@ -231,6 +229,8 @@ DynMap.prototype = {
|
||||||
me.onTileUpdated(row.name);
|
me.onTileUpdated(row.name);
|
||||||
}
|
}
|
||||||
, chat: function() {
|
, chat: function() {
|
||||||
|
if (!me.options.showchatballoons)
|
||||||
|
return;
|
||||||
var chats = line.split(' ');
|
var chats = line.split(' ');
|
||||||
var message = '';
|
var message = '';
|
||||||
for (var chatIndex = 2; chatIndex < chats.length; chatIndex++)
|
for (var chatIndex = 2; chatIndex < chats.length; chatIndex++)
|
||||||
|
|
@ -268,13 +268,13 @@ DynMap.prototype = {
|
||||||
delete me.markers[m];
|
delete me.markers[m];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setTimeout(function() { me.update(); }, me.options.updateRate);
|
setTimeout(function() { me.update(); }, me.options.updaterate);
|
||||||
},
|
},
|
||||||
error: function(request, statusText, ex) {
|
error: function(request, statusText, ex) {
|
||||||
me.alertbox
|
me.alertbox
|
||||||
.text('Could not update map')
|
.text('Could not update map')
|
||||||
.show();
|
.show();
|
||||||
setTimeout(function() { me.update(); }, me.options.updateRate);
|
setTimeout(function() { me.update(); }, me.options.updaterate);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -369,13 +369,14 @@ DynMap.prototype = {
|
||||||
.append($('<span/>')
|
.append($('<span/>')
|
||||||
.addClass('playerName')
|
.addClass('playerName')
|
||||||
.text(mi.text))
|
.text(mi.text))
|
||||||
|
if (me.options.showplayerfacesonmap) {
|
||||||
getMinecraftHead(mi.text, 32, function(head) {
|
getMinecraftHead(mi.text, 32, function(head) {
|
||||||
$(head)
|
$(head)
|
||||||
.addClass('playerIcon')
|
.addClass('playerIcon')
|
||||||
.prependTo(div);
|
.prependTo(div);
|
||||||
playerImage.remove();
|
playerImage.remove();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var marker = new CustomMarker(mi.position, map, contentfun, mi);
|
var marker = new CustomMarker(mi.position, map, contentfun, mi);
|
||||||
|
|
@ -404,11 +405,13 @@ DynMap.prototype = {
|
||||||
.click(function(e) { map.panTo(markers[mi.id].getPosition()); })
|
.click(function(e) { map.panTo(markers[mi.id].getPosition()); })
|
||||||
);
|
);
|
||||||
|
|
||||||
getMinecraftHead(mi.text, 16, function(head) {
|
if (me.options.showplayerfacesinmenu) {
|
||||||
marker.playerRow.icon = $(head)
|
getMinecraftHead(mi.text, 16, function(head) {
|
||||||
.addClass('playerIcon')
|
marker.playerRow.icon = $(head)
|
||||||
.appendTo(marker.playerIconContainer);
|
.addClass('playerIcon')
|
||||||
});
|
.appendTo(marker.playerIconContainer);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
me.playerlist.append(marker.playerRow);
|
me.playerlist.append(marker.playerRow);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue