From 367702dc0028c3b726714cf1552ff6f25ad1ec2c Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Fri, 18 Dec 2020 17:26:59 +0100 Subject: [PATCH] Changed CM.Config into CM.Options --- CookieMonster.js | 329 ++++++++++++++++++++++++----------------------- src/Cache.js | 10 +- src/Config.js | 62 ++++----- src/Disp.js | 227 ++++++++++++++++---------------- src/Header.js | 2 + src/Main.js | 28 ++-- 6 files changed, 332 insertions(+), 326 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index cbcb41d..7239d5f 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -18,6 +18,8 @@ RunCookieMonsterHeader = function() { CM.Main = {}; + CM.Options = {}; + CM.Sim = {}; } @@ -113,7 +115,7 @@ CM.Cache.RemakeBuildingsPP = function() { CM.Cache.max = -1; CM.Cache.mid = -1; // Calculate PP and colors when compared to purchase of single optimal building - if (CM.Config.ColorPPBulkMode == 0) { + if (CM.Options.ColorPPBulkMode == 0) { for (var i in CM.Cache.Objects) { //CM.Cache.Objects[i].pp = Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus; if (Game.cookiesPs) { @@ -446,7 +448,7 @@ CM.Cache.UpdateAvgCPS = function() { var sortedGainWrink = new Array(); var sortedGainChoEgg = new Array(); - var cpsLength = Math.min(CM.Cache.CookiesDiff.getLength(), CM.Disp.cookieTimes[CM.Config.AvgCPSHist]); + var cpsLength = Math.min(CM.Cache.CookiesDiff.getLength(), CM.Disp.cookieTimes[CM.Options.AvgCPSHist]); // Assumes the queues are the same length for (var i = CM.Cache.CookiesDiff.getLength() - cpsLength; i < CM.Cache.CookiesDiff.getLength(); i++) { @@ -480,11 +482,11 @@ CM.Cache.UpdateAvgCPS = function() { totalGainWrink += sortedGainWrink[i]; totalGainChoEgg += sortedGainChoEgg[i]; } - CM.Cache.AvgCPS = (totalGainBank + (CM.Config.CalcWrink ? totalGainWrink : 0)) / sortedGainBank.length; + CM.Cache.AvgCPS = (totalGainBank + (CM.Options.CalcWrink ? totalGainWrink : 0)) / sortedGainBank.length; var choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')); - if (choEgg || CM.Config.CalcWrink == 0) { + if (choEgg || CM.Options.CalcWrink == 0) { CM.Cache.AvgCPSChoEgg = (totalGainBank + totalGainWrink + (choEgg ? totalGainChoEgg : 0)) / sortedGainBank.length; } else { @@ -492,7 +494,7 @@ CM.Cache.UpdateAvgCPS = function() { } var totalClicks = 0; - var clicksLength = Math.min(CM.Cache.ClicksDiff.getLength(), CM.Disp.clickTimes[CM.Config.AvgClicksHist]); + var clicksLength = Math.min(CM.Cache.ClicksDiff.getLength(), CM.Disp.clickTimes[CM.Options.AvgClicksHist]); for (var i = CM.Cache.ClicksDiff.getLength() - clicksLength; i < CM.Cache.ClicksDiff.getLength(); i++) { totalClicks += CM.Cache.ClicksDiff.get(i); } @@ -588,59 +590,59 @@ CM.Cache.dragonAura2 = 0; * This function saves the config of CookieMonster to localStorage * It is called by CM.LoadConfig(), CM.RestoreDefault(), * any of the CM.ToggleConfig() functions and upon changes to URL or volume settings - * @param {object} config The Config to be saved (normally CM.Config) + * @param {object} config The Config to be saved (normally CM.Options) */ CM.SaveConfig = function(config) { localStorage.setItem(CM.ConfigPrefix, JSON.stringify(config)); } /** - * This function loads the config of CookieMonster saved in localStorage and loads it into CM.Config + * This function loads the config of CookieMonster saved in localStorage and loads it into CM.Options * It is called by CM.DelayInit() and CM.RestoreDefault() */ CM.LoadConfig = function() { if (localStorage.getItem(CM.ConfigPrefix) != null) { - CM.Config = JSON.parse(localStorage.getItem(CM.ConfigPrefix)); + CM.Options = JSON.parse(localStorage.getItem(CM.ConfigPrefix)); // Check values var mod = false; for (var i in CM.Data.ConfigDefault) { - if (typeof CM.Config[i] === 'undefined') { + if (typeof CM.Options[i] === 'undefined') { mod = true; - CM.Config[i] = CM.Data.ConfigDefault[i]; + CM.Options[i] = CM.Data.ConfigDefault[i]; } else if (i != 'StatsPref' && i != 'Colors') { if (i.indexOf('SoundURL') == -1) { - if (!(CM.Config[i] > -1 && CM.Config[i] < CM.ConfigData[i].label.length)) { + if (!(CM.Options[i] > -1 && CM.Options[i] < CM.ConfigData[i].label.length)) { mod = true; - CM.Config[i] = CM.Data.ConfigDefault[i]; + CM.Options[i] = CM.Data.ConfigDefault[i]; } } else { // Sound URLs - if (typeof CM.Config[i] != 'string') { + if (typeof CM.Options[i] != 'string') { mod = true; - CM.Config[i] = CM.Data.ConfigDefault[i]; + CM.Options[i] = CM.Data.ConfigDefault[i]; } } } else if (i == 'StatsPref') { for (var j in CM.Data.ConfigDefault.StatsPref) { - if (typeof CM.Config[i][j] === 'undefined' || !(CM.Config[i][j] > -1 && CM.Config[i][j] < 2)) { + if (typeof CM.Options[i][j] === 'undefined' || !(CM.Options[i][j] > -1 && CM.Options[i][j] < 2)) { mod = true; - CM.Config[i][j] = CM.Data.ConfigDefault[i][j]; + CM.Options[i][j] = CM.Data.ConfigDefault[i][j]; } } } else { // Colors for (var j in CM.Data.ConfigDefault.Colors) { - if (typeof CM.Config[i][j] === 'undefined' || typeof CM.Config[i][j] != 'string') { + if (typeof CM.Options[i][j] === 'undefined' || typeof CM.Options[i][j] != 'string') { mod = true; - CM.Config[i][j] = CM.Data.ConfigDefault[i][j]; + CM.Options[i][j] = CM.Data.ConfigDefault[i][j]; } } } } - if (mod) CM.SaveConfig(CM.Config); + if (mod) CM.SaveConfig(CM.Options); CM.Loop(); // Do loop once for (var i in CM.Data.ConfigDefault) { if (i != 'StatsPref' && i != 'OptionsPref' && typeof CM.ConfigData[i].func !== 'undefined') { @@ -658,7 +660,7 @@ CM.LoadConfig = function() { * It is called by resDefBut.onclick loaded in the options page or by CM.LoadConfig is no localStorage is found */ CM.RestoreDefault = function() { - CM.Config = {}; + CM.Options = {}; CM.SaveConfig(CM.Data.ConfigDefault); CM.LoadConfig(); Game.UpdateMenu(); @@ -676,7 +678,7 @@ CM.RestoreDefault = function() { CM.ToggleConfig = function(config) { CM.ToggleConfigUp(config); if (CM.ConfigData[config].toggle) { - if (CM.Config[config] == 0) { + if (CM.Options[config] == 0) { l(CM.ConfigPrefix + config).className = 'option off'; } else { @@ -686,15 +688,15 @@ CM.ToggleConfig = function(config) { } CM.ToggleConfigUp = function(config) { - CM.Config[config]++; - if (CM.Config[config] == CM.ConfigData[config].label.length) { - CM.Config[config] = 0; + CM.Options[config]++; + if (CM.Options[config] == CM.ConfigData[config].label.length) { + CM.Options[config] = 0; } if (typeof CM.ConfigData[config].func !== 'undefined') { CM.ConfigData[config].func(); } - l(CM.ConfigPrefix + config).innerHTML = CM.ConfigData[config].label[CM.Config[config]]; - CM.SaveConfig(CM.Config); + l(CM.ConfigPrefix + config).innerHTML = CM.ConfigData[config].label[CM.Options[config]]; + CM.SaveConfig(CM.Options); } /** @@ -705,29 +707,29 @@ CM.ToggleConfigUp = function(config) { CM.ToggleConfigVolume = function(config) { if (l("slider" + config) != null) { l("slider" + config + "right").innerHTML = l("slider" + config).value + "%"; - CM.Config[config] = Math.round(l("slider" + config).value); + CM.Options[config] = Math.round(l("slider" + config).value); } - CM.SaveConfig(CM.Config); + CM.SaveConfig(CM.Options); } CM.ToggleStatsConfig = function(config) { - if (CM.Config.StatsPref[config] == 0) { - CM.Config.StatsPref[config]++; + if (CM.Options.StatsPref[config] == 0) { + CM.Options.StatsPref[config]++; } else { - CM.Config.StatsPref[config]--; + CM.Options.StatsPref[config]--; } - CM.SaveConfig(CM.Config); + CM.SaveConfig(CM.Options); } CM.ToggleOptionsConfig = function(config) { - if (CM.Config.OptionsPref[config] == 0) { - CM.Config.OptionsPref[config]++; + if (CM.Options.OptionsPref[config] == 0) { + CM.Options.OptionsPref[config]++; } else { - CM.Config.OptionsPref[config]--; + CM.Options.OptionsPref[config]--; } - CM.SaveConfig(CM.Config); + CM.SaveConfig(CM.Options); } // Checks if the browsers has permissions to produce notifications @@ -1030,11 +1032,11 @@ CM.Data.ConfigDefault = { /** * This function returns the total amount stored in the Wrinkler Bank - * as calculated by CM.Cache.RemakeWrinkBank() if CM.Config.CalcWrink is set + * as calculated by CM.Cache.RemakeWrinkBank() if CM.Options.CalcWrink is set * @returns {number} 0 or the amount of cookies stored (CM.Cache.WrinkBankTotal) */ CM.Disp.GetWrinkConfigBank = function() { - if (CM.Config.CalcWrink) + if (CM.Options.CalcWrink) return CM.Cache.WrinkBankTotal; else return 0; @@ -1053,11 +1055,11 @@ CM.Disp.PopAllNormalWrinklers = function() { } /** - * This function returns the cps as either current or average CPS depending on CM.Config.CPSMode + * This function returns the cps as either current or average CPS depending on CM.Options.CPSMode * @returns {number} The average or current cps */ CM.Disp.GetCPS = function() { - if (CM.Config.CPSMode) + if (CM.Options.CPSMode) return CM.Cache.AvgCPS; else return (Game.cookiesPs * (1 - Game.cpsSucked)); @@ -1139,7 +1141,7 @@ CM.Disp.FormatTime = function(time, longFormat) { var m = Math.floor(time % 3600 / 60); var s = Math.floor(time % 60); var str = ''; - if (CM.Config.TimeFormat) { + if (CM.Options.TimeFormat) { if (time > 3155760000) return 'XX:XX:XX:XX:XX'; str += (y < 10 ? '0' : '') + y + ':'; str += (d < 10 ? '0' : '') + d + ':'; @@ -1165,7 +1167,7 @@ CM.Disp.GetTimeColor = function(time) { var color; var text; if (time < 0) { - if (CM.Config.TimeFormat) text = '00:00:00:00:00'; + if (CM.Options.TimeFormat) text = '00:00:00:00:00'; else text = 'Done!'; color = CM.Disp.colorGreen; } @@ -1186,8 +1188,8 @@ CM.Disp.GetTimeColor = function(time) { * @returns {string} Formatted number */ CM.Disp.Beautify = function(num, frac, forced) { - var decimals = CM.Config.ScaleDecimals + 1; - if (CM.Config.Scale == 0) { + var decimals = CM.Options.ScaleDecimals + 1; + if (CM.Options.Scale == 0) { return CM.Backup.Beautify(num, frac); } else if (isFinite(num)) { @@ -1205,8 +1207,8 @@ CM.Disp.Beautify = function(num, frac, forced) { // TODO: Add changing separators of thousands and making this cut-off user configurable answer = Math.round(num * 100) / 100; } - else if (CM.Config.Scale == 3 && !forced || forced == 3) { // Scientific notation, 123456789 => 1.235E+8 - answer = num[0] + (CM.Config.ScaleSeparator ? ',' : '.'); + else if (CM.Options.Scale == 3 && !forced || forced == 3) { // Scientific notation, 123456789 => 1.235E+8 + answer = num[0] + (CM.Options.ScaleSeparator ? ',' : '.'); i = 0; while (i < decimals - 1) { answer += num[i + 2]; // num has a 0-based index and [1] is a '.' @@ -1231,13 +1233,13 @@ CM.Disp.Beautify = function(num, frac, forced) { numbersToAdd = (restOfNumber.indexOf('.') > -1 ? restOfNumber.indexOf('.') + 1 + decimals : (restOfNumber.length)) i = 0 while (i < numbersToAdd - 1 && i < restOfNumber.length - 1) { - answer += (CM.Config.ScaleSeparator && restOfNumber[i] == '.' ? ',' : restOfNumber[i]); + answer += (CM.Options.ScaleSeparator && restOfNumber[i] == '.' ? ',' : restOfNumber[i]); i++ } answer += (i + 1 < restOfNumber.length ? Math.round(restOfNumber[i] + '.' + restOfNumber[i + 1]) : restOfNumber[i]); // answer is now "xxx.xx" (e.g., 123456789 would be 123.46) - if (CM.Config.Scale == 1 && !forced || forced == 1) { // Metric scale, 123456789 => 123.457 M + if (CM.Options.Scale == 1 && !forced || forced == 1) { // Metric scale, 123456789 => 123.457 M if (timesTenToPowerThree - 1 < CM.Data.metric.length) { answer += ' ' + CM.Data.metric[timesTenToPowerThree - 1] } @@ -1245,7 +1247,7 @@ CM.Disp.Beautify = function(num, frac, forced) { return CM.Disp.Beautify(num, 0, 3); } } - else if (CM.Config.Scale == 2 && !forced || forced == 2) { // Short scale, 123456789 => 123.457 M + else if (CM.Options.Scale == 2 && !forced || forced == 2) { // Short scale, 123456789 => 123.457 M if (timesTenToPowerThree < CM.Data.shortScale.length + 1) { answer += ' ' + CM.Data.shortScale[timesTenToPowerThree - 1]; } @@ -1253,7 +1255,7 @@ CM.Disp.Beautify = function(num, frac, forced) { return CM.Disp.Beautify(num, 0, 3); } } - else if (CM.Config.Scale == 4 && !forced || forced == 4) { // Engineering notation, 123456789 => 123.457E+6 + else if (CM.Options.Scale == 4 && !forced || forced == 4) { // Engineering notation, 123456789 => 123.457E+6 answer += 'E+' + (timesTenToPowerThree * 3); } } @@ -1283,8 +1285,8 @@ CM.Disp.Beautify = function(num, frac, forced) { CM.Disp.UpdateAscendState = function() { if (Game.OnAscend) { l('game').style.bottom = '0px'; - if (CM.Config.BotBar == 1) CM.Disp.BotBar.style.display = 'none'; - if (CM.Config.TimerBar == 1) CM.Disp.TimerBar.style.display = 'none'; + if (CM.Options.BotBar == 1) CM.Disp.BotBar.style.display = 'none'; + if (CM.Options.TimerBar == 1) CM.Disp.TimerBar.style.display = 'none'; } else { CM.Disp.ToggleBotBar(); @@ -1335,7 +1337,7 @@ CM.Disp.Draw = function () { // Draw autosave timer in stats menu if ( (Game.prefs.autosave && Game.drawT % 10 == 0) && // with autosave ON and every 10 ticks - (Game.onMenu == 'stats' && CM.Config.Stats) // while being on the stats menu only + (Game.onMenu == 'stats' && CM.Options.Stats) // while being on the stats menu only ) { var timer = document.getElementById('CMStatsAutosaveTimer'); if (timer) { @@ -1349,10 +1351,10 @@ CM.Disp.Draw = function () { /** * This function toggle the bottom bar - * It is called by CM.Disp.UpdateAscendState() and a change in CM.Config.BotBar + * It is called by CM.Disp.UpdateAscendState() and a change in CM.Options.BotBar */ CM.Disp.ToggleBotBar = function() { - if (CM.Config.BotBar == 1) { + if (CM.Options.BotBar == 1) { CM.Disp.BotBar.style.display = ''; CM.Disp.UpdateBotBar(); } @@ -1364,7 +1366,7 @@ CM.Disp.ToggleBotBar = function() { /** * This function creates the bottom bar and appends it to l('wrapper') - * It is called by CM.DelayInit and a change in CM.Config.BotBar + * It is called by CM.DelayInit and a change in CM.Options.BotBar */ CM.Disp.CreateBotBar = function() { CM.Disp.BotBar = document.createElement('div'); @@ -1418,7 +1420,7 @@ CM.Disp.CreateBotBar = function() { * It is called by CM.Loop() */ CM.Disp.UpdateBotBar = function() { - if (CM.Config.BotBar == 1) { + if (CM.Options.BotBar == 1) { var count = 0; for (var i in CM.Cache.Objects) { var target = 'Objects'; @@ -1567,7 +1569,7 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { * It is called by CM.Loop() */ CM.Disp.UpdateTimerBar = function() { - if (CM.Config.TimerBar == 1) { + if (CM.Options.TimerBar == 1) { // label width: 113, timer width: 26, div margin: 20 var maxWidth = CM.Disp.TimerBar.offsetWidth - 159; var numberOfTimers = 0; @@ -1642,20 +1644,20 @@ CM.Disp.UpdateTimerBar = function() { /** * This function changes the visibility of the timer bar - * It is called by CM.Disp.UpdateAscendState() or a change in CM.Config.TimerBar + * It is called by CM.Disp.UpdateAscendState() or a change in CM.Options.TimerBar */ CM.Disp.ToggleTimerBar = function() { - if (CM.Config.TimerBar == 1) CM.Disp.TimerBar.style.display = ''; + if (CM.Options.TimerBar == 1) CM.Disp.TimerBar.style.display = ''; else CM.Disp.TimerBar.style.display = 'none'; CM.Disp.UpdateBotTimerBarPosition(); } /** * This function changes the position of the timer bar - * It is called by a change in CM.Config.TimerBarPos + * It is called by a change in CM.Options.TimerBarPos */ CM.Disp.ToggleTimerBarPos = function() { - if (CM.Config.TimerBarPos == 0) { + if (CM.Options.TimerBarPos == 0) { CM.Disp.TimerBar.style.width = '30%'; CM.Disp.TimerBar.style.bottom = ''; l('game').insertBefore(CM.Disp.TimerBar, l('sectionLeft')); @@ -1676,22 +1678,22 @@ CM.Disp.ToggleTimerBarPos = function() { * It is called by CM.Disp.ToggleTimerBar(), CM.Disp.ToggleTimerBarPos() and CM.Disp.ToggleBotBar() */ CM.Disp.UpdateBotTimerBarPosition = function() { - if (CM.Config.BotBar == 1 && CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 1) { + if (CM.Options.BotBar == 1 && CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 1) { CM.Disp.BotBar.style.bottom = '48px'; l('game').style.bottom = '118px'; } - else if (CM.Config.BotBar == 1) { + else if (CM.Options.BotBar == 1) { CM.Disp.BotBar.style.bottom = '0px'; l('game').style.bottom = '70px'; } - else if (CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 1) { + else if (CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 1) { l('game').style.bottom = '48px'; } else { // No bars l('game').style.bottom = '0px'; } - if (CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 0) { + if (CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 0) { l('sectionLeft').style.top = '48px'; } else { @@ -1706,18 +1708,18 @@ CM.Disp.UpdateBotTimerBarPosition = function() { /** * This function adjusts some things in the column of buildings. - * It colours them, helps display the correct sell-price and shuffles the order when CM.Config.SortBuildings is set + * It colours them, helps display the correct sell-price and shuffles the order when CM.Options.SortBuildings is set * The function is called by CM.Loop(), CM.Disp.UpdateColors() & CM.Disp.RefreshScale() - * And by changes in CM.Config.BuildColor, CM.Config.SortBuild & CM.ConfigData.BulkBuildColor + * And by changes in CM.Options.BuildColor, CM.Options.SortBuild & CM.ConfigData.BulkBuildColor */ CM.Disp.UpdateBuildings = function() { - if (CM.Config.BuildColor == 1 && Game.buyMode == 1) { + if (CM.Options.BuildColor == 1 && Game.buyMode == 1) { var target = ''; - if (Game.buyBulk == 10 && CM.Config.BulkBuildColor == 1) target = 'Objects10'; - else if (Game.buyBulk == 100 && CM.Config.BulkBuildColor == 1) target = 'Objects100'; + if (Game.buyBulk == 10 && CM.Options.BulkBuildColor == 1) target = 'Objects10'; + else if (Game.buyBulk == 100 && CM.Options.BulkBuildColor == 1) target = 'Objects100'; else target = 'Objects'; for (var i in CM.Cache[target]) { - l('productPrice' + Game.Objects[i].id).style.color = CM.Config.Colors[CM.Cache[target][i].color]; + l('productPrice' + Game.Objects[i].id).style.color = CM.Options.Colors[CM.Cache[target][i].color]; } } else if (Game.buyMode == -1) { @@ -1739,7 +1741,7 @@ CM.Disp.UpdateBuildings = function() { // Build array of pointers, sort by pp, use array index (+2) as the grid row number // (grid rows are 1-based indexing, and row 1 is the bulk buy/sell options) // This regulates sorting of buildings - if (Game.buyMode == 1 && CM.Config.SortBuildings) { + if (Game.buyMode == 1 && CM.Options.SortBuildings) { var arr = Object.keys(CM.Cache[target]).map(k => { var o = CM.Cache[target][k]; @@ -1770,13 +1772,13 @@ CM.Disp.UpdateBuildings = function() { /** * This function adjusts some things in the upgrades section - * It colours them and shuffles the order when CM.Config.SortBuildings is set + * It colours them and shuffles the order when CM.Options.SortBuildings is set * The function is called by CM.Loop(), CM.Disp.ToggleUpgradeBarAndColor & CM.Disp.RefreshScale() - * And by changes in CM.Config.SortUpgrades + * And by changes in CM.Options.SortUpgrades */ CM.Disp.UpdateUpgrades = function() { // This counts the amount of upgrades for each pp group and updates the Upgrade Bar - if (CM.Config.UpBarColor > 0) { + if (CM.Options.UpBarColor > 0) { var blue = 0; var green = 0; var yellow = 0; @@ -1831,7 +1833,7 @@ CM.Disp.UpdateUpgrades = function() { arr.push(o); } - if (CM.Config.SortUpgrades) + if (CM.Options.SortUpgrades) arr.sort((a, b) => a.pp - b.pp); else arr.sort((a, b) => a.price - b.price); @@ -1846,14 +1848,14 @@ CM.Disp.UpdateUpgrades = function() { /** * This function toggles the upgrade bar and the colours of upgrades - * It is called by a change in CM.Config.UpBarColor + * It is called by a change in CM.Options.UpBarColor */ CM.Disp.ToggleUpgradeBarAndColor = function() { - if (CM.Config.UpBarColor == 1) { // Colours and bar on + if (CM.Options.UpBarColor == 1) { // Colours and bar on CM.Disp.UpgradeBar.style.display = ''; CM.Disp.UpdateUpgrades(); } - else if (CM.Config.UpBarColor == 2) {// Colours on and bar off + else if (CM.Options.UpBarColor == 2) {// Colours on and bar off CM.Disp.UpgradeBar.style.display = 'none'; CM.Disp.UpdateUpgrades(); } @@ -1865,10 +1867,10 @@ CM.Disp.ToggleUpgradeBarAndColor = function() { /** * This function toggles the position of the upgrade bar from fixed or non-fixed mode - * It is called by a change in CM.Config.UpgradeBarFixedPos + * It is called by a change in CM.Options.UpgradeBarFixedPos */ CM.Disp.ToggleUpgradeBarFixedPos = function() { - if (CM.Config.UpgradeBarFixedPos == 1) { // Fix to top of screen when scrolling + if (CM.Options.UpgradeBarFixedPos == 1) { // Fix to top of screen when scrolling CM.Disp.UpgradeBar.style.position = 'sticky'; CM.Disp.UpgradeBar.style.top = '0px'; } @@ -1978,10 +1980,10 @@ CM.Disp.CreateWhiteScreen = function() { * that check game-events and which have settings for Flashes (e.g., Golden Cookies appearing, Magic meter being full) * @param {number} mode Sets the intensity of the flash, used to recursively dim flash * All calls of function have use mode == 3 - * @param {string} config The setting in CM.Config that is checked before creating the flash + * @param {string} config The setting in CM.Options that is checked before creating the flash */ CM.Disp.Flash = function(mode, config) { - if ((CM.Config[config] == 1 && mode == 3) || mode == 1) { + if ((CM.Options[config] == 1 && mode == 3) || mode == 1) { CM.Disp.WhiteScreen.style.opacity = '0.5'; if (mode == 3) { CM.Disp.WhiteScreen.style.display = 'inline'; @@ -2001,14 +2003,14 @@ CM.Disp.Flash = function(mode, config) { /** * This function plays a sound depending on configs. It is called by all functions * that check game-events and which have settings for sound (e.g., Golden Cookies appearing, Magic meter being full) - * @param {variable} url A variable that gives the url for the sound (e.g., CM.Config.GCSoundURL) - * @param {string} sndConfig The setting in CM.Config that is checked before creating the sound - * @param {string} volConfig The setting in CM.Config that is checked to determine volume + * @param {variable} url A variable that gives the url for the sound (e.g., CM.Options.GCSoundURL) + * @param {string} sndConfig The setting in CM.Options that is checked before creating the sound + * @param {string} volConfig The setting in CM.Options that is checked to determine volume */ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { - if (CM.Config[sndConfig] == 1) { + if (CM.Options[sndConfig] == 1) { var sound = new realAudio(url); - sound.volume = (CM.Config[volConfig] / 100) * (Game.volume / 100); + sound.volume = (CM.Options[volConfig] / 100) * (Game.volume / 100); sound.play(); } } @@ -2016,12 +2018,12 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { /** * This function creates a notifcation depending on configs. It is called by all functions * that check game-events and which have settings for notifications (e.g., Golden Cookies appearing, Magic meter being full) - * @param {string} notifyConfig The setting in CM.Config that is checked before creating the notification + * @param {string} notifyConfig The setting in CM.Options that is checked before creating the notification * @param {string} title The title of the to-be created notifications * @param {string} message The text of the to-be created notifications */ CM.Disp.Notification = function(notifyConfig, title, message) { - if (CM.Config[notifyConfig] == 1 && document.visibilityState == 'hidden') { + if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden') { var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico' notification = new Notification(title, {body: message, badge: CookieIcon}); } @@ -2043,11 +2045,11 @@ CM.Disp.CreateFavicon = function() { /** * This function updates the Favicon depending on whether a Golden Cookie has spawned - * It is called on every loop by CM.Main.CheckGoldenCookie() or by a change in CM.Config.Favicon + * It is called on every loop by CM.Main.CheckGoldenCookie() or by a change in CM.Options.Favicon * By relying on CM.Cache.spawnedGoldenShimmer it only changes for non-user spawned cookie */ CM.Disp.UpdateFavicon = function() { - if (CM.Config.Favicon == 1 && CM.Main.lastGoldenCookieState > 0) { + if (CM.Options.Favicon == 1 && CM.Main.lastGoldenCookieState > 0) { if (CM.Cache.spawnedGoldenShimmer.wrath) CM.Disp.Favicon.href = 'https://aktanusa.github.io/CookieMonster/favicon/wrathCookie.ico'; else CM.Disp.Favicon.href = 'https://aktanusa.github.io/CookieMonster/favicon/goldenCookie.ico'; } @@ -2059,10 +2061,10 @@ CM.Disp.UpdateFavicon = function() { * It is called on every loop by Game.Logic() which also sets CM.Cache.Title to Game.cookies */ CM.Disp.UpdateTitle = function() { - if (Game.OnAscend || CM.Config.Title == 0) { + if (Game.OnAscend || CM.Options.Title == 0) { document.title = CM.Cache.Title; } - else if (CM.Config.Title == 1) { + else if (CM.Options.Title == 1) { var addFC = false; var addSP = false; var titleGC; @@ -2098,7 +2100,7 @@ CM.Disp.UpdateTitle = function() { } document.title = titleGC + (addFC ? titleFC : '') + (addSP ? titleSP : '') + ' ' + str; } - else if (CM.Config.Title == 2) { + else if (CM.Options.Title == 2) { var str = ''; var spawn = false; if (CM.Cache.spawnedGoldenShimmer) { @@ -2143,7 +2145,7 @@ CM.Disp.CreateGCTimer = function(cookie) { GCTimer.style.fontSize = '35px'; GCTimer.style.cursor = 'pointer'; GCTimer.style.display = 'block'; - if (CM.Config.GCTimer == 0) GCTimer.style.display = 'none'; + if (CM.Options.GCTimer == 0) GCTimer.style.display = 'none'; GCTimer.style.left = cookie.l.style.left; GCTimer.style.top = cookie.l.style.top; GCTimer.onclick = function () {cookie.pop();}; @@ -2156,10 +2158,10 @@ CM.Disp.CreateGCTimer = function(cookie) { /** * This function toggles GC Timers are visible - * It is called by a change in CM.Config.GCTimer + * It is called by a change in CM.Options.GCTimer */ CM.Disp.ToggleGCTimer = function() { - if (CM.Config.GCTimer == 1) { + if (CM.Options.GCTimer == 1) { for (var i in CM.Disp.GCTimers) { CM.Disp.GCTimers[i].style.display = 'block'; CM.Disp.GCTimers[i].style.left = CM.Cache.goldenShimmersByID[i].l.style.left; @@ -2275,7 +2277,7 @@ CM.Disp.Tooltip = function(type, name) { if (type == 'b') { // Buildings l('tooltip').innerHTML = Game.Objects[name].tooltip(); // Adds amortization info to the list of info per building - if (CM.Config.TooltipAmor == 1) { + if (CM.Options.TooltipAmor == 1) { var buildPrice = CM.Sim.BuildingGetPrice(Game.Objects[name], Game.Objects[name].basePrice, 0, Game.Objects[name].free, Game.Objects[name].amount); var amortizeAmount = buildPrice - Game.Objects[name].totalCookies; if (amortizeAmount > 0) { @@ -2470,7 +2472,7 @@ CM.Disp.UpdateTooltip = function() { * It is called when Building tooltips are created or refreshed by CM.Disp.UpdateTooltip() */ CM.Disp.UpdateTooltipBuilding = function() { - if (CM.Config.TooltipBuildUp == 1 && Game.buyMode == 1) { + if (CM.Options.TooltipBuildUp == 1 && Game.buyMode == 1) { tooltipBox = l('CMTooltipBorder'); CM.Disp.TooltipCreateCalculationSection(tooltipBox); @@ -2485,7 +2487,7 @@ CM.Disp.UpdateTooltipBuilding = function() { CM.Disp.TooltipBonusIncome = CM.Cache[target][CM.Disp.tooltipName].bonus; - if (CM.Config.TooltipBuildUp == 1 && Game.buyMode == 1) { + if (CM.Options.TooltipBuildUp == 1 && Game.buyMode == 1) { l('CMTooltipIncome').textContent = Beautify(CM.Disp.TooltipBonusIncome, 2); var increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000); if (isFinite(increase) && increase != 0) { @@ -2530,7 +2532,7 @@ CM.Disp.UpdateTooltipUpgrade = function() { CM.Disp.TooltipBonusIncome = CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bonus; CM.Disp.TooltipPrice = Game.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].getPrice(); - if (CM.Config.TooltipBuildUp == 1) { + if (CM.Options.TooltipBuildUp == 1) { l('CMTooltipIncome').textContent = Beautify(CM.Disp.TooltipBonusIncome, 2); var increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000); if (isFinite(increase) && increase != 0) { @@ -2561,7 +2563,7 @@ CM.Disp.UpdateTooltipUpgrade = function() { * It adds to the additional information to l('CMTooltipArea') */ CM.Disp.UpdateTooltipSugarLump = function() { - if (CM.Config.TooltipLump === 1) { + if (CM.Options.TooltipLump === 1) { tooltipBox = l('CMTooltipBorder'); tooltipBox.appendChild(CM.Disp.TooltipCreateHeader('Current Sugar Lump')); @@ -2584,7 +2586,7 @@ CM.Disp.UpdateTooltipGrimoire = function() { var minigame = Game.Objects['Wizard tower'].minigame; var spellCost = minigame.getSpellCost(minigame.spellsById[CM.Disp.tooltipName]); - if (CM.Config.TooltipGrim == 1 && spellCost <= minigame.magicM) { + if (CM.Options.TooltipGrim == 1 && spellCost <= minigame.magicM) { tooltipBox = l('CMTooltipBorder'); // Time left till enough magic for spell @@ -2642,14 +2644,14 @@ CM.Disp.UpdateTooltipWarnings = function() { CM.Disp.ToggleToolWarnPos(); } - if (CM.Config.ToolWarnPos == 0) CM.Disp.TooltipWarn.style.right = '0px'; + if (CM.Options.ToolWarnPos == 0) CM.Disp.TooltipWarn.style.right = '0px'; else CM.Disp.TooltipWarn.style.top = (l('tooltip').offsetHeight) + 'px'; CM.Disp.TooltipWarn.style.width = (l('tooltip').offsetWidth - 6) + 'px'; - if (CM.Config.ToolWarnLucky == 1) { + if (CM.Options.ToolWarnLucky == 1) { var limitLucky = CM.Cache.Lucky; - if (CM.Config.ToolWarnBon == 1) { + if (CM.Options.ToolWarnBon == 1) { var bonusNoFren = CM.Disp.TooltipBonusIncome; bonusNoFren /= CM.Sim.getCPSBuffMult(); limitLucky += ((bonusNoFren * 60 * 15) / 0.15); @@ -2678,9 +2680,9 @@ CM.Disp.UpdateTooltipWarnings = function() { l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; } - if (CM.Config.ToolWarnConjure == 1) { + if (CM.Options.ToolWarnConjure == 1) { var limitLucky = CM.Cache.Lucky; - if (CM.Config.ToolWarnBon == 1) { + if (CM.Options.ToolWarnBon == 1) { var bonusNoFren = CM.Disp.TooltipBonusIncome; bonusNoFren /= CM.Sim.getCPSBuffMult(); limitLucky += ((bonusNoFren * 60 * 15) / 0.15); @@ -2712,25 +2714,25 @@ CM.Disp.UpdateTooltipWarnings = function() { CM.Disp.UpdateTooltipLocation = function() { if (Game.tooltip.origin == 'store') { var warnOffset = 0; - if (CM.Config.ToolWarnLucky == 1 && CM.Config.ToolWarnPos == 1 && typeof CM.Disp.TooltipWarn != "undefined") { + if (CM.Options.ToolWarnLucky == 1 && CM.Options.ToolWarnPos == 1 && typeof CM.Disp.TooltipWarn != "undefined") { warnOffset = CM.Disp.TooltipWarn.clientHeight - 4; } Game.tooltip.tta.style.top = Math.min(parseInt(Game.tooltip.tta.style.top), (l('game').clientHeight + l('topBar').clientHeight) - Game.tooltip.tt.clientHeight - warnOffset - 46) + 'px'; } // Kept for future possible use if the code changes again - /*else if (!Game.onCrate && !Game.OnAscend && CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 0) { + /*else if (!Game.onCrate && !Game.OnAscend && CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 0) { Game.tooltip.tta.style.top = (parseInt(Game.tooltip.tta.style.top) + parseInt(CM.Disp.TimerBar.style.height)) + 'px'; }*/ } /** * This function toggles the position of the warnings created by CM.Disp.TooltipCreateWarningSection() - * It is called by a change in CM.Config.ToolWarnPos + * It is called by a change in CM.Options.ToolWarnPos * and upon creation of the warning tooltip by CM.Disp.UpdateTooltipWarnings() */ CM.Disp.ToggleToolWarnPos = function() { if (typeof CM.Disp.TooltipWarn != "undefined") { - if (CM.Config.ToolWarnPos == 0) { + if (CM.Options.ToolWarnPos == 0) { CM.Disp.TooltipWarn.style.top = 'auto'; CM.Disp.TooltipWarn.style.margin = '4px -4px'; CM.Disp.TooltipWarn.style.padding = '3px 4px'; @@ -2749,7 +2751,7 @@ CM.Disp.ToggleToolWarnPos = function() { * TODO: Change this code to be the same as other tooltips. (i.d., create tooltip with type "w") */ CM.Disp.CheckWrinklerTooltip = function() { - if (CM.Config.ToolWrink == 1 && CM.Disp.TooltipWrinklerArea == 1) { // Latter is set by CM.Main.AddWrinklerAreaDetect + if (CM.Options.ToolWrink == 1 && CM.Disp.TooltipWrinklerArea == 1) { // Latter is set by CM.Main.AddWrinklerAreaDetect var showingTooltip = false; for (var i in Game.wrinklers) { var me = Game.wrinklers[i]; @@ -2787,7 +2789,7 @@ CM.Disp.CheckWrinklerTooltip = function() { * TODO: Change this code to be the same as other tooltips. Fit this into CM.Disp.UpdateTooltip() */ CM.Disp.UpdateWrinklerTooltip = function() { - if (CM.Config.ToolWrink == 1 && l('CMTooltipWrinkler') != null) { + if (CM.Options.ToolWrink == 1 && l('CMTooltipWrinkler') != null) { var sucked = Game.wrinklers[CM.Disp.TooltipWrinkler].sucked; var toSuck = 1.1; if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05; @@ -2813,7 +2815,7 @@ CM.Disp.UpdateWrinklerTooltip = function() { * @param {number} aura The number of the aura currently selected by the mouse/user */ CM.Disp.AddAuraInfo = function(aura) { - if (CM.Config.DragonAuraInfo == 1) { + if (CM.Options.DragonAuraInfo == 1) { var [bonusCPS, priceOfChange] = CM.Sim.CalculateChangeAura(aura); var timeToRecover = CM.Disp.FormatTime(priceOfChange / (bonusCPS + Game.cookiesPs)); var bonusCPSPercentage = CM.Disp.Beautify(bonusCPS / Game.cookiesPs); @@ -2854,18 +2856,18 @@ CM.Disp.AddMenu = function() { CM.Disp.AddMenuPref(title); } else if (Game.onMenu == 'stats') { - if (CM.Config.Stats) { + if (CM.Options.Stats) { CM.Disp.AddMenuStats(title); } } } /** - * This function refreshes the stats page, CM.Config.UpStats determines the rate at which that happens + * This function refreshes the stats page, CM.Options.UpStats determines the rate at which that happens * It is called by CM.Loop() */ 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(); + if (CM.Options.UpStats && Game.onMenu == 'stats' && (Game.drawT - 1) % (Game.fps * 5) != 0 && (Game.drawT - 1) % Game.fps == 0) Game.UpdateMenu(); } /******** @@ -2883,7 +2885,7 @@ CM.Disp.AddMenuPref = function(title) { for (var group in CM.ConfigGroups) { groupObject = CM.Disp.CreatePrefHeader(group, CM.ConfigGroups[group]) // (group, display-name of group) frag.appendChild(groupObject) - if (CM.Config.OptionsPref[group]) { // 0 is show, 1 is collapsed + if (CM.Options.OptionsPref[group]) { // 0 is show, 1 is collapsed for (var option in CM.ConfigData) { if (CM.ConfigData[option].group == group) frag.appendChild(CM.Disp.CreatePrefOption(option)) } @@ -2912,6 +2914,7 @@ CM.Disp.AddMenuPref = function(title) { CM.Disp.CreatePrefHeader = function(config, text) { var div = document.createElement('div'); div.className = 'title'; + div.style.opacity = '0.7'; div.style.fontSize = '17px'; div.appendChild(document.createTextNode(text + ' ')); @@ -2926,7 +2929,7 @@ CM.Disp.CreatePrefHeader = function(config, text) { span.style.color = 'black'; span.style.fontSize = '13px'; span.style.verticalAlign = 'middle'; - span.textContent = CM.Config.OptionsPref[config] ? '-' : '+'; + span.textContent = CM.Options.OptionsPref[config] ? '-' : '+'; span.onclick = function() {CM.ToggleOptionsConfig(config); Game.UpdateMenu();}; div.appendChild(span); return div; @@ -2943,7 +2946,7 @@ CM.Disp.CreatePrefOption = function(config) { var div = document.createElement('div'); div.className = 'listing'; var a = document.createElement('a'); - if (CM.ConfigData[config].toggle && CM.Config[config] == 0) { + if (CM.ConfigData[config].toggle && CM.Options[config] == 0) { a.className = 'option off'; } else { @@ -2951,7 +2954,7 @@ CM.Disp.CreatePrefOption = function(config) { } a.id = CM.ConfigPrefix + config; a.onclick = function() {CM.ToggleConfig(config);}; - a.textContent = CM.ConfigData[config].label[CM.Config[config]]; + a.textContent = CM.ConfigData[config].label[CM.Options[config]]; div.appendChild(a); var label = document.createElement('label'); label.textContent = CM.ConfigData[config].desc; @@ -2970,7 +2973,7 @@ CM.Disp.CreatePrefOption = function(config) { var percent = title = document.createElement('div'); percent.id = "slider" + config + "right"; percent.style.float = "right"; - percent.innerHTML = CM.Config[config] + "%"; + percent.innerHTML = CM.Options[config] + "%"; volume.appendChild(percent); var slider = document.createElement('input'); slider.className = "slider"; @@ -2980,7 +2983,7 @@ CM.Disp.CreatePrefOption = function(config) { slider.min = "0"; slider.max = "100"; slider.step = "1"; - slider.value = CM.Config[config]; + slider.value = CM.Options[config]; slider.oninput = function() {CM.ToggleConfigVolume(config)}; slider.onchange = function() {CM.ToggleConfigVolume(config)}; volume.appendChild(slider); @@ -2999,7 +3002,7 @@ CM.Disp.CreatePrefOption = function(config) { input.className = 'option'; input.type = 'text'; input.readOnly = true; - input.setAttribute('value', CM.Config[config]); + input.setAttribute('value', CM.Options[config]); input.style.width = '300px'; div.appendChild(input); div.appendChild(document.createTextNode(' ')); @@ -3007,10 +3010,10 @@ CM.Disp.CreatePrefOption = function(config) { inputPrompt.id = CM.ConfigPrefix + config + 'Prompt'; inputPrompt.className = 'option'; inputPrompt.type = 'text'; - inputPrompt.setAttribute('value', CM.Config[config]); + inputPrompt.setAttribute('value', CM.Options[config]); var a = document.createElement('a'); a.className = 'option'; - a.onclick = function() {Game.Prompt(inputPrompt.outerHTML, [['Save', 'CM.Config[\'' + config + '\'] = l(CM.ConfigPrefix + \'' + config + '\' + \'Prompt\').value; CM.SaveConfig(CM.Config); Game.ClosePrompt(); Game.UpdateMenu();'], 'Cancel']);}; + a.onclick = function() {Game.Prompt(inputPrompt.outerHTML, [['Save', 'CM.Options[\'' + config + '\'] = l(CM.ConfigPrefix + \'' + config + '\' + \'Prompt\').value; CM.SaveConfig(CM.Options); Game.ClosePrompt(); Game.UpdateMenu();'], 'Cancel']);}; a.textContent = 'Edit'; div.appendChild(a); var label = document.createElement('label'); @@ -3026,9 +3029,9 @@ CM.Disp.CreatePrefOption = function(config) { input.id = CM.ConfigPrefix + 'Color' + CM.Disp.colors[i]; input.className = 'option'; input.style.width = '65px'; - input.setAttribute('value', CM.Config.Colors[CM.Disp.colors[i]]); + input.setAttribute('value', CM.Options.Colors[CM.Disp.colors[i]]); div.appendChild(input); - eval('var change = function() {CM.Config.Colors[\'' + CM.Disp.colors[i] + '\'] = l(CM.ConfigPrefix + \'Color\' + \'' + CM.Disp.colors[i] + '\').value; CM.Disp.UpdateColors(); CM.SaveConfig(CM.Config);}'); + eval('var change = function() {CM.Options.Colors[\'' + CM.Disp.colors[i] + '\'] = l(CM.ConfigPrefix + \'Color\' + \'' + CM.Disp.colors[i] + '\').value; CM.Disp.UpdateColors(); CM.SaveConfig(CM.Options);}'); var jscolorpicker = new jscolor.color(input, {hash: true, caps: false, pickerZIndex: 1000000, pickerPosition: 'right', onImmediateChange: change}); var label = document.createElement('label'); label.textContent = CM.ConfigData.Colors.desc[CM.Disp.colors[i]]; @@ -3040,16 +3043,16 @@ CM.Disp.CreatePrefOption = function(config) { /** * This function changes some of the time-displays in the game to be more detailed - * It is called by a change in CM.Config.DetailedTime + * It is called by a change in CM.Options.DetailedTime */ CM.Disp.ToggleDetailedTime = function() { - if (CM.Config.DetailedTime == 1) Game.sayTime = CM.Disp.sayTime; + if (CM.Options.DetailedTime == 1) Game.sayTime = CM.Disp.sayTime; else Game.sayTime = CM.Backup.sayTime; } /** * This function refreshes all numbers after a change in scale-setting - * It is therefore called by a change in CM.Config.Scale and CM.Config.ScaleDecimals + * It is therefore called by a change in CM.Options.Scale and CM.Options.ScaleDecimals */ CM.Disp.RefreshScale = function() { BeautifyAll(); @@ -3063,18 +3066,18 @@ CM.Disp.RefreshScale = function() { /** * This function changes/refreshes colours if the user has set new standard colours - * The function is therefore called by a change in CM.Config.Colors + * The function is therefore called by a change in CM.Options.Colors */ CM.Disp.UpdateColors = function() { var str = ''; for (var i = 0; i < CM.Disp.colors.length; i++) { - str += '.' + CM.Disp.colorTextPre + CM.Disp.colors[i] + ' { color: ' + CM.Config.Colors[CM.Disp.colors[i]] + '; }\n'; + str += '.' + CM.Disp.colorTextPre + CM.Disp.colors[i] + ' { color: ' + CM.Options.Colors[CM.Disp.colors[i]] + '; }\n'; } for (var i = 0; i < CM.Disp.colors.length; i++) { - str += '.' + CM.Disp.colorBackPre + CM.Disp.colors[i] + ' { background-color: ' + CM.Config.Colors[CM.Disp.colors[i]] + '; }\n'; + str += '.' + CM.Disp.colorBackPre + CM.Disp.colors[i] + ' { background-color: ' + CM.Options.Colors[CM.Disp.colors[i]] + '; }\n'; } for (var i = 0; i < CM.Disp.colors.length; i++) { - str += '.' + CM.Disp.colorBorderPre + CM.Disp.colors[i] + ' { border: 1px solid ' + CM.Config.Colors[CM.Disp.colors[i]] + '; }\n'; + str += '.' + CM.Disp.colorBorderPre + CM.Disp.colors[i] + ' { border: 1px solid ' + CM.Options.Colors[CM.Disp.colors[i]] + '; }\n'; } CM.Disp.Css.textContent = str; CM.Disp.UpdateBuildings(); // Class has been already set @@ -3095,28 +3098,28 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(title()); stats.appendChild(CM.Disp.CreateStatsHeader('Lucky Cookies', 'Lucky')); - if (CM.Config.StatsPref.Lucky) { + if (CM.Options.StatsPref.Lucky) { stats.appendChild(CM.Disp.CreateStatsLuckySection()); } stats.appendChild(CM.Disp.CreateStatsHeader('Chain Cookies', 'Chain')); - if (CM.Config.StatsPref.Chain) { + if (CM.Options.StatsPref.Chain) { stats.appendChild(CM.Disp.CreateStatsChainSection()); } stats.appendChild(CM.Disp.CreateStatsHeader('Conjure Baked Goods', 'Conjure')); - if (CM.Config.StatsPref.Conjure) { + if (CM.Options.StatsPref.Conjure) { stats.appendChild(CM.Disp.CreateStatsConjureSection()); } stats.appendChild(CM.Disp.CreateStatsHeader('Prestige', 'Prestige')); - if (CM.Config.StatsPref.Prestige) { + if (CM.Options.StatsPref.Prestige) { stats.appendChild(CM.Disp.CreateStatsPrestigeSection()); } if (Game.cpsSucked > 0) { stats.appendChild(CM.Disp.CreateStatsHeader('Wrinklers', 'Wrink')); - if (CM.Config.StatsPref.Wrink) { + if (CM.Options.StatsPref.Wrink) { var popAllFrag = document.createDocumentFragment(); popAllFrag.appendChild(document.createTextNode(Beautify(CM.Cache.WrinkBankTotal) + ' / ' + Beautify(CM.Cache.WrinkBankNormal) + ' ')); var popAllA = document.createElement('a'); @@ -3170,7 +3173,7 @@ CM.Disp.AddMenuStats = function(title) { if (Game.season == 'christmas' || specDisp || choEgg || centEgg) { stats.appendChild(CM.Disp.CreateStatsHeader('Season Specials', 'Sea')); - if (CM.Config.StatsPref.Sea) { + if (CM.Options.StatsPref.Sea) { if (specDisp) { if (missingHalloweenCookies.length != 0) stats.appendChild(CM.Disp.CreateStatsListing("basic", 'Halloween Cookies Left to Buy', CM.Disp.CreateStatsMissDisp(missingHalloweenCookies))); if (missingChristmasCookies.length != 0) stats.appendChild(CM.Disp.CreateStatsListing("basic", 'Christmas Cookies Left to Buy', CM.Disp.CreateStatsMissDisp(missingChristmasCookies))); @@ -3190,12 +3193,12 @@ CM.Disp.AddMenuStats = function(title) { } stats.appendChild(CM.Disp.CreateStatsHeader('Miscellaneous', 'Misc')); - if (CM.Config.StatsPref.Misc) { + if (CM.Options.StatsPref.Misc) { stats.appendChild(CM.Disp.CreateStatsListing("basic", - 'Average Cookies Per Second (Past ' + (CM.Disp.cookieTimes[CM.Config.AvgCPSHist] < 60 ? (CM.Disp.cookieTimes[CM.Config.AvgCPSHist] + ' seconds') : ((CM.Disp.cookieTimes[CM.Config.AvgCPSHist] / 60) + (CM.Config.AvgCPSHist == 3 ? ' minute' : ' minutes'))) + ')', + '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)) )); - stats.appendChild(CM.Disp.CreateStatsListing("basic", 'Average Cookie Clicks Per Second (Past ' + CM.Disp.clickTimes[CM.Config.AvgClicksHist] + (CM.Config.AvgClicksHist == 0 ? ' second' : ' seconds') + ')', document.createTextNode(Beautify(CM.Cache.AvgClicks, 1)))); + 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.AvgClicks, 1)))); if (Game.Has('Fortune cookies')) { var fortunes = []; for (var i in CM.Data.Fortunes) { @@ -3216,7 +3219,7 @@ CM.Disp.AddMenuStats = function(title) { l('menu').insertBefore(stats, l('menu').childNodes[2]); - if (CM.Config.MissingUpgrades) { + if (CM.Options.MissingUpgrades) { CM.Disp.AddMissingUpgrades(); } } @@ -3247,7 +3250,7 @@ CM.Disp.CreateStatsHeader = function(text, config) { span.style.color = 'black'; span.style.fontSize = '13px'; span.style.verticalAlign = 'middle'; - span.textContent = CM.Config.StatsPref[config] ? '-' : '+'; + span.textContent = CM.Options.StatsPref[config] ? '-' : '+'; span.onclick = function() {CM.ToggleStatsConfig(config); Game.UpdateMenu();}; div.appendChild(span); return div; @@ -3862,7 +3865,7 @@ CM.ReplaceNativeGrimoireDraw = function() { CM.Backup.GrimoireDraw = minigame.draw; Game.Objects['Wizard tower'].minigame.draw = function() { CM.Backup.GrimoireDraw(); - if (CM.Config.GrimoireBar == 1 && minigame.magic < minigame.magicM) { + if (CM.Options.GrimoireBar == 1 && minigame.magic < minigame.magicM) { minigame.magicBarTextL.innerHTML += ' (' + CM.Disp.FormatTime(CM.Disp.CalculateGrimoireRefillTime(minigame.magic, minigame.magicM, minigame.magicM)) + ')'; } } @@ -4050,7 +4053,7 @@ CM.Main.CheckGoldenCookie = function() { if (CM.Main.lastGoldenCookieState) { if (CM.Main.lastSpawnedGoldenCookieState < CM.Main.currSpawnedGoldenCookieState) { CM.Disp.Flash(3, 'GCFlash'); - CM.Disp.PlaySound(CM.Config.GCSoundURL, 'GCSound', 'GCVolume'); + CM.Disp.PlaySound(CM.Options.GCSoundURL, 'GCSound', 'GCVolume'); CM.Disp.Notification('GCNotification', "Golden Cookie Spawned", "A Golden Cookie has spawned. Click it now!") } @@ -4064,7 +4067,7 @@ CM.Main.CheckGoldenCookie = function() { CM.Main.lastSpawnedGoldenCookieState = CM.Main.currSpawnedGoldenCookieState; if (CM.Main.currSpawnedGoldenCookieState == 0) CM.Cache.spawnedGoldenShimmer = 0; } - else if (CM.Config.GCTimer == 1 && CM.Main.lastGoldenCookieState) { + else if (CM.Options.GCTimer == 1 && CM.Main.lastGoldenCookieState) { for (var i in CM.Disp.GCTimers) { CM.Disp.GCTimers[i].style.opacity = CM.Cache.goldenShimmersByID[i].l.style.opacity; CM.Disp.GCTimers[i].style.transform = CM.Cache.goldenShimmersByID[i].l.style.transform; @@ -4087,7 +4090,7 @@ CM.Main.CheckSeasonPopup = function() { } } CM.Disp.Flash(3, 'SeaFlash'); - CM.Disp.PlaySound(CM.Config.SeaSoundURL, 'SeaSound', 'SeaVolume'); + CM.Disp.PlaySound(CM.Options.SeaSoundURL, 'SeaSound', 'SeaVolume'); CM.Disp.Notification('SeaNotification',"Reindeer sighted!", "A Reindeer has spawned. Click it now!") } } @@ -4101,7 +4104,7 @@ CM.Main.CheckTickerFortune = function() { CM.Main.lastTickerFortuneState = (Game.TickerEffect && Game.TickerEffect.type == 'fortune'); if (CM.Main.lastTickerFortuneState) { CM.Disp.Flash(3, 'FortuneFlash'); - CM.Disp.PlaySound(CM.Config.FortuneSoundURL, 'FortuneSound', 'FortuneVolume'); + CM.Disp.PlaySound(CM.Options.FortuneSoundURL, 'FortuneSound', 'FortuneVolume'); CM.Disp.Notification('FortuneNotification', "Fortune Cookie found", "A Fortune Cookie has appeared on the Ticker.") } } @@ -4115,7 +4118,7 @@ CM.Main.CheckGardenTick = function() { if (Game.Objects['Farm'].minigameLoaded && CM.Main.lastGardenNextStep != Game.Objects['Farm'].minigame.nextStep) { if (CM.Main.lastGardenNextStep != 0 && CM.Main.lastGardenNextStep < Date.now()) { CM.Disp.Flash(3, 'GardFlash'); - CM.Disp.PlaySound(CM.Config.GardSoundURL, 'GardSound', 'GardVolume'); + CM.Disp.PlaySound(CM.Options.GardSoundURL, 'GardSound', 'GardVolume'); } CM.Main.lastGardenNextStep = Game.Objects['Farm'].minigame.nextStep; } @@ -4126,13 +4129,13 @@ CM.Main.CheckGardenTick = function() { * It is called by CM.Loop */ CM.Main.CheckMagicMeter = function() { - if (Game.Objects['Wizard tower'].minigameLoaded && CM.Config.GrimoireBar == 1) { + if (Game.Objects['Wizard tower'].minigameLoaded && CM.Options.GrimoireBar == 1) { var minigame = Game.Objects['Wizard tower'].minigame; if (minigame.magic < minigame.magicM) CM.Main.lastMagicBarFull = false; else if (!CM.Main.lastMagicBarFull) { CM.Main.lastMagicBarFull = true; CM.Disp.Flash(3, 'MagicFlash'); - CM.Disp.PlaySound(CM.Config.MagicSoundURL, 'MagicSound', 'MagicVolume'); + CM.Disp.PlaySound(CM.Options.MagicSoundURL, 'MagicSound', 'MagicVolume'); CM.Disp.Notification('MagicNotification', "Magic Meter full", "Your Magic Meter is full. Cast a spell!") } } @@ -4150,17 +4153,17 @@ CM.Main.CheckWrinklerCount = function() { } if (CurrentWrinklers > CM.Main.lastWrinklerCount) { CM.Main.lastWrinklerCount = CurrentWrinklers - if (CurrentWrinklers == Game.getWrinklersMax() && CM.Config.WrinklerMaxFlash) { + if (CurrentWrinklers == Game.getWrinklersMax() && CM.Options.WrinklerMaxFlash) { CM.Disp.Flash(3, 'WrinklerMaxFlash'); } else { CM.Disp.Flash(3, 'WrinklerFlash'); } - if (CurrentWrinklers == Game.getWrinklersMax() && CM.Config.WrinklerMaxSound) { - CM.Disp.PlaySound(CM.Config.WrinklerMaxSoundURL, 'WrinklerMaxSound', 'WrinklerMaxVolume'); + if (CurrentWrinklers == Game.getWrinklersMax() && CM.Options.WrinklerMaxSound) { + CM.Disp.PlaySound(CM.Options.WrinklerMaxSoundURL, 'WrinklerMaxSound', 'WrinklerMaxVolume'); } else { - CM.Disp.PlaySound(CM.Config.WrinklerSoundURL, 'WrinklerSound', 'WrinklerVolume'); + CM.Disp.PlaySound(CM.Options.WrinklerSoundURL, 'WrinklerSound', 'WrinklerVolume'); } - if (CurrentWrinklers == Game.getWrinklersMax() && CM.Config.WrinklerMaxNotification) { + if (CurrentWrinklers == Game.getWrinklersMax() && CM.Options.WrinklerMaxNotification) { CM.Disp.Notification('WrinklerMaxNotification', "Maximum Wrinklers Reached", "You have reached your maximum ammount of wrinklers") } else { CM.Disp.Notification('WrinklerNotification', "A Wrinkler appeared", "A new wrinkler has appeared") @@ -4197,7 +4200,7 @@ CM.Main.AddWrinklerAreaDetect = function() { * before execution of their actual function */ CM.Main.FixMouseY = function(target) { - if (CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 0) { + if (CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 0) { var timerBarHeight = parseInt(CM.Disp.TimerBar.style.height); Game.mouseY -= timerBarHeight; target(); diff --git a/src/Cache.js b/src/Cache.js index f9dfa39..83416ad 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -86,7 +86,7 @@ CM.Cache.RemakeBuildingsPP = function() { CM.Cache.max = -1; CM.Cache.mid = -1; // Calculate PP and colors when compared to purchase of single optimal building - if (CM.Config.ColorPPBulkMode == 0) { + if (CM.Options.ColorPPBulkMode == 0) { for (var i in CM.Cache.Objects) { //CM.Cache.Objects[i].pp = Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus; if (Game.cookiesPs) { @@ -419,7 +419,7 @@ CM.Cache.UpdateAvgCPS = function() { var sortedGainWrink = new Array(); var sortedGainChoEgg = new Array(); - var cpsLength = Math.min(CM.Cache.CookiesDiff.getLength(), CM.Disp.cookieTimes[CM.Config.AvgCPSHist]); + var cpsLength = Math.min(CM.Cache.CookiesDiff.getLength(), CM.Disp.cookieTimes[CM.Options.AvgCPSHist]); // Assumes the queues are the same length for (var i = CM.Cache.CookiesDiff.getLength() - cpsLength; i < CM.Cache.CookiesDiff.getLength(); i++) { @@ -453,11 +453,11 @@ CM.Cache.UpdateAvgCPS = function() { totalGainWrink += sortedGainWrink[i]; totalGainChoEgg += sortedGainChoEgg[i]; } - CM.Cache.AvgCPS = (totalGainBank + (CM.Config.CalcWrink ? totalGainWrink : 0)) / sortedGainBank.length; + CM.Cache.AvgCPS = (totalGainBank + (CM.Options.CalcWrink ? totalGainWrink : 0)) / sortedGainBank.length; var choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')); - if (choEgg || CM.Config.CalcWrink == 0) { + if (choEgg || CM.Options.CalcWrink == 0) { CM.Cache.AvgCPSChoEgg = (totalGainBank + totalGainWrink + (choEgg ? totalGainChoEgg : 0)) / sortedGainBank.length; } else { @@ -465,7 +465,7 @@ CM.Cache.UpdateAvgCPS = function() { } var totalClicks = 0; - var clicksLength = Math.min(CM.Cache.ClicksDiff.getLength(), CM.Disp.clickTimes[CM.Config.AvgClicksHist]); + var clicksLength = Math.min(CM.Cache.ClicksDiff.getLength(), CM.Disp.clickTimes[CM.Options.AvgClicksHist]); for (var i = CM.Cache.ClicksDiff.getLength() - clicksLength; i < CM.Cache.ClicksDiff.getLength(); i++) { totalClicks += CM.Cache.ClicksDiff.get(i); } diff --git a/src/Config.js b/src/Config.js index 8438360..a4def30 100644 --- a/src/Config.js +++ b/src/Config.js @@ -9,59 +9,59 @@ * This function saves the config of CookieMonster to localStorage * It is called by CM.LoadConfig(), CM.RestoreDefault(), * any of the CM.ToggleConfig() functions and upon changes to URL or volume settings - * @param {object} config The Config to be saved (normally CM.Config) + * @param {object} config The Config to be saved (normally CM.Options) */ CM.SaveConfig = function(config) { localStorage.setItem(CM.ConfigPrefix, JSON.stringify(config)); } /** - * This function loads the config of CookieMonster saved in localStorage and loads it into CM.Config + * This function loads the config of CookieMonster saved in localStorage and loads it into CM.Options * It is called by CM.DelayInit() and CM.RestoreDefault() */ CM.LoadConfig = function() { if (localStorage.getItem(CM.ConfigPrefix) != null) { - CM.Config = JSON.parse(localStorage.getItem(CM.ConfigPrefix)); + CM.Options = JSON.parse(localStorage.getItem(CM.ConfigPrefix)); // Check values var mod = false; for (var i in CM.Data.ConfigDefault) { - if (typeof CM.Config[i] === 'undefined') { + if (typeof CM.Options[i] === 'undefined') { mod = true; - CM.Config[i] = CM.Data.ConfigDefault[i]; + CM.Options[i] = CM.Data.ConfigDefault[i]; } else if (i != 'StatsPref' && i != 'Colors') { if (i.indexOf('SoundURL') == -1) { - if (!(CM.Config[i] > -1 && CM.Config[i] < CM.ConfigData[i].label.length)) { + if (!(CM.Options[i] > -1 && CM.Options[i] < CM.ConfigData[i].label.length)) { mod = true; - CM.Config[i] = CM.Data.ConfigDefault[i]; + CM.Options[i] = CM.Data.ConfigDefault[i]; } } else { // Sound URLs - if (typeof CM.Config[i] != 'string') { + if (typeof CM.Options[i] != 'string') { mod = true; - CM.Config[i] = CM.Data.ConfigDefault[i]; + CM.Options[i] = CM.Data.ConfigDefault[i]; } } } else if (i == 'StatsPref') { for (var j in CM.Data.ConfigDefault.StatsPref) { - if (typeof CM.Config[i][j] === 'undefined' || !(CM.Config[i][j] > -1 && CM.Config[i][j] < 2)) { + if (typeof CM.Options[i][j] === 'undefined' || !(CM.Options[i][j] > -1 && CM.Options[i][j] < 2)) { mod = true; - CM.Config[i][j] = CM.Data.ConfigDefault[i][j]; + CM.Options[i][j] = CM.Data.ConfigDefault[i][j]; } } } else { // Colors for (var j in CM.Data.ConfigDefault.Colors) { - if (typeof CM.Config[i][j] === 'undefined' || typeof CM.Config[i][j] != 'string') { + if (typeof CM.Options[i][j] === 'undefined' || typeof CM.Options[i][j] != 'string') { mod = true; - CM.Config[i][j] = CM.Data.ConfigDefault[i][j]; + CM.Options[i][j] = CM.Data.ConfigDefault[i][j]; } } } } - if (mod) CM.SaveConfig(CM.Config); + if (mod) CM.SaveConfig(CM.Options); CM.Loop(); // Do loop once for (var i in CM.Data.ConfigDefault) { if (i != 'StatsPref' && i != 'OptionsPref' && typeof CM.ConfigData[i].func !== 'undefined') { @@ -79,7 +79,7 @@ CM.LoadConfig = function() { * It is called by resDefBut.onclick loaded in the options page or by CM.LoadConfig is no localStorage is found */ CM.RestoreDefault = function() { - CM.Config = {}; + CM.Options = {}; CM.SaveConfig(CM.Data.ConfigDefault); CM.LoadConfig(); Game.UpdateMenu(); @@ -97,7 +97,7 @@ CM.RestoreDefault = function() { CM.ToggleConfig = function(config) { CM.ToggleConfigUp(config); if (CM.ConfigData[config].toggle) { - if (CM.Config[config] == 0) { + if (CM.Options[config] == 0) { l(CM.ConfigPrefix + config).className = 'option off'; } else { @@ -107,15 +107,15 @@ CM.ToggleConfig = function(config) { } CM.ToggleConfigUp = function(config) { - CM.Config[config]++; - if (CM.Config[config] == CM.ConfigData[config].label.length) { - CM.Config[config] = 0; + CM.Options[config]++; + if (CM.Options[config] == CM.ConfigData[config].label.length) { + CM.Options[config] = 0; } if (typeof CM.ConfigData[config].func !== 'undefined') { CM.ConfigData[config].func(); } - l(CM.ConfigPrefix + config).innerHTML = CM.ConfigData[config].label[CM.Config[config]]; - CM.SaveConfig(CM.Config); + l(CM.ConfigPrefix + config).innerHTML = CM.ConfigData[config].label[CM.Options[config]]; + CM.SaveConfig(CM.Options); } /** @@ -126,29 +126,29 @@ CM.ToggleConfigUp = function(config) { CM.ToggleConfigVolume = function(config) { if (l("slider" + config) != null) { l("slider" + config + "right").innerHTML = l("slider" + config).value + "%"; - CM.Config[config] = Math.round(l("slider" + config).value); + CM.Options[config] = Math.round(l("slider" + config).value); } - CM.SaveConfig(CM.Config); + CM.SaveConfig(CM.Options); } CM.ToggleStatsConfig = function(config) { - if (CM.Config.StatsPref[config] == 0) { - CM.Config.StatsPref[config]++; + if (CM.Options.StatsPref[config] == 0) { + CM.Options.StatsPref[config]++; } else { - CM.Config.StatsPref[config]--; + CM.Options.StatsPref[config]--; } - CM.SaveConfig(CM.Config); + CM.SaveConfig(CM.Options); } CM.ToggleOptionsConfig = function(config) { - if (CM.Config.OptionsPref[config] == 0) { - CM.Config.OptionsPref[config]++; + if (CM.Options.OptionsPref[config] == 0) { + CM.Options.OptionsPref[config]++; } else { - CM.Config.OptionsPref[config]--; + CM.Options.OptionsPref[config]--; } - CM.SaveConfig(CM.Config); + CM.SaveConfig(CM.Options); } // Checks if the browsers has permissions to produce notifications diff --git a/src/Disp.js b/src/Disp.js index d87eac7..6d56715 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -12,11 +12,11 @@ /** * This function returns the total amount stored in the Wrinkler Bank - * as calculated by CM.Cache.RemakeWrinkBank() if CM.Config.CalcWrink is set + * as calculated by CM.Cache.RemakeWrinkBank() if CM.Options.CalcWrink is set * @returns {number} 0 or the amount of cookies stored (CM.Cache.WrinkBankTotal) */ CM.Disp.GetWrinkConfigBank = function() { - if (CM.Config.CalcWrink) + if (CM.Options.CalcWrink) return CM.Cache.WrinkBankTotal; else return 0; @@ -35,11 +35,11 @@ CM.Disp.PopAllNormalWrinklers = function() { } /** - * This function returns the cps as either current or average CPS depending on CM.Config.CPSMode + * This function returns the cps as either current or average CPS depending on CM.Options.CPSMode * @returns {number} The average or current cps */ CM.Disp.GetCPS = function() { - if (CM.Config.CPSMode) + if (CM.Options.CPSMode) return CM.Cache.AvgCPS; else return (Game.cookiesPs * (1 - Game.cpsSucked)); @@ -121,7 +121,7 @@ CM.Disp.FormatTime = function(time, longFormat) { var m = Math.floor(time % 3600 / 60); var s = Math.floor(time % 60); var str = ''; - if (CM.Config.TimeFormat) { + if (CM.Options.TimeFormat) { if (time > 3155760000) return 'XX:XX:XX:XX:XX'; str += (y < 10 ? '0' : '') + y + ':'; str += (d < 10 ? '0' : '') + d + ':'; @@ -147,7 +147,7 @@ CM.Disp.GetTimeColor = function(time) { var color; var text; if (time < 0) { - if (CM.Config.TimeFormat) text = '00:00:00:00:00'; + if (CM.Options.TimeFormat) text = '00:00:00:00:00'; else text = 'Done!'; color = CM.Disp.colorGreen; } @@ -168,8 +168,8 @@ CM.Disp.GetTimeColor = function(time) { * @returns {string} Formatted number */ CM.Disp.Beautify = function(num, frac, forced) { - var decimals = CM.Config.ScaleDecimals + 1; - if (CM.Config.Scale == 0) { + var decimals = CM.Options.ScaleDecimals + 1; + if (CM.Options.Scale == 0) { return CM.Backup.Beautify(num, frac); } else if (isFinite(num)) { @@ -187,8 +187,8 @@ CM.Disp.Beautify = function(num, frac, forced) { // TODO: Add changing separators of thousands and making this cut-off user configurable answer = Math.round(num * 100) / 100; } - else if (CM.Config.Scale == 3 && !forced || forced == 3) { // Scientific notation, 123456789 => 1.235E+8 - answer = num[0] + (CM.Config.ScaleSeparator ? ',' : '.'); + else if (CM.Options.Scale == 3 && !forced || forced == 3) { // Scientific notation, 123456789 => 1.235E+8 + answer = num[0] + (CM.Options.ScaleSeparator ? ',' : '.'); i = 0; while (i < decimals - 1) { answer += num[i + 2]; // num has a 0-based index and [1] is a '.' @@ -213,13 +213,13 @@ CM.Disp.Beautify = function(num, frac, forced) { numbersToAdd = (restOfNumber.indexOf('.') > -1 ? restOfNumber.indexOf('.') + 1 + decimals : (restOfNumber.length)) i = 0 while (i < numbersToAdd - 1 && i < restOfNumber.length - 1) { - answer += (CM.Config.ScaleSeparator && restOfNumber[i] == '.' ? ',' : restOfNumber[i]); + answer += (CM.Options.ScaleSeparator && restOfNumber[i] == '.' ? ',' : restOfNumber[i]); i++ } answer += (i + 1 < restOfNumber.length ? Math.round(restOfNumber[i] + '.' + restOfNumber[i + 1]) : restOfNumber[i]); // answer is now "xxx.xx" (e.g., 123456789 would be 123.46) - if (CM.Config.Scale == 1 && !forced || forced == 1) { // Metric scale, 123456789 => 123.457 M + if (CM.Options.Scale == 1 && !forced || forced == 1) { // Metric scale, 123456789 => 123.457 M if (timesTenToPowerThree - 1 < CM.Data.metric.length) { answer += ' ' + CM.Data.metric[timesTenToPowerThree - 1] } @@ -227,7 +227,7 @@ CM.Disp.Beautify = function(num, frac, forced) { return CM.Disp.Beautify(num, 0, 3); } } - else if (CM.Config.Scale == 2 && !forced || forced == 2) { // Short scale, 123456789 => 123.457 M + else if (CM.Options.Scale == 2 && !forced || forced == 2) { // Short scale, 123456789 => 123.457 M if (timesTenToPowerThree < CM.Data.shortScale.length + 1) { answer += ' ' + CM.Data.shortScale[timesTenToPowerThree - 1]; } @@ -235,7 +235,7 @@ CM.Disp.Beautify = function(num, frac, forced) { return CM.Disp.Beautify(num, 0, 3); } } - else if (CM.Config.Scale == 4 && !forced || forced == 4) { // Engineering notation, 123456789 => 123.457E+6 + else if (CM.Options.Scale == 4 && !forced || forced == 4) { // Engineering notation, 123456789 => 123.457E+6 answer += 'E+' + (timesTenToPowerThree * 3); } } @@ -265,8 +265,8 @@ CM.Disp.Beautify = function(num, frac, forced) { CM.Disp.UpdateAscendState = function() { if (Game.OnAscend) { l('game').style.bottom = '0px'; - if (CM.Config.BotBar == 1) CM.Disp.BotBar.style.display = 'none'; - if (CM.Config.TimerBar == 1) CM.Disp.TimerBar.style.display = 'none'; + if (CM.Options.BotBar == 1) CM.Disp.BotBar.style.display = 'none'; + if (CM.Options.TimerBar == 1) CM.Disp.TimerBar.style.display = 'none'; } else { CM.Disp.ToggleBotBar(); @@ -317,7 +317,7 @@ CM.Disp.Draw = function () { // Draw autosave timer in stats menu if ( (Game.prefs.autosave && Game.drawT % 10 == 0) && // with autosave ON and every 10 ticks - (Game.onMenu == 'stats' && CM.Config.Stats) // while being on the stats menu only + (Game.onMenu == 'stats' && CM.Options.Stats) // while being on the stats menu only ) { var timer = document.getElementById('CMStatsAutosaveTimer'); if (timer) { @@ -331,10 +331,10 @@ CM.Disp.Draw = function () { /** * This function toggle the bottom bar - * It is called by CM.Disp.UpdateAscendState() and a change in CM.Config.BotBar + * It is called by CM.Disp.UpdateAscendState() and a change in CM.Options.BotBar */ CM.Disp.ToggleBotBar = function() { - if (CM.Config.BotBar == 1) { + if (CM.Options.BotBar == 1) { CM.Disp.BotBar.style.display = ''; CM.Disp.UpdateBotBar(); } @@ -346,7 +346,7 @@ CM.Disp.ToggleBotBar = function() { /** * This function creates the bottom bar and appends it to l('wrapper') - * It is called by CM.DelayInit and a change in CM.Config.BotBar + * It is called by CM.DelayInit and a change in CM.Options.BotBar */ CM.Disp.CreateBotBar = function() { CM.Disp.BotBar = document.createElement('div'); @@ -400,7 +400,7 @@ CM.Disp.CreateBotBar = function() { * It is called by CM.Loop() */ CM.Disp.UpdateBotBar = function() { - if (CM.Config.BotBar == 1) { + if (CM.Options.BotBar == 1) { var count = 0; for (var i in CM.Cache.Objects) { var target = 'Objects'; @@ -549,7 +549,7 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { * It is called by CM.Loop() */ CM.Disp.UpdateTimerBar = function() { - if (CM.Config.TimerBar == 1) { + if (CM.Options.TimerBar == 1) { // label width: 113, timer width: 26, div margin: 20 var maxWidth = CM.Disp.TimerBar.offsetWidth - 159; var numberOfTimers = 0; @@ -624,20 +624,20 @@ CM.Disp.UpdateTimerBar = function() { /** * This function changes the visibility of the timer bar - * It is called by CM.Disp.UpdateAscendState() or a change in CM.Config.TimerBar + * It is called by CM.Disp.UpdateAscendState() or a change in CM.Options.TimerBar */ CM.Disp.ToggleTimerBar = function() { - if (CM.Config.TimerBar == 1) CM.Disp.TimerBar.style.display = ''; + if (CM.Options.TimerBar == 1) CM.Disp.TimerBar.style.display = ''; else CM.Disp.TimerBar.style.display = 'none'; CM.Disp.UpdateBotTimerBarPosition(); } /** * This function changes the position of the timer bar - * It is called by a change in CM.Config.TimerBarPos + * It is called by a change in CM.Options.TimerBarPos */ CM.Disp.ToggleTimerBarPos = function() { - if (CM.Config.TimerBarPos == 0) { + if (CM.Options.TimerBarPos == 0) { CM.Disp.TimerBar.style.width = '30%'; CM.Disp.TimerBar.style.bottom = ''; l('game').insertBefore(CM.Disp.TimerBar, l('sectionLeft')); @@ -658,22 +658,22 @@ CM.Disp.ToggleTimerBarPos = function() { * It is called by CM.Disp.ToggleTimerBar(), CM.Disp.ToggleTimerBarPos() and CM.Disp.ToggleBotBar() */ CM.Disp.UpdateBotTimerBarPosition = function() { - if (CM.Config.BotBar == 1 && CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 1) { + if (CM.Options.BotBar == 1 && CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 1) { CM.Disp.BotBar.style.bottom = '48px'; l('game').style.bottom = '118px'; } - else if (CM.Config.BotBar == 1) { + else if (CM.Options.BotBar == 1) { CM.Disp.BotBar.style.bottom = '0px'; l('game').style.bottom = '70px'; } - else if (CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 1) { + else if (CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 1) { l('game').style.bottom = '48px'; } else { // No bars l('game').style.bottom = '0px'; } - if (CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 0) { + if (CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 0) { l('sectionLeft').style.top = '48px'; } else { @@ -688,18 +688,18 @@ CM.Disp.UpdateBotTimerBarPosition = function() { /** * This function adjusts some things in the column of buildings. - * It colours them, helps display the correct sell-price and shuffles the order when CM.Config.SortBuildings is set + * It colours them, helps display the correct sell-price and shuffles the order when CM.Options.SortBuildings is set * The function is called by CM.Loop(), CM.Disp.UpdateColors() & CM.Disp.RefreshScale() - * And by changes in CM.Config.BuildColor, CM.Config.SortBuild & CM.ConfigData.BulkBuildColor + * And by changes in CM.Options.BuildColor, CM.Options.SortBuild & CM.ConfigData.BulkBuildColor */ CM.Disp.UpdateBuildings = function() { - if (CM.Config.BuildColor == 1 && Game.buyMode == 1) { + if (CM.Options.BuildColor == 1 && Game.buyMode == 1) { var target = ''; - if (Game.buyBulk == 10 && CM.Config.BulkBuildColor == 1) target = 'Objects10'; - else if (Game.buyBulk == 100 && CM.Config.BulkBuildColor == 1) target = 'Objects100'; + if (Game.buyBulk == 10 && CM.Options.BulkBuildColor == 1) target = 'Objects10'; + else if (Game.buyBulk == 100 && CM.Options.BulkBuildColor == 1) target = 'Objects100'; else target = 'Objects'; for (var i in CM.Cache[target]) { - l('productPrice' + Game.Objects[i].id).style.color = CM.Config.Colors[CM.Cache[target][i].color]; + l('productPrice' + Game.Objects[i].id).style.color = CM.Options.Colors[CM.Cache[target][i].color]; } } else if (Game.buyMode == -1) { @@ -721,7 +721,7 @@ CM.Disp.UpdateBuildings = function() { // Build array of pointers, sort by pp, use array index (+2) as the grid row number // (grid rows are 1-based indexing, and row 1 is the bulk buy/sell options) // This regulates sorting of buildings - if (Game.buyMode == 1 && CM.Config.SortBuildings) { + if (Game.buyMode == 1 && CM.Options.SortBuildings) { var arr = Object.keys(CM.Cache[target]).map(k => { var o = CM.Cache[target][k]; @@ -752,13 +752,13 @@ CM.Disp.UpdateBuildings = function() { /** * This function adjusts some things in the upgrades section - * It colours them and shuffles the order when CM.Config.SortBuildings is set + * It colours them and shuffles the order when CM.Options.SortBuildings is set * The function is called by CM.Loop(), CM.Disp.ToggleUpgradeBarAndColor & CM.Disp.RefreshScale() - * And by changes in CM.Config.SortUpgrades + * And by changes in CM.Options.SortUpgrades */ CM.Disp.UpdateUpgrades = function() { // This counts the amount of upgrades for each pp group and updates the Upgrade Bar - if (CM.Config.UpBarColor > 0) { + if (CM.Options.UpBarColor > 0) { var blue = 0; var green = 0; var yellow = 0; @@ -813,7 +813,7 @@ CM.Disp.UpdateUpgrades = function() { arr.push(o); } - if (CM.Config.SortUpgrades) + if (CM.Options.SortUpgrades) arr.sort((a, b) => a.pp - b.pp); else arr.sort((a, b) => a.price - b.price); @@ -828,14 +828,14 @@ CM.Disp.UpdateUpgrades = function() { /** * This function toggles the upgrade bar and the colours of upgrades - * It is called by a change in CM.Config.UpBarColor + * It is called by a change in CM.Options.UpBarColor */ CM.Disp.ToggleUpgradeBarAndColor = function() { - if (CM.Config.UpBarColor == 1) { // Colours and bar on + if (CM.Options.UpBarColor == 1) { // Colours and bar on CM.Disp.UpgradeBar.style.display = ''; CM.Disp.UpdateUpgrades(); } - else if (CM.Config.UpBarColor == 2) {// Colours on and bar off + else if (CM.Options.UpBarColor == 2) {// Colours on and bar off CM.Disp.UpgradeBar.style.display = 'none'; CM.Disp.UpdateUpgrades(); } @@ -847,10 +847,10 @@ CM.Disp.ToggleUpgradeBarAndColor = function() { /** * This function toggles the position of the upgrade bar from fixed or non-fixed mode - * It is called by a change in CM.Config.UpgradeBarFixedPos + * It is called by a change in CM.Options.UpgradeBarFixedPos */ CM.Disp.ToggleUpgradeBarFixedPos = function() { - if (CM.Config.UpgradeBarFixedPos == 1) { // Fix to top of screen when scrolling + if (CM.Options.UpgradeBarFixedPos == 1) { // Fix to top of screen when scrolling CM.Disp.UpgradeBar.style.position = 'sticky'; CM.Disp.UpgradeBar.style.top = '0px'; } @@ -960,10 +960,10 @@ CM.Disp.CreateWhiteScreen = function() { * that check game-events and which have settings for Flashes (e.g., Golden Cookies appearing, Magic meter being full) * @param {number} mode Sets the intensity of the flash, used to recursively dim flash * All calls of function have use mode == 3 - * @param {string} config The setting in CM.Config that is checked before creating the flash + * @param {string} config The setting in CM.Options that is checked before creating the flash */ CM.Disp.Flash = function(mode, config) { - if ((CM.Config[config] == 1 && mode == 3) || mode == 1) { + if ((CM.Options[config] == 1 && mode == 3) || mode == 1) { CM.Disp.WhiteScreen.style.opacity = '0.5'; if (mode == 3) { CM.Disp.WhiteScreen.style.display = 'inline'; @@ -983,14 +983,14 @@ CM.Disp.Flash = function(mode, config) { /** * This function plays a sound depending on configs. It is called by all functions * that check game-events and which have settings for sound (e.g., Golden Cookies appearing, Magic meter being full) - * @param {variable} url A variable that gives the url for the sound (e.g., CM.Config.GCSoundURL) - * @param {string} sndConfig The setting in CM.Config that is checked before creating the sound - * @param {string} volConfig The setting in CM.Config that is checked to determine volume + * @param {variable} url A variable that gives the url for the sound (e.g., CM.Options.GCSoundURL) + * @param {string} sndConfig The setting in CM.Options that is checked before creating the sound + * @param {string} volConfig The setting in CM.Options that is checked to determine volume */ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { - if (CM.Config[sndConfig] == 1) { + if (CM.Options[sndConfig] == 1) { var sound = new realAudio(url); - sound.volume = (CM.Config[volConfig] / 100) * (Game.volume / 100); + sound.volume = (CM.Options[volConfig] / 100) * (Game.volume / 100); sound.play(); } } @@ -998,12 +998,12 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { /** * This function creates a notifcation depending on configs. It is called by all functions * that check game-events and which have settings for notifications (e.g., Golden Cookies appearing, Magic meter being full) - * @param {string} notifyConfig The setting in CM.Config that is checked before creating the notification + * @param {string} notifyConfig The setting in CM.Options that is checked before creating the notification * @param {string} title The title of the to-be created notifications * @param {string} message The text of the to-be created notifications */ CM.Disp.Notification = function(notifyConfig, title, message) { - if (CM.Config[notifyConfig] == 1 && document.visibilityState == 'hidden') { + if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden') { var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico' notification = new Notification(title, {body: message, badge: CookieIcon}); } @@ -1025,11 +1025,11 @@ CM.Disp.CreateFavicon = function() { /** * This function updates the Favicon depending on whether a Golden Cookie has spawned - * It is called on every loop by CM.Main.CheckGoldenCookie() or by a change in CM.Config.Favicon + * It is called on every loop by CM.Main.CheckGoldenCookie() or by a change in CM.Options.Favicon * By relying on CM.Cache.spawnedGoldenShimmer it only changes for non-user spawned cookie */ CM.Disp.UpdateFavicon = function() { - if (CM.Config.Favicon == 1 && CM.Main.lastGoldenCookieState > 0) { + if (CM.Options.Favicon == 1 && CM.Main.lastGoldenCookieState > 0) { if (CM.Cache.spawnedGoldenShimmer.wrath) CM.Disp.Favicon.href = 'https://aktanusa.github.io/CookieMonster/favicon/wrathCookie.ico'; else CM.Disp.Favicon.href = 'https://aktanusa.github.io/CookieMonster/favicon/goldenCookie.ico'; } @@ -1041,10 +1041,10 @@ CM.Disp.UpdateFavicon = function() { * It is called on every loop by Game.Logic() which also sets CM.Cache.Title to Game.cookies */ CM.Disp.UpdateTitle = function() { - if (Game.OnAscend || CM.Config.Title == 0) { + if (Game.OnAscend || CM.Options.Title == 0) { document.title = CM.Cache.Title; } - else if (CM.Config.Title == 1) { + else if (CM.Options.Title == 1) { var addFC = false; var addSP = false; var titleGC; @@ -1080,7 +1080,7 @@ CM.Disp.UpdateTitle = function() { } document.title = titleGC + (addFC ? titleFC : '') + (addSP ? titleSP : '') + ' ' + str; } - else if (CM.Config.Title == 2) { + else if (CM.Options.Title == 2) { var str = ''; var spawn = false; if (CM.Cache.spawnedGoldenShimmer) { @@ -1125,7 +1125,7 @@ CM.Disp.CreateGCTimer = function(cookie) { GCTimer.style.fontSize = '35px'; GCTimer.style.cursor = 'pointer'; GCTimer.style.display = 'block'; - if (CM.Config.GCTimer == 0) GCTimer.style.display = 'none'; + if (CM.Options.GCTimer == 0) GCTimer.style.display = 'none'; GCTimer.style.left = cookie.l.style.left; GCTimer.style.top = cookie.l.style.top; GCTimer.onclick = function () {cookie.pop();}; @@ -1138,10 +1138,10 @@ CM.Disp.CreateGCTimer = function(cookie) { /** * This function toggles GC Timers are visible - * It is called by a change in CM.Config.GCTimer + * It is called by a change in CM.Options.GCTimer */ CM.Disp.ToggleGCTimer = function() { - if (CM.Config.GCTimer == 1) { + if (CM.Options.GCTimer == 1) { for (var i in CM.Disp.GCTimers) { CM.Disp.GCTimers[i].style.display = 'block'; CM.Disp.GCTimers[i].style.left = CM.Cache.goldenShimmersByID[i].l.style.left; @@ -1257,7 +1257,7 @@ CM.Disp.Tooltip = function(type, name) { if (type == 'b') { // Buildings l('tooltip').innerHTML = Game.Objects[name].tooltip(); // Adds amortization info to the list of info per building - if (CM.Config.TooltipAmor == 1) { + if (CM.Options.TooltipAmor == 1) { var buildPrice = CM.Sim.BuildingGetPrice(Game.Objects[name], Game.Objects[name].basePrice, 0, Game.Objects[name].free, Game.Objects[name].amount); var amortizeAmount = buildPrice - Game.Objects[name].totalCookies; if (amortizeAmount > 0) { @@ -1452,7 +1452,7 @@ CM.Disp.UpdateTooltip = function() { * It is called when Building tooltips are created or refreshed by CM.Disp.UpdateTooltip() */ CM.Disp.UpdateTooltipBuilding = function() { - if (CM.Config.TooltipBuildUp == 1 && Game.buyMode == 1) { + if (CM.Options.TooltipBuildUp == 1 && Game.buyMode == 1) { tooltipBox = l('CMTooltipBorder'); CM.Disp.TooltipCreateCalculationSection(tooltipBox); @@ -1467,7 +1467,7 @@ CM.Disp.UpdateTooltipBuilding = function() { CM.Disp.TooltipBonusIncome = CM.Cache[target][CM.Disp.tooltipName].bonus; - if (CM.Config.TooltipBuildUp == 1 && Game.buyMode == 1) { + if (CM.Options.TooltipBuildUp == 1 && Game.buyMode == 1) { l('CMTooltipIncome').textContent = Beautify(CM.Disp.TooltipBonusIncome, 2); var increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000); if (isFinite(increase) && increase != 0) { @@ -1512,7 +1512,7 @@ CM.Disp.UpdateTooltipUpgrade = function() { CM.Disp.TooltipBonusIncome = CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bonus; CM.Disp.TooltipPrice = Game.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].getPrice(); - if (CM.Config.TooltipBuildUp == 1) { + if (CM.Options.TooltipBuildUp == 1) { l('CMTooltipIncome').textContent = Beautify(CM.Disp.TooltipBonusIncome, 2); var increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000); if (isFinite(increase) && increase != 0) { @@ -1543,7 +1543,7 @@ CM.Disp.UpdateTooltipUpgrade = function() { * It adds to the additional information to l('CMTooltipArea') */ CM.Disp.UpdateTooltipSugarLump = function() { - if (CM.Config.TooltipLump === 1) { + if (CM.Options.TooltipLump === 1) { tooltipBox = l('CMTooltipBorder'); tooltipBox.appendChild(CM.Disp.TooltipCreateHeader('Current Sugar Lump')); @@ -1566,7 +1566,7 @@ CM.Disp.UpdateTooltipGrimoire = function() { var minigame = Game.Objects['Wizard tower'].minigame; var spellCost = minigame.getSpellCost(minigame.spellsById[CM.Disp.tooltipName]); - if (CM.Config.TooltipGrim == 1 && spellCost <= minigame.magicM) { + if (CM.Options.TooltipGrim == 1 && spellCost <= minigame.magicM) { tooltipBox = l('CMTooltipBorder'); // Time left till enough magic for spell @@ -1624,14 +1624,14 @@ CM.Disp.UpdateTooltipWarnings = function() { CM.Disp.ToggleToolWarnPos(); } - if (CM.Config.ToolWarnPos == 0) CM.Disp.TooltipWarn.style.right = '0px'; + if (CM.Options.ToolWarnPos == 0) CM.Disp.TooltipWarn.style.right = '0px'; else CM.Disp.TooltipWarn.style.top = (l('tooltip').offsetHeight) + 'px'; CM.Disp.TooltipWarn.style.width = (l('tooltip').offsetWidth - 6) + 'px'; - if (CM.Config.ToolWarnLucky == 1) { + if (CM.Options.ToolWarnLucky == 1) { var limitLucky = CM.Cache.Lucky; - if (CM.Config.ToolWarnBon == 1) { + if (CM.Options.ToolWarnBon == 1) { var bonusNoFren = CM.Disp.TooltipBonusIncome; bonusNoFren /= CM.Sim.getCPSBuffMult(); limitLucky += ((bonusNoFren * 60 * 15) / 0.15); @@ -1660,9 +1660,9 @@ CM.Disp.UpdateTooltipWarnings = function() { l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; } - if (CM.Config.ToolWarnConjure == 1) { + if (CM.Options.ToolWarnConjure == 1) { var limitLucky = CM.Cache.Lucky; - if (CM.Config.ToolWarnBon == 1) { + if (CM.Options.ToolWarnBon == 1) { var bonusNoFren = CM.Disp.TooltipBonusIncome; bonusNoFren /= CM.Sim.getCPSBuffMult(); limitLucky += ((bonusNoFren * 60 * 15) / 0.15); @@ -1694,25 +1694,25 @@ CM.Disp.UpdateTooltipWarnings = function() { CM.Disp.UpdateTooltipLocation = function() { if (Game.tooltip.origin == 'store') { var warnOffset = 0; - if (CM.Config.ToolWarnLucky == 1 && CM.Config.ToolWarnPos == 1 && typeof CM.Disp.TooltipWarn != "undefined") { + if (CM.Options.ToolWarnLucky == 1 && CM.Options.ToolWarnPos == 1 && typeof CM.Disp.TooltipWarn != "undefined") { warnOffset = CM.Disp.TooltipWarn.clientHeight - 4; } Game.tooltip.tta.style.top = Math.min(parseInt(Game.tooltip.tta.style.top), (l('game').clientHeight + l('topBar').clientHeight) - Game.tooltip.tt.clientHeight - warnOffset - 46) + 'px'; } // Kept for future possible use if the code changes again - /*else if (!Game.onCrate && !Game.OnAscend && CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 0) { + /*else if (!Game.onCrate && !Game.OnAscend && CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 0) { Game.tooltip.tta.style.top = (parseInt(Game.tooltip.tta.style.top) + parseInt(CM.Disp.TimerBar.style.height)) + 'px'; }*/ } /** * This function toggles the position of the warnings created by CM.Disp.TooltipCreateWarningSection() - * It is called by a change in CM.Config.ToolWarnPos + * It is called by a change in CM.Options.ToolWarnPos * and upon creation of the warning tooltip by CM.Disp.UpdateTooltipWarnings() */ CM.Disp.ToggleToolWarnPos = function() { if (typeof CM.Disp.TooltipWarn != "undefined") { - if (CM.Config.ToolWarnPos == 0) { + if (CM.Options.ToolWarnPos == 0) { CM.Disp.TooltipWarn.style.top = 'auto'; CM.Disp.TooltipWarn.style.margin = '4px -4px'; CM.Disp.TooltipWarn.style.padding = '3px 4px'; @@ -1731,7 +1731,7 @@ CM.Disp.ToggleToolWarnPos = function() { * TODO: Change this code to be the same as other tooltips. (i.d., create tooltip with type "w") */ CM.Disp.CheckWrinklerTooltip = function() { - if (CM.Config.ToolWrink == 1 && CM.Disp.TooltipWrinklerArea == 1) { // Latter is set by CM.Main.AddWrinklerAreaDetect + if (CM.Options.ToolWrink == 1 && CM.Disp.TooltipWrinklerArea == 1) { // Latter is set by CM.Main.AddWrinklerAreaDetect var showingTooltip = false; for (var i in Game.wrinklers) { var me = Game.wrinklers[i]; @@ -1769,7 +1769,7 @@ CM.Disp.CheckWrinklerTooltip = function() { * TODO: Change this code to be the same as other tooltips. Fit this into CM.Disp.UpdateTooltip() */ CM.Disp.UpdateWrinklerTooltip = function() { - if (CM.Config.ToolWrink == 1 && l('CMTooltipWrinkler') != null) { + if (CM.Options.ToolWrink == 1 && l('CMTooltipWrinkler') != null) { var sucked = Game.wrinklers[CM.Disp.TooltipWrinkler].sucked; var toSuck = 1.1; if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05; @@ -1795,7 +1795,7 @@ CM.Disp.UpdateWrinklerTooltip = function() { * @param {number} aura The number of the aura currently selected by the mouse/user */ CM.Disp.AddAuraInfo = function(aura) { - if (CM.Config.DragonAuraInfo == 1) { + if (CM.Options.DragonAuraInfo == 1) { var [bonusCPS, priceOfChange] = CM.Sim.CalculateChangeAura(aura); var timeToRecover = CM.Disp.FormatTime(priceOfChange / (bonusCPS + Game.cookiesPs)); var bonusCPSPercentage = CM.Disp.Beautify(bonusCPS / Game.cookiesPs); @@ -1836,18 +1836,18 @@ CM.Disp.AddMenu = function() { CM.Disp.AddMenuPref(title); } else if (Game.onMenu == 'stats') { - if (CM.Config.Stats) { + if (CM.Options.Stats) { CM.Disp.AddMenuStats(title); } } } /** - * This function refreshes the stats page, CM.Config.UpStats determines the rate at which that happens + * This function refreshes the stats page, CM.Options.UpStats determines the rate at which that happens * It is called by CM.Loop() */ 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(); + if (CM.Options.UpStats && Game.onMenu == 'stats' && (Game.drawT - 1) % (Game.fps * 5) != 0 && (Game.drawT - 1) % Game.fps == 0) Game.UpdateMenu(); } /******** @@ -1865,7 +1865,7 @@ CM.Disp.AddMenuPref = function(title) { for (var group in CM.ConfigGroups) { groupObject = CM.Disp.CreatePrefHeader(group, CM.ConfigGroups[group]) // (group, display-name of group) frag.appendChild(groupObject) - if (CM.Config.OptionsPref[group]) { // 0 is show, 1 is collapsed + if (CM.Options.OptionsPref[group]) { // 0 is show, 1 is collapsed for (var option in CM.ConfigData) { if (CM.ConfigData[option].group == group) frag.appendChild(CM.Disp.CreatePrefOption(option)) } @@ -1894,6 +1894,7 @@ CM.Disp.AddMenuPref = function(title) { CM.Disp.CreatePrefHeader = function(config, text) { var div = document.createElement('div'); div.className = 'title'; + div.style.opacity = '0.7'; div.style.fontSize = '17px'; div.appendChild(document.createTextNode(text + ' ')); @@ -1908,7 +1909,7 @@ CM.Disp.CreatePrefHeader = function(config, text) { span.style.color = 'black'; span.style.fontSize = '13px'; span.style.verticalAlign = 'middle'; - span.textContent = CM.Config.OptionsPref[config] ? '-' : '+'; + span.textContent = CM.Options.OptionsPref[config] ? '-' : '+'; span.onclick = function() {CM.ToggleOptionsConfig(config); Game.UpdateMenu();}; div.appendChild(span); return div; @@ -1925,7 +1926,7 @@ CM.Disp.CreatePrefOption = function(config) { var div = document.createElement('div'); div.className = 'listing'; var a = document.createElement('a'); - if (CM.ConfigData[config].toggle && CM.Config[config] == 0) { + if (CM.ConfigData[config].toggle && CM.Options[config] == 0) { a.className = 'option off'; } else { @@ -1933,7 +1934,7 @@ CM.Disp.CreatePrefOption = function(config) { } a.id = CM.ConfigPrefix + config; a.onclick = function() {CM.ToggleConfig(config);}; - a.textContent = CM.ConfigData[config].label[CM.Config[config]]; + a.textContent = CM.ConfigData[config].label[CM.Options[config]]; div.appendChild(a); var label = document.createElement('label'); label.textContent = CM.ConfigData[config].desc; @@ -1952,7 +1953,7 @@ CM.Disp.CreatePrefOption = function(config) { var percent = title = document.createElement('div'); percent.id = "slider" + config + "right"; percent.style.float = "right"; - percent.innerHTML = CM.Config[config] + "%"; + percent.innerHTML = CM.Options[config] + "%"; volume.appendChild(percent); var slider = document.createElement('input'); slider.className = "slider"; @@ -1962,7 +1963,7 @@ CM.Disp.CreatePrefOption = function(config) { slider.min = "0"; slider.max = "100"; slider.step = "1"; - slider.value = CM.Config[config]; + slider.value = CM.Options[config]; slider.oninput = function() {CM.ToggleConfigVolume(config)}; slider.onchange = function() {CM.ToggleConfigVolume(config)}; volume.appendChild(slider); @@ -1981,7 +1982,7 @@ CM.Disp.CreatePrefOption = function(config) { input.className = 'option'; input.type = 'text'; input.readOnly = true; - input.setAttribute('value', CM.Config[config]); + input.setAttribute('value', CM.Options[config]); input.style.width = '300px'; div.appendChild(input); div.appendChild(document.createTextNode(' ')); @@ -1989,10 +1990,10 @@ CM.Disp.CreatePrefOption = function(config) { inputPrompt.id = CM.ConfigPrefix + config + 'Prompt'; inputPrompt.className = 'option'; inputPrompt.type = 'text'; - inputPrompt.setAttribute('value', CM.Config[config]); + inputPrompt.setAttribute('value', CM.Options[config]); var a = document.createElement('a'); a.className = 'option'; - a.onclick = function() {Game.Prompt(inputPrompt.outerHTML, [['Save', 'CM.Config[\'' + config + '\'] = l(CM.ConfigPrefix + \'' + config + '\' + \'Prompt\').value; CM.SaveConfig(CM.Config); Game.ClosePrompt(); Game.UpdateMenu();'], 'Cancel']);}; + a.onclick = function() {Game.Prompt(inputPrompt.outerHTML, [['Save', 'CM.Options[\'' + config + '\'] = l(CM.ConfigPrefix + \'' + config + '\' + \'Prompt\').value; CM.SaveConfig(CM.Options); Game.ClosePrompt(); Game.UpdateMenu();'], 'Cancel']);}; a.textContent = 'Edit'; div.appendChild(a); var label = document.createElement('label'); @@ -2008,9 +2009,9 @@ CM.Disp.CreatePrefOption = function(config) { input.id = CM.ConfigPrefix + 'Color' + CM.Disp.colors[i]; input.className = 'option'; input.style.width = '65px'; - input.setAttribute('value', CM.Config.Colors[CM.Disp.colors[i]]); + input.setAttribute('value', CM.Options.Colors[CM.Disp.colors[i]]); div.appendChild(input); - eval('var change = function() {CM.Config.Colors[\'' + CM.Disp.colors[i] + '\'] = l(CM.ConfigPrefix + \'Color\' + \'' + CM.Disp.colors[i] + '\').value; CM.Disp.UpdateColors(); CM.SaveConfig(CM.Config);}'); + eval('var change = function() {CM.Options.Colors[\'' + CM.Disp.colors[i] + '\'] = l(CM.ConfigPrefix + \'Color\' + \'' + CM.Disp.colors[i] + '\').value; CM.Disp.UpdateColors(); CM.SaveConfig(CM.Options);}'); var jscolorpicker = new jscolor.color(input, {hash: true, caps: false, pickerZIndex: 1000000, pickerPosition: 'right', onImmediateChange: change}); var label = document.createElement('label'); label.textContent = CM.ConfigData.Colors.desc[CM.Disp.colors[i]]; @@ -2022,16 +2023,16 @@ CM.Disp.CreatePrefOption = function(config) { /** * This function changes some of the time-displays in the game to be more detailed - * It is called by a change in CM.Config.DetailedTime + * It is called by a change in CM.Options.DetailedTime */ CM.Disp.ToggleDetailedTime = function() { - if (CM.Config.DetailedTime == 1) Game.sayTime = CM.Disp.sayTime; + if (CM.Options.DetailedTime == 1) Game.sayTime = CM.Disp.sayTime; else Game.sayTime = CM.Backup.sayTime; } /** * This function refreshes all numbers after a change in scale-setting - * It is therefore called by a change in CM.Config.Scale and CM.Config.ScaleDecimals + * It is therefore called by a change in CM.Options.Scale and CM.Options.ScaleDecimals */ CM.Disp.RefreshScale = function() { BeautifyAll(); @@ -2045,18 +2046,18 @@ CM.Disp.RefreshScale = function() { /** * This function changes/refreshes colours if the user has set new standard colours - * The function is therefore called by a change in CM.Config.Colors + * The function is therefore called by a change in CM.Options.Colors */ CM.Disp.UpdateColors = function() { var str = ''; for (var i = 0; i < CM.Disp.colors.length; i++) { - str += '.' + CM.Disp.colorTextPre + CM.Disp.colors[i] + ' { color: ' + CM.Config.Colors[CM.Disp.colors[i]] + '; }\n'; + str += '.' + CM.Disp.colorTextPre + CM.Disp.colors[i] + ' { color: ' + CM.Options.Colors[CM.Disp.colors[i]] + '; }\n'; } for (var i = 0; i < CM.Disp.colors.length; i++) { - str += '.' + CM.Disp.colorBackPre + CM.Disp.colors[i] + ' { background-color: ' + CM.Config.Colors[CM.Disp.colors[i]] + '; }\n'; + str += '.' + CM.Disp.colorBackPre + CM.Disp.colors[i] + ' { background-color: ' + CM.Options.Colors[CM.Disp.colors[i]] + '; }\n'; } for (var i = 0; i < CM.Disp.colors.length; i++) { - str += '.' + CM.Disp.colorBorderPre + CM.Disp.colors[i] + ' { border: 1px solid ' + CM.Config.Colors[CM.Disp.colors[i]] + '; }\n'; + str += '.' + CM.Disp.colorBorderPre + CM.Disp.colors[i] + ' { border: 1px solid ' + CM.Options.Colors[CM.Disp.colors[i]] + '; }\n'; } CM.Disp.Css.textContent = str; CM.Disp.UpdateBuildings(); // Class has been already set @@ -2077,28 +2078,28 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(title()); stats.appendChild(CM.Disp.CreateStatsHeader('Lucky Cookies', 'Lucky')); - if (CM.Config.StatsPref.Lucky) { + if (CM.Options.StatsPref.Lucky) { stats.appendChild(CM.Disp.CreateStatsLuckySection()); } stats.appendChild(CM.Disp.CreateStatsHeader('Chain Cookies', 'Chain')); - if (CM.Config.StatsPref.Chain) { + if (CM.Options.StatsPref.Chain) { stats.appendChild(CM.Disp.CreateStatsChainSection()); } stats.appendChild(CM.Disp.CreateStatsHeader('Conjure Baked Goods', 'Conjure')); - if (CM.Config.StatsPref.Conjure) { + if (CM.Options.StatsPref.Conjure) { stats.appendChild(CM.Disp.CreateStatsConjureSection()); } stats.appendChild(CM.Disp.CreateStatsHeader('Prestige', 'Prestige')); - if (CM.Config.StatsPref.Prestige) { + if (CM.Options.StatsPref.Prestige) { stats.appendChild(CM.Disp.CreateStatsPrestigeSection()); } if (Game.cpsSucked > 0) { stats.appendChild(CM.Disp.CreateStatsHeader('Wrinklers', 'Wrink')); - if (CM.Config.StatsPref.Wrink) { + if (CM.Options.StatsPref.Wrink) { var popAllFrag = document.createDocumentFragment(); popAllFrag.appendChild(document.createTextNode(Beautify(CM.Cache.WrinkBankTotal) + ' / ' + Beautify(CM.Cache.WrinkBankNormal) + ' ')); var popAllA = document.createElement('a'); @@ -2152,7 +2153,7 @@ CM.Disp.AddMenuStats = function(title) { if (Game.season == 'christmas' || specDisp || choEgg || centEgg) { stats.appendChild(CM.Disp.CreateStatsHeader('Season Specials', 'Sea')); - if (CM.Config.StatsPref.Sea) { + if (CM.Options.StatsPref.Sea) { if (specDisp) { if (missingHalloweenCookies.length != 0) stats.appendChild(CM.Disp.CreateStatsListing("basic", 'Halloween Cookies Left to Buy', CM.Disp.CreateStatsMissDisp(missingHalloweenCookies))); if (missingChristmasCookies.length != 0) stats.appendChild(CM.Disp.CreateStatsListing("basic", 'Christmas Cookies Left to Buy', CM.Disp.CreateStatsMissDisp(missingChristmasCookies))); @@ -2172,12 +2173,12 @@ CM.Disp.AddMenuStats = function(title) { } stats.appendChild(CM.Disp.CreateStatsHeader('Miscellaneous', 'Misc')); - if (CM.Config.StatsPref.Misc) { + if (CM.Options.StatsPref.Misc) { stats.appendChild(CM.Disp.CreateStatsListing("basic", - 'Average Cookies Per Second (Past ' + (CM.Disp.cookieTimes[CM.Config.AvgCPSHist] < 60 ? (CM.Disp.cookieTimes[CM.Config.AvgCPSHist] + ' seconds') : ((CM.Disp.cookieTimes[CM.Config.AvgCPSHist] / 60) + (CM.Config.AvgCPSHist == 3 ? ' minute' : ' minutes'))) + ')', + '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)) )); - stats.appendChild(CM.Disp.CreateStatsListing("basic", 'Average Cookie Clicks Per Second (Past ' + CM.Disp.clickTimes[CM.Config.AvgClicksHist] + (CM.Config.AvgClicksHist == 0 ? ' second' : ' seconds') + ')', document.createTextNode(Beautify(CM.Cache.AvgClicks, 1)))); + 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.AvgClicks, 1)))); if (Game.Has('Fortune cookies')) { var fortunes = []; for (var i in CM.Data.Fortunes) { @@ -2198,7 +2199,7 @@ CM.Disp.AddMenuStats = function(title) { l('menu').insertBefore(stats, l('menu').childNodes[2]); - if (CM.Config.MissingUpgrades) { + if (CM.Options.MissingUpgrades) { CM.Disp.AddMissingUpgrades(); } } @@ -2229,7 +2230,7 @@ CM.Disp.CreateStatsHeader = function(text, config) { span.style.color = 'black'; span.style.fontSize = '13px'; span.style.verticalAlign = 'middle'; - span.textContent = CM.Config.StatsPref[config] ? '-' : '+'; + span.textContent = CM.Options.StatsPref[config] ? '-' : '+'; span.onclick = function() {CM.ToggleStatsConfig(config); Game.UpdateMenu();}; div.appendChild(span); return div; diff --git a/src/Header.js b/src/Header.js index 3731fa3..11f5e28 100644 --- a/src/Header.js +++ b/src/Header.js @@ -18,6 +18,8 @@ RunCookieMonsterHeader = function() { CM.Main = {}; + CM.Options = {}; + CM.Sim = {}; } diff --git a/src/Main.js b/src/Main.js index 20705c2..b15660c 100644 --- a/src/Main.js +++ b/src/Main.js @@ -126,7 +126,7 @@ CM.ReplaceNativeGrimoireDraw = function() { CM.Backup.GrimoireDraw = minigame.draw; Game.Objects['Wizard tower'].minigame.draw = function() { CM.Backup.GrimoireDraw(); - if (CM.Config.GrimoireBar == 1 && minigame.magic < minigame.magicM) { + if (CM.Options.GrimoireBar == 1 && minigame.magic < minigame.magicM) { minigame.magicBarTextL.innerHTML += ' (' + CM.Disp.FormatTime(CM.Disp.CalculateGrimoireRefillTime(minigame.magic, minigame.magicM, minigame.magicM)) + ')'; } } @@ -314,7 +314,7 @@ CM.Main.CheckGoldenCookie = function() { if (CM.Main.lastGoldenCookieState) { if (CM.Main.lastSpawnedGoldenCookieState < CM.Main.currSpawnedGoldenCookieState) { CM.Disp.Flash(3, 'GCFlash'); - CM.Disp.PlaySound(CM.Config.GCSoundURL, 'GCSound', 'GCVolume'); + CM.Disp.PlaySound(CM.Options.GCSoundURL, 'GCSound', 'GCVolume'); CM.Disp.Notification('GCNotification', "Golden Cookie Spawned", "A Golden Cookie has spawned. Click it now!") } @@ -328,7 +328,7 @@ CM.Main.CheckGoldenCookie = function() { CM.Main.lastSpawnedGoldenCookieState = CM.Main.currSpawnedGoldenCookieState; if (CM.Main.currSpawnedGoldenCookieState == 0) CM.Cache.spawnedGoldenShimmer = 0; } - else if (CM.Config.GCTimer == 1 && CM.Main.lastGoldenCookieState) { + else if (CM.Options.GCTimer == 1 && CM.Main.lastGoldenCookieState) { for (var i in CM.Disp.GCTimers) { CM.Disp.GCTimers[i].style.opacity = CM.Cache.goldenShimmersByID[i].l.style.opacity; CM.Disp.GCTimers[i].style.transform = CM.Cache.goldenShimmersByID[i].l.style.transform; @@ -351,7 +351,7 @@ CM.Main.CheckSeasonPopup = function() { } } CM.Disp.Flash(3, 'SeaFlash'); - CM.Disp.PlaySound(CM.Config.SeaSoundURL, 'SeaSound', 'SeaVolume'); + CM.Disp.PlaySound(CM.Options.SeaSoundURL, 'SeaSound', 'SeaVolume'); CM.Disp.Notification('SeaNotification',"Reindeer sighted!", "A Reindeer has spawned. Click it now!") } } @@ -365,7 +365,7 @@ CM.Main.CheckTickerFortune = function() { CM.Main.lastTickerFortuneState = (Game.TickerEffect && Game.TickerEffect.type == 'fortune'); if (CM.Main.lastTickerFortuneState) { CM.Disp.Flash(3, 'FortuneFlash'); - CM.Disp.PlaySound(CM.Config.FortuneSoundURL, 'FortuneSound', 'FortuneVolume'); + CM.Disp.PlaySound(CM.Options.FortuneSoundURL, 'FortuneSound', 'FortuneVolume'); CM.Disp.Notification('FortuneNotification', "Fortune Cookie found", "A Fortune Cookie has appeared on the Ticker.") } } @@ -379,7 +379,7 @@ CM.Main.CheckGardenTick = function() { if (Game.Objects['Farm'].minigameLoaded && CM.Main.lastGardenNextStep != Game.Objects['Farm'].minigame.nextStep) { if (CM.Main.lastGardenNextStep != 0 && CM.Main.lastGardenNextStep < Date.now()) { CM.Disp.Flash(3, 'GardFlash'); - CM.Disp.PlaySound(CM.Config.GardSoundURL, 'GardSound', 'GardVolume'); + CM.Disp.PlaySound(CM.Options.GardSoundURL, 'GardSound', 'GardVolume'); } CM.Main.lastGardenNextStep = Game.Objects['Farm'].minigame.nextStep; } @@ -390,13 +390,13 @@ CM.Main.CheckGardenTick = function() { * It is called by CM.Loop */ CM.Main.CheckMagicMeter = function() { - if (Game.Objects['Wizard tower'].minigameLoaded && CM.Config.GrimoireBar == 1) { + if (Game.Objects['Wizard tower'].minigameLoaded && CM.Options.GrimoireBar == 1) { var minigame = Game.Objects['Wizard tower'].minigame; if (minigame.magic < minigame.magicM) CM.Main.lastMagicBarFull = false; else if (!CM.Main.lastMagicBarFull) { CM.Main.lastMagicBarFull = true; CM.Disp.Flash(3, 'MagicFlash'); - CM.Disp.PlaySound(CM.Config.MagicSoundURL, 'MagicSound', 'MagicVolume'); + CM.Disp.PlaySound(CM.Options.MagicSoundURL, 'MagicSound', 'MagicVolume'); CM.Disp.Notification('MagicNotification', "Magic Meter full", "Your Magic Meter is full. Cast a spell!") } } @@ -414,17 +414,17 @@ CM.Main.CheckWrinklerCount = function() { } if (CurrentWrinklers > CM.Main.lastWrinklerCount) { CM.Main.lastWrinklerCount = CurrentWrinklers - if (CurrentWrinklers == Game.getWrinklersMax() && CM.Config.WrinklerMaxFlash) { + if (CurrentWrinklers == Game.getWrinklersMax() && CM.Options.WrinklerMaxFlash) { CM.Disp.Flash(3, 'WrinklerMaxFlash'); } else { CM.Disp.Flash(3, 'WrinklerFlash'); } - if (CurrentWrinklers == Game.getWrinklersMax() && CM.Config.WrinklerMaxSound) { - CM.Disp.PlaySound(CM.Config.WrinklerMaxSoundURL, 'WrinklerMaxSound', 'WrinklerMaxVolume'); + if (CurrentWrinklers == Game.getWrinklersMax() && CM.Options.WrinklerMaxSound) { + CM.Disp.PlaySound(CM.Options.WrinklerMaxSoundURL, 'WrinklerMaxSound', 'WrinklerMaxVolume'); } else { - CM.Disp.PlaySound(CM.Config.WrinklerSoundURL, 'WrinklerSound', 'WrinklerVolume'); + CM.Disp.PlaySound(CM.Options.WrinklerSoundURL, 'WrinklerSound', 'WrinklerVolume'); } - if (CurrentWrinklers == Game.getWrinklersMax() && CM.Config.WrinklerMaxNotification) { + if (CurrentWrinklers == Game.getWrinklersMax() && CM.Options.WrinklerMaxNotification) { CM.Disp.Notification('WrinklerMaxNotification', "Maximum Wrinklers Reached", "You have reached your maximum ammount of wrinklers") } else { CM.Disp.Notification('WrinklerNotification', "A Wrinkler appeared", "A new wrinkler has appeared") @@ -461,7 +461,7 @@ CM.Main.AddWrinklerAreaDetect = function() { * before execution of their actual function */ CM.Main.FixMouseY = function(target) { - if (CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 0) { + if (CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 0) { var timerBarHeight = parseInt(CM.Disp.TimerBar.style.height); Game.mouseY -= timerBarHeight; target();