diff --git a/CookieMonster.js b/CookieMonster.js index 4d1a1a3..aad7ba9 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -542,6 +542,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();}}; /******** @@ -1699,6 +1700,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')); @@ -2086,6 +2088,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; @@ -2524,20 +2538,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'); @@ -2680,17 +2683,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 @@ -2764,7 +2764,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)) + ')'; } } @@ -2903,7 +2903,7 @@ CM.ConfigDefault = {BotBar: 1, TimerBar: 1, TimerBarPos: 0, BuildColor: 1, BulkB CM.ConfigPrefix = 'CMConfig'; CM.VersionMajor = '2.012'; -CM.VersionMinor = '1'; +CM.VersionMinor = '2'; /******* * Sim * @@ -2956,7 +2956,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/Config.js b/src/Config.js index 528f7de..339e2a5 100644 --- a/src/Config.js +++ b/src/Config.js @@ -148,5 +148,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 8245ea5..de46b2d 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1145,6 +1145,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')); @@ -1532,6 +1533,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; @@ -1970,20 +1983,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 539bac4..8cfa663 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 @@ -113,7 +110,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)) + ')'; } } @@ -248,9 +245,10 @@ 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.ConfigPrefix = 'CMConfig'; CM.VersionMajor = '2.012'; -CM.VersionMinor = '1'; +CM.VersionMinor = '2'; 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;