Fixed edit prompts in settings #732

This commit is contained in:
Daniël van Noord
2021-03-28 15:07:41 +02:00
parent fb0f9c3bf3
commit 305762e797
6 changed files with 36 additions and 6 deletions

View File

@@ -9,6 +9,7 @@ module.exports = {
b64_to_utf8: 'readonly',
utf8_to_b64: 'readonly',
BeautifyAll: 'readonly',
PlaySound: 'readonly',
},
extends: ['airbnb-base', 'plugin:prettier/recommended'],
parserOptions: {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,23 @@
/* eslint-disable no-return-assign */
/** Creates a Prompt similar to the base game without some of the stuff breaking them */
export default function CookieMonsterPrompt(content, options) {
Game.promptWrapL.className = 'framed';
const str = content;
Game.promptL.innerHTML = `${str}<div class="optionBox"></div>`;
Object.keys(options).forEach((i) => {
const option = document.createElement('a');
option.id = `promptOption${i}`;
option.className = 'option';
option.onclick = function () {
PlaySound('snd/tick.mp3');
options[i][1]();
};
option.textContent = options[i][0];
Game.promptL.children[1].appendChild(option);
});
Game.promptAnchorL.style.display = 'block';
Game.darkenL.style.display = 'block';
Game.promptL.focus();
Game.promptOn = 1;
Game.UpdatePrompt();
}

View File

@@ -22,6 +22,7 @@ import RefreshScale from '../HelperFunctions/RefreshScale';
import UpdateColours from '../HelperFunctions/UpdateColours';
import Flash from '../Notifications/Flash';
import PlaySound from '../Notifications/Sound';
import CookieMonsterPrompt from './Prompt';
/**
* This function creates a header-object for the options page
@@ -147,17 +148,22 @@ function CreatePrefOption(config) {
const a = document.createElement('a');
a.className = 'option';
a.onclick = function () {
Game.Prompt(inputPrompt.outerHTML, [
CookieMonsterPrompt(inputPrompt.outerHTML, [
[
'Save',
function () {
CMOptions[`${config}`] = l(`${ConfigPrefix}${config}Prompt`).value;
CMOptions[config] = l(`${ConfigPrefix}${config}Prompt`).value;
SaveConfig();
Game.ClosePrompt();
Game.UpdateMenu();
},
],
'Cancel',
[
'Cancel',
function () {
Game.ClosePrompt();
},
],
]);
};
a.textContent = 'Edit';