From 68957197596f66a6bade58210a5c0ea34f343c57 Mon Sep 17 00:00:00 2001 From: Aktanusa Date: Thu, 9 Aug 2018 17:01:43 -0400 Subject: [PATCH 1/2] Version change to 2.012.2 and added option for turning off the timer in Grimoire magic meter --- CookieMonster.js | 8 +++++--- src/Config.js | 1 + src/Disp.js | 1 + src/Main.js | 6 +++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index b9692d4..76e7636 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -541,6 +541,7 @@ CM.ConfigData.Stats = {label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra 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}; CM.ConfigData.SayTime = {label: ['Format Time OFF', 'Format Time ON'], desc: 'Change how time is displayed in statistics', toggle: true, func: function() {CM.Disp.ToggleSayTime();}}; +CM.ConfigData.GrimoireBar = {label: ['Grimoire Magic Meter Timer OFF', 'Grimoire Magic Meter Timer ON'], desc: 'A timer on how long before the Grimoire magic meter is full', toggle: true}; CM.ConfigData.Scale = {label: ['Game\'s Setting Scale', 'Metric', 'Short Scale', 'Scientific Notation', 'Engineering Notation'], desc: 'Change how long numbers are handled', toggle: false, func: function() {CM.Disp.RefreshScale();}}; /******** @@ -1657,6 +1658,7 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(listing('UpStats')); frag.appendChild(listing('TimeFormat')); frag.appendChild(listing('SayTime')); + frag.appendChild(listing('GrimoireBar')); frag.appendChild(header('Other')); frag.appendChild(listing('Scale')); @@ -2673,7 +2675,7 @@ CM.ReplaceNativeGrimoireDraw = function() { CM.Backup.GrimoireDraw = minigame.draw; Game.Objects['Wizard tower'].minigame.draw = function() { CM.Backup.GrimoireDraw(); - if (minigame.magic < minigame.magicM) { + if (CM.Config.GrimoireBar == 1 && minigame.magic < minigame.magicM) { minigame.magicBarTextL.innerHTML += ' (' + CM.Disp.FormatTime(CM.Disp.CalculateGrimoireRefillTime(minigame.magic, minigame.magicM, minigame.magicM)) + ')'; } } @@ -2807,11 +2809,11 @@ 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, 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, 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, Stats: 1, UpStats: 1, TimeFormat: 0, SayTime: 1, GrimoireBar: 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.ConfigPrefix = 'CMConfig'; CM.VersionMajor = '2.012'; -CM.VersionMinor = '1'; +CM.VersionMinor = '2'; /******* * Sim * diff --git a/src/Config.js b/src/Config.js index a3f353e..f709f88 100644 --- a/src/Config.js +++ b/src/Config.js @@ -147,5 +147,6 @@ CM.ConfigData.Stats = {label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra 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}; CM.ConfigData.SayTime = {label: ['Format Time OFF', 'Format Time ON'], desc: 'Change how time is displayed in statistics', toggle: true, func: function() {CM.Disp.ToggleSayTime();}}; +CM.ConfigData.GrimoireBar = {label: ['Grimoire Magic Meter Timer OFF', 'Grimoire Magic Meter Timer ON'], desc: 'A timer on how long before the Grimoire magic meter is full', toggle: true}; CM.ConfigData.Scale = {label: ['Game\'s Setting Scale', 'Metric', 'Short Scale', 'Scientific Notation', 'Engineering Notation'], desc: 'Change how long numbers are handled', toggle: false, func: function() {CM.Disp.RefreshScale();}}; diff --git a/src/Disp.js b/src/Disp.js index c1c2edf..5ad51f4 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1104,6 +1104,7 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(listing('UpStats')); frag.appendChild(listing('TimeFormat')); frag.appendChild(listing('SayTime')); + frag.appendChild(listing('GrimoireBar')); frag.appendChild(header('Other')); frag.appendChild(listing('Scale')); diff --git a/src/Main.js b/src/Main.js index 1ea76d4..3275f47 100644 --- a/src/Main.js +++ b/src/Main.js @@ -113,7 +113,7 @@ CM.ReplaceNativeGrimoireDraw = function() { CM.Backup.GrimoireDraw = minigame.draw; Game.Objects['Wizard tower'].minigame.draw = function() { CM.Backup.GrimoireDraw(); - if (minigame.magic < minigame.magicM) { + if (CM.Config.GrimoireBar == 1 && minigame.magic < minigame.magicM) { minigame.magicBarTextL.innerHTML += ' (' + CM.Disp.FormatTime(CM.Disp.CalculateGrimoireRefillTime(minigame.magic, minigame.magicM, minigame.magicM)) + ')'; } } @@ -247,9 +247,9 @@ 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, 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, 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, Stats: 1, UpStats: 1, TimeFormat: 0, SayTime: 1, GrimoireBar: 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.ConfigPrefix = 'CMConfig'; CM.VersionMajor = '2.012'; -CM.VersionMinor = '1'; +CM.VersionMinor = '2'; From 2f862ac6878832e445ae12739d9c87d0bece6bc9 Mon Sep 17 00:00:00 2001 From: Aktanusa Date: Fri, 17 Aug 2018 15:50:31 -0400 Subject: [PATCH 2/2] Fix bug with timer bar displacing wrinkler detection area (Issue #213) and use game detection instead of copying code plus a minor code formatting change --- CookieMonster.js | 42 ++++++++++++++++++++---------------------- src/Disp.js | 25 +++++++++++++------------ src/Main.js | 15 ++++++--------- src/Sim.js | 2 +- 4 files changed, 40 insertions(+), 44 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 76e7636..feed6a6 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -2046,6 +2046,18 @@ CM.Disp.RefreshMenu = function() { if (CM.Config.UpStats && Game.onMenu == 'stats' && (Game.drawT - 1) % (Game.fps * 5) != 0 && (Game.drawT - 1) % Game.fps == 0) Game.UpdateMenu(); } +CM.Disp.FixMouseY = function(target) { + if (CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 0) { + var timerBarHeight = parseInt(CM.Disp.TimerBar.style.height); + Game.mouseY -= timerBarHeight; + target(); + Game.mouseY += timerBarHeight; + } + else { + target(); + } +} + CM.Disp.UpdateTooltipLocation = function() { if (Game.tooltip.origin == 'store') { var warnCautOffset = 0; @@ -2435,20 +2447,9 @@ CM.Disp.AddWrinklerAreaDetect = function() { CM.Disp.CheckWrinklerTooltip = function() { if (CM.Config.ToolWrink == 1 && CM.Disp.TooltipWrinklerArea == 1) { var showingTooltip = false; - var mouseInWrinkler = function (x, y, rect) { - var dx = x + Math.sin(-rect.r) * (-(rect.h / 2 - rect.o)), dy = y + Math.cos(-rect.r) * (-(rect.h / 2 - rect.o)); - var h1 = Math.sqrt(dx * dx + dy * dy); - var currA = Math.atan2(dy, dx); - var newA = currA - rect.r; - var x2 = Math.cos(newA) * h1; - var y2 = Math.sin(newA) * h1; - if (x2 > -0.5 * rect.w && x2 < 0.5 * rect.w && y2 > -0.5 * rect.h && y2 < 0.5 * rect.h) return true; - return false; - } for (var i in Game.wrinklers) { var me = Game.wrinklers[i]; - var rect = {w: 100, h: 200, r: (-me.r) * Math.PI / 180, o: 10}; - if (me.phase > 0 && Game.LeftBackground && Game.mouseX < Game.LeftBackground.canvas.width && mouseInWrinkler(Game.mouseX - me.x, Game.mouseY - me.y, rect)) { + if (me.phase > 0 && me.selected) { showingTooltip = true; if (CM.Disp.TooltipWrinklerCache[i] == 0) { var placeholder = document.createElement('div'); @@ -2591,17 +2592,14 @@ CM.ReplaceNative = function() { CM.Disp.UpdateTooltipLocation(); } + CM.Backup.UpdateWrinklers = Game.UpdateWrinklers; + Game.UpdateWrinklers = function() { + CM.Disp.FixMouseY(CM.Backup.UpdateWrinklers); + } + CM.Backup.UpdateSpecial = Game.UpdateSpecial; Game.UpdateSpecial = function() { - if (CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 0) { - var timerBarHeight = parseInt(CM.Disp.TimerBar.style.height); - Game.mouseY -= timerBarHeight; - CM.Backup.UpdateSpecial(); - Game.mouseY += timerBarHeight; - } - else { - CM.Backup.UpdateSpecial(); - } + CM.Disp.FixMouseY(CM.Backup.UpdateSpecial); } // Probably better to load per minigame @@ -2866,7 +2864,7 @@ CM.Sim.BuildingSell = function(basePrice, start, free, amount, emuAura) { price = Game.modifyBuildingPrice(null, price); price = Math.ceil(price); var giveBack = 0.25; - if (Game.hasAura('Earth Shatterer') || emuAura) giveBack=0.5; + if (Game.hasAura('Earth Shatterer') || emuAura) giveBack = 0.5; price = Math.floor(price * giveBack); if (start > 0) { moni += price; diff --git a/src/Disp.js b/src/Disp.js index 5ad51f4..ed59071 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1492,6 +1492,18 @@ CM.Disp.RefreshMenu = function() { if (CM.Config.UpStats && Game.onMenu == 'stats' && (Game.drawT - 1) % (Game.fps * 5) != 0 && (Game.drawT - 1) % Game.fps == 0) Game.UpdateMenu(); } +CM.Disp.FixMouseY = function(target) { + if (CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 0) { + var timerBarHeight = parseInt(CM.Disp.TimerBar.style.height); + Game.mouseY -= timerBarHeight; + target(); + Game.mouseY += timerBarHeight; + } + else { + target(); + } +} + CM.Disp.UpdateTooltipLocation = function() { if (Game.tooltip.origin == 'store') { var warnCautOffset = 0; @@ -1881,20 +1893,9 @@ CM.Disp.AddWrinklerAreaDetect = function() { CM.Disp.CheckWrinklerTooltip = function() { if (CM.Config.ToolWrink == 1 && CM.Disp.TooltipWrinklerArea == 1) { var showingTooltip = false; - var mouseInWrinkler = function (x, y, rect) { - var dx = x + Math.sin(-rect.r) * (-(rect.h / 2 - rect.o)), dy = y + Math.cos(-rect.r) * (-(rect.h / 2 - rect.o)); - var h1 = Math.sqrt(dx * dx + dy * dy); - var currA = Math.atan2(dy, dx); - var newA = currA - rect.r; - var x2 = Math.cos(newA) * h1; - var y2 = Math.sin(newA) * h1; - if (x2 > -0.5 * rect.w && x2 < 0.5 * rect.w && y2 > -0.5 * rect.h && y2 < 0.5 * rect.h) return true; - return false; - } for (var i in Game.wrinklers) { var me = Game.wrinklers[i]; - var rect = {w: 100, h: 200, r: (-me.r) * Math.PI / 180, o: 10}; - if (me.phase > 0 && Game.LeftBackground && Game.mouseX < Game.LeftBackground.canvas.width && mouseInWrinkler(Game.mouseX - me.x, Game.mouseY - me.y, rect)) { + if (me.phase > 0 && me.selected) { showingTooltip = true; if (CM.Disp.TooltipWrinklerCache[i] == 0) { var placeholder = document.createElement('div'); diff --git a/src/Main.js b/src/Main.js index 3275f47..39f7f82 100644 --- a/src/Main.js +++ b/src/Main.js @@ -29,17 +29,14 @@ CM.ReplaceNative = function() { CM.Disp.UpdateTooltipLocation(); } + CM.Backup.UpdateWrinklers = Game.UpdateWrinklers; + Game.UpdateWrinklers = function() { + CM.Disp.FixMouseY(CM.Backup.UpdateWrinklers); + } + CM.Backup.UpdateSpecial = Game.UpdateSpecial; Game.UpdateSpecial = function() { - if (CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 0) { - var timerBarHeight = parseInt(CM.Disp.TimerBar.style.height); - Game.mouseY -= timerBarHeight; - CM.Backup.UpdateSpecial(); - Game.mouseY += timerBarHeight; - } - else { - CM.Backup.UpdateSpecial(); - } + CM.Disp.FixMouseY(CM.Backup.UpdateSpecial); } // Probably better to load per minigame diff --git a/src/Sim.js b/src/Sim.js index 1b7cc90..302e893 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -49,7 +49,7 @@ CM.Sim.BuildingSell = function(basePrice, start, free, amount, emuAura) { price = Game.modifyBuildingPrice(null, price); price = Math.ceil(price); var giveBack = 0.25; - if (Game.hasAura('Earth Shatterer') || emuAura) giveBack=0.5; + if (Game.hasAura('Earth Shatterer') || emuAura) giveBack = 0.5; price = Math.floor(price * giveBack); if (start > 0) { moni += price;