From 3ad99d9461289288d2021a1ce535a829f9eb8dea Mon Sep 17 00:00:00 2001 From: CounterPillow Date: Tue, 1 Jan 2013 21:15:38 +0100 Subject: [PATCH] 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. --- overviewer_core/aux_files/genPOI.py | 20 ++++++++++++++++---- overviewer_core/data/js_src/util.js | 2 +- overviewer_core/data/js_src/views.js | 3 ++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/overviewer_core/aux_files/genPOI.py b/overviewer_core/aux_files/genPOI.py index 80439cb..62750cb 100755 --- a/overviewer_core/aux_files/genPOI.py +++ b/overviewer_core/aux_files/genPOI.py @@ -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: diff --git a/overviewer_core/data/js_src/util.js b/overviewer_core/data/js_src/util.js index c7d289a..d3c9515 100644 --- a/overviewer_core/data/js_src/util.js +++ b/overviewer_core/data/js_src/util.js @@ -452,7 +452,7 @@ overviewer.util = { */ 'createMarkerInfoWindow': function(marker) { var windowContent = '

' + marker.title.replace(/\n/g,'
') + '

'; + '"/>

' + marker.content.replace(/\n/g,'
') + '

'; var infowindow = new google.maps.InfoWindow({ 'content': windowContent }); diff --git a/overviewer_core/data/js_src/views.js b/overviewer_core/data/js_src/views.js index 117bc8f..bbd75c1 100644 --- a/overviewer_core/data/js_src/views.js +++ b/overviewer_core/data/js_src/views.js @@ -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 });