0

make create info window optional parameter

This commit is contained in:
alexan
2012-05-06 16:06:04 +03:00
committed by Andrew Chin
parent 4ae77a9f47
commit e0a4976e6a
3 changed files with 21 additions and 8 deletions

View File

@@ -93,7 +93,7 @@ of dictionaries. For example::
'world': 'myworld', 'world': 'myworld',
'title': "Example", 'title': "Example",
'markers': [dict(name="All signs", filterFunction=signFilter), 'markers': [dict(name="All signs", filterFunction=signFilter),
dict(name="Chests", filterFunction=chestFilter, icon="chest.png")] dict(name="Chests", filterFunction=chestFilter, icon="chest.png", createInfoWindow=False)]
} }
@@ -112,6 +112,9 @@ The following keys are accepted in the marker dictionary:
on the POI itself (this can be done by modifying the POI in the filter function. See the on the POI itself (this can be done by modifying the POI in the filter function. See the
example above) example above)
``createInfoWindow``
Optional. Specifies wether or not the icon displays a spezial info window on click. Defaults to true
Generating the POI Markers Generating the POI Markers
========================== ==========================

View File

@@ -153,15 +153,15 @@ def main():
return 1 return 1
for f in render['markers']: for f in render['markers']:
d = dict(icon="signpost_icon.png") d = dict(icon="signpost_icon.png", createInfoWindow=True)
d.update(f) d.update(f)
markersets.add(((d['name'], d['filterFunction']), rset)) markersets.add(((d['name'], d['filterFunction']), rset))
name = f['name'].replace(" ","_") + hex(hash(f['filterFunction']))[-4:] + "_" + hex(hash(rset))[-4:] name = f['name'].replace(" ","_") + hex(hash(f['filterFunction']))[-4:] + "_" + hex(hash(rset))[-4:]
try: try:
l = markers[rname] l = markers[rname]
l.append(dict(groupName=name, displayName = f['name'], icon=d['icon'])) l.append(dict(groupName=name, displayName = f['name'], icon=d['icon'], createInfoWindow=d['createInfoWindow']))
except KeyError: except KeyError:
markers[rname] = [dict(groupName=name, displayName=f['name'], icon=d['icon']),] markers[rname] = [dict(groupName=name, displayName=f['name'], icon=d['icon'], createInfoWindow=d['createInfoWindow']),]
handleSigns(rset, os.path.join(destdir, rname), render, rname) handleSigns(rset, os.path.join(destdir, rname), render, rname)
handlePlayers(rset, render, worldpath) handlePlayers(rset, render, worldpath)
@@ -179,16 +179,20 @@ def main():
for poi in rset._pois['TileEntities']: for poi in rset._pois['TileEntities']:
result = filter_function(poi) result = filter_function(poi)
if result: if result:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, createInfoWindow=True) d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result)
if "icon" in poi: if "icon" in poi:
d.update({"icon": poi['icon']}) d.update({"icon": poi['icon']})
if "createInfoWindow" in poi:
d.update({"createInfoWindow": poi['createInfoWindow']})
markerSetDict[name]['raw'].append(d) markerSetDict[name]['raw'].append(d)
for poi in rset._pois['Players']: for poi in rset._pois['Players']:
result = filter_function(poi) result = filter_function(poi)
if result: if result:
d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, createInfoWindow=True) d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result)
if "icon" in poi: if "icon" in poi:
d.update({"icon": poi['icon']}) d.update({"icon": poi['icon']})
if "createInfoWindow" in poi:
d.update({"createInfoWindow": poi['createInfoWindow']})
markerSetDict[name]['raw'].append(d) markerSetDict[name]['raw'].append(d)
#print markerSetDict #print markerSetDict

View File

@@ -458,8 +458,14 @@ overviewer.views.SignControlView = Backbone.View.extend({
'icon': iconURL, 'icon': iconURL,
'visible': false 'visible': false
}); });
if (entity.createInfoWindow) { if(entity['createInfoWindow']) {
overviewer.util.createMarkerInfoWindow(marker); if (entity.createInfoWindow) {
overviewer.util.createMarkerInfoWindow(marker);
}
} else {
if(dataRoot[i].createInfoWindow) {
overviewer.util.createMarkerInfoWindow(marker);
}
} }
jQuery.extend(entity, {markerObj: marker}); jQuery.extend(entity, {markerObj: marker});
} }