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