0

Added possibility to return tuple from filterfunc

If the returned type is a tuple, it will be interpreted as first the
title (i.e. hovertext), then the content of the infowindow. If the
returned type is a string, it will be used as both the title and
infowindow content (the old behaviour). This means that older configs
are still compatible and need no changes.
This commit is contained in:
CounterPillow
2013-01-01 21:15:38 +01:00
parent b13f0044e2
commit 3ad99d9461
3 changed files with 19 additions and 6 deletions

View File

@@ -201,7 +201,10 @@ def main():
for poi in rset._pois['Entities']:
result = filter_function(poi)
if result:
d = dict(x=poi['Pos'][0], y=poi['Pos'][1], z=poi['Pos'][2], text=result)
if type(result) == str:
d = dict(x=poi['Pos'][0], y=poi['Pos'][1], z=poi['Pos'][2], text=result, hovertext=result)
elif type(result) == tuple:
d = dict(x=poi['Pos'][0], y=poi['Pos'][1], z=poi['Pos'][2], text=result[1], hovertext=result[0])
if "icon" in poi:
d.update({"icon": poi['icon']})
if "createInfoWindow" in poi:
@@ -210,7 +213,10 @@ def main():
for poi in rset._pois['TileEntities']:
result = filter_function(poi)
if result:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result)
if type(result) == str:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, hovertext=result)
elif type(result) == tuple:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result[1], hovertext=result[0])
if "icon" in poi:
d.update({"icon": poi['icon']})
if "createInfoWindow" in poi:
@@ -219,7 +225,10 @@ def main():
for poi in rset._pois['Players']:
result = filter_function(poi)
if result:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result)
if type(result) == str:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, hovertext=result)
elif type(result) == tuple:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result[1], hovertext=result[0])
if "icon" in poi:
d.update({"icon": poi['icon']})
if "createInfoWindow" in poi:
@@ -228,7 +237,10 @@ def main():
for poi in rset._pois['Manual']:
result = filter_function(poi)
if result:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result)
if type(result) == str:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, hovertext=result)
elif type(result) == tuple:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result[1], hovertext=result[0])
if "icon" in poi:
d.update({"icon": poi['icon']})
if "createInfoWindow" in poi:

View File

@@ -452,7 +452,7 @@ overviewer.util = {
*/
'createMarkerInfoWindow': function(marker) {
var windowContent = '<div class="infoWindow"><img src="' + marker.icon +
'"/><p>' + marker.title.replace(/\n/g,'<br/>') + '</p></div>';
'"/><p>' + marker.content.replace(/\n/g,'<br/>') + '</p></div>';
var infowindow = new google.maps.InfoWindow({
'content': windowContent
});

View File

@@ -461,7 +461,8 @@ overviewer.views.SignControlView = Backbone.View.extend({
'position': overviewer.util.fromWorldToLatLng(entity.x,
entity.y, entity.z, overviewer.mapView.options.currentTileSet),
'map': overviewer.map,
'title': jQuery.trim(entity.text),
'title': jQuery.trim(entity.hovertext),
'content': jQuery.trim(entity.text),
'icon': iconURL,
'visible': false
});