Merge pull request #480 from DanielNoord/tooltip

Hotfix for dragon levelup Tooltip
This commit is contained in:
DanielNoord
2020-12-28 12:53:04 +01:00
committed by GitHub
3 changed files with 10 additions and 8 deletions

View File

@@ -348,7 +348,7 @@ CM.Cache.CacheDragonCost = function() {
cost += price; cost += price;
CM.Sim.Objects[target].amount--; CM.Sim.Objects[target].amount--;
} }
CM.Cache.CostDragonUpgrade = CM.Disp.Beautify(cost); CM.Cache.CostDragonUpgrade = "Cost to rebuy: " + CM.Disp.Beautify(cost);
} }
} }
else { else {
@@ -358,6 +358,7 @@ CM.Cache.CacheDragonCost = function() {
target = j; target = j;
if (Game.Objects[target].amount < amount) { if (Game.Objects[target].amount < amount) {
CM.Cache.CostDragonUpgrade = "Not enough buildings to sell"; CM.Cache.CostDragonUpgrade = "Not enough buildings to sell";
break
} }
else { else {
for (var i = 0; i < amount; i++) { for (var i = 0; i < amount; i++) {
@@ -368,8 +369,8 @@ CM.Cache.CacheDragonCost = function() {
CM.Sim.Objects[target].amount--; CM.Sim.Objects[target].amount--;
} }
} }
CM.Cache.CostDragonUpgrade = "Cost to rebuy: " + CM.Disp.Beautify(cost);
} }
CM.Cache.CostDragonUpgrade = CM.Disp.Beautify(cost);
} }
} }
CM.Cache.lastDragonLevel = Game.dragonLevel; CM.Cache.lastDragonLevel = Game.dragonLevel;
@@ -3023,7 +3024,7 @@ CM.Disp.AddDragonLevelUpTooltip = function() {
if ((l('specialPopup').className.match(/onScreen/) && l('specialPopup').children[0].style.background.match(/dragon/)) != null) { if ((l('specialPopup').className.match(/onScreen/) && l('specialPopup').children[0].style.background.match(/dragon/)) != null) {
for (let i = 0; i < l('specialPopup').childNodes.length; i++) { for (let i = 0; i < l('specialPopup').childNodes.length; i++) {
if (l('specialPopup').childNodes[i].className == "optionBox") { if (l('specialPopup').childNodes[i].className == "optionBox") {
l('specialPopup').children[i].onmouseover = function() {CM.Cache.CacheDragonCost(); Game.tooltip.dynamic = 1; Game.tooltip.draw(this, CM.Cache.CostDragonUpgrade, 'this'); Game.tooltip.wobble();} l('specialPopup').children[i].onmouseover = function() {CM.Cache.CacheDragonCost(); Game.tooltip.dynamic = 1; Game.tooltip.draw(l('specialPopup'), `<div style="min-width:200px;text-align:center;">${CM.Cache.CostDragonUpgrade}</div>`, 'this'); Game.tooltip.wobble();}
l('specialPopup').children[i].onmouseout = function() {Game.tooltip.shouldHide = 1;} l('specialPopup').children[i].onmouseout = function() {Game.tooltip.shouldHide = 1;}
} }
} }

View File

@@ -317,7 +317,7 @@ CM.Cache.CacheDragonCost = function() {
cost += price; cost += price;
CM.Sim.Objects[target].amount--; CM.Sim.Objects[target].amount--;
} }
CM.Cache.CostDragonUpgrade = CM.Disp.Beautify(cost); CM.Cache.CostDragonUpgrade = "Cost to rebuy: " + CM.Disp.Beautify(cost);
} }
} }
else { else {
@@ -327,6 +327,7 @@ CM.Cache.CacheDragonCost = function() {
target = j; target = j;
if (Game.Objects[target].amount < amount) { if (Game.Objects[target].amount < amount) {
CM.Cache.CostDragonUpgrade = "Not enough buildings to sell"; CM.Cache.CostDragonUpgrade = "Not enough buildings to sell";
break
} }
else { else {
for (var i = 0; i < amount; i++) { for (var i = 0; i < amount; i++) {
@@ -337,8 +338,8 @@ CM.Cache.CacheDragonCost = function() {
CM.Sim.Objects[target].amount--; CM.Sim.Objects[target].amount--;
} }
} }
CM.Cache.CostDragonUpgrade = "Cost to rebuy: " + CM.Disp.Beautify(cost);
} }
CM.Cache.CostDragonUpgrade = CM.Disp.Beautify(cost);
} }
} }
CM.Cache.lastDragonLevel = Game.dragonLevel; CM.Cache.lastDragonLevel = Game.dragonLevel;

View File

@@ -1847,7 +1847,7 @@ CM.Disp.AddDragonLevelUpTooltip = function() {
if ((l('specialPopup').className.match(/onScreen/) && l('specialPopup').children[0].style.background.match(/dragon/)) != null) { if ((l('specialPopup').className.match(/onScreen/) && l('specialPopup').children[0].style.background.match(/dragon/)) != null) {
for (let i = 0; i < l('specialPopup').childNodes.length; i++) { for (let i = 0; i < l('specialPopup').childNodes.length; i++) {
if (l('specialPopup').childNodes[i].className == "optionBox") { if (l('specialPopup').childNodes[i].className == "optionBox") {
l('specialPopup').children[i].onmouseover = function() {CM.Cache.CacheDragonCost(); Game.tooltip.dynamic = 1; Game.tooltip.draw(this, CM.Cache.CostDragonUpgrade, 'this'); Game.tooltip.wobble();} l('specialPopup').children[i].onmouseover = function() {CM.Cache.CacheDragonCost(); Game.tooltip.dynamic = 1; Game.tooltip.draw(l('specialPopup'), `<div style="min-width:200px;text-align:center;">${CM.Cache.CostDragonUpgrade}</div>`, 'this'); Game.tooltip.wobble();}
l('specialPopup').children[i].onmouseout = function() {Game.tooltip.shouldHide = 1;} l('specialPopup').children[i].onmouseout = function() {Game.tooltip.shouldHide = 1;}
} }
} }