Merge pull request #2635 from SillyTavern/independent-WI-disable

Split WI Entry 'disable' into separate toggle
This commit is contained in:
Cohee 2024-08-11 00:11:23 +03:00 committed by GitHub
commit 9af640cdf8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 40 additions and 41 deletions

View File

@ -120,6 +120,14 @@
flex-wrap: wrap;
}
.world_entry .inline-drawer-header {
cursor: initial;
}
.world_entry .killSwitch {
cursor: pointer;
}
.world_entry_form_control input[type=button] {
cursor: pointer;
}
@ -173,6 +181,10 @@
width: 7em;
}
.world_entry .killSwitch.fa-toggle-on {
color: var(--SmartThemeQuoteColor);
}
.wi-card-entry {
border: 1px solid;
border-color: var(--SmartThemeBorderColor);

View File

@ -5298,21 +5298,22 @@
<div class="world_entry">
<form class="world_entry_form wi-card-entry">
<div class="inline-drawer wide100p">
<div class="inline-drawer-toggle inline-drawer-header gap5px padding0">
<div class="inline-drawer-header gap5px padding0">
<span class="drag-handle">&#9776;</span>
<div class="gap5px world_entry_thin_controls wide100p alignitemscenter">
<div class="fa-fw fa-solid fa-circle-chevron-down inline-drawer-icon down"></div>
<div class="inline-drawer-toggle fa-fw fa-solid fa-circle-chevron-down inline-drawer-icon down"></div>
<div class="fa-solid fa-toggle-on killSwitch" name="entryKillSwitch" title="Toggle entry's active state."></div>
<div class="flex-container alignitemscenter wide100p">
<div class="WIEntryTitleAndStatus flex-container flex1 alignitemscenter">
<div class="flex-container flex1">
<textarea class="text_pole" rows="1" name="comment" maxlength="5000" data-i18n="[placeholder]Entry Title/Memo" placeholder="Entry Title/Memo"></textarea>
</div>
<!-- <span class="world_entry_form_position_value"></span> -->
<select data-i18n="[title]WI Entry Status:🔵 Constant🟢 Normal🔗 Vectorized❌ Disabled" title="WI Entry Status:&#13;🔵 Constant&#13;🟢 Normal&#13;🔗 Vectorized&#13;❌ Disabled" name="entryStateSelector" class="text_pole widthNatural margin0">
<option value="constant" title="Constant" data-i18n="[title]WI_Entry_Status_Constant">🔵</option>
<option value="normal" title="Normal" data-i18n="[title]WI_Entry_Status_Normal">🟢</option>
<option value="vectorized" title="Vectorized" data-i18n="[title]WI_Entry_Status_Vectorized">🔗</option>
<option value="disabled" title="Disabled" data-i18n="[title]WI_Entry_Status_Disabled"></option>
</select>
</div>
<div class="WIEnteryHeaderControls flex-container">

View File

@ -1,6 +1,6 @@
<div id="WIEntryHeaderTitlesPC" class="flex-container wide100p spaceBetween justifyCenter textAlignCenter" style="padding:0 4.5em;">
<small class="flex1" data-i18n="Title/Memo">Title/Memo</small>
<small style="width: calc(3.5em + 15px)" data-i18n="Status">Status</small>
<small style="width: calc(3.5em + 15px)" data-i18n="Strategy">Strategy</small>
<small style="width: calc(3.5em + 30px)" data-i18n="Position">Position</small>
<small style="width: calc(3.5em + 20px)" data-i18n="Depth">Depth</small>
<small style="width: calc(3.5em + 20px)" data-i18n="Order">Order</small>

View File

@ -2859,21 +2859,7 @@ async function getWorldEntry(name, data, entry) {
//add UID above content box (less important doesn't need to be always visible)
template.find('.world_entry_form_uid_value').text(`(UID: ${entry.uid})`);
// disable
/*
const disableInput = template.find('input[name="disable"]');
disableInput.data("uid", entry.uid);
disableInput.on("input", async function () {
const uid = $(this).data("uid");
const value = $(this).prop("checked");
data.entries[uid].disable = value;
setOriginalDataValue(data, uid, "enabled", !data.entries[uid].disable);
await saveWorldInfo(name, data);
});
disableInput.prop("checked", entry.disable).trigger("input");
*/
//new tri-state selector for constant/normal/disabled
//new tri-state selector for constant/normal/vectorized
const entryStateSelector = template.find('select[name="entryStateSelector"]');
entryStateSelector.data('uid', entry.uid);
entryStateSelector.on('click', function (event) {
@ -2886,49 +2872,43 @@ async function getWorldEntry(name, data, entry) {
switch (value) {
case 'constant':
data.entries[uid].constant = true;
data.entries[uid].disable = false;
data.entries[uid].vectorized = false;
setWIOriginalDataValue(data, uid, 'enabled', true);
setWIOriginalDataValue(data, uid, 'constant', true);
setWIOriginalDataValue(data, uid, 'extensions.vectorized', false);
template.removeClass('disabledWIEntry');
break;
case 'normal':
data.entries[uid].constant = false;
data.entries[uid].disable = false;
data.entries[uid].vectorized = false;
setWIOriginalDataValue(data, uid, 'enabled', true);
setWIOriginalDataValue(data, uid, 'constant', false);
setWIOriginalDataValue(data, uid, 'extensions.vectorized', false);
template.removeClass('disabledWIEntry');
break;
case 'vectorized':
data.entries[uid].constant = false;
data.entries[uid].disable = false;
data.entries[uid].vectorized = true;
setWIOriginalDataValue(data, uid, 'enabled', true);
setWIOriginalDataValue(data, uid, 'constant', false);
setWIOriginalDataValue(data, uid, 'extensions.vectorized', true);
template.removeClass('disabledWIEntry');
break;
case 'disabled':
data.entries[uid].constant = false;
data.entries[uid].disable = true;
data.entries[uid].vectorized = false;
setWIOriginalDataValue(data, uid, 'enabled', false);
setWIOriginalDataValue(data, uid, 'constant', false);
setWIOriginalDataValue(data, uid, 'extensions.vectorized', false);
template.addClass('disabledWIEntry');
break;
}
await saveWorldInfo(name, data);
});
const entryKillSwitch = template.find('div[name="entryKillSwitch"]');
entryKillSwitch.data('uid', entry.uid);
entryKillSwitch.on('click', async function (event) {
const uid = entry.uid;
data.entries[uid].disable = !data.entries[uid].disable;
const isActive = !data.entries[uid].disable;
setWIOriginalDataValue(data, uid, 'enabled', isActive);
template.toggleClass('disabledWIEntry', !isActive);
entryKillSwitch.toggleClass('fa-toggle-off', !isActive);
entryKillSwitch.toggleClass('fa-toggle-on', isActive);
await saveWorldInfo(name, data);
});
const entryState = function () {
if (entry.disable === true) {
return 'disabled';
} else if (entry.constant === true) {
if (entry.constant === true) {
return 'constant';
} else if (entry.vectorized === true) {
return 'vectorized';
@ -2936,6 +2916,12 @@ async function getWorldEntry(name, data, entry) {
return 'normal';
}
};
const isActive = !entry.disable;
template.toggleClass('disabledWIEntry', !isActive);
entryKillSwitch.toggleClass('fa-toggle-off', !isActive);
entryKillSwitch.toggleClass('fa-toggle-on', isActive);
template
.find(`select[name="entryStateSelector"] option[value=${entryState()}]`)
.prop('selected', true)