diff --git a/mods/betterMenuScreens.js b/mods/betterMenuScreens.js index dc18861c..d150d814 100644 --- a/mods/betterMenuScreens.js +++ b/mods/betterMenuScreens.js @@ -153,7 +153,7 @@ class MenuScreen { /** * Sets close button visibility. When false the close button will not be added to the menu screen - * @param {boolean} show Visibility of the close button + * @param {boolean} show Visibility of the close g button */ setShowCloseButton(show) { this.showCloseButton = show; diff --git a/mods/betterSettings.js b/mods/betterSettings.js index 811946a7..bb213cc0 100644 --- a/mods/betterSettings.js +++ b/mods/betterSettings.js @@ -6,16 +6,19 @@ const settingType = { SELECT: [4, null] } class Setting { - constructor (name, storageName, type, disabled = false, defaultValue = null) { + constructor (name, storageName, type, disabled = false, defaultValue = null, description = "", customValidator = () => true) { this.tabName = null; this.name = name; this.storageName = storageName; this.type = type[0]; this.disabled = disabled; this.defaultValue = defaultValue ?? type[1]; + this.description = description; + this.validate = customValidator; } set(value) { + if (!this.validate(value)) return false; this.value = value; const settings = JSON.parse(localStorage.getItem(`${this.tabName}/settings`)) ?? {}; settings[this.name] = value; @@ -61,7 +64,7 @@ class Setting { const id = "betterSettings/" + this.modName + "/" + this.storageName; const span = document.createElement("span"); span.className = "setting-span"; - span.title = 'Default: "' + this.defaultValue + '"' + (this.disabled ? ". This setting is disabled." : ""); + span.title = 'Default: "' + this.defaultValue + '"' + (this.disabled ? ". This setting is disabled" : "") + (this.description ? `. ${this.description}` : ""); span.innerText = this.name + " "; const element = document.createElement("input"); switch (this.type) { @@ -162,12 +165,14 @@ class SettingsTab { if (this.categories.has(category)) this.categories.get(category).push(setting); else this.categories.set(category, [setting]); this.registry.set(setting.storageName, setting); + return this; } registerSettings(category = "General", ...settings) { for (const setting of settings) { this.registerSetting(setting, category); } + return this; } set(name, value) { diff --git a/mods/elementsManager.js b/mods/elementsManager.js index 74cdbee9..23ac1dd0 100644 --- a/mods/elementsManager.js +++ b/mods/elementsManager.js @@ -257,7 +257,7 @@ if (enabledMods.includes("mods/betterMenuScreens.js")) { // ugly way of doing it but probably works const checkType = (key, value) => { - if (key == "behavior" && (typeof value == "function" || (value instanceof Array && value.filter(e => e instanceof Array && e.filter(s => typeof s == "string").length == e.length).length == value.length))) return true; + if (key == "behavior" && (typeof value == "function" || (value instanceof Array && value.filter(e => typeof e == "string").length == value.length))) return true; else if (key == "behavior") return false; if (["darkText", "hidden", "insulate", "noMix", "isFood", "forceAutoGen", "customColor", "ignoreAir", "excludeRandom", "burning", "flipX", "flipY", "flippableX", "flippableY"].includes(key) && typeof value != "boolean") return false; if (["name", "category", "desc", "alias", "seed", "baby", "state", "stateHigh", "stateHighName", "stateHighColor", "stateLow", "stateLowNmae", "stateLowColor"].includes(key) && typeof value != "string") return false; diff --git a/mods/moreViews.js b/mods/moreViews.js index 1d874d60..c2c18f67 100644 --- a/mods/moreViews.js +++ b/mods/moreViews.js @@ -34,18 +34,19 @@ setView = (n) => { document.querySelector('span[setting="view"]').children[0].value = view ?? 0; } -for (const i in views) { - if (i < 4) continue; - const option = document.createElement("option"); - option.setAttribute("value", i); - option.innerText = views[i]; - document.querySelector('.setting-span[setting="view"]').querySelector("select").appendChild(option); - viewKey[i] = views[i]; -} +runAfterLoadList.push(() => { + for (const i in views) { + if (i < 4) continue; + const option = document.createElement("option"); + option.setAttribute("value", i); + option.innerText = views[i]; + document.querySelector('.setting-span[setting="view"]').querySelector("select").appendChild(option); + viewKey[i] = views[i]; + } +}) const vcrFont = new FontFace("VCR", "url(mods/VCR_OSD_MONO.ttf)"); vcrFont.load().then(font => { - console.log(font); document.fonts.add(font); }) diff --git a/mods/video.js b/mods/video.js index ce21ee24..2a75e490 100644 --- a/mods/video.js +++ b/mods/video.js @@ -89,6 +89,7 @@ elements.video = { } }; + currentVideoFrames = []; video.currentTime = 0; video.onseeked = () => {