From fce021ce0267709385d1aba2c0c81442078da792 Mon Sep 17 00:00:00 2001
From: RossAscends <124905043+RossAscends@users.noreply.github.com>
Date: Mon, 1 May 2023 06:10:33 +0900
Subject: [PATCH] toggle to disable world Info entries
---
public/index.html | 7 +++++++
public/scripts/world-info.js | 28 +++++++++++++++++++++++-----
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/public/index.html b/public/index.html
index 4470c3f52..5c2516511 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1870,6 +1870,7 @@
+
UID:
@@ -1882,6 +1883,12 @@
0
+
+
+
diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js
index 34b49cbe8..344714590 100644
--- a/public/scripts/world-info.js
+++ b/public/scripts/world-info.js
@@ -240,6 +240,7 @@ function appendWorldEntry(entry) {
$(this).siblings("input").click();
});
+
// constant
const constantInput = template.find('input[name="constant"]');
constantInput.data("uid", entry.uid);
@@ -287,6 +288,21 @@ function appendWorldEntry(entry) {
// display uid
template.find(".world_entry_form_uid_value").html(entry.uid);
+ // disable
+ const disableInput = template.find('input[name="disable"]');
+ disableInput.data("uid", entry.uid);
+ disableInput.on("input", function () {
+ const uid = $(this).data("uid");
+ const value = $(this).prop("checked");
+ world_info_data.entries[uid].disable = value;
+ saveWorldInfo();
+ console.log(`WI #${entry.uid} disabled? ${world_info_data.entries[uid].disable}`);
+ });
+ disableInput.prop("checked", entry.disable).trigger("input");
+ disableInput.siblings(".checkbox_fancy").click(function () {
+ $(this).siblings("input").click();
+ });
+
// delete button
const deleteButton = template.find("input.delete_entry_button");
deleteButton.data("uid", entry.uid);
@@ -319,6 +335,7 @@ function createWorldInfoEntry() {
selective: false,
order: 100,
position: 0,
+ disable: false,
};
const newUid = getFreeWorldEntryUid();
@@ -351,7 +368,7 @@ async function saveWorldInfo(immediately) {
if (immediately) {
return await _save();
}
-
+
saveWorldDebounced();
}
@@ -458,19 +475,20 @@ function checkWorldInfo(chat) {
const sortedEntries = Object.keys(world_info_data.entries)
.map((x) => world_info_data.entries[x])
.sort((a, b) => b.order - a.order);
+
while (needsToScan) {
let activatedNow = new Set();
for (let entry of sortedEntries) {
- if (allActivatedEntries.has(entry.uid)) {
+ if (allActivatedEntries.has(entry.uid) && entry.disable == false) {
continue;
}
- if (entry.constant) {
+ if (entry.constant && entry.disable == false) {
activatedNow.add(entry.uid);
}
- if (Array.isArray(entry.key) && entry.key.length) {
+ if (Array.isArray(entry.key) && entry.key.length && entry.disable == false) {
primary: for (let key of entry.key) {
if (key && textToScan.includes(key.trim().toLowerCase())) {
if (
@@ -616,7 +634,7 @@ $(document).ready(() => {
});
$("#world_popup_delete").click(() => {
- callPopup("Delete the World Info?
", "del_world");
+ callPopup("Delete the World Info?
", "del_world");
});
$("#world_popup_new").click(() => {