Add overlay and save to building locking #763
This commit is contained in:
2
dist/CookieMonsterDev.js
vendored
2
dist/CookieMonsterDev.js
vendored
File diff suppressed because one or more lines are too long
2
dist/CookieMonsterDev.js.map
vendored
2
dist/CookieMonsterDev.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* This function toggle the locked state of a building
|
||||
* @param {number} index Index of the row to change
|
||||
*/
|
||||
export default function ToggleBuildingLock(index) {
|
||||
if (l(`productLock${index}`).innerHTML === 'Unlocked') {
|
||||
l(`productLock${index}`).innerHTML = 'Locked';
|
||||
l(`row${index}`).children[3].style.pointerEvents = 'none';
|
||||
} else {
|
||||
l(`productLock${index}`).innerHTML = 'Unlocked';
|
||||
l(`row${index}`).children[3].style.pointerEvents = 'auto';
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
import ToggleBuildingLock from './ToggleBuildingLock';
|
||||
import toggleBuildingLock from './toggleBuildingLock';
|
||||
|
||||
/**
|
||||
* This function adds a lock button to the "building view" in the middle section
|
||||
*/
|
||||
export default function CreateBuildingLockButtons() {
|
||||
export default function createBuildingLockButtons() {
|
||||
Object.keys(l('rows').children).forEach((index) => {
|
||||
const productButtons = l('rows').children[index].children[1];
|
||||
const button = document.createElement('div');
|
||||
button.id = `productLock${Number(index) + 1}`;
|
||||
button.className = 'productButton';
|
||||
button.innerHTML = 'Unlocked';
|
||||
button.innerHTML = 'Lock';
|
||||
button.onclick = function () {
|
||||
ToggleBuildingLock(Number(index) + 1);
|
||||
toggleBuildingLock(Number(index) + 1);
|
||||
};
|
||||
productButtons.appendChild(button);
|
||||
});
|
||||
23
src/Disp/buildingTiles/toggleBuildingLock.js
Normal file
23
src/Disp/buildingTiles/toggleBuildingLock.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* This function toggle the locked state of a building
|
||||
* @param {number} index Index of the row to change
|
||||
*/
|
||||
export default function toggleBuildingLock(index) {
|
||||
if (l(`productLock${index}`).innerHTML === 'Lock') {
|
||||
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.lockedMinigames.push(
|
||||
index.toString(),
|
||||
);
|
||||
l(`row${index}`).style.pointerEvents = 'none';
|
||||
l(`row${index}`).style.opacity = '0.4';
|
||||
l(`productLock${index}`).innerHTML = 'Unlock';
|
||||
l(`productLock${index}`).style.pointerEvents = 'auto';
|
||||
} else {
|
||||
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.lockedMinigames =
|
||||
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.lockedMinigames.filter(
|
||||
(value) => value !== index.toString(),
|
||||
);
|
||||
l(`productLock${index}`).innerHTML = 'Lock';
|
||||
l(`row${index}`).style.pointerEvents = 'auto';
|
||||
l(`row${index}`).style.opacity = '1';
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,27 @@ export default function load(str) {
|
||||
|
||||
// Load saveData
|
||||
saveAndLoadingFunctions.loadMod('cookieMonsterMod', str, settings, headers, CMLoopHook);
|
||||
if (
|
||||
typeof Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.lockedMinigames ===
|
||||
'undefined'
|
||||
) {
|
||||
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.lockedMinigames = [];
|
||||
}
|
||||
|
||||
// Update display
|
||||
// Update display with colours and locking of minigames
|
||||
UpdateColours();
|
||||
for (
|
||||
let index = 0;
|
||||
index < Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.lockedMinigames.length;
|
||||
index++
|
||||
) {
|
||||
const buildingIndex =
|
||||
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.lockedMinigames[index];
|
||||
l(`row${buildingIndex}`).style.pointerEvents = 'none';
|
||||
l(`row${buildingIndex}`).style.opacity = '0.4';
|
||||
l(`productLock${buildingIndex}`).innerHTML = 'Unlock';
|
||||
l(`productLock${buildingIndex}`).style.pointerEvents = 'auto';
|
||||
}
|
||||
|
||||
// Notify of update
|
||||
if (
|
||||
|
||||
@@ -17,7 +17,7 @@ import ReplaceTooltips from './ReplaceGameElements/Tooltips';
|
||||
import ReplaceNative from './ReplaceGameFunctions/ReplaceNative';
|
||||
import { LastModCount } from './VariablesAndData'; // eslint-disable-line no-unused-vars
|
||||
import AddWrinklerAreaDetect from './WrinklerArea/AddDetectArea';
|
||||
import CreateBuildingLockButtons from '../Disp/Buildings/CreateBuildingLockButtons';
|
||||
import createBuildingLockButtons from '../Disp/buildingTiles/createBuildingLockButtons';
|
||||
import createMenuInfo from '../Disp/MenuSections/createMenuInfo';
|
||||
import createMenuOptions from '../Disp/MenuSections/createMenuOptions';
|
||||
|
||||
@@ -51,7 +51,7 @@ export default function InitializeCookieMonster() {
|
||||
});
|
||||
CreateWrinklerButtons();
|
||||
UpdateBuildingUpgradeStyle();
|
||||
CreateBuildingLockButtons();
|
||||
createBuildingLockButtons();
|
||||
|
||||
ReplaceTooltips();
|
||||
AddWrinklerAreaDetect();
|
||||
|
||||
Reference in New Issue
Block a user