- Markers are now known as "Signs"

- map-markerpath is now map-signspath (YOU MUST SET THIS TO YOUR CURRENT FILE IF YOU HAVE ONE)
 - Commands have been renamed to: /addsign, /removesign, /listsigns, /tpsign (Update groups.txt if required)
 - New map-showmarkers server.property (comma separated list of options spawn,homes,warps,signs,players or you can set it to all or none; yes, can even hide players but still show warps, spawns, etc...)
 - map-showmarkers directly affects what output via the "up" directory so what you include in your options is included in the data, and ultimately the map
 - Internally, signs are now Warp based so no longer owner based
 - index.html updated to add divs around checkboxes
 - map.js updated to consolidate both players and markers into a single if statement
 - checkboxes dynamically show/hide from the map based on the number of items on the map (will hide if there are none, especially based on map-showmarkers)
 - Player list shows/hides based on number of players (or map-showmarkers setting)
This commit is contained in:
fescen9 2010-12-11 04:56:06 +00:00
parent 70cb6a5a7f
commit 7a2b1598eb
10 changed files with 281 additions and 199 deletions

View File

@ -6,8 +6,7 @@ import java.util.logging.Logger;
public class MapListener extends PluginListener { public class MapListener extends PluginListener {
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
private MapManager mgr; private MapManager mgr;
private ArrayList<MapMarker> markers;
public MapListener(MapManager mgr) public MapListener(MapManager mgr)
{ {
this.mgr = mgr; this.mgr = mgr;
@ -76,58 +75,58 @@ public class MapListener extends PluginListener {
return true; return true;
} }
if(split[0].equals("/addmarker")) { if(split[0].equals("/addsign")) {
if(split.length < 2) if(split.length < 2)
{ {
player.sendMessage("Map> " + Colors.Red + "Usage: /map_addmarker [name]"); player.sendMessage("Map> " + Colors.Red + "Usage: /addsign [name]");
} }
else else
{ {
if (mgr.addMapMarker(player, split[1], player.getX(), player.getY(), player.getZ())) if (mgr.addSign(player, split[1], player.getX(), player.getY(), player.getZ()))
{ {
player.sendMessage("Map> " + Colors.White + "Marker \"" + split[1] + "\" added successfully"); player.sendMessage("Map> " + Colors.White + "Sign \"" + split[1] + "\" added successfully");
} }
} }
return true; return true;
} }
if(split[0].equals("/removemarker")) { if(split[0].equals("/removesign")) {
if(split.length < 2) if(split.length < 2)
{ {
player.sendMessage("Map> " + Colors.Red + "Usage: /map_removemarker [name]"); player.sendMessage("Map> " + Colors.Red + "Usage: /removesign [name]");
} }
else else
{ {
if (mgr.removeMapMarker(player, split[1])) if (mgr.removeSign(player, split[1]))
{ {
player.sendMessage("Map> " + Colors.White + "Marker \"" + split[1] + "\" removed successfully"); player.sendMessage("Map> " + Colors.White + "Sign \"" + split[1] + "\" removed successfully");
} }
} }
return true; return true;
} }
if(split[0].equals("/listmarkers")) { if(split[0].equals("/listsigns")) {
String msg = ""; String msg = "";
Collection<MapMarker> values = mgr.markers.values(); Collection<Warp> values = mgr.signs.values();
Iterator<MapMarker> it = values.iterator(); Iterator<Warp> it = values.iterator();
while(it.hasNext()) while(it.hasNext())
{ {
MapMarker marker = it.next(); Warp sign = it.next();
String line = " - " + marker.name + " (" + marker.owner + ")\t"; String line = " - " + sign.Name + "\t";
msg += line; msg += line;
} }
player.sendMessage("" + Colors.White + msg); player.sendMessage("" + Colors.White + msg);
return true; return true;
} }
if(split[0].equals("/tpmarker")) { if(split[0].equals("/tpsign")) {
if(split.length < 2) if(split.length < 2)
{ {
player.sendMessage("Map> " + Colors.Red + "Usage: /map_tpmarker [name]"); player.sendMessage("Map> " + Colors.Red + "Usage: /tpsign [name]");
} }
else else
{ {
if (mgr.teleportToMapMarker(player, split[1])) if (mgr.teleportToSign(player, split[1]))
{ {
//player.sendMessage("Map> " + Colors.White + ""); //player.sendMessage("Map> " + Colors.White + "");
} }

View File

@ -1,6 +1,5 @@
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.util.List;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster; import java.awt.image.WritableRaster;
@ -18,6 +17,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Scanner; import java.util.Scanner;
@ -65,8 +65,8 @@ public class MapManager extends Thread {
/* path to image tile directory */ /* path to image tile directory */
public String tilepath = "tiles/"; public String tilepath = "tiles/";
/* path to markers file */ /* path to signs file */
public String markerpath = "markers.txt"; public String signspath = "signs.txt";
/* port to run web server on */ /* port to run web server on */
public int serverport = 8123; public int serverport = 8123;
@ -83,14 +83,27 @@ public class MapManager extends Thread {
/* map debugging mode (send debugging messages to this player) */ /* map debugging mode (send debugging messages to this player) */
public String debugPlayer = null; public String debugPlayer = null;
/* hashmap of markers */ /* hashmap of signs */
public HashMap<String,MapMarker> markers = null; public HashMap<String, Warp> signs = null;
/* cache this many zoomed-out tiles */ /* cache this many zoomed-out tiles */
public static final int zoomCacheSize = 64; public static final int zoomCacheSize = 64;
/* zoomed-out tile cache */ /* zoomed-out tile cache */
public Cache<String, BufferedImage> zoomCache; public Cache<String, BufferedImage> zoomCache;
/* data source */
public String datasource = "flatfile";
/* which markers to show (spawn,homes,warps,signs,players,all,none) */
public String showmarkers = "all";
/* booleans designating what to show on the map */
public Boolean showSpawn = false;
public Boolean showHomes = false;
public Boolean showWarps = false;
public Boolean showSigns = false;
public Boolean showPlayers = false;
public void debug(String msg) public void debug(String msg)
{ {
@ -110,8 +123,10 @@ public class MapManager extends Thread {
try { try {
tilepath = properties.getString("map-tilepath", "tiles/"); tilepath = properties.getString("map-tilepath", "tiles/");
colorsetpath = properties.getString("map-colorsetpath", "colors.txt"); colorsetpath = properties.getString("map-colorsetpath", "colors.txt");
markerpath = properties.getString("map-markerpath", "markers.txt"); signspath = properties.getString("map-signspath", "signs.txt");
serverport = Integer.parseInt(properties.getString("map-serverport", "8123")); serverport = Integer.parseInt(properties.getString("map-serverport", "8123"));
datasource = properties.getString("data-source", "flatfile");
showmarkers = properties.getString("map-showmarkers", "all");
} catch(Exception ex) { } catch(Exception ex) {
log.log(Level.SEVERE, "Exception while reading properties for dynamic map", ex); log.log(Level.SEVERE, "Exception while reading properties for dynamic map", ex);
} }
@ -121,7 +136,9 @@ public class MapManager extends Thread {
tileUpdates = new LinkedList<TileUpdate>(); tileUpdates = new LinkedList<TileUpdate>();
zoomCache = new Cache<String, BufferedImage>(zoomCacheSize); zoomCache = new Cache<String, BufferedImage>(zoomCacheSize);
markers = new HashMap<String,MapMarker>(); signs = new HashMap<String, Warp>();
loadShowOptions();
} }
/* tile X for position x */ /* tile X for position x */
@ -169,7 +186,7 @@ public class MapManager extends Thread {
/* load colorset */ /* load colorset */
File cfile = new File(colorsetpath); File cfile = new File(colorsetpath);
loadMapMarkers(); loadSigns();
try { try {
Scanner scanner = new Scanner(cfile); Scanner scanner = new Scanner(cfile);
@ -566,116 +583,124 @@ public class MapManager extends Thread {
return good; return good;
} }
/* adds a marker to the map */ /* adds a sign to the map */
public boolean addMapMarker(Player player, String name, double px, double py, double pz) public boolean addSign(Player player, String name, double px, double py, double pz)
{ {
if (markers.containsKey(name)) if (signs.containsKey(name))
{ {
player.sendMessage("Map> " + Colors.Red + "Marker \"" + name + "\" already exists."); player.sendMessage("Map> " + Colors.Red + "Sign \"" + name + "\" already exists.");
return false; return false;
} }
MapMarker marker = new MapMarker(); Warp sign = new Warp();
marker.name = name; sign.Name = name;
marker.owner = player.getName(); sign.Location = new Location(px,py,pz);
marker.px = px; signs.put(name, sign);
marker.py = py;
marker.pz = pz;
markers.put(name, marker);
try try
{ {
saveMapMarkers(); saveSigns();
return true; return true;
} }
catch(IOException e) catch(IOException e)
{ {
log.log(Level.SEVERE, "Failed to save markers.txt", e); log.log(Level.SEVERE, "Failed to save signs.txt", e);
} }
return false; return false;
} }
/* removes a marker from the map */ /* removes a sign from the map */
public boolean removeMapMarker(Player player, String name) public boolean removeSign(Player player, String name)
{ {
if (markers.containsKey(name)) if (signs.containsKey(name))
{ {
MapMarker marker = markers.get(name); Warp sign = signs.get(name);
if (marker.owner.equalsIgnoreCase(player.getName()))
{
markers.remove(name);
try
{
saveMapMarkers();
return true;
}
catch(IOException e)
{
log.log(Level.SEVERE, "Failed to save markers.txt", e);
}
}
else
{
player.sendMessage("Map> " + Colors.Red + "Marker \"" + name + "\" does not belong to you.");
}
}
else
{
player.sendMessage("Map> " + Colors.Red + "Marker \"" + name + "\" does not exist.");
}
return false;
}
/* teleports a user to a marker */
public boolean teleportToMapMarker(Player player, String name)
{
if (markers.containsKey(name))
{
MapMarker marker = markers.get(name);
player.teleportTo(marker.px, marker.py, marker.pz, 0, 0); signs.remove(name);
try
{
saveSigns();
return true;
}
catch(IOException e)
{
log.log(Level.SEVERE, "Failed to save signs.txt", e);
}
} }
else else
{ {
player.sendMessage("Map> " + Colors.Red + "Marker \"" + name + "\" does not exist."); player.sendMessage("Map> " + Colors.Red + "Sign \"" + name + "\" does not exist.");
} }
return false; return false;
} }
/* load the map marker file */ /* teleports a user to a sign */
private void loadMapMarkers() public boolean teleportToSign(Player player, String name)
{
if (signs.containsKey(name))
{
Warp sign = signs.get(name);
player.teleportTo(sign.Location.x, sign.Location.y, sign.Location.z, 0, 0);
}
else
{
player.sendMessage("Map> " + Colors.Red + "Sign \"" + name + "\" does not exist.");
}
return false;
}
/* load the map sign file */
private void loadSigns()
{ {
Scanner scanner = null; Scanner scanner = null;
try try
{ {
scanner = new Scanner(new FileInputStream(markerpath), "UTF-8"); scanner = new Scanner(new FileInputStream(signspath), "UTF-8");
while (scanner.hasNextLine()) while (scanner.hasNextLine())
{ {
String line = scanner.nextLine(); String line = scanner.nextLine();
String[] values = line.split(":"); String[] values = line.split(":");
String name = "";
Double x = 0.0,y = 0.0,z = 0.0;
// If user has old style of file (CSV) // If user has old style of file (CSV)
if (values.length != 5) if (values.length == 1)
{ {
values = line.split(","); values = line.split(",");
} }
// If user has old style of file (owners)
if (values.length == 5) if (values.length == 5)
{ {
MapMarker marker = new MapMarker(); name = values[0];
marker.name = values[0]; x = Double.parseDouble(values[2]);
marker.owner = values[1]; y = Double.parseDouble(values[3]);
marker.px = Double.parseDouble(values[2]); z = Double.parseDouble(values[4]);
marker.py = Double.parseDouble(values[3]); }
marker.pz = Double.parseDouble(values[4]); else if (values.length == 4)
markers.put(marker.name, marker); {
name = values[0];
x = Double.parseDouble(values[1]);
y = Double.parseDouble(values[2]);
z = Double.parseDouble(values[3]);
} }
else else
{ {
log.log(Level.INFO, "Failed to load marker: " + values[0]); log.log(Level.INFO, "Failed to load sign: " + values[0]);
}
// If a sign was loaded, add it to the hash
if (name.isEmpty() == false && x != 0.0 && y != 0.0 && z != 0.0)
{
Warp sign = new Warp();
sign.Name = name;
sign.Location = new Location(x, y, z);
signs.put(sign.Name, sign);
} }
} }
} }
@ -689,19 +714,19 @@ public class MapManager extends Thread {
} }
} }
/* save the map marker file */ /* save the map sign file */
private void saveMapMarkers() throws IOException private void saveSigns() throws IOException
{ {
Writer out = null; Writer out = null;
try try
{ {
out = new OutputStreamWriter(new FileOutputStream(markerpath), "UTF-8"); out = new OutputStreamWriter(new FileOutputStream(signspath), "UTF-8");
Collection<MapMarker> values = markers.values(); Collection<Warp> values = signs.values();
Iterator<MapMarker> it = values.iterator(); Iterator<Warp> it = values.iterator();
while(it.hasNext()) while(it.hasNext())
{ {
MapMarker marker = it.next(); Warp sign = it.next();
String line = marker.name + ":" + marker.owner + ":" + marker.px + ":" + marker.py + ":" + marker.pz + "\n"; String line = sign.Name + ":" + sign.Location.x + ":" + sign.Location.y + ":" + sign.Location.z + "\n";
out.write(line); out.write(line);
} }
} }
@ -711,7 +736,7 @@ public class MapManager extends Thread {
} }
catch(FileNotFoundException e) catch(FileNotFoundException e)
{ {
log.log(Level.SEVERE, "markers.txt not found", e); log.log(Level.SEVERE, "signs.txt not found", e);
} }
finally finally
{ {
@ -723,23 +748,19 @@ public class MapManager extends Thread {
protected List<Warp> loadWarps() protected List<Warp> loadWarps()
{ {
PropertiesFile props = new PropertiesFile("server.properties");
List<Warp> warps = null; List<Warp> warps = null;
if (props.getString("data-source").equals("flatfile")) { if (datasource.equals("flatfile")) {
DMFlatFileSource dataSource = new DMFlatFileSource(); DMFlatFileSource ds = new DMFlatFileSource();
dataSource.initialize(); ds.initialize();
dataSource.loadWarps(); ds.loadWarps();
dataSource.loadHomes(); warps = ds.getAllWarps();
warps = dataSource.getAllWarps();
} }
else if (props.getString("data-source").equals("mysql")) { else if (datasource.equals("mysql")) {
DMMySQLSource dataSource = new DMMySQLSource(); DMMySQLSource ds = new DMMySQLSource();
dataSource.initialize(); ds.initialize();
dataSource.loadWarps(); ds.loadWarps();
dataSource.loadHomes(); warps = ds.getAllWarps();
warps = dataSource.getAllWarps();
} }
return warps; return warps;
@ -747,25 +768,68 @@ public class MapManager extends Thread {
protected List<Warp> loadHomes() protected List<Warp> loadHomes()
{ {
PropertiesFile props = new PropertiesFile("server.properties");
List<Warp> homes = null; List<Warp> homes = null;
if (props.getString("data-source").equals("flatfile")) { if (datasource.equals("flatfile")) {
DMFlatFileSource dataSource = new DMFlatFileSource(); DMFlatFileSource ds = new DMFlatFileSource();
dataSource.initialize(); ds.initialize();
dataSource.loadWarps(); ds.loadHomes();
dataSource.loadHomes(); homes = ds.getAllHomes();
homes = dataSource.getAllHomes();
} }
else if (props.getString("data-source").equals("mysql")) { else if (datasource.equals("mysql")) {
DMMySQLSource dataSource = new DMMySQLSource(); DMMySQLSource ds = new DMMySQLSource();
dataSource.initialize(); ds.initialize();
dataSource.loadWarps(); ds.loadHomes();
dataSource.loadHomes(); homes = ds.getAllHomes();
homes = dataSource.getAllHomes();
} }
return homes; return homes;
} }
private void loadShowOptions()
{
String[] values = showmarkers.split(",");
for (int i = 0; i < values.length; i++)
{
String opt = values[i];
if (opt.equals("all"))
{
showSpawn = true;
showHomes = true;
showWarps = true;
showSigns = true;
showPlayers = true;
}
else if (opt.equals("none"))
{
showSpawn = false;
showHomes = false;
showWarps = false;
showSigns = false;
showPlayers = false;
}
else if (opt.equals("spawn"))
{
showSpawn = true;
}
else if (opt.equals("homes"))
{
showHomes = true;
}
else if (opt.equals("warps"))
{
showWarps = true;
}
else if (opt.equals("signs"))
{
showSigns = true;
}
else if (opt.equals("players"))
{
showPlayers = true;
}
}
}
} }

View File

@ -1,4 +0,0 @@
public class MapMarker {
public double px, py, pz;
public String name, owner;
}

View File

@ -72,33 +72,44 @@ public class WebServerRequest extends Thread {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(current + "\n"); sb.append(current + "\n");
for(Player player : etc.getServer().getPlayerList()) { if (mgr.showPlayers) {
sb.append(player.getName() + " " + player.getX() + " " + player.getY() + " " + player.getZ() + "\n"); for(Player player : etc.getServer().getPlayerList()) {
sb.append(player.getName() + " player " + player.getX() + " " + player.getY() + " " + player.getZ() + "\n");
}
} }
for(MapMarker marker : mgr.markers.values()) if (mgr.showSigns) {
{ for(Warp sign : mgr.signs.values())
sb.append(marker.name + " marker " + marker.owner + " " + marker.px + " " + marker.py + " " + marker.pz + "\n"); {
sb.append(sign.Name + " sign " + sign.Location.x + " " + sign.Location.y + " " + sign.Location.z + "\n");
}
} }
List<Warp> warps = mgr.loadWarps(); if (mgr.showWarps) {
List<Warp> homes = mgr.loadHomes(); List<Warp> warps = mgr.loadWarps();
Location spawnLocation = etc.getServer().getSpawnLocation(); if (warps != null) {
for(Warp warp : warps) {
if (warps != null) { sb.append(warp.Name + " warp " + warp.Location.x + " " + warp.Location.y + " " + warp.Location.z + "\n");
for(Warp warp : warps) { }
sb.append(warp.Name + " warp unknown " + warp.Location.x + " " + warp.Location.y + " " + warp.Location.z + "\n");
} }
} }
if (homes != null) { if (mgr.showHomes) {
for(Warp warp : homes) { List<Warp> homes = mgr.loadHomes();
sb.append(warp.Name + " home " + warp.Name + " " + warp.Location.x + " " + warp.Location.y + " " + warp.Location.z + "\n");
if (homes != null) {
for(Warp warp : homes) {
sb.append(warp.Name + " home " + warp.Location.x + " " + warp.Location.y + " " + warp.Location.z + "\n");
}
} }
} }
sb.append("Spawn spawn none " + spawnLocation.x + " " + spawnLocation.y + " " + spawnLocation.z + "\n"); if (mgr.showSpawn) {
Location spawnLocation = etc.getServer().getSpawnLocation();
sb.append("Spawn spawn " + spawnLocation.x + " " + spawnLocation.y + " " + spawnLocation.z + "\n");
}
synchronized(mgr.lock) { synchronized(mgr.lock) {
for(TileUpdate tu : mgr.tileUpdates) { for(TileUpdate tu : mgr.tileUpdates) {

BIN
dist/DynamicMap.rar vendored

Binary file not shown.

View File

@ -48,9 +48,9 @@ public class map extends Plugin {
etc.getInstance().addCommand("/map_regen", " - regenerate entire map"); etc.getInstance().addCommand("/map_regen", " - regenerate entire map");
etc.getInstance().addCommand("/map_debug", " - send map debugging messages"); etc.getInstance().addCommand("/map_debug", " - send map debugging messages");
etc.getInstance().addCommand("/map_nodebug", " - disable map debugging messages"); etc.getInstance().addCommand("/map_nodebug", " - disable map debugging messages");
etc.getInstance().addCommand("/addmarker", " [name] - adds a named marker to the map"); etc.getInstance().addCommand("/addsign", " [name] - adds a named sign to the map");
etc.getInstance().addCommand("/removemarker", " [name] - removes a named marker to the map"); etc.getInstance().addCommand("/removesign", " [name] - removes a named sign to the map");
etc.getInstance().addCommand("/listmarkers", " - list all named markers"); etc.getInstance().addCommand("/listsigns", " - list all named signs");
etc.getInstance().addCommand("/tpmarker", " [name] - teleport to a named marker"); etc.getInstance().addCommand("/tpsign", " [name] - teleport to a named sign");
} }
} }

View File

@ -7,14 +7,15 @@ Commands
/map_nodebug - disable map debugging messages /map_nodebug - disable map debugging messages
/map_regenzoom - regenerates zoom-out tiles /map_regenzoom - regenerates zoom-out tiles
/addmarker [name] - adds a named marker to the map /addsign [name] - adds a named sign to the map
/removemarker [name] - removes a named marker to the map /removesign [name] - removes a named sign to the map
/listmarkers - list all named markers /listsigns - list all named signs
/tpmarker [name] - teleport to a named marker /tpsign [name] - teleport to a named sign
server.properties server.properties
-------------------------------------------------- --------------------------------------------------
map-colorsetpath - point to colors.txt map-colorsetpath - point to colors.txt
map-tilepath - point to web/tiles folder map-tilepath - point to web/tiles folder
map-markerpath - point to markers.csv file (do not need to create the file, one will be created when you create a marker) map-signspath - point to signs.txt file (do not need to create the file, one will be created when you create a sign)
map-serverport - the port the web server runs on (default is 8123) map-serverport - the port the web server runs on (default is 8123)
map-showmarkers - a list of which markers to show on the map, comma separated if multiple (spawn, homes, warps, signs, players, all, none)

View File

@ -20,15 +20,23 @@
<div id="lst">[Connecting]</div> <div id="lst">[Connecting]</div>
</div> </div>
<div id="controls"> <div id="controls">
<form action="#" method="get"> <form action="#" method="get">
<img src="warp.png" alt="Warps" title="Warps" /> <div id="warpsDiv">
<input type="checkbox" checked="checked" id="showWarps" /><br /> <img src="warp.png" alt="Warps" title="Warps" />
<img src="marker.png" alt="Markers" title="Markers" /> <input type="checkbox" checked="checked" id="showWarps" />
<input type="checkbox" checked="checked" id="showMarkers" /><br /> </div>
<img src="home.png" alt="Homes" title="Homes" /> <div id="signsDiv">
<input type="checkbox" checked="checked" id="showHomes" /><br /> <img src="sign.png" alt="Signs" title="Signs" />
<img src="spawn.png" alt="Spawn" title="Spawn" /> <input type="checkbox" checked="checked" id="showSigns" /><br />
<input type="checkbox" checked="checked" id="showSpawn" /><br /> </div>
<div id="homesDiv">
<img src="home.png" alt="Homes" title="Homes" />
<input type="checkbox" checked="checked" id="showHomes" /><br />
</div>
<div id="spawnsDiv">
<img src="spawn.png" alt="Spawn" title="Spawn" />
<input type="checkbox" checked="checked" id="showSpawn" /><br />
</div>
</form> </form>
</div> </div>
<div id="link"></div> <div id="link"></div>

View File

@ -565,7 +565,7 @@ function makeRequest(url, func, type, fail, post, contenttype)
var rows = res.split('\n'); var rows = res.split('\n');
var loggedin = new Array(); var loggedin = new Array();
var showWarps = document.getElementById('showWarps').checked; var showWarps = document.getElementById('showWarps').checked;
var showMarkers = document.getElementById('showMarkers').checked; var showSigns = document.getElementById('showSigns').checked;
var showHomes = document.getElementById('showHomes').checked; var showHomes = document.getElementById('showHomes').checked;
var showSpawn = document.getElementById('showSpawn').checked; var showSpawn = document.getElementById('showSpawn').checked;
@ -573,55 +573,49 @@ function makeRequest(url, func, type, fail, post, contenttype)
delete rows[0]; delete rows[0];
var playerlst = '' var playerlst = ''
var numwarps = 0;
var numsigns = 0;
var numhomes = 0;
var numspawns = 0;
var numplayers = 0;
for(var line in rows) { for(var line in rows) {
var p = rows[line].split(' '); var p = rows[line].split(' ');
// Hack to keep duplicate markers/warps/players from conflicting with eachother if(p[0] == '') continue;
if(p.length == 6) {
// Hack to keep duplicate markers from conflicting with eachother
if (p[1] != 'player') {
p[0] = p[0] + '<span style="display:none;">' + p[1] + '</span>'; p[0] = p[0] + '<span style="display:none;">' + p[1] + '</span>';
} }
loggedin[p[0]] = 1; loggedin[p[0]] = 1;
if(p[0] == '') continue;
if (p[1] == 'player') {
if(p.length == 4) {
if(playerlst != '') playerlst += '<br />'; if(playerlst != '') playerlst += '<br />';
playerlst += '<img id="icon_' + p[0] + '" class="plicon" src="' + (p[0] == followPlayer ? 'follow_on.png' : 'follow_off.png') + '" onclick="plfollow(' + "'" + p[0] + "'" + ')" alt="" /> <a href="#" onclick="plclick(' + "'" + p[0] + "'" + ')">' + p[0] + '</a>'; playerlst += '<img id="icon_' + p[0] + '" class="plicon" src="' + (p[0] == followPlayer ? 'follow_on.png' : 'follow_off.png') + '" onclick="plfollow(' + "'" + p[0] + "'" + ')" alt="" /> <a href="#" onclick="plclick(' + "'" + p[0] + "'" + ')">' + p[0] + '</a>';
}
if(p[0] == followPlayer) { if(p.length == 5) {
map.setCenter(fromWorldToLatLng(p[1], p[2], p[3]));
}
if(p[0] in markers) {
var m = markers[p[0]];
var converted = fromWorldToLatLng(p[1], p[2], p[3]);
m.setPosition(converted);
} else {
var converted = fromWorldToLatLng(p[1], p[2], p[3]);
var marker = new MarkerWithLabel({
position: converted,
map: map,
labelContent: p[0],
labelAnchor: new google.maps.Point(-14, 10),
labelClass: "labels",
clickable: false,
flat: true,
icon: new google.maps.MarkerImage('player.png', new google.maps.Size(28, 28), new google.maps.Point(0, 0), new google.maps.Point(14, 14))
});
markers[p[0]] = marker;
}
} else if(p.length == 6) {
var image = p[1] + '.png'; var image = p[1] + '.png';
if (p[1] == 'warp') numwarps++;
if (p[1] == 'sign') numsigns++;
if (p[1] == 'home') numhomes++;
if (p[1] == 'spawn') numspawns++;
if (p[1] == 'player') numplayers++;
var hideMarker = ( var hideMarker = (
(p[1] == 'warp' && showWarps == false) || (p[1] == 'warp' && showWarps == false) ||
(p[1] == 'marker' && showMarkers == false) || (p[1] == 'sign' && showSigns == false) ||
(p[1] == 'home' && showHomes == false) || (p[1] == 'home' && showHomes == false) ||
(p[1] == 'spawn' && showSpawn == false) (p[1] == 'spawn' && showSpawn == false)
); );
if(p[0] == followPlayer) {
map.panTo(fromWorldToLatLng(p[2], p[3], p[4]));
}
if(p[0] in markers) { if(p[0] in markers) {
var m = markers[p[0]]; var m = markers[p[0]];
@ -633,14 +627,14 @@ function makeRequest(url, func, type, fail, post, contenttype)
m.setMap(map); m.setMap(map);
} }
var converted = fromWorldToLatLng(p[3], p[4], p[5]); var converted = fromWorldToLatLng(p[2], p[3], p[4]);
m.setPosition(converted); m.setPosition(converted);
} else { } else {
if (hideMarker) { if (hideMarker) {
continue; continue;
} }
var converted = fromWorldToLatLng(p[3], p[4], p[5]); var converted = fromWorldToLatLng(p[2], p[3], p[4]);
var marker = new MarkerWithLabel({ var marker = new MarkerWithLabel({
position: converted, position: converted,
map: map, map: map,
@ -674,6 +668,15 @@ function makeRequest(url, func, type, fail, post, contenttype)
delete markers[m]; delete markers[m];
} }
} }
document.getElementById('warpsDiv').style.display = (numwarps == 0)?'none':'';
document.getElementById('signsDiv').style.display = (numsigns == 0)?'none':'';
document.getElementById('homesDiv').style.display = (numhomes == 0)?'none':'';
document.getElementById('spawnsDiv').style.display = (numspawns == 0)?'none':'';
document.getElementById('plist').style.display = (numplayers == 0)?'none':'';
document.getElementById('controls').style.display = ((numwarps + numsigns + numhomes + numspawns) == 0)?'none':'';
setTimeout(mapUpdate, config.updateRate); setTimeout(mapUpdate, config.updateRate);
}, 'text', function() { alert('failed to get update data'); } ); }, 'text', function() { alert('failed to get update data'); } );

View File

Before

Width:  |  Height:  |  Size: 681 B

After

Width:  |  Height:  |  Size: 681 B