removed unnecessary 'unlocked' property, changed the values so config saving is not failing the regex check

This commit is contained in:
Jack 2021-06-03 23:14:36 +01:00
parent 8f7112cb89
commit a0b8944f21
3 changed files with 21 additions and 55 deletions

View file

@ -1294,7 +1294,7 @@ let commandsCopyWordsToClipboard = {
};
let commandsMonkeyPowerLevel = {
title: "You control the power",
title: "Power mode...",
list: [
{
id: "monkeyPowerLevelOff",
@ -1302,24 +1302,24 @@ let commandsMonkeyPowerLevel = {
exec: () => UpdateConfig.setMonkeyPowerLevel("off"),
},
{
id: "monkeyPowerLevelMellow",
display: "mellow",
exec: () => UpdateConfig.setMonkeyPowerLevel("mellow"),
id: "monkeyPowerLevel1",
display: "1",
exec: () => UpdateConfig.setMonkeyPowerLevel("1"),
},
{
id: "monkeyPowerLevelHigh",
display: "high",
exec: () => UpdateConfig.setMonkeyPowerLevel("high"),
id: "monkeyPowerLevel2",
display: "2",
exec: () => UpdateConfig.setMonkeyPowerLevel("2"),
},
{
id: "monkeyPowerLevelUltra",
display: "ultra",
exec: () => UpdateConfig.setMonkeyPowerLevel("ultra"),
id: "monkeyPowerLevel3",
display: "3",
exec: () => UpdateConfig.setMonkeyPowerLevel("3"),
},
{
id: "monkeyPowerLevelOver9000",
display: "over 9000",
exec: () => UpdateConfig.setMonkeyPowerLevel(">9000"),
id: "monkeyPowerLevel4",
display: "4",
exec: () => UpdateConfig.setMonkeyPowerLevel("4"),
},
],
};
@ -2066,28 +2066,9 @@ export let defaultCommands = {
exec: (input) => {},
},
{
id: "unlockMonkeyPower",
display: "Unlock the MONKEY POWER!!",
alias: "monkeypower",
available: () => !Config.monkeyPowerUnlocked,
exec: () => {
UpdateConfig.setMonkeyPowerUnlocked(true);
},
},
{
id: "lockMonkeyPower",
display: "Lock away the Monkey Power.. Its to much!",
alias: "monkeypower",
available: () => Config.monkeyPowerUnlocked,
exec: () => {
UpdateConfig.setMonkeyPowerUnlocked(false);
},
},
{
id: "monkeyPowerLevel",
display: "Is the monkey power to much? You can tone it down.",
alias: "monkeypwrlvl",
available: () => Config.monkeyPowerUnlocked,
id: "monkeyPower",
display: "Power mode...",
alias: "powermode",
subgroup: true,
exec: () => {
current.push(commandsMonkeyPowerLevel);

View file

@ -121,8 +121,7 @@ let defaultConfig = {
customBackgroundSize: "cover",
customBackgroundFilter: [0, 1, 1, 1, 1],
customLayoutfluid: "qwerty#dvorak#colemak",
monkeyPowerUnlocked: false,
monkeyPowerLevel: ">9000",
monkeyPowerLevel: "off",
};
function isConfigKeyValid(name) {
@ -1486,19 +1485,11 @@ export function setCustomBackgroundFilter(array, nosave) {
}
export function setMonkeyPowerLevel(level, nosave) {
if (!["off", "mellow", "high", "ultra", ">9000"].includes(level))
level = "off";
if (!["off", "1", "2", "3", "4"].includes(level)) level = "off";
config.monkeyPowerLevel = level;
if (!nosave) saveToLocalStorage();
}
export function setMonkeyPowerUnlocked(val, nosave) {
if (val !== true) val = false;
config.monkeyPowerUnlocked = val;
if (val) setMonkeyPowerLevel(">9000");
if (!nosave) saveToLocalStorage();
}
export function apply(configObj) {
if (configObj == null || configObj == undefined) {
Notifications.add("Could not apply config", -1, 3);
@ -1583,7 +1574,6 @@ export function apply(configObj) {
setMode(configObj.mode, true);
setMonkey(configObj.monkey, true);
setRepeatQuotes(configObj.repeatQuotes, true);
setMonkeyPowerUnlocked(configObj.monkeyPowerUnlocked, true);
setMonkeyPowerLevel(configObj.monkeyPowerLevel, true);
LanguagePicker.setActiveGroup();

View file

@ -176,15 +176,10 @@ function randomColor() {
* @param {boolean} good Good power or not?
*/
export function addPower(good = true, extra = false) {
if (
!TestLogic.active ||
!Config.monkeyPowerUnlocked ||
Config.monkeyPowerLevel === "off"
)
return;
if (!TestLogic.active || Config.monkeyPowerLevel === "off") return;
// Shake
if (["ultra", ">9000"].includes(Config.monkeyPowerLevel)) {
if (["3", "4"].includes(Config.monkeyPowerLevel)) {
$("html").css("overflow", "hidden");
const shake = [
Math.round(shakeAmount - Math.random() * shakeAmount),
@ -210,7 +205,7 @@ export function addPower(good = true, extra = false) {
i > 0;
i--
) {
const color = ["high", ">9000"].includes(Config.monkeyPowerLevel)
const color = ["2", "4"].includes(Config.monkeyPowerLevel)
? randomColor()
: good
? ThemeColors.caret