Skip to content

Commit

Permalink
Merge pull request #689 from DanielNoord/update
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
DanielNoord authored Mar 17, 2021
2 parents f3b0bfa + 00edec1 commit 104159e
Show file tree
Hide file tree
Showing 14 changed files with 1,747 additions and 612 deletions.
2 changes: 1 addition & 1 deletion CookieMonster.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/CookieMonster.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/CookieMonster.js.map

Large diffs are not rendered by default.

2,239 changes: 1,643 additions & 596 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
],
"scripts": {
"copy-file": "cp dist/CookieMonster.js CookieMonster.js",
"eslint_src": "eslint src",
"build": "run-s eslint_src pack_prod remove_comment copy-file",
"build_test": "run-s pack_dev",
"pack_prod": "webpack --env production",
"pack_dev": "webpack",
"remove_comment": "sed -i '' -e '/\\/\\/# sourceMappingURL.*/d' dist/CookieMonster.js"
"eslint-src": "eslint src",
"build": "run-s eslint-src pack-prod remove-comment copy-file",
"build-test": "run-s pack-dev",
"pack-prod": "webpack --env production",
"pack-dev": "webpack",
"remove-comment": "sed -i '' -e '/\\/\\/# sourceMappingURL.*/d' dist/CookieMonster.js"
},
"repository": {
"type": "git",
Expand Down
13 changes: 13 additions & 0 deletions src/Config/Toggles/ToggleSectionHideButtons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CMOptions } from '../VariablesAndData';

/**
* This function updates the display setting of the two objects created by CM.Disp.CreateWrinklerButtons()
* It is called by changes in CM.Options.WrinklerButtons
*/
export default function ToggleSectionHideButtons() {
if (CMOptions.HideSectionsButtons) {
l('CMSectionHidButtons').style.display = '';
} else {
l('CMSectionHidButtons').style.display = 'none';
}
}
20 changes: 19 additions & 1 deletion src/Data/SettingsData.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ToggleTimerBar, ToggleTimerBarPos } from '../Config/SpecificToggles';
import ToggleBotBar from '../Config/Toggles/ToggleBotBar';
import ToggleDetailedTime from '../Config/Toggles/ToggleDetailedTime';
import ToggleGCTimer from '../Config/Toggles/ToggleGCTimer';
import ToggleSectionHideButtons from '../Config/Toggles/ToggleSectionHideButtons';
import ToggleToolWarnPos from '../Config/Toggles/ToggleToolWarnPos';
import ToggleUpgradeBarAndColor from '../Config/Toggles/ToggleUpgradeBarAndColor';
import ToggleUpgradeBarFixedPos from '../Config/Toggles/ToggleUpgradeBarFixedPos';
Expand Down Expand Up @@ -100,6 +101,13 @@ const Config = {
UpdateBuildings();
},
),
PPDisplayTime: new SettingStandard(
'bool',
'BarsColors',
['PP As Value (Standard)', 'PP As Time Unit'],
'Display PP as calculated value or as approximate time unit. Note that PP does not translate directly into a time unit and this is therefore only an approximation.',
false,
),
UpBarColor: new SettingStandard(
'bool',
'BarsColors',
Expand Down Expand Up @@ -728,13 +736,23 @@ const Config = {
WrinklerButtons: new SettingStandard(
'bool',
'Miscellaneous',
['Extra Buttons OFF', 'Extra Buttons ON'],
['Extra Wrinkler Buttons OFF', 'Extra Wrinkler Buttons ON'],
'Show buttons for popping wrinklers at bottom of cookie section',
true,
function () {
ToggleWrinklerButtons();
},
),
HideSectionsButtons: new SettingStandard(
'bool',
'Miscellaneous',
['Hide Upgrades/Buildings Button OFF', 'Hide Upgrades/Buildings Button ON'],
'Show buttons for hiding and showing the upgrades and buildings section in the right column',
true,
function () {
ToggleSectionHideButtons();
},
),
BulkBuyBlock: new SettingStandard(
'bool',
'Miscellaneous',
Expand Down
2 changes: 2 additions & 0 deletions src/Data/SettingsDefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const ConfigDefault = {
TimerBarPos: 0,
TimerBarOverlay: 2,
BuildColor: 1,
PPDisplayTime: 0,
UpBarColor: 1,
UpgradeBarFixedPos: 1,
CalcWrink: 0,
Expand Down Expand Up @@ -100,6 +101,7 @@ const ConfigDefault = {
GCTimer: 1,
Favicon: 1,
WrinklerButtons: 1,
HideSectionsButtons: 0,
BulkBuyBlock: 0,
Header: {
BarsColors: 1,
Expand Down
1 change: 1 addition & 0 deletions src/Disp/BeautifyAndFormatting/BeautifyFormatting.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export function Beautify(num, floats, forced) {
export function FormatTime(time, longFormat) {
let formattedTime = time;
if (time === Infinity) return time;
if (time < 0) return 'Negative time period';
formattedTime = Math.ceil(time);
const y = Math.floor(formattedTime / 31557600);
const d = Math.floor((formattedTime % 31557600) / 86400);
Expand Down
7 changes: 6 additions & 1 deletion src/Disp/InfoBars/BottomBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CMOptions } from '../../Config/VariablesAndData';
import { VersionMajor, VersionMinor } from '../../Data/Moddata';
import {
Beautify,
FormatTime,
GetTimeColor,
} from '../BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../HelperFunctions/GetCPS';
Expand Down Expand Up @@ -94,9 +95,13 @@ export function UpdateBotBar() {
l('CMBotBar').firstChild.firstChild.childNodes[2].childNodes[
count
].className = ColorTextPre + target[i].color;
let PPString;
if (CMOptions.PPDisplayTime)
PPString = FormatTime(Math.round(target[i].pp));
else PPString = Beautify(Math.round(target[i].pp), 2);
l('CMBotBar').firstChild.firstChild.childNodes[2].childNodes[
count
].textContent = Beautify(Math.round(target[i].pp), 2);
].textContent = PPString;
const timeColor = GetTimeColor(
(Game.Objects[i].bulkPrice - (Game.cookies + GetWrinkConfigBank())) /
GetCPS(),
Expand Down
38 changes: 38 additions & 0 deletions src/Disp/Initialization/CreateSectionHideButtons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* This function creates two objects at the top of the right column that allowing hiding the upgrade and building section
*/
export default function CreateSectionHideButtons() {
const div = document.createElement('div');
div.id = 'CMSectionHidButtons';
div.style.textAlign = 'center';
const a = document.createElement('a');
a.className = 'option';
a.onclick = function () {
if (l('upgrades').style.display === 'flex') {
l('upgrades').style.display = 'none';
l('toggleUpgrades').style.display = 'none';
l('techUpgrades').style.display = 'none';
l('vaultUpgrades').style.display = 'none';
} else {
l('upgrades').style.display = 'flex';
if (l('toggleUpgrades').children.length !== 0)
l('toggleUpgrades').style.display = 'block';
if (l('techUpgrades').children.length !== 0)
l('techUpgrades').style.display = 'block';
if (l('vaultUpgrades').children.length !== 0)
l('vaultUpgrades').style.display = 'block';
}
};
a.textContent = 'Hide/Show Upgrades';
div.appendChild(a);
const b = document.createElement('a');
b.className = 'option';
b.onclick = function () {
if (l('products').style.display === 'grid')
l('products').style.display = 'none';
else l('products').style.display = 'grid';
};
b.textContent = 'Hide/Show Buildings';
div.appendChild(b);
l('store').insertBefore(div, l('store').childNodes[2]);
}
5 changes: 4 additions & 1 deletion src/Disp/Tooltips/TypesOfTooltips/Building.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { CMOptions } from '../../../Config/VariablesAndData';
import { SimObjects } from '../../../Sim/VariablesAndData';
import {
Beautify,
FormatTime,
GetTimeColor,
} from '../../BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../../HelperFunctions/GetCPS';
Expand Down Expand Up @@ -55,7 +56,9 @@ export default function Building() {
}01% of income)`;
}
l('CMTooltipBorder').className = ColorTextPre + target[TooltipName].color;
l('CMTooltipPP').textContent = Beautify(target[TooltipName].pp, 2);
if (CMOptions.PPDisplayTime)
l('CMTooltipPP').textContent = FormatTime(target[TooltipName].pp);
else l('CMTooltipPP').textContent = Beautify(target[TooltipName].pp, 2);
l('CMTooltipPP').className = ColorTextPre + target[TooltipName].color;
const timeColor = GetTimeColor(
(TooltipPrice - (Game.cookies + GetWrinkConfigBank())) / GetCPS(),
Expand Down
14 changes: 10 additions & 4 deletions src/Disp/Tooltips/TypesOfTooltips/Upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
import { CMOptions } from '../../../Config/VariablesAndData';
import {
Beautify,
FormatTime,
GetTimeColor,
} from '../../BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../../HelperFunctions/GetCPS';
Expand Down Expand Up @@ -70,10 +71,15 @@ export default function Upgrade() {
)} Clicks`;
l('CMTooltipPP').style.color = 'white';
} else {
l('CMTooltipPP').textContent = Beautify(
CacheUpgrades[Game.UpgradesInStore[TooltipName].name].pp,
2,
);
if (CMOptions.PPDisplayTime)
l('CMTooltipPP').textContent = FormatTime(
CacheUpgrades[Game.UpgradesInStore[TooltipName].name].pp,
);
else
l('CMTooltipPP').textContent = Beautify(
CacheUpgrades[Game.UpgradesInStore[TooltipName].name].pp,
2,
);
l('CMTooltipPP').className =
ColorTextPre +
CacheUpgrades[Game.UpgradesInStore[TooltipName].name].color;
Expand Down
2 changes: 2 additions & 0 deletions src/Main/Initialization.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { VersionMajor, VersionMinor } from '../Data/Moddata';
import CreateUpgradeBar from '../Disp/BuildingsUpgrades/UpgradeBar';
import { CreateBotBar } from '../Disp/InfoBars/BottomBar';
import { CreateTimerBar } from '../Disp/InfoBars/TimerBar';
import CreateSectionHideButtons from '../Disp/Initialization/CreateSectionHideButtons';
import CreateWrinklerButtons from '../Disp/Initialization/CreateWrinklerButton';
import CreateCssArea from '../Disp/Initialization/CssArea';
import UpdateBuildingUpgradeStyle from '../Disp/Initialization/UpdateBuildingUpgradeStyle';
Expand Down Expand Up @@ -37,6 +38,7 @@ export default function InitializeCookieMonster() {
CreateTimerBar();
CreateUpgradeBar();
CreateWhiteScreen();
CreateSectionHideButtons();
CreateFavicon();
Object.keys(TooltipText).forEach((i) => {
CreateSimpleTooltip(
Expand Down

0 comments on commit 104159e

Please sign in to comment.