Allow user-customizable tooltip warnings #105

This commit is contained in:
Daniël van Noord
2021-02-21 23:37:15 +01:00
parent b854773766
commit e0c7643671
4 changed files with 18 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@@ -42,7 +42,7 @@ CM.Cache.LoopCache = function() {
CM.Cache.CacheHeavenlyChipsPS();
let cookiesToNext = Game.HowManyCookiesReset(Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) + 1) - (Game.cookiesEarned + Game.cookiesReset);
CM.Cache.TimeTillNextPrestige = CM.Disp.FormatTime(cookiesToNext / CM.Cache.AvgCPS);
CM.Cache.TimeTillNextPrestige = CM.Disp.FormatTime(cookiesToNext / CM.Disp.GetCPS());
};
@@ -671,7 +671,7 @@ CM.Cache.ColourOfPP = function(me, price) {
// Colour based on price in terms of CPS
if (Number(CM.Options.PPSecondsLowerLimit) !== 0) {
if (price / CM.Cache.AvgCPS < Number(CM.Options.PPSecondsLowerLimit)) color = CM.Disp.colorBlue
if (price / CM.Disp.GetCPS() < Number(CM.Options.PPSecondsLowerLimit)) color = CM.Disp.colorBlue
}
// Colour based on being able to purchase
if (CM.Options.PPOnlyConsiderBuyable) {

View File

@@ -220,6 +220,7 @@ CM.Data.Config.ToolWarnLuckyFrenzy = {type: 'bool', group: 'Tooltip', label: ['T
CM.Data.Config.ToolWarnConjure = {type: 'bool', group: 'Tooltip', label: ['Tooltip Conjure Warning OFF', 'Tooltip Conjure Warning ON'], desc: 'A warning when buying if it will put the bank under the amount needed for max "Conjure Baked Goods" rewards', toggle: true};
CM.Data.Config.ToolWarnConjureFrenzy = {type: 'bool', group: 'Tooltip', label: ['Tooltip Conjure Frenzy Warning OFF', 'Tooltip Conjure Frenzy Warning ON'], desc: 'A warning when buying if it will put the bank under the amount needed for max "Conjure Baked Goods" rewards with Frenzy active', toggle: true};
CM.Data.Config.ToolWarnEdifice = {type: 'bool', group: 'Tooltip', label: ['Tooltip Edifice Warning OFF', 'Tooltip Edifice Warning ON'], desc: 'A warning when buying if it will put the bank under the amount needed for "Spontaneous Edifice" to possibly give you your most expensive building', toggle: true};
CM.Data.Config.ToolWarnUser = {type: 'numscale', group: 'Tooltip', label: 'Tooltip Warning At x times CPS: ', desc: 'Use this to show a customized warning if buying it will put the bank under the amount equal to value times cps; setting to 0 disables the function altogether', min: 0, max: Infinity};
CM.Data.Config.ToolWarnPos = {type: 'bool', group: 'Tooltip', label: ['Tooltip Warning Position (Left)', 'Tooltip Warning Position (Bottom)'], desc: 'Placement of the warning boxes', toggle: false, func: function() {CM.Disp.ToggleToolWarnPos();}};
CM.Data.Config.TooltipGrim = {type: 'bool', group: 'Tooltip', label: ['Grimoire Tooltip Information OFF', 'Grimoire Tooltip Information ON'], desc: 'Extra information in tooltip for grimoire', toggle: true};
CM.Data.Config.TooltipWrink = {type: 'bool', group: 'Tooltip', label: ['Wrinkler Tooltip OFF', 'Wrinkler Tooltip ON'], desc: 'Shows the amount of cookies a wrinkler will give when popping it', toggle: true};
@@ -316,6 +317,7 @@ CM.Data.ConfigDefault = {
ToolWarnConjure: 1,
ToolWarnConjureFrenzy: 1,
ToolWarnEdifice: 1,
ToolWarnUser: 0,
ToolWarnPos: 1,
TooltipGrim:1,
TooltipWrink: 1,

View File

@@ -1397,6 +1397,8 @@ CM.Disp.TooltipCreateWarningSection = function() {
CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnConjureFrenzy', CM.Disp.colorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Conjure Baked Goods" (Frenzy)', 'CMDispTooltipWarnConjureFrenzyText'));
CM.Disp.TooltipWarn.lastChild.style.marginBottom = '4px';
CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnEdifice', CM.Disp.colorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies needed for "Spontaneous Edifice" to possibly give you your most expensive building"', 'CMDispTooltipWarnEdificeText'));
CM.Disp.TooltipWarn.lastChild.style.marginBottom = '4px';
CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnUser', CM.Disp.colorRed, 'Warning: ', `Purchase of this item will put you under the number of Cookies equal to ${CM.Options.ToolWarnUser} seconds of CPS`, 'CMDispTooltipWarnUserText'));
return CM.Disp.TooltipWarn;
};
@@ -1762,6 +1764,16 @@ CM.Disp.UpdateTooltipWarnings = function() {
} else l('CMDispTooltipWarnEdifice').style.display = 'none';
}
else l('CMDispTooltipWarnEdifice').style.display = 'none';
if (CM.Options.ToolWarnUser > 0) {
if (amount < CM.Options.ToolWarnUser * CM.Disp.GetCPS() && (CM.Disp.tooltipType != 'b' || Game.buyMode === 1)) {
l('CMDispTooltipWarnUser').style.display = '';
// Need to update tooltip text dynamically
l('CMDispTooltipWarnUser').children[0].textContent = `Purchase of this item will put you under the number of Cookies equal to ${CM.Options.ToolWarnUser} seconds of CPS`
l('CMDispTooltipWarnUserText').textContent = Beautify(CM.Options.ToolWarnUser * CM.Disp.GetCPS() - amount) + ' (' + CM.Disp.FormatTime((CM.Options.ToolWarnUser * CM.Disp.GetCPS() - amount) / (CM.Disp.GetCPS() + CM.Disp.TooltipBonusIncome)) + ')';
} else l('CMDispTooltipWarnUser').style.display = 'none';
}
else l('CMDispTooltipWarnUser').style.display = 'none';
}
else {
if (l('CMDispTooltipWarningParent') != null) {
@@ -2330,7 +2342,7 @@ CM.Disp.AddMenuStats = function(title) {
if (CM.Options.Header.Misc) {
stats.appendChild(CM.Disp.CreateStatsListing("basic",
'Average Cookies Per Second (Past ' + (CM.Disp.cookieTimes[CM.Options.AvgCPSHist] < 60 ? (CM.Disp.cookieTimes[CM.Options.AvgCPSHist] + ' seconds') : ((CM.Disp.cookieTimes[CM.Options.AvgCPSHist] / 60) + (CM.Options.AvgCPSHist === 3 ? ' minute' : ' minutes'))) + ')',
document.createTextNode(Beautify(CM.Cache.AvgCPS, 3))
document.createTextNode(Beautify(CM.Disp.GetCPS(), 3))
));
stats.appendChild(CM.Disp.CreateStatsListing("basic", 'Average Cookie Clicks Per Second (Past ' + CM.Disp.clickTimes[CM.Options.AvgClicksHist] + (CM.Options.AvgClicksHist === 0 ? ' second' : ' seconds') + ')', document.createTextNode(Beautify(CM.Cache.AverageClicks, 1))));
if (Game.Has('Fortune cookies')) {