mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-24 19:25:15 +01:00
Add support for 8x8 and 32x32 marker icons (default still 16x16)
This commit is contained in:
parent
52a09d41b4
commit
348a37af87
@ -1,5 +1,6 @@
|
||||
package org.dynmap.markers.impl;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -17,6 +18,8 @@ import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
@ -38,6 +41,7 @@ import org.dynmap.markers.AreaMarker;
|
||||
import org.dynmap.markers.Marker;
|
||||
import org.dynmap.markers.MarkerAPI;
|
||||
import org.dynmap.markers.MarkerIcon;
|
||||
import org.dynmap.markers.MarkerIcon.MarkerSize;
|
||||
import org.dynmap.markers.MarkerSet;
|
||||
import org.dynmap.web.Json;
|
||||
|
||||
@ -82,6 +86,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
public String set;
|
||||
public boolean markup;
|
||||
public String desc;
|
||||
public String dim;
|
||||
|
||||
public MarkerUpdated(Marker m, boolean deleted) {
|
||||
this.id = m.getMarkerID();
|
||||
@ -93,6 +98,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
this.icon = m.getMarkerIcon().getMarkerIconID();
|
||||
this.markup = m.isLabelMarkup();
|
||||
this.desc = m.getDescription();
|
||||
this.dim = m.getMarkerIcon().getMarkerIconSize().getSize();
|
||||
if(deleted)
|
||||
msg = "markerdeleted";
|
||||
else
|
||||
@ -269,7 +275,9 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
InputStream in = null;
|
||||
File infile = new File(markerdir, ico.getMarkerIconID() + ".png"); /* Get source file name */
|
||||
File outfile = new File(markertiledir, ico.getMarkerIconID() + ".png"); /* Destination */
|
||||
BufferedImage im = null;
|
||||
OutputStream out = null;
|
||||
|
||||
try {
|
||||
out = new FileOutputStream(outfile);
|
||||
} catch (IOException iox) {
|
||||
@ -280,6 +288,26 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
in = getClass().getResourceAsStream("/markers/" + ico.getMarkerIconID() + ".png");
|
||||
}
|
||||
else if(infile.canRead()) { /* If it exists and is readable */
|
||||
try {
|
||||
im = ImageIO.read(infile);
|
||||
} catch (IOException e) {
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
if(im != null) {
|
||||
MarkerIconImpl icon = (MarkerIconImpl)ico;
|
||||
int w = im.getWidth(); /* Get width */
|
||||
if(w <= 8) { /* Small size? */
|
||||
icon.setMarkerIconSize(MarkerSize.MARKER_8x8);
|
||||
}
|
||||
else if(w > 16) {
|
||||
icon.setMarkerIconSize(MarkerSize.MARKER_32x32);
|
||||
}
|
||||
else {
|
||||
icon.setMarkerIconSize(MarkerSize.MARKER_16x16);
|
||||
}
|
||||
im.flush();
|
||||
}
|
||||
|
||||
try {
|
||||
in = new FileInputStream(infile);
|
||||
} catch (IOException iox) {
|
||||
@ -1447,7 +1475,9 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
mdata.put("x", m.getX());
|
||||
mdata.put("y", m.getY());
|
||||
mdata.put("z", m.getZ());
|
||||
mdata.put("icon", m.getMarkerIcon().getMarkerIconID());
|
||||
MarkerIcon mi = m.getMarkerIcon();
|
||||
mdata.put("icon", mi.getMarkerIconID());
|
||||
mdata.put("dim", mi.getMarkerIconSize().getSize());
|
||||
mdata.put("label", m.getLabel());
|
||||
mdata.put("markup", m.isLabelMarkup());
|
||||
if(m.getDescription() != null)
|
||||
|
@ -15,6 +15,7 @@ class MarkerIconImpl implements MarkerIcon {
|
||||
private String iconid;
|
||||
private String label;
|
||||
private boolean is_builtin;
|
||||
private MarkerSize size = MarkerSize.MARKER_16x16;
|
||||
|
||||
MarkerIconImpl(String id) {
|
||||
iconid = id;
|
||||
@ -93,4 +94,12 @@ class MarkerIconImpl implements MarkerIcon {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MarkerSize getMarkerIconSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
void setMarkerIconSize(MarkerSize sz) {
|
||||
size = sz;
|
||||
}
|
||||
}
|
||||
|
@ -779,8 +779,6 @@
|
||||
.dynmap .mapMarker .markerName-show {
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: -8px;
|
||||
left: 10px;
|
||||
z-index: 16;
|
||||
|
||||
white-space: nowrap;
|
||||
@ -791,12 +789,42 @@
|
||||
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
|
||||
}
|
||||
|
||||
.dynmap .mapMarker .markerName16x16 {
|
||||
top: -6px;
|
||||
left: 10px;
|
||||
}
|
||||
|
||||
.dynmap .mapMarker .markerName8x8 {
|
||||
top: -4px;
|
||||
left: 6px;
|
||||
}
|
||||
|
||||
.dynmap .mapMarker .markerName32x32 {
|
||||
top: -8px;
|
||||
left: 18px;
|
||||
}
|
||||
|
||||
.dynmap .mapMarker .markerIcon16x16 {
|
||||
margin-top: -8px;
|
||||
margin-left: -8px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.dynmap .mapMarker .markerIcon8x8 {
|
||||
margin-top: -4px;
|
||||
margin-left: -4px;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
.dynmap .mapMarker .markerIcon32x32 {
|
||||
margin-top: -16px;
|
||||
margin-left: -16px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.dynmap .mapMarker .markerName_offline_players {
|
||||
|
@ -42,7 +42,7 @@ componentconstructors['markers'] = function(dynmap, configuration) {
|
||||
dynmapmarkersets[name] = ms;
|
||||
$.each(markerset.markers, function(mname, marker) {
|
||||
ms.markers[mname] = { label: marker.label, markup: marker.markup, x: marker.x, y: marker.y, z:marker.z,
|
||||
icon: marker.icon, desc: marker.desc };
|
||||
icon: marker.icon, desc: marker.desc, dim: marker.dim };
|
||||
createMarker(ms, ms.markers[mname], ts);
|
||||
});
|
||||
$.each(markerset.areas, function(aname, area) {
|
||||
@ -70,17 +70,19 @@ componentconstructors['markers'] = function(dynmap, configuration) {
|
||||
$(div)
|
||||
.addClass('Marker')
|
||||
.addClass('mapMarker')
|
||||
.append($('<img/>').addClass('markerIcon16x16').attr({ src: dynmap.options.tileUrl+'_markers_/'+marker.icon+'.png' }));
|
||||
.append($('<img/>').addClass('markerIcon'+marker.dim).attr({ src: dynmap.options.tileUrl+'_markers_/'+marker.icon+'.png' }));
|
||||
if(marker.markup) {
|
||||
$(div).append($('<span/>')
|
||||
.addClass(configuration.showlabel?'markerName-show':'markerName')
|
||||
.addClass('markerName_' + set.id)
|
||||
.addClass('markerName' + marker.dim)
|
||||
.append(marker.label));
|
||||
}
|
||||
else
|
||||
$(div).append($('<span/>')
|
||||
.addClass(configuration.showlabel?'markerName-show':'markerName')
|
||||
.addClass('markerName_' + set.id)
|
||||
.addClass('markerName' + marker.dim)
|
||||
.text(marker.label));
|
||||
return div;
|
||||
}});
|
||||
@ -226,7 +228,7 @@ componentconstructors['markers'] = function(dynmap, configuration) {
|
||||
dynmapmarkersets[msg.set].layergroup.removeLayer(marker.our_marker);
|
||||
delete marker.our_marker;
|
||||
}
|
||||
marker = { x: msg.x, y: msg.y, z: msg.z, icon: msg.icon, label: msg.label, markup: msg.markup, desc: msg.desc };
|
||||
marker = { x: msg.x, y: msg.y, z: msg.z, icon: msg.icon, label: msg.label, markup: msg.markup, desc: msg.desc, dim: msg.dim || '16x16' };
|
||||
dynmapmarkersets[msg.set].markers[msg.id] = marker;
|
||||
createMarker(dynmapmarkersets[msg.set], marker, msg.timestamp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user