Merge pull request #435 from GGodPL/main

a bunch of fixes
This commit is contained in:
slweeb 2024-03-21 19:47:24 -04:00 committed by GitHub
commit 600a56dcbc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 13 deletions

View File

@ -153,7 +153,7 @@ class MenuScreen {
/** /**
* Sets close button visibility. When false the close button will not be added to the menu screen * 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) { setShowCloseButton(show) {
this.showCloseButton = show; this.showCloseButton = show;

View File

@ -6,16 +6,19 @@ const settingType = {
SELECT: [4, null] SELECT: [4, null]
} }
class Setting { 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.tabName = null;
this.name = name; this.name = name;
this.storageName = storageName; this.storageName = storageName;
this.type = type[0]; this.type = type[0];
this.disabled = disabled; this.disabled = disabled;
this.defaultValue = defaultValue ?? type[1]; this.defaultValue = defaultValue ?? type[1];
this.description = description;
this.validate = customValidator;
} }
set(value) { set(value) {
if (!this.validate(value)) return false;
this.value = value; this.value = value;
const settings = JSON.parse(localStorage.getItem(`${this.tabName}/settings`)) ?? {}; const settings = JSON.parse(localStorage.getItem(`${this.tabName}/settings`)) ?? {};
settings[this.name] = value; settings[this.name] = value;
@ -61,7 +64,7 @@ class Setting {
const id = "betterSettings/" + this.modName + "/" + this.storageName; const id = "betterSettings/" + this.modName + "/" + this.storageName;
const span = document.createElement("span"); const span = document.createElement("span");
span.className = "setting-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 + " "; span.innerText = this.name + " ";
const element = document.createElement("input"); const element = document.createElement("input");
switch (this.type) { switch (this.type) {
@ -162,12 +165,14 @@ class SettingsTab {
if (this.categories.has(category)) this.categories.get(category).push(setting); if (this.categories.has(category)) this.categories.get(category).push(setting);
else this.categories.set(category, [setting]); else this.categories.set(category, [setting]);
this.registry.set(setting.storageName, setting); this.registry.set(setting.storageName, setting);
return this;
} }
registerSettings(category = "General", ...settings) { registerSettings(category = "General", ...settings) {
for (const setting of settings) { for (const setting of settings) {
this.registerSetting(setting, category); this.registerSetting(setting, category);
} }
return this;
} }
set(name, value) { set(name, value) {

View File

@ -257,7 +257,7 @@ if (enabledMods.includes("mods/betterMenuScreens.js")) {
// ugly way of doing it but probably works // ugly way of doing it but probably works
const checkType = (key, value) => { 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; 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 (["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; if (["name", "category", "desc", "alias", "seed", "baby", "state", "stateHigh", "stateHighName", "stateHighColor", "stateLow", "stateLowNmae", "stateLowColor"].includes(key) && typeof value != "string") return false;

View File

@ -34,18 +34,19 @@ setView = (n) => {
document.querySelector('span[setting="view"]').children[0].value = view ?? 0; document.querySelector('span[setting="view"]').children[0].value = view ?? 0;
} }
for (const i in views) { runAfterLoadList.push(() => {
for (const i in views) {
if (i < 4) continue; if (i < 4) continue;
const option = document.createElement("option"); const option = document.createElement("option");
option.setAttribute("value", i); option.setAttribute("value", i);
option.innerText = views[i]; option.innerText = views[i];
document.querySelector('.setting-span[setting="view"]').querySelector("select").appendChild(option); document.querySelector('.setting-span[setting="view"]').querySelector("select").appendChild(option);
viewKey[i] = views[i]; viewKey[i] = views[i];
} }
})
const vcrFont = new FontFace("VCR", "url(mods/VCR_OSD_MONO.ttf)"); const vcrFont = new FontFace("VCR", "url(mods/VCR_OSD_MONO.ttf)");
vcrFont.load().then(font => { vcrFont.load().then(font => {
console.log(font);
document.fonts.add(font); document.fonts.add(font);
}) })

View File

@ -89,6 +89,7 @@ elements.video = {
} }
}; };
currentVideoFrames = [];
video.currentTime = 0; video.currentTime = 0;
video.onseeked = () => { video.onseeked = () => {