initial implementation of ornaments
This commit is contained in:
parent
c44f4793cf
commit
a64f76c862
@ -584,6 +584,7 @@ function boot() {
|
|||||||
window.setupSidebarToggle();
|
window.setupSidebarToggle();
|
||||||
window.updateGameScore();
|
window.updateGameScore();
|
||||||
window.artifact.setup();
|
window.artifact.setup();
|
||||||
|
window.ornaments.setup();
|
||||||
window.setupPlayerStat();
|
window.setupPlayerStat();
|
||||||
window.setupTooltips();
|
window.setupTooltips();
|
||||||
window.chat.setup();
|
window.chat.setup();
|
||||||
|
@ -44,7 +44,7 @@ window.Render.prototype.clearPortalsBelowLevel = function(level) {
|
|||||||
for (var guid in window.portals) {
|
for (var guid in window.portals) {
|
||||||
var p = portals[guid];
|
var p = portals[guid];
|
||||||
// clear portals below specified level - unless it's the selected portal, or it's relevant to artifacts
|
// clear portals below specified level - unless it's the selected portal, or it's relevant to artifacts
|
||||||
if (parseInt(p.options.level) < level && guid !== selectedPortal && !artifact.isInterestingPortal(guid)) {
|
if (parseInt(p.options.level) < level && guid !== selectedPortal && !artifact.isInterestingPortal(guid) && !ornaments.isInterestingPortal(p)) {
|
||||||
this.deletePortalEntity(guid);
|
this.deletePortalEntity(guid);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
@ -433,7 +433,7 @@ window.Render.prototype.resetPortalClusters = function() {
|
|||||||
var guid = c[i];
|
var guid = c[i];
|
||||||
var p = window.portals[guid];
|
var p = window.portals[guid];
|
||||||
var layerGroup = portalsFactionLayers[parseInt(p.options.level)][p.options.team];
|
var layerGroup = portalsFactionLayers[parseInt(p.options.level)][p.options.team];
|
||||||
if ((i<this.CLUSTER_PORTAL_LIMIT || p.options.guid == selectedPortal || artifact.isInterestingPortal(p.options.guid)) && this.bounds.contains(p.getLatLng())) {
|
if ((i<this.CLUSTER_PORTAL_LIMIT || p.options.guid == selectedPortal || artifact.isInterestingPortal(p.options.guid) || ornaments.isInterestingPortal(p)) && this.bounds.contains(p.getLatLng())) {
|
||||||
if (!layerGroup.hasLayer(p)) {
|
if (!layerGroup.hasLayer(p)) {
|
||||||
layerGroup.addLayer(p);
|
layerGroup.addLayer(p);
|
||||||
}
|
}
|
||||||
@ -456,10 +456,15 @@ window.Render.prototype.addPortalToMapLayer = function(portal) {
|
|||||||
|
|
||||||
this.portalClusters[cid].push(portal.options.guid);
|
this.portalClusters[cid].push(portal.options.guid);
|
||||||
|
|
||||||
|
window.ornaments.addPortal(portal);
|
||||||
|
|
||||||
// now, at this point, we could match the above re-cluster code - sorting, and adding/removing as necessary
|
// now, at this point, we could match the above re-cluster code - sorting, and adding/removing as necessary
|
||||||
// however, it won't make a lot of visible difference compared to just pushing to the end of the list, then
|
// however, it won't make a lot of visible difference compared to just pushing to the end of the list, then
|
||||||
// adding to the visible layer if the list is below the limit
|
// adding to the visible layer if the list is below the limit
|
||||||
if (this.portalClusters[cid].length < this.CLUSTER_PORTAL_LIMIT || portal.options.guid == selectedPortal || artifact.isInterestingPortal(portal.options.guid)) {
|
if(this.portalClusters[cid].length < this.CLUSTER_PORTAL_LIMIT
|
||||||
|
|| portal.options.guid == selectedPortal
|
||||||
|
|| artifact.isInterestingPortal(portal.options.guid)
|
||||||
|
|| ornaments.isInterestingPortal(portal)) {
|
||||||
if (this.bounds.contains(portal.getLatLng())) {
|
if (this.bounds.contains(portal.getLatLng())) {
|
||||||
portalsFactionLayers[parseInt(portal.options.level)][portal.options.team].addLayer(portal);
|
portalsFactionLayers[parseInt(portal.options.level)][portal.options.team].addLayer(portal);
|
||||||
}
|
}
|
||||||
@ -471,6 +476,8 @@ window.Render.prototype.removePortalFromMapLayer = function(portal) {
|
|||||||
//remove it from the portalsLevels layer
|
//remove it from the portalsLevels layer
|
||||||
portalsFactionLayers[parseInt(portal.options.level)][portal.options.team].removeLayer(portal);
|
portalsFactionLayers[parseInt(portal.options.level)][portal.options.team].removeLayer(portal);
|
||||||
|
|
||||||
|
window.ornaments.removePortal(portal);
|
||||||
|
|
||||||
// and ensure there's no mention of the portal in the cluster list
|
// and ensure there's no mention of the portal in the cluster list
|
||||||
var cid = this.getPortalClusterID(portal);
|
var cid = this.getPortalClusterID(portal);
|
||||||
|
|
||||||
|
56
code/ornaments.js
Normal file
56
code/ornaments.js
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// ORNAMENTS ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// added as part of the ingress #helios in 2014, ornaments
|
||||||
|
// are additional image overlays for portals
|
||||||
|
// currently there are 28 known ornaments: ap$x$suffix
|
||||||
|
// - cluster portals (without suffix)
|
||||||
|
// - volatile portals (_v)
|
||||||
|
// - meeting points (_start)
|
||||||
|
// - finish points (_end)
|
||||||
|
// (there are 7 different colors for each of them)
|
||||||
|
|
||||||
|
|
||||||
|
window.ornaments = {}
|
||||||
|
window.ornaments.OVERLAY_SIZE = 60;
|
||||||
|
window.ornaments.OVERLAY_OPACITY = 0.6;
|
||||||
|
|
||||||
|
window.ornaments.setup = function() {
|
||||||
|
window.ornaments._portals = {};
|
||||||
|
window.ornaments._layer = L.layerGroup();
|
||||||
|
window.addLayerGroup('Ornaments', window.ornaments._layer, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// quick test for portal having ornaments
|
||||||
|
window.ornaments.isInterestingPortal = function(portal) {
|
||||||
|
return portal.options.data.ornaments.length != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.ornaments.addPortal = function(portal) {
|
||||||
|
var guid = portal.options.guid;
|
||||||
|
|
||||||
|
window.ornaments.removePortal(portal);
|
||||||
|
|
||||||
|
var size = window.ornaments.OVERLAY_SIZE;
|
||||||
|
var latlng = portal.getLatLng();
|
||||||
|
|
||||||
|
window.ornaments._portals[guid] = portal.options.data.ornaments.map(function(ornament) {
|
||||||
|
var icon = L.icon({
|
||||||
|
iconUrl: "//commondatastorage.googleapis.com/ingress.com/img/map_icons/marker_images/"+ornament+".png",
|
||||||
|
iconSize: [size, size],
|
||||||
|
iconAnchor: [size/2,size/2],
|
||||||
|
className: 'no-pointer-events' // the clickable: false below still blocks events going through to the svg underneath
|
||||||
|
});
|
||||||
|
|
||||||
|
return L.marker(latlng, {icon: icon, clickable: false, keyboard: false, opacity: window.ornaments.OVERLAY_OPACITY }).addTo(window.ornaments._layer);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
window.ornaments.removePortal = function(portal) {
|
||||||
|
var guid = portal.options.guid;
|
||||||
|
if(window.ornaments._portals[guid]) {
|
||||||
|
window.ornaments._portals[guid].forEach(function(marker) {
|
||||||
|
window.ornaments._layer.removeLayer(marker);
|
||||||
|
});
|
||||||
|
delete window.ornaments._portals[guid];
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user