Add overlay and save to building locking #763
This commit is contained in:
@@ -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';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user