Merge pull request #2635 from SillyTavern/independent-WI-disable Split WI Entry 'disable' into separate toggle
Signed| @@ -120,6 +120,14 @@ | ||
| 120 | 120 | flex-wrap: wrap; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | +.world_entry .inline-drawer-header { | |
| 124 | + cursor: initial; | |
| 125 | +} | |
| 126 | + | |
| 127 | +.world_entry .killSwitch { | |
| 128 | + cursor: pointer; | |
| 129 | +} | |
| 130 | + | |
| 123 | 131 | .world_entry_form_control input[type=button] { |
| 124 | 132 | cursor: pointer; |
| 125 | 133 | } |
| @@ -173,6 +181,10 @@ | ||
| 173 | 181 | width: 7em; |
| 174 | 182 | } |
| 175 | 183 | |
| 184 | +.world_entry .killSwitch.fa-toggle-on { | |
| 185 | + color: var(--SmartThemeQuoteColor); | |
| 186 | +} | |
| 187 | + | |
| 176 | 188 | .wi-card-entry { |
| 177 | 189 | border: 1px solid; |
| 178 | 190 | border-color: var(--SmartThemeBorderColor); |
| @@ -5298,21 +5298,22 @@ | ||
| 5298 | 5298 | <div class="world_entry"> |
| 5299 | 5299 | <form class="world_entry_form wi-card-entry"> |
| 5300 | 5300 | <div class="inline-drawer wide100p"> |
| 5301 | 5301 | <div class="inline-drawer-toggle inline-drawer-header gap5px padding0"> |
| 5302 | 5302 | <span class="drag-handle">☰</span> |
| 5303 | 5303 | <div class="gap5px world_entry_thin_controls wide100p alignitemscenter"> |
| 5304 | 5304 | <div class="inline-drawer-toggle fa-fw fa-solid fa-circle-chevron-down inline-drawer-icon down"></div> |
| 5305 | + <div class="fa-solid fa-toggle-on killSwitch" name="entryKillSwitch" title="Toggle entry's active state."></div> | |
| 5305 | 5306 | <div class="flex-container alignitemscenter wide100p"> |
| 5307 | + | |
| 5306 | 5308 | <div class="WIEntryTitleAndStatus flex-container flex1 alignitemscenter"> |
| 5309 | + | |
| 5307 | 5310 | <div class="flex-container flex1"> |
| 5308 | 5311 | <textarea class="text_pole" rows="1" name="comment" maxlength="5000" data-i18n="[placeholder]Entry Title/Memo" placeholder="Entry Title/Memo"></textarea> |
| 5309 | 5312 | </div> |
| 5310 | - <!-- <span class="world_entry_form_position_value"></span> --> | |
| 5311 | 5313 | <select data-i18n="[title]WI Entry Status:🔵 Constant🟢 Normal🔗 Vectorized❌ Disabled" title="WI Entry Status: 🔵 Constant 🟢 Normal 🔗 Vectorized ❌ Disabled" name="entryStateSelector" class="text_pole widthNatural margin0"> |
| 5312 | 5314 | <option value="constant" title="Constant" data-i18n="[title]WI_Entry_Status_Constant">🔵</option> |
| 5313 | 5315 | <option value="normal" title="Normal" data-i18n="[title]WI_Entry_Status_Normal">🟢</option> |
| 5314 | 5316 | <option value="vectorized" title="Vectorized" data-i18n="[title]WI_Entry_Status_Vectorized">🔗</option> |
| 5315 | - <option value="disabled" title="Disabled" data-i18n="[title]WI_Entry_Status_Disabled">❌</option> | |
| 5316 | 5317 | </select> |
| 5317 | 5318 | </div> |
| 5318 | 5319 | <div class="WIEnteryHeaderControls flex-container"> |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | <div id="WIEntryHeaderTitlesPC" class="flex-container wide100p spaceBetween justifyCenter textAlignCenter" style="padding:0 4.5em;"> |
| 2 | 2 | <small class="flex1" data-i18n="Title/Memo">Title/Memo</small> |
| 3 | 3 | <small style="width: calc(3.5em + 15px)" data-i18n="StatusStrategy">StatusStrategy</small> |
| 4 | 4 | <small style="width: calc(3.5em + 30px)" data-i18n="Position">Position</small> |
| 5 | 5 | <small style="width: calc(3.5em + 20px)" data-i18n="Depth">Depth</small> |
| 6 | 6 | <small style="width: calc(3.5em + 20px)" data-i18n="Order">Order</small> |
| @@ -2859,21 +2859,7 @@ async function getWorldEntry(name, data, entry) { | ||
| 2859 | 2859 | //add UID above content box (less important doesn't need to be always visible) |
| 2860 | 2860 | template.find('.world_entry_form_uid_value').text(`(UID: ${entry.uid})`); |
| 2861 | 2861 | |
| 2862 | - // disable | |
| 2862 | + //new tri-state selector for constant/normal/vectorized | |
| 2863 | - /* | |
| 2864 | - const disableInput = template.find('input[name="disable"]'); | |
| 2865 | - disableInput.data("uid", entry.uid); | |
| 2866 | - disableInput.on("input", async function () { | |
| 2867 | - const uid = $(this).data("uid"); | |
| 2868 | - const value = $(this).prop("checked"); | |
| 2869 | - data.entries[uid].disable = value; | |
| 2870 | - setOriginalDataValue(data, uid, "enabled", !data.entries[uid].disable); | |
| 2871 | - await saveWorldInfo(name, data); | |
| 2872 | - }); | |
| 2873 | - disableInput.prop("checked", entry.disable).trigger("input"); | |
| 2874 | - */ | |
| 2875 | - | |
| 2876 | - //new tri-state selector for constant/normal/disabled | |
| 2877 | 2863 | const entryStateSelector = template.find('select[name="entryStateSelector"]'); |
| 2878 | 2864 | entryStateSelector.data('uid', entry.uid); |
| 2879 | 2865 | entryStateSelector.on('click', function (event) { |
| @@ -2886,49 +2872,43 @@ async function getWorldEntry(name, data, entry) { | ||
| 2886 | 2872 | switch (value) { |
| 2887 | 2873 | case 'constant': |
| 2888 | 2874 | data.entries[uid].constant = true; |
| 2889 | - data.entries[uid].disable = false; | |
| 2890 | 2875 | data.entries[uid].vectorized = false; |
| 2891 | - setWIOriginalDataValue(data, uid, 'enabled', true); | |
| 2892 | 2876 | setWIOriginalDataValue(data, uid, 'constant', true); |
| 2893 | 2877 | setWIOriginalDataValue(data, uid, 'extensions.vectorized', false); |
| 2894 | - template.removeClass('disabledWIEntry'); | |
| 2895 | 2878 | break; |
| 2896 | 2879 | case 'normal': |
| 2897 | 2880 | data.entries[uid].constant = false; |
| 2898 | - data.entries[uid].disable = false; | |
| 2899 | 2881 | data.entries[uid].vectorized = false; |
| 2900 | - setWIOriginalDataValue(data, uid, 'enabled', true); | |
| 2901 | 2882 | setWIOriginalDataValue(data, uid, 'constant', false); |
| 2902 | 2883 | setWIOriginalDataValue(data, uid, 'extensions.vectorized', false); |
| 2903 | - template.removeClass('disabledWIEntry'); | |
| 2904 | 2884 | break; |
| 2905 | 2885 | case 'vectorized': |
| 2906 | 2886 | data.entries[uid].constant = false; |
| 2907 | - data.entries[uid].disable = false; | |
| 2908 | 2887 | data.entries[uid].vectorized = true; |
| 2909 | - setWIOriginalDataValue(data, uid, 'enabled', true); | |
| 2910 | 2888 | setWIOriginalDataValue(data, uid, 'constant', false); |
| 2911 | 2889 | setWIOriginalDataValue(data, uid, 'extensions.vectorized', true); |
| 2912 | - template.removeClass('disabledWIEntry'); | |
| 2913 | - break; | |
| 2914 | - case 'disabled': | |
| 2915 | - data.entries[uid].constant = false; | |
| 2916 | - data.entries[uid].disable = true; | |
| 2917 | - data.entries[uid].vectorized = false; | |
| 2918 | - setWIOriginalDataValue(data, uid, 'enabled', false); | |
| 2919 | - setWIOriginalDataValue(data, uid, 'constant', false); | |
| 2920 | - setWIOriginalDataValue(data, uid, 'extensions.vectorized', false); | |
| 2921 | - template.addClass('disabledWIEntry'); | |
| 2922 | 2890 | break; |
| 2923 | 2891 | } |
| 2924 | 2892 | await saveWorldInfo(name, data); |
| 2925 | 2893 | |
| 2926 | 2894 | }); |
| 2927 | 2895 | |
| 2896 | + const entryKillSwitch = template.find('div[name="entryKillSwitch"]'); | |
| 2897 | + entryKillSwitch.data('uid', entry.uid); | |
| 2898 | + entryKillSwitch.on('click', async function (event) { | |
| 2899 | + const uid = entry.uid; | |
| 2900 | + data.entries[uid].disable = !data.entries[uid].disable; | |
| 2901 | + const isActive = !data.entries[uid].disable; | |
| 2902 | + setWIOriginalDataValue(data, uid, 'enabled', isActive); | |
| 2903 | + template.toggleClass('disabledWIEntry', !isActive); | |
| 2904 | + entryKillSwitch.toggleClass('fa-toggle-off', !isActive); | |
| 2905 | + entryKillSwitch.toggleClass('fa-toggle-on', isActive); | |
| 2906 | + await saveWorldInfo(name, data); | |
| 2907 | + | |
| 2908 | + }); | |
| 2909 | + | |
| 2928 | 2910 | const entryState = function () { |
| 2929 | 2911 | if (entry.disableconstant === true) { |
| 2930 | - return 'disabled'; | |
| 2931 | - } else if (entry.constant === true) { | |
| 2932 | 2912 | return 'constant'; |
| 2933 | 2913 | } else if (entry.vectorized === true) { |
| 2934 | 2914 | return 'vectorized'; |
| @@ -2936,6 +2916,12 @@ async function getWorldEntry(name, data, entry) { | ||
| 2936 | 2916 | return 'normal'; |
| 2937 | 2917 | } |
| 2938 | 2918 | }; |
| 2919 | + | |
| 2920 | + const isActive = !entry.disable; | |
| 2921 | + template.toggleClass('disabledWIEntry', !isActive); | |
| 2922 | + entryKillSwitch.toggleClass('fa-toggle-off', !isActive); | |
| 2923 | + entryKillSwitch.toggleClass('fa-toggle-on', isActive); | |
| 2924 | + | |
| 2939 | 2925 | template |
| 2940 | 2926 | .find(`select[name="entryStateSelector"] option[value=${entryState()}]`) |
| 2941 | 2927 | .prop('selected', true) |