0

Merge branches 'config-include', 'hashchange', 'poi-polylines', 'showlocationmarker' and 'signed-timestamps'

This commit is contained in:
Aaron Griffith
2013-05-20 20:56:40 -04:00
10 changed files with 109 additions and 22 deletions

View File

@@ -294,7 +294,7 @@ the form ``key = value``. Two items take a different form:, ``worlds`` and
* ``messages=dict(totalTiles=<string>, renderCompleted=<string>, renderProgress=<string>)`` * ``messages=dict(totalTiles=<string>, renderCompleted=<string>, renderProgress=<string>)``
Customises messages displayed in browser. All three messages must be Customises messages displayed in browser. All three messages must be
defined as follows: defined similar to the following:
* ``totalTiles="Rendering %d tiles"`` * ``totalTiles="Rendering %d tiles"``
The ``%d`` format string will be replaced with the total number of The ``%d`` format string will be replaced with the total number of
@@ -304,9 +304,9 @@ the form ``key = value``. Two items take a different form:, ``worlds`` and
The three format strings will be replaced with the number of hours. The three format strings will be replaced with the number of hours.
minutes and seconds taken to complete this render. minutes and seconds taken to complete this render.
* ``renderProgress="Rendered %d of %d tiles (%d%%)"`` * ``renderProgress="Rendered %d of %d tiles (%d%% ETA:%s)""``
The three format strings will be replaced with the number of tiles The four format strings will be replaced with the number of tiles
completed, the total number of tiles and the percentage complete completed, the total number of tiles, the percentage complete, and the ETA.
Format strings are explained here: http://docs.python.org/library/stdtypes.html#string-formatting Format strings are explained here: http://docs.python.org/library/stdtypes.html#string-formatting
All format strings must be present in your custom messages. All format strings must be present in your custom messages.
@@ -529,6 +529,12 @@ values. The valid configuration keys are listed below.
**Default:** Automatically set to most detailed zoom level **Default:** Automatically set to most detailed zoom level
``showlocationmarker``
Allows you to specify whether to show the location marker when accessing a URL
with coordinates specified.
**Default:** ``True``
``base`` ``base``
Allows you to specify a remote location for the tile folder, useful if you Allows you to specify a remote location for the tile folder, useful if you
rsync your map's images to a remote server. Leave a trailing slash and point rsync your map's images to a remote server. Leave a trailing slash and point

View File

@@ -460,7 +460,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
# only pass to the TileSet the options it really cares about # only pass to the TileSet the options it really cares about
render['name'] = render_name # perhaps a hack. This is stored here for the asset manager render['name'] = render_name # perhaps a hack. This is stored here for the asset manager
tileSetOpts = util.dict_subset(render, ["name", "imgformat", "renderchecks", "rerenderprob", "bgcolor", "defaultzoom", "imgquality", "optimizeimg", "rendermode", "worldname_orig", "title", "dimension", "changelist", "showspawn", "overlay", "base", "poititle", "maxzoom"]) tileSetOpts = util.dict_subset(render, ["name", "imgformat", "renderchecks", "rerenderprob", "bgcolor", "defaultzoom", "imgquality", "optimizeimg", "rendermode", "worldname_orig", "title", "dimension", "changelist", "showspawn", "overlay", "base", "poititle", "maxzoom", "showlocationmarker"])
tileSetOpts.update({"spawn": w.find_true_spawn()}) # TODO find a better way to do this tileSetOpts.update({"spawn": w.find_true_spawn()}) # TODO find a better way to do this
tset = tileset.TileSet(w, rset, assetMrg, tex, tileSetOpts, tileset_dir) tset = tileset.TileSet(w, rset, assetMrg, tex, tileSetOpts, tileset_dir)
tilesets.append(tset) tilesets.append(tset)

View File

@@ -95,7 +95,7 @@ directory.
'queryMarker': 'http://google-maps-icons.googlecode.com/files/regroup.png' 'queryMarker': 'http://google-maps-icons.googlecode.com/files/regroup.png'
} }
dump['CONST']['mapDivId'] = 'mcmap' dump['CONST']['mapDivId'] = 'mcmap'
dump['CONST']['regionStrokeWeight'] = 2 dump['CONST']['regionStrokeWeight'] = 2 # Obselete
dump['CONST']['UPPERLEFT'] = world.UPPER_LEFT; dump['CONST']['UPPERLEFT'] = world.UPPER_LEFT;
dump['CONST']['UPPERRIGHT'] = world.UPPER_RIGHT; dump['CONST']['UPPERRIGHT'] = world.UPPER_RIGHT;
dump['CONST']['LOWERLEFT'] = world.LOWER_LEFT; dump['CONST']['LOWERLEFT'] = world.LOWER_LEFT;
@@ -122,7 +122,7 @@ directory.
'mapType': True, 'mapType': True,
'overlays': True, 'overlays': True,
'coordsBox': True, 'coordsBox': True,
'searchBox': True 'searchBox': True # Lolwat. Obselete
} }

View File

@@ -219,6 +219,22 @@ def main():
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, hovertext=result) d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, hovertext=result)
elif type(result) == tuple: elif type(result) == tuple:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result[1], hovertext=result[0]) d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result[1], hovertext=result[0])
# Dict support to allow more flexible things in the future as well as polylines on the map.
elif type(result) == dict:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result['text'])
# Use custom hovertext if provided...
if 'hovertext' in result and isinstance(result['hovertext'], basestring):
d['hovertext'] = result['hovertext']
else: # ...otherwise default to display text.
d['hovertext'] = result['text']
if 'polyline' in result and type(result['polyline']) == tuple: #if type(result.get('polyline', '')) == tuple:
d['polyline'] = []
for point in result['polyline']:
# This poor man's validation code almost definately needs improving.
if type(point) == dict:
d['polyline'].append(dict(x=point['x'],y=point['y'],z=point['z']))
if isinstance(result['color'], basestring):
d['strokeColor'] = result['color']
if "icon" in poi: if "icon" in poi:
d.update({"icon": poi['icon']}) d.update({"icon": poi['icon']})
if "createInfoWindow" in poi: if "createInfoWindow" in poi:
@@ -231,6 +247,22 @@ def main():
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, hovertext=result) d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, hovertext=result)
elif type(result) == tuple: elif type(result) == tuple:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result[1], hovertext=result[0]) d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result[1], hovertext=result[0])
# Dict support to allow more flexible things in the future as well as polylines on the map.
elif type(result) == dict:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result['text'])
# Use custom hovertext if provided...
if 'hovertext' in result and isinstance(result['hovertext'], basestring):
d['hovertext'] = result['hovertext']
else: # ...otherwise default to display text.
d['hovertext'] = result['text']
if 'polyline' in result and type(result['polyline']) == tuple: #if type(result.get('polyline', '')) == tuple:
d['polyline'] = []
for point in result['polyline']:
# This poor man's validation code almost definately needs improving.
if type(point) == dict:
d['polyline'].append(dict(x=point['x'],y=point['y'],z=point['z']))
if isinstance(result['color'], basestring):
d['strokeColor'] = result['color']
if "icon" in poi: if "icon" in poi:
d.update({"icon": poi['icon']}) d.update({"icon": poi['icon']})
if "createInfoWindow" in poi: if "createInfoWindow" in poi:
@@ -243,6 +275,22 @@ def main():
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, hovertext=result) d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, hovertext=result)
elif type(result) == tuple: elif type(result) == tuple:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result[1], hovertext=result[0]) d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result[1], hovertext=result[0])
# Dict support to allow more flexible things in the future as well as polylines on the map.
elif type(result) == dict:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result['text'])
# Use custom hovertext if provided...
if 'hovertext' in result and isinstance(result['hovertext'], basestring):
d['hovertext'] = result['hovertext']
else: # ...otherwise default to display text.
d['hovertext'] = result['text']
if 'polyline' in result and type(result['polyline']) == tuple: #if type(result.get('polyline', '')) == tuple:
d['polyline'] = []
for point in result['polyline']:
# This poor man's validation code almost definately needs improving.
if type(point) == dict:
d['polyline'].append(dict(x=point['x'],y=point['y'],z=point['z']))
if isinstance(result['color'], basestring):
d['strokeColor'] = result['color']
if "icon" in poi: if "icon" in poi:
d.update({"icon": poi['icon']}) d.update({"icon": poi['icon']})
if "createInfoWindow" in poi: if "createInfoWindow" in poi:

View File

@@ -3,7 +3,9 @@ overviewer.util = {
// vars for callback // vars for callback
readyQueue: [], readyQueue: [],
isReady: false, isReady: false,
lastHash: null,
/* fuzz tester! /* fuzz tester!
*/ */
'testMaths': function(t) { 'testMaths': function(t) {
@@ -138,8 +140,9 @@ overviewer.util = {
overviewer.mapView.render(); overviewer.mapView.render();
// Jump to the hash if given // Jump to the hash if given (and do so for any further hash changes)
overviewer.util.initHash(); overviewer.util.initHash();
$(window).on('hashchange', function() { overviewer.util.initHash(); });
// create this control after initHash so it can correctly select the current world // create this control after initHash so it can correctly select the current world
var worldSelector = new overviewer.views.WorldSelectorView({tagName:'DIV'}); var worldSelector = new overviewer.views.WorldSelectorView({tagName:'DIV'});
@@ -465,18 +468,23 @@ overviewer.util = {
}); });
}, },
'initHash': function() { 'initHash': function() {
if(window.location.hash.split("/").length > 1) { var newHash = window.location.hash;
overviewer.util.goToHash(); if (overviewer.util.lastHash !== newHash) {
// Clean up the hash. overviewer.util.lastHash = newHash;
overviewer.util.updateHash(); if(newHash.split("/").length > 1) {
overviewer.util.goToHash();
// Clean up the hash.
overviewer.util.updateHash();
}
} }
}, },
'setHash': function(x, y, z, zoom, w, maptype) { 'setHash': function(x, y, z, zoom, w, maptype) {
// save this info is a nice easy to parse format // save this info is a nice easy to parse format
var currentWorldView = overviewer.mapModel.get("currentWorldView"); var currentWorldView = overviewer.mapModel.get("currentWorldView");
currentWorldView.options.lastViewport = [x,y,z,zoom]; currentWorldView.options.lastViewport = [x,y,z,zoom];
window.location.replace("#/" + Math.floor(x) + "/" + Math.floor(y) + "/" + Math.floor(z) + "/" + zoom + "/" + w + "/" + maptype); var newHash = "#/" + Math.floor(x) + "/" + Math.floor(y) + "/" + Math.floor(z) + "/" + zoom + "/" + w + "/" + maptype;
overviewer.util.lastHash = newHash; // this should not trigger initHash
window.location.replace(newHash);
}, },
'updateHash': function() { 'updateHash': function() {
var currTileset = overviewer.mapView.options.currentTileSet; var currTileset = overviewer.mapView.options.currentTileSet;

View File

@@ -474,6 +474,22 @@ overviewer.views.SignControlView = Backbone.View.extend({
} }
} }
dataRoot[i].markerObjs.push(marker); dataRoot[i].markerObjs.push(marker);
// Polyline stuff added by FreakusGeekus. Probably needs work.
if (typeof entity['polyline'] != 'undefined') {
var polypath = new Array();
for (point in entity.polyline) {
polypath.push(overviewer.util.fromWorldToLatLng(entity.polyline[point].x, entity.polyline[point].y, entity.polyline[point].z, overviewer.mapView.options.currentTileSet));
}
var polyline = new google.maps.Polyline({
'path': polypath,
'clickable': false,
'map': overviewer.map,
'visible': false,
'strokeColor': entity['strokeColor']
});
dataRoot[i].markerObjs.push(polyline);
}
} }
dataRoot[i].created = true; dataRoot[i].created = true;
} }
@@ -571,7 +587,7 @@ overviewer.views.LocationIconView = Backbone.View.extend({
'icon': overviewerConfig.CONST.image.queryMarker, 'icon': overviewerConfig.CONST.image.queryMarker,
'visible': false 'visible': false
}); });
overviewer.collections.locationMarker.setVisible(true); overviewer.collections.locationMarker.setVisible(overviewer.mapView.options.currentTileSet.get("showlocationmarker"));
} }
}); });

View File

@@ -199,7 +199,8 @@ class MCRFileReader(object):
listing chunks contained in the file. listing chunks contained in the file.
""" """
_table_format = struct.Struct(">1024I") _location_table_format = struct.Struct(">1024I")
_timestamp_table_format = struct.Struct(">1024i")
_chunk_header_format = struct.Struct(">I B") _chunk_header_format = struct.Struct(">I B")
def __init__(self, fileobj): def __init__(self, fileobj):
@@ -217,8 +218,8 @@ class MCRFileReader(object):
raise CorruptRegionError("invalid timestamp table") raise CorruptRegionError("invalid timestamp table")
# turn this data into a useful list # turn this data into a useful list
self._locations = self._table_format.unpack(location_data) self._locations = self._location_table_format.unpack(location_data)
self._timestamps = self._table_format.unpack(timestamp_data) self._timestamps = self._timestamp_table_format.unpack(timestamp_data)
def close(self): def close(self):
"""Close the region file and free any resources associated """Close the region file and free any resources associated

View File

@@ -83,10 +83,11 @@ renders = Setting(required=True, default=util.OrderedDict(),
"overlay": Setting(required=False, validator=validateOverlays, default=[]), "overlay": Setting(required=False, validator=validateOverlays, default=[]),
"showspawn": Setting(required=False, validator=validateBool, default=True), "showspawn": Setting(required=False, validator=validateBool, default=True),
"base": Setting(required=False, validator=validateStr, default=""), "base": Setting(required=False, validator=validateStr, default=""),
"poititle": Setting(required=False, validator=validateStr, default="Signs"), "poititle": Setting(required=False, validator=validateStr, default="Markers"),
"customwebassets": Setting(required=False, validator=validateWebAssetsPath, default=None), "customwebassets": Setting(required=False, validator=validateWebAssetsPath, default=None),
"maxzoom": Setting(required=False, validator=validateInt, default=None), "maxzoom": Setting(required=False, validator=validateInt, default=None),
"manualpois": Setting(required=False, validator=validateManualPOIs, default=[]), "manualpois": Setting(required=False, validator=validateManualPOIs, default=[]),
"showlocationmarker": Setting(required=False, validator=validateBool, default=True),
# Remove this eventually (once people update their configs) # Remove this eventually (once people update their configs)
"worldname": Setting(required=False, default=None, "worldname": Setting(required=False, default=None,
validator=error("The option 'worldname' is now called 'world'. Please update your config files")), validator=error("The option 'worldname' is now called 'world'. Please update your config files")),

View File

@@ -3159,7 +3159,7 @@ def stone_brick(self, blockid, data):
return img return img
# huge brown and red mushroom # huge brown and red mushroom
@material(blockid=[99,100], data=range(11), solid=True) @material(blockid=[99,100], data= range(11) + [14,15], solid=True)
def huge_mushroom(self, blockid, data): def huge_mushroom(self, blockid, data):
# rotation # rotation
if self.rotation == 1: if self.rotation == 1:
@@ -3232,6 +3232,12 @@ def huge_mushroom(self, blockid, data):
if data == 10: # stem if data == 10: # stem
img = self.build_full_block(porous, None, None, stem, stem) img = self.build_full_block(porous, None, None, stem, stem)
if data == 14: # all cap
img = self.build_block(cap,cap)
if data == 15: # all stem
img = self.build_block(stem,stem)
return img return img
# iron bars and glass pane # iron bars and glass pane

View File

@@ -528,7 +528,8 @@ class TileSet(object):
last_rendertime = self.max_chunk_mtime, last_rendertime = self.max_chunk_mtime,
imgextension = self.imgextension, imgextension = self.imgextension,
isOverlay = isOverlay, isOverlay = isOverlay,
poititle = self.options.get("poititle") poititle = self.options.get("poititle"),
showlocationmarker = self.options.get("showlocationmarker")
) )
if isOverlay: if isOverlay: