|
|
@@ -110,7 +110,10 @@ function addPowerup(key, powerup) { |
|
|
powerupList.appendChild(powerupEntry); |
|
|
powerupList.appendChild(powerupEntry); |
|
|
|
|
|
|
|
|
activePowerups[key] = {powerup: powerup, life: powerup.duration, maxLife: powerup.duration, element: powerupEntry }; |
|
|
activePowerups[key] = {powerup: powerup, life: powerup.duration, maxLife: powerup.duration, element: powerupEntry }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
powerupEntry.addEventListener("mousemove", function (e) { powerupTooltip(key, e); }); |
|
|
|
|
|
powerupEntry.addEventListener("mouseleave", function () { powerupTooltipRemove(); }); |
|
|
|
|
|
|
|
|
updateAll(); |
|
|
updateAll(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -1157,6 +1160,36 @@ function buildingTooltipRemove() { |
|
|
tooltip.style.setProperty("display", "none"); |
|
|
tooltip.style.setProperty("display", "none"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function powerupTooltip(id, event) { |
|
|
|
|
|
|
|
|
|
|
|
let tooltip = document.querySelector("#powerup-tooltip"); |
|
|
|
|
|
tooltip.style.setProperty("display", "inline-block"); |
|
|
|
|
|
|
|
|
|
|
|
const count = buildingCount(); |
|
|
|
|
|
|
|
|
|
|
|
fillTooltip("powerup", "name", powerups[id].name); |
|
|
|
|
|
fillTooltip("powerup", "desc", powerups[id].description); |
|
|
|
|
|
|
|
|
|
|
|
let xPos = tooltip.parentElement.getBoundingClientRect().x + 450; |
|
|
|
|
|
|
|
|
|
|
|
// wow browsers are bad |
|
|
|
|
|
|
|
|
|
|
|
var body = document.body, |
|
|
|
|
|
html = document.documentElement; |
|
|
|
|
|
|
|
|
|
|
|
var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight); |
|
|
|
|
|
|
|
|
|
|
|
let yPos = Math.min(event.clientY, height - 200); |
|
|
|
|
|
|
|
|
|
|
|
tooltip.style.setProperty("transform", "translate(" + xPos + "px, " + yPos + "px)") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function powerupTooltipRemove() { |
|
|
|
|
|
let tooltip = document.querySelector("#powerup-tooltip"); |
|
|
|
|
|
|
|
|
|
|
|
tooltip.style.setProperty("display", "none"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
window.onload = function () { |
|
|
window.onload = function () { |
|
|
setup(); |
|
|
setup(); |
|
|
|
|
|
|
|
|
|