From eda7514001f26cb0a7905566033c737429d123fa Mon Sep 17 00:00:00 2001 From: DanielNoord Date: Tue, 24 Nov 2020 13:29:02 +0100 Subject: [PATCH] Option to play sound at full Grimoire Meter (#337) --- CookieMonster.js | 33 +++++++++++++++++++++++++++++++++ src/Config.js | 7 +++++++ src/Disp.js | 19 +++++++++++++++++++ src/Main.js | 7 +++++++ 4 files changed, 66 insertions(+) diff --git a/CookieMonster.js b/CookieMonster.js index 2f7bc99..d482f64 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -580,6 +580,13 @@ for (var i = 0; i < 101; i++) { CM.ConfigData.GardVolume.label[i] = i + '%'; } CM.ConfigData.GardSoundURL = {label: 'Garden Tick Sound URL:', desc: 'URL of the sound to be played when the garden ticks'}; +CM.ConfigData.MagicFlash = {label: ['Magic Max Flash OFF', 'Magic Max Flash ON'], desc: 'Flash screen when magic reaches maxium', toggle: true}; +CM.ConfigData.MagicSound = {label: ['Magic Max Sound OFF', 'Magic Max Sound ON'], desc: 'Play a sound when magic reaches maxium', toggle: true}; +CM.ConfigData.MagicVolume = {label: [], desc: 'Volume of the Max Magic sound'}; +for (var i = 0; i < 101; i++) { + CM.ConfigData.MagicVolume.label[i] = i + '%'; +} +CM.ConfigData.MagicSoundURL = {label: 'Magic Max Sound URL:', desc: 'URL of the sound to be played when magic reaches maxium'}; CM.ConfigData.Title = {label: ['Title OFF', 'Title ON', 'Title Pinned Tab Highlight'], desc: 'Update title with Golden Cookie/Season Popup timers; pinned tab highlight only changes the title when a Golden Cookie/Season Popup spawns', toggle: true}; CM.ConfigData.TooltipBuildUp = {label: ['Buildings/Upgrades Tooltip Information OFF', 'Buildings/Upgrades Tooltip Information ON'], desc: 'Extra information in tooltip for buildings/upgrades', toggle: true}; CM.ConfigData.TooltipAmor = {label: ['Buildings Tooltip Amortization Information OFF', 'Buildings Tooltip Amortization Information ON'], desc: 'Add amortization information to buildings tooltip', toggle: true}; @@ -1635,6 +1642,20 @@ CM.Disp.CheckGardenTick = function() { } } +CM.Disp.CheckMagicMeter = function() { + if (Game.Objects['Wizard tower'].minigameLoaded && CM.Config.GrimoireBar == 1) { + var minigame = Game.Objects['Wizard tower'].minigame; + if (minigame.magic < minigame.magicM) { + CM.Disp.lastMagicBarFull = false; + } + else if (!CM.Disp.lastMagicBarFull) { + CM.Disp.lastMagicBarFull = true; + CM.Disp.Flash(3, 'MagicFlash'); + CM.Disp.PlaySound(CM.Config.MagicSoundURL, 'MagicSound', 'MagicVolume'); + } + } +} + CM.Disp.UpdateTitle = function() { if (Game.OnAscend || CM.Config.Title == 0) { document.title = CM.Cache.Title; @@ -1874,6 +1895,10 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(listing('GardSound')); frag.appendChild(vol('GardVolume')); frag.appendChild(url('GardSoundURL')); + frag.appendChild(listing('MagicFlash')); + frag.appendChild(listing('MagicSound')); + frag.appendChild(vol('MagicVolume')); + frag.appendChild(url('MagicSoundURL')); frag.appendChild(listing('Title')); frag.appendChild(header('Tooltip')); @@ -2943,6 +2968,7 @@ CM.Disp.lastGoldenCookieState = 0; CM.Disp.lastTickerFortuneState = 0; CM.Disp.lastSeasonPopupState = 0; CM.Disp.lastGardenNextStep = 0; +CM.Disp.lastMagicBarFull = 0; CM.Disp.goldenShimmer; CM.Disp.seasonPopShimmer; CM.Disp.lastAscendState = -1; @@ -3166,6 +3192,9 @@ CM.Loop = function() { // Check Garden Tick CM.Disp.CheckGardenTick(); + // Check Grimoire Meter + CM.Disp.CheckMagicMeter(); + // Update Average CPS (might need to move) CM.Cache.UpdateAvgCPS() } @@ -3254,6 +3283,10 @@ CM.ConfigDefault = { GardSound: 1, GardVolume: 100, GardSoundURL: 'https://freesound.org/data/previews/103/103046_861714-lq.mp3', + MagicFlash: 1, + MagicSound: 1, + MagicVolume: 100, + MagicSoundURL: 'https://freesound.org/data/previews/221/221683_1015240-lq.mp3', Title: 1, TooltipBuildUp: 1, TooltipAmor: 0, diff --git a/src/Config.js b/src/Config.js index 6e8ad84..5aeba0b 100644 --- a/src/Config.js +++ b/src/Config.js @@ -170,6 +170,13 @@ for (var i = 0; i < 101; i++) { CM.ConfigData.GardVolume.label[i] = i + '%'; } CM.ConfigData.GardSoundURL = {label: 'Garden Tick Sound URL:', desc: 'URL of the sound to be played when the garden ticks'}; +CM.ConfigData.MagicFlash = {label: ['Magic Max Flash OFF', 'Magic Max Flash ON'], desc: 'Flash screen when magic reaches maxium', toggle: true}; +CM.ConfigData.MagicSound = {label: ['Magic Max Sound OFF', 'Magic Max Sound ON'], desc: 'Play a sound when magic reaches maxium', toggle: true}; +CM.ConfigData.MagicVolume = {label: [], desc: 'Volume of the Max Magic sound'}; +for (var i = 0; i < 101; i++) { + CM.ConfigData.MagicVolume.label[i] = i + '%'; +} +CM.ConfigData.MagicSoundURL = {label: 'Magic Max Sound URL:', desc: 'URL of the sound to be played when magic reaches maxium'}; CM.ConfigData.Title = {label: ['Title OFF', 'Title ON', 'Title Pinned Tab Highlight'], desc: 'Update title with Golden Cookie/Season Popup timers; pinned tab highlight only changes the title when a Golden Cookie/Season Popup spawns', toggle: true}; CM.ConfigData.TooltipBuildUp = {label: ['Buildings/Upgrades Tooltip Information OFF', 'Buildings/Upgrades Tooltip Information ON'], desc: 'Extra information in tooltip for buildings/upgrades', toggle: true}; CM.ConfigData.TooltipAmor = {label: ['Buildings Tooltip Amortization Information OFF', 'Buildings Tooltip Amortization Information ON'], desc: 'Add amortization information to buildings tooltip', toggle: true}; diff --git a/src/Disp.js b/src/Disp.js index 39a1213..2dbc5a9 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1003,6 +1003,20 @@ CM.Disp.CheckGardenTick = function() { } } +CM.Disp.CheckMagicMeter = function() { + if (Game.Objects['Wizard tower'].minigameLoaded && CM.Config.GrimoireBar == 1) { + var minigame = Game.Objects['Wizard tower'].minigame; + if (minigame.magic < minigame.magicM) { + CM.Disp.lastMagicBarFull = false; + } + else if (!CM.Disp.lastMagicBarFull) { + CM.Disp.lastMagicBarFull = true; + CM.Disp.Flash(3, 'MagicFlash'); + CM.Disp.PlaySound(CM.Config.MagicSoundURL, 'MagicSound', 'MagicVolume'); + } + } +} + CM.Disp.UpdateTitle = function() { if (Game.OnAscend || CM.Config.Title == 0) { document.title = CM.Cache.Title; @@ -1242,6 +1256,10 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(listing('GardSound')); frag.appendChild(vol('GardVolume')); frag.appendChild(url('GardSoundURL')); + frag.appendChild(listing('MagicFlash')); + frag.appendChild(listing('MagicSound')); + frag.appendChild(vol('MagicVolume')); + frag.appendChild(url('MagicSoundURL')); frag.appendChild(listing('Title')); frag.appendChild(header('Tooltip')); @@ -2311,6 +2329,7 @@ CM.Disp.lastGoldenCookieState = 0; CM.Disp.lastTickerFortuneState = 0; CM.Disp.lastSeasonPopupState = 0; CM.Disp.lastGardenNextStep = 0; +CM.Disp.lastMagicBarFull = 0; CM.Disp.goldenShimmer; CM.Disp.seasonPopShimmer; CM.Disp.lastAscendState = -1; diff --git a/src/Main.js b/src/Main.js index 4e1af4c..a1c4693 100644 --- a/src/Main.js +++ b/src/Main.js @@ -195,6 +195,9 @@ CM.Loop = function() { // Check Garden Tick CM.Disp.CheckGardenTick(); + // Check Grimoire Meter + CM.Disp.CheckMagicMeter(); + // Update Average CPS (might need to move) CM.Cache.UpdateAvgCPS() } @@ -283,6 +286,10 @@ CM.ConfigDefault = { GardSound: 1, GardVolume: 100, GardSoundURL: 'https://freesound.org/data/previews/103/103046_861714-lq.mp3', + MagicFlash: 1, + MagicSound: 1, + MagicVolume: 100, + MagicSoundURL: 'https://freesound.org/data/previews/221/221683_1015240-lq.mp3', Title: 1, TooltipBuildUp: 1, TooltipAmor: 0,