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: