Merge pull request #572 from DanielNoord/hotfix/missingupgrades
Fix crash with no upgrades #528
This commit is contained in:
@@ -3886,52 +3886,55 @@ CM.Disp.CreateStatsPrestigeSection = function() {
|
|||||||
* It is called by CM.Disp.AddMenuStats() when CM.Options.MissingUpgrades is set
|
* It is called by CM.Disp.AddMenuStats() when CM.Options.MissingUpgrades is set
|
||||||
*/
|
*/
|
||||||
CM.Disp.AddMissingUpgrades = function() {
|
CM.Disp.AddMissingUpgrades = function() {
|
||||||
if (CM.Cache.MissingUpgradesPrestige) {
|
for (let menuSection of (l('menu').children)) {
|
||||||
var prestigeUpgradesOwned = Game.PrestigeUpgrades.length - l('menu').children[5].children[3].children.length;
|
if (menuSection.children[0]) {
|
||||||
var title = document.createElement('div');
|
if (menuSection.children[0].innerHTML === "Prestige" && CM.Cache.MissingUpgradesPrestige) {
|
||||||
|
let prestigeUpgradesMissing = CM.Cache.MissingUpgradesPrestige.match(new RegExp("div", "g") || []).length / 2;
|
||||||
|
let title = document.createElement('div');
|
||||||
title.id = "CMMissingUpgradesPrestigeTitle";
|
title.id = "CMMissingUpgradesPrestigeTitle";
|
||||||
title.className = "listing";
|
title.className = "listing";
|
||||||
titlefrag = document.createElement('div');
|
let titlefrag = document.createElement('div');
|
||||||
titlefrag.innerHTML = '<b>Missing Prestige upgrades:</b> '+ prestigeUpgradesOwned + '/' + Game.PrestigeUpgrades.length + ' (' + Math.floor((prestigeUpgradesOwned / Game.PrestigeUpgrades.length) * 100) + '%)';
|
titlefrag.innerHTML = '<b>Missing Prestige upgrades:</b> '+ prestigeUpgradesMissing + '/' + Game.PrestigeUpgrades.length + ' (' + Math.floor((prestigeUpgradesMissing / Game.PrestigeUpgrades.length) * 100) + '%)';
|
||||||
title.appendChild(titlefrag)
|
title.appendChild(titlefrag);
|
||||||
l('menu').children[5].appendChild(title)
|
menuSection.appendChild(title);
|
||||||
upgrades = document.createElement('div');
|
let upgrades = document.createElement('div');
|
||||||
upgrades.className = "listing crateBox";
|
upgrades.className = "listing crateBox";
|
||||||
upgrades.innerHTML = CM.Cache.MissingUpgradesPrestige;
|
upgrades.innerHTML = CM.Cache.MissingUpgradesPrestige;
|
||||||
l('menu').children[5].appendChild(upgrades)
|
menuSection.appendChild(upgrades);
|
||||||
}
|
}
|
||||||
|
else if (menuSection.children[0].innerHTML === "Upgrades") {
|
||||||
if (CM.Cache.MissingUpgrades) {
|
if (CM.Cache.MissingUpgrades) {
|
||||||
if (Game.UpgradesOwned) {
|
let normalUpgradesMissing = CM.Cache.MissingUpgrades.match(new RegExp("div", "g") || []).length / 2;
|
||||||
var normalUpgradesOwned = Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length - l('menu').children[6].childNodes[2].children.length;
|
let title = document.createElement('div');
|
||||||
} else var normalUpgradesOwned = 0;
|
|
||||||
var title = document.createElement('div');
|
|
||||||
title.id = "CMMissingUpgradesTitle";
|
title.id = "CMMissingUpgradesTitle";
|
||||||
title.className = "listing";
|
title.className = "listing";
|
||||||
titlefrag = document.createElement('div');
|
let titlefrag = document.createElement('div');
|
||||||
titlefrag.innerHTML = '<b>Missing normal upgrades:</b> '+ normalUpgradesOwned + '/' + (Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length) + ' (' + Math.floor((normalUpgradesOwned / ( Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length)) * 100) + '%)';
|
titlefrag.innerHTML = '<b>Missing normal upgrades:</b> '+ normalUpgradesMissing + '/' + (Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length) + ' (' + Math.floor((normalUpgradesMissing / ( Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length)) * 100) + '%)';
|
||||||
title.appendChild(titlefrag)
|
title.appendChild(titlefrag);
|
||||||
l('menu').children[6].insertBefore(title, l('menu').children[6].childNodes[3])
|
menuSection.insertBefore(title, l('menu').children[6].childNodes[3]);
|
||||||
upgrades = document.createElement('div');
|
let upgrades = document.createElement('div');
|
||||||
upgrades.className = "listing crateBox";
|
upgrades.className = "listing crateBox";
|
||||||
upgrades.innerHTML = CM.Cache.MissingUpgrades;
|
upgrades.innerHTML = CM.Cache.MissingUpgrades;
|
||||||
l('menu').children[6].insertBefore(upgrades, document.getElementById("CMMissingUpgradesTitle").nextSibling)
|
menuSection.insertBefore(upgrades, document.getElementById("CMMissingUpgradesTitle").nextSibling);
|
||||||
}
|
}
|
||||||
if (CM.Cache.MissingUpgradesCookies) {
|
if (CM.Cache.MissingUpgradesCookies) {
|
||||||
var cookieUpgradesOwned = Game.UpgradesByPool["cookie"].length - l('menu').children[6].lastChild.children.length;
|
let cookieUpgradesMissing = CM.Cache.MissingUpgradesCookies.match(new RegExp("div", "g") || []).length / 2;
|
||||||
var title = document.createElement('div');
|
let title = document.createElement('div');
|
||||||
title.id = "CMMissingUpgradesCookiesTitle";
|
title.id = "CMMissingUpgradesCookiesTitle";
|
||||||
title.className = "listing";
|
title.className = "listing";
|
||||||
titlefrag = document.createElement('div');
|
let titlefrag = document.createElement('div');
|
||||||
titlefrag.innerHTML = '<b>Missing Cookie upgrades:</b> '+ cookieUpgradesOwned + '/' + Game.UpgradesByPool["cookie"].length + ' (' + Math.floor((cookieUpgradesOwned / Game.UpgradesByPool["cookie"].length) * 100) + '%)';
|
titlefrag.innerHTML = '<b>Missing Cookie upgrades:</b> '+ cookieUpgradesMissing + '/' + Game.UpgradesByPool.cookie.length + ' (' + Math.floor((cookieUpgradesMissing / Game.UpgradesByPool.cookie.length) * 100) + '%)';
|
||||||
title.appendChild(titlefrag)
|
title.appendChild(titlefrag);
|
||||||
l('menu').children[6].appendChild(title)
|
menuSection.appendChild(title);
|
||||||
upgrades = document.createElement('div');
|
let upgrades = document.createElement('div');
|
||||||
upgrades.className = "listing crateBox";
|
upgrades.className = "listing crateBox";
|
||||||
upgrades.innerHTML = CM.Cache.MissingUpgradesCookies;
|
upgrades.innerHTML = CM.Cache.MissingUpgradesCookies;
|
||||||
l('menu').children[6].appendChild(upgrades)
|
menuSection.appendChild(upgrades);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function returns the "crates" (icons) for missing upgrades in the stats sections
|
* This function returns the "crates" (icons) for missing upgrades in the stats sections
|
||||||
|
|||||||
61
src/Disp.js
61
src/Disp.js
@@ -2702,52 +2702,55 @@ CM.Disp.CreateStatsPrestigeSection = function() {
|
|||||||
* It is called by CM.Disp.AddMenuStats() when CM.Options.MissingUpgrades is set
|
* It is called by CM.Disp.AddMenuStats() when CM.Options.MissingUpgrades is set
|
||||||
*/
|
*/
|
||||||
CM.Disp.AddMissingUpgrades = function() {
|
CM.Disp.AddMissingUpgrades = function() {
|
||||||
if (CM.Cache.MissingUpgradesPrestige) {
|
for (let menuSection of (l('menu').children)) {
|
||||||
var prestigeUpgradesOwned = Game.PrestigeUpgrades.length - l('menu').children[5].children[3].children.length;
|
if (menuSection.children[0]) {
|
||||||
var title = document.createElement('div');
|
if (menuSection.children[0].innerHTML === "Prestige" && CM.Cache.MissingUpgradesPrestige) {
|
||||||
|
let prestigeUpgradesMissing = CM.Cache.MissingUpgradesPrestige.match(new RegExp("div", "g") || []).length / 2;
|
||||||
|
let title = document.createElement('div');
|
||||||
title.id = "CMMissingUpgradesPrestigeTitle";
|
title.id = "CMMissingUpgradesPrestigeTitle";
|
||||||
title.className = "listing";
|
title.className = "listing";
|
||||||
titlefrag = document.createElement('div');
|
let titlefrag = document.createElement('div');
|
||||||
titlefrag.innerHTML = '<b>Missing Prestige upgrades:</b> '+ prestigeUpgradesOwned + '/' + Game.PrestigeUpgrades.length + ' (' + Math.floor((prestigeUpgradesOwned / Game.PrestigeUpgrades.length) * 100) + '%)';
|
titlefrag.innerHTML = '<b>Missing Prestige upgrades:</b> '+ prestigeUpgradesMissing + '/' + Game.PrestigeUpgrades.length + ' (' + Math.floor((prestigeUpgradesMissing / Game.PrestigeUpgrades.length) * 100) + '%)';
|
||||||
title.appendChild(titlefrag)
|
title.appendChild(titlefrag);
|
||||||
l('menu').children[5].appendChild(title)
|
menuSection.appendChild(title);
|
||||||
upgrades = document.createElement('div');
|
let upgrades = document.createElement('div');
|
||||||
upgrades.className = "listing crateBox";
|
upgrades.className = "listing crateBox";
|
||||||
upgrades.innerHTML = CM.Cache.MissingUpgradesPrestige;
|
upgrades.innerHTML = CM.Cache.MissingUpgradesPrestige;
|
||||||
l('menu').children[5].appendChild(upgrades)
|
menuSection.appendChild(upgrades);
|
||||||
}
|
}
|
||||||
|
else if (menuSection.children[0].innerHTML === "Upgrades") {
|
||||||
if (CM.Cache.MissingUpgrades) {
|
if (CM.Cache.MissingUpgrades) {
|
||||||
if (Game.UpgradesOwned) {
|
let normalUpgradesMissing = CM.Cache.MissingUpgrades.match(new RegExp("div", "g") || []).length / 2;
|
||||||
var normalUpgradesOwned = Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length - l('menu').children[6].childNodes[2].children.length;
|
let title = document.createElement('div');
|
||||||
} else var normalUpgradesOwned = 0;
|
|
||||||
var title = document.createElement('div');
|
|
||||||
title.id = "CMMissingUpgradesTitle";
|
title.id = "CMMissingUpgradesTitle";
|
||||||
title.className = "listing";
|
title.className = "listing";
|
||||||
titlefrag = document.createElement('div');
|
let titlefrag = document.createElement('div');
|
||||||
titlefrag.innerHTML = '<b>Missing normal upgrades:</b> '+ normalUpgradesOwned + '/' + (Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length) + ' (' + Math.floor((normalUpgradesOwned / ( Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length)) * 100) + '%)';
|
titlefrag.innerHTML = '<b>Missing normal upgrades:</b> '+ normalUpgradesMissing + '/' + (Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length) + ' (' + Math.floor((normalUpgradesMissing / ( Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length)) * 100) + '%)';
|
||||||
title.appendChild(titlefrag)
|
title.appendChild(titlefrag);
|
||||||
l('menu').children[6].insertBefore(title, l('menu').children[6].childNodes[3])
|
menuSection.insertBefore(title, l('menu').children[6].childNodes[3]);
|
||||||
upgrades = document.createElement('div');
|
let upgrades = document.createElement('div');
|
||||||
upgrades.className = "listing crateBox";
|
upgrades.className = "listing crateBox";
|
||||||
upgrades.innerHTML = CM.Cache.MissingUpgrades;
|
upgrades.innerHTML = CM.Cache.MissingUpgrades;
|
||||||
l('menu').children[6].insertBefore(upgrades, document.getElementById("CMMissingUpgradesTitle").nextSibling)
|
menuSection.insertBefore(upgrades, document.getElementById("CMMissingUpgradesTitle").nextSibling);
|
||||||
}
|
}
|
||||||
if (CM.Cache.MissingUpgradesCookies) {
|
if (CM.Cache.MissingUpgradesCookies) {
|
||||||
var cookieUpgradesOwned = Game.UpgradesByPool["cookie"].length - l('menu').children[6].lastChild.children.length;
|
let cookieUpgradesMissing = CM.Cache.MissingUpgradesCookies.match(new RegExp("div", "g") || []).length / 2;
|
||||||
var title = document.createElement('div');
|
let title = document.createElement('div');
|
||||||
title.id = "CMMissingUpgradesCookiesTitle";
|
title.id = "CMMissingUpgradesCookiesTitle";
|
||||||
title.className = "listing";
|
title.className = "listing";
|
||||||
titlefrag = document.createElement('div');
|
let titlefrag = document.createElement('div');
|
||||||
titlefrag.innerHTML = '<b>Missing Cookie upgrades:</b> '+ cookieUpgradesOwned + '/' + Game.UpgradesByPool["cookie"].length + ' (' + Math.floor((cookieUpgradesOwned / Game.UpgradesByPool["cookie"].length) * 100) + '%)';
|
titlefrag.innerHTML = '<b>Missing Cookie upgrades:</b> '+ cookieUpgradesMissing + '/' + Game.UpgradesByPool.cookie.length + ' (' + Math.floor((cookieUpgradesMissing / Game.UpgradesByPool.cookie.length) * 100) + '%)';
|
||||||
title.appendChild(titlefrag)
|
title.appendChild(titlefrag);
|
||||||
l('menu').children[6].appendChild(title)
|
menuSection.appendChild(title);
|
||||||
upgrades = document.createElement('div');
|
let upgrades = document.createElement('div');
|
||||||
upgrades.className = "listing crateBox";
|
upgrades.className = "listing crateBox";
|
||||||
upgrades.innerHTML = CM.Cache.MissingUpgradesCookies;
|
upgrades.innerHTML = CM.Cache.MissingUpgradesCookies;
|
||||||
l('menu').children[6].appendChild(upgrades)
|
menuSection.appendChild(upgrades);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function returns the "crates" (icons) for missing upgrades in the stats sections
|
* This function returns the "crates" (icons) for missing upgrades in the stats sections
|
||||||
|
|||||||
Reference in New Issue
Block a user