diff --git a/CookieMonster.js b/CookieMonster.js index 030470a..4172ab1 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -583,6 +583,7 @@ CM.ConfigData.ToolWarnCaut = {label: ['Tooltip Warning/Caution OFF', 'Tooltip Wa CM.ConfigData.ToolWarnCautPos = {label: ['Tooltip Warning/Caution Position (Left)', 'Tooltip Warning/Caution Position (Bottom)'], desc: 'Placement of the warning/caution boxes', toggle: false, func: function() {CM.Disp.ToggleToolWarnCautPos();}}; CM.ConfigData.TooltipGrim = {label: ['Grimoire Tooltip Information OFF', 'Grimoire Tooltip Information ON'], desc: 'Extra information in tooltip for grimoire', toggle: true}; CM.ConfigData.ToolWrink = {label: ['Wrinkler Tooltip OFF', 'Wrinkler Tooltip ON'], desc: 'Shows the amount of cookies a wrinkler will give when popping it', toggle: true}; +CM.ConfigData.TooltipLump = {label: ['Sugar Lump Tooltip OFF', 'Sugar Lump Tooltip ON'], desc: 'Shows the current Sugar Lump type in Sugar lump tooltip.', toggle: true}; CM.ConfigData.Stats = {label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra Cookie Monster statistics!', toggle: true}; CM.ConfigData.UpStats = {label: ['Statistics Update Rate (Default)', 'Statistics Update Rate (1s)'], desc: 'Default Game rate is once every 5 seconds', toggle: false}; CM.ConfigData.TimeFormat = {label: ['Time XXd, XXh, XXm, XXs', 'Time XX:XX:XX:XX:XX'], desc: 'Change the time format', toggle: false}; @@ -714,6 +715,46 @@ CM.Disp.GetTimeColor = function(price, bank, cps, time) { return {text: text, color: color}; } +/** + * This function returns Name and Color as object for sugar lump type that is given as input param. + * @param type Sugar Lump Type. + * @returns {{text: string, color: string}} + * @constructor + */ +CM.Disp.GetLumpColor = function(type) { + var name = ""; + var color = ""; + + switch (type) { + case 0: + name = "Normal"; + color = CM.Disp.colorGray; + break; + case 1: + name = "Bifurcated"; + color = CM.Disp.colorGreen; + break; + case 2: + name = "Golden"; + color = CM.Disp.colorYellow; + break; + case 3: + name = "Meaty"; + color = CM.Disp.colorOrange; + break; + case 4: + name = "Caramelized"; + color = CM.Disp.colorPurple; + break; + default: + name = "Unknown Sugar Lump"; + color = CM.Disp.colorRed; + break; + } + + return {text: name, color: color}; +}; + CM.Disp.Beautify = function(num, frac) { if (CM.Config.Scale != 0 && isFinite(num)) { var answer = ''; @@ -1836,6 +1877,7 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(listing('ToolWarnCautPos')); frag.appendChild(listing('TooltipGrim')); frag.appendChild(listing('ToolWrink')); + frag.appendChild(listing('TooltipLump')); frag.appendChild(header('Statistics')); frag.appendChild(listing('Stats')); @@ -2381,6 +2423,17 @@ CM.Disp.AddTooltipGrimoire = function() { } } +/** + * This function improves Sugar Lump tooltip by adding extra infromation. + * @constructor + */ +CM.Disp.AddTooltipLump = function() { + if (Game.canLumps()) { + CM.Disp.TooltipLumpBack = l('lumps').onmouseover; + eval('l(\'lumps\').onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'s\', \'Lump\');}, \'this\'); Game.tooltip.wobble();}'); + } +}; + CM.Disp.Tooltip = function(type, name) { if (type == 'b') { l('tooltip').innerHTML = Game.Objects[name].tooltip(); @@ -2421,6 +2474,10 @@ CM.Disp.Tooltip = function(type, name) { if (!Game.UpgradesInStore[name]) return ''; l('tooltip').innerHTML = Game.crateTooltip(Game.UpgradesInStore[name], 'store'); } + else if (type === 's') { + // Sugar Lump + l('tooltip').innerHTML = Game.lumpTooltip(); + } else { // Grimoire l('tooltip').innerHTML = Game.Objects['Wizard tower'].minigame.spellTooltip(name)(); } @@ -2570,6 +2627,40 @@ CM.Disp.UpdateTooltip = function() { CM.Disp.TooltipWarnCaut.style.display = 'none'; } } + else if (CM.Disp.tooltipType === 's') { + // Adding information about Sugar Lumps. + + CM.Disp.TooltipWarnCaut.style.display = 'none'; + l('CMDispTooltipWarn').style.display = 'none'; + l('CMDispTooltipCaut').style.display = 'none'; + + if (CM.Config.TooltipLump === 1) { + l('CMTooltipArea').innerHTML = ''; + + l('tooltip').firstChild.style.paddingBottom = '4px'; + var lumpTooltip = document.createElement('div'); + lumpTooltip.style.border = '1px solid'; + lumpTooltip.style.padding = '4px'; + lumpTooltip.style.margin = '0px -4px'; + lumpTooltip.id = 'CMTooltipBorder'; + lumpTooltip.className = CM.Disp.colorTextPre + CM.Disp.colorGray; + + var lumpHeader = document.createElement('div'); + lumpHeader.style.fontWeight = 'bold'; + lumpHeader.className = CM.Disp.colorTextPre + CM.Disp.colorBlue; + lumpHeader.textContent = 'Current Sugar Lump'; + + lumpTooltip.appendChild(lumpHeader); + var lumpType = document.createElement('div'); + lumpType.id = 'CMTooltipTime'; + lumpTooltip.appendChild(lumpType); + var lumpColor = CM.Disp.GetLumpColor(Game.lumpCurrentType); + lumpType.textContent = lumpColor.text; + lumpType.className = CM.Disp.colorTextPre + lumpColor.color; + + l('CMTooltipArea').appendChild(lumpTooltip); + } + } else { // Grimoire CM.Disp.TooltipWarnCaut.style.display = 'none'; l('CMDispTooltipWarn').style.display = 'none'; @@ -3012,6 +3103,7 @@ CM.DelayInit = function() { CM.Disp.CreateTooltipWarnCaut(); CM.Disp.AddTooltipBuild(); CM.Disp.AddTooltipGrimoire(); + CM.Disp.AddTooltipLump(); CM.Disp.AddWrinklerAreaDetect(); CM.Cache.InitCookiesDiff(); CM.ReplaceNative(); diff --git a/src/Config.js b/src/Config.js index 56974a8..8c437cf 100644 --- a/src/Config.js +++ b/src/Config.js @@ -177,6 +177,7 @@ CM.ConfigData.ToolWarnCaut = {label: ['Tooltip Warning/Caution OFF', 'Tooltip Wa CM.ConfigData.ToolWarnCautPos = {label: ['Tooltip Warning/Caution Position (Left)', 'Tooltip Warning/Caution Position (Bottom)'], desc: 'Placement of the warning/caution boxes', toggle: false, func: function() {CM.Disp.ToggleToolWarnCautPos();}}; CM.ConfigData.TooltipGrim = {label: ['Grimoire Tooltip Information OFF', 'Grimoire Tooltip Information ON'], desc: 'Extra information in tooltip for grimoire', toggle: true}; CM.ConfigData.ToolWrink = {label: ['Wrinkler Tooltip OFF', 'Wrinkler Tooltip ON'], desc: 'Shows the amount of cookies a wrinkler will give when popping it', toggle: true}; +CM.ConfigData.TooltipLump = {label: ['Sugar Lump Tooltip OFF', 'Sugar Lump Tooltip ON'], desc: 'Shows the current Sugar Lump type in Sugar lump tooltip.', toggle: true}; CM.ConfigData.Stats = {label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra Cookie Monster statistics!', toggle: true}; CM.ConfigData.UpStats = {label: ['Statistics Update Rate (Default)', 'Statistics Update Rate (1s)'], desc: 'Default Game rate is once every 5 seconds', toggle: false}; CM.ConfigData.TimeFormat = {label: ['Time XXd, XXh, XXm, XXs', 'Time XX:XX:XX:XX:XX'], desc: 'Change the time format', toggle: false}; diff --git a/src/Disp.js b/src/Disp.js index 0e4642f..de8211e 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -88,6 +88,46 @@ CM.Disp.GetTimeColor = function(price, bank, cps, time) { return {text: text, color: color}; } +/** + * This function returns Name and Color as object for sugar lump type that is given as input param. + * @param type Sugar Lump Type. + * @returns {{text: string, color: string}} + * @constructor + */ +CM.Disp.GetLumpColor = function(type) { + var name = ""; + var color = ""; + + switch (type) { + case 0: + name = "Normal"; + color = CM.Disp.colorGray; + break; + case 1: + name = "Bifurcated"; + color = CM.Disp.colorGreen; + break; + case 2: + name = "Golden"; + color = CM.Disp.colorYellow; + break; + case 3: + name = "Meaty"; + color = CM.Disp.colorOrange; + break; + case 4: + name = "Caramelized"; + color = CM.Disp.colorPurple; + break; + default: + name = "Unknown Sugar Lump"; + color = CM.Disp.colorRed; + break; + } + + return {text: name, color: color}; +}; + CM.Disp.Beautify = function(num, frac) { if (CM.Config.Scale != 0 && isFinite(num)) { var answer = ''; @@ -1210,6 +1250,7 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(listing('ToolWarnCautPos')); frag.appendChild(listing('TooltipGrim')); frag.appendChild(listing('ToolWrink')); + frag.appendChild(listing('TooltipLump')); frag.appendChild(header('Statistics')); frag.appendChild(listing('Stats')); @@ -1755,6 +1796,17 @@ CM.Disp.AddTooltipGrimoire = function() { } } +/** + * This function improves Sugar Lump tooltip by adding extra infromation. + * @constructor + */ +CM.Disp.AddTooltipLump = function() { + if (Game.canLumps()) { + CM.Disp.TooltipLumpBack = l('lumps').onmouseover; + eval('l(\'lumps\').onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'s\', \'Lump\');}, \'this\'); Game.tooltip.wobble();}'); + } +}; + CM.Disp.Tooltip = function(type, name) { if (type == 'b') { l('tooltip').innerHTML = Game.Objects[name].tooltip(); @@ -1795,6 +1847,10 @@ CM.Disp.Tooltip = function(type, name) { if (!Game.UpgradesInStore[name]) return ''; l('tooltip').innerHTML = Game.crateTooltip(Game.UpgradesInStore[name], 'store'); } + else if (type === 's') { + // Sugar Lump + l('tooltip').innerHTML = Game.lumpTooltip(); + } else { // Grimoire l('tooltip').innerHTML = Game.Objects['Wizard tower'].minigame.spellTooltip(name)(); } @@ -1944,6 +2000,40 @@ CM.Disp.UpdateTooltip = function() { CM.Disp.TooltipWarnCaut.style.display = 'none'; } } + else if (CM.Disp.tooltipType === 's') { + // Adding information about Sugar Lumps. + + CM.Disp.TooltipWarnCaut.style.display = 'none'; + l('CMDispTooltipWarn').style.display = 'none'; + l('CMDispTooltipCaut').style.display = 'none'; + + if (CM.Config.TooltipLump === 1) { + l('CMTooltipArea').innerHTML = ''; + + l('tooltip').firstChild.style.paddingBottom = '4px'; + var lumpTooltip = document.createElement('div'); + lumpTooltip.style.border = '1px solid'; + lumpTooltip.style.padding = '4px'; + lumpTooltip.style.margin = '0px -4px'; + lumpTooltip.id = 'CMTooltipBorder'; + lumpTooltip.className = CM.Disp.colorTextPre + CM.Disp.colorGray; + + var lumpHeader = document.createElement('div'); + lumpHeader.style.fontWeight = 'bold'; + lumpHeader.className = CM.Disp.colorTextPre + CM.Disp.colorBlue; + lumpHeader.textContent = 'Current Sugar Lump'; + + lumpTooltip.appendChild(lumpHeader); + var lumpType = document.createElement('div'); + lumpType.id = 'CMTooltipTime'; + lumpTooltip.appendChild(lumpType); + var lumpColor = CM.Disp.GetLumpColor(Game.lumpCurrentType); + lumpType.textContent = lumpColor.text; + lumpType.className = CM.Disp.colorTextPre + lumpColor.color; + + l('CMTooltipArea').appendChild(lumpTooltip); + } + } else { // Grimoire CM.Disp.TooltipWarnCaut.style.display = 'none'; l('CMDispTooltipWarn').style.display = 'none'; diff --git a/src/Main.js b/src/Main.js index 2d3b3e8..a325077 100644 --- a/src/Main.js +++ b/src/Main.js @@ -232,6 +232,7 @@ CM.DelayInit = function() { CM.Disp.CreateTooltipWarnCaut(); CM.Disp.AddTooltipBuild(); CM.Disp.AddTooltipGrimoire(); + CM.Disp.AddTooltipLump(); CM.Disp.AddWrinklerAreaDetect(); CM.Cache.InitCookiesDiff(); CM.ReplaceNative(); @@ -251,6 +252,7 @@ CM.DelayInit = function() { CM.HasReplaceNativeGrimoireLaunch = false; CM.HasReplaceNativeGrimoireDraw = false; +CM.ConfigDefault = {BotBar: 1, TimerBar: 1, TimerBarPos: 0, BuildColor: 1, BulkBuildColor: 0, UpBarColor: 1, CalcWrink: 0, CPSMode: 1, AvgCPSHist: 3, AvgClicksHist: 0, ToolWarnCautBon: 0, Flash: 1, Sound: 1, Volume: 100, GCSoundURL: 'https://freesound.org/data/previews/66/66717_931655-lq.mp3', SeaSoundURL: 'https://www.freesound.org/data/previews/121/121099_2193266-lq.mp3', GCTimer: 1, Title: 1, Favicon: 1, TooltipBuildUp: 1, TooltipAmor: 0, ToolWarnCaut: 1, ToolWarnCautPos: 1, TooltipGrim:1, ToolWrink: 1, TooltipLump: 1, Stats: 1, UpStats: 1, TimeFormat: 0, SayTime: 1, Scale: 2, StatsPref: {Lucky: 1, Chain: 1, Prestige: 1, Wrink: 1, Sea: 1, Misc: 1}, Colors : {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3', Pink: '#ff1493', Brown: '#8b4513'}}; CM.ConfigDefault = { BotBar: 1, TimerBar: 1,