Merge pull request #2521 from SillyTavern/char-action-popups Update most char submenu popups to new popup
Signed| @@ -5123,23 +5123,6 @@ | ||
| 5123 | 5123 | </div> |
| 5124 | 5124 | </div> |
| 5125 | 5125 | <!-- templates for JS to reuse when needed --> |
| 5126 | - <div id="scenario_override_template" class="template_element"> | |
| 5127 | - <div class="scenario_override range-block flexFlowColumn flex-container"> | |
| 5128 | - <div class="range-block-title title_restorable"> | |
| 5129 | - <h3><span data-i18n="Chat Scenario Override" class="margin0">Chat Scenario Override</span></h3> | |
| 5130 | - <div title="Remove" data-i18n="[title]Remove" class="menu_button fa-solid fa-trash-can remove_scenario_override"></div> | |
| 5131 | - </div> | |
| 5132 | - <div class="range-block-counter justifyLeft flex-container flexFlowColumn"> | |
| 5133 | - <strong>Unique to this chat.</strong> | |
| 5134 | - <span data-group="true">All group members will use the following scenario text instead of what is specified in their character cards.</span> | |
| 5135 | - <span data-character="true">The following scenario text will be used instead of the value set in the character card.</span> | |
| 5136 | - Checkpoints inherit the scenario override from their parent, and can be changed individually after that. | |
| 5137 | - </div> | |
| 5138 | - <div class="range-block-range wide100p"> | |
| 5139 | - <textarea class="wide100p chat_scenario" class="text_pole" rows="15" data-i18n="[placeholder]Type here..." placeholder="Type here..."></textarea> | |
| 5140 | - </div> | |
| 5141 | - </div> | |
| 5142 | - </div> | |
| 5143 | 5126 | <div id="chat_world_template" class="template_element"> |
| 5144 | 5127 | <div class="chat_world range-block flexFlowColumn flex-container"> |
| 5145 | 5128 | <div class="range-block-title"> |
| @@ -7184,20 +7184,23 @@ function updateFavButtonState(state) { | ||
| 7184 | 7184 | $('#favorite_button').toggleClass('fav_off', !fav_ch_checked); |
| 7185 | 7185 | } |
| 7186 | 7186 | |
| 7187 | 7187 | export async function setScenarioOverride() { |
| 7188 | 7188 | if (!selected_group && !this_chid) { |
| 7189 | 7189 | console.warn('setScenarioOverride() -- no selected group or character'); |
| 7190 | 7190 | return; |
| 7191 | 7191 | } |
| 7192 | 7192 | |
| 7193 | - const template = $('#scenario_override_template .scenario_override').clone(); | |
| 7194 | 7193 | const metadataValue = chat_metadata['scenario'] || ''; |
| 7195 | 7194 | const isGroup = !!selected_group; |
| 7196 | - template.find('[data-group="true"]').toggle(isGroup); | |
| 7195 | + | |
| 7197 | - template.find('[data-character="true"]').toggle(!isGroup); | |
| 7196 | + const $template = $(await renderTemplateAsync('scenarioOverride')); | |
| 7198 | - template.find('.chat_scenario').val(metadataValue).on('input', onScenarioOverrideInput); | |
| 7197 | + $template.find('[data-group="true"]').toggle(isGroup); | |
| 7199 | 7198 | $template.find('.remove_scenario_override[data-character="true"]').ontoggle('click', onScenarioOverrideRemoveClick!isGroup); |
| 7200 | - callPopup(template, 'text'); | |
| 7199 | + // TODO: Why does this save on every character input? Save on popup close | |
| 7200 | + $template.find('.chat_scenario').val(metadataValue).on('input', onScenarioOverrideInput); | |
| 7201 | + $template.find('.remove_scenario_override').on('click', onScenarioOverrideRemoveClick); | |
| 7202 | + | |
| 7203 | + await callGenericPopup($template, POPUP_TYPE.TEXT, ''); | |
| 7201 | 7204 | } |
| 7202 | 7205 | |
| 7203 | 7206 | function onScenarioOverrideInput() { |
| @@ -10653,7 +10656,7 @@ jQuery(async function () { | ||
| 10653 | 10656 | openCharacterWorldPopup(); |
| 10654 | 10657 | break; |
| 10655 | 10658 | case 'set_chat_scenario': |
| 10656 | 10659 | await setScenarioOverride(); |
| 10657 | 10660 | break; |
| 10658 | 10661 | case 'renameCharButton': |
| 10659 | 10662 | renameCharacter(); |
| @@ -10674,7 +10677,7 @@ jQuery(async function () { | ||
| 10674 | 10677 | const source = getCharacterSource(this_chid); |
| 10675 | 10678 | if (source && isValidUrl(source)) { |
| 10676 | 10679 | const url = new URL(source); |
| 10677 | 10680 | const confirm = await callPopupPopup.show.confirm(`'Open Source', `<span>Do you want to open the link to ${url.hostname} in a new tab?</span><var>${url}</var>`, 'confirm'); |
| 10678 | 10681 | if (confirm) { |
| 10679 | 10682 | window.open(source, '_blank'); |
| 10680 | 10683 | } |
| @@ -10683,7 +10686,7 @@ jQuery(async function () { | ||
| 10683 | 10686 | } |
| 10684 | 10687 | } break; |
| 10685 | 10688 | case 'replace_update': { |
| 10686 | 10689 | const confirm = await callPopupPopup.show.confirm('Replace Character', '<p><b>Choose a new character card to replace this character with.</b></p><p>All chats, assets and group memberships will be preserved, but local changes to the character data will be lost.<br /p><p>Proceed?</p>', 'confirm', ''); |
| 10687 | 10690 | if (confirm) { |
| 10688 | 10691 | async function uploadReplacementCard(e) { |
| 10689 | 10692 | const file = e.target.files[0]; |
| @@ -395,19 +395,16 @@ export async function convertCharacterToPersona(characterId = null) { | ||
| 395 | 395 | const overwriteName = `${name} (Persona).png`; |
| 396 | 396 | |
| 397 | 397 | if (overwriteName in power_user.personas) { |
| 398 | 398 | const confirmationconfirm = await callPopupPopup.show.confirm('Overwrite Existing Persona', 'This character exists as a persona already. AreDo you sure want to overwrite it?', 'confirm', '', { okButton: 'Yes' }); |
| 399 | - | |
| 399 | + if (!confirm) { | |
| 400 | - if (confirmation === false) { | |
| 401 | 400 | console.log('User cancelled the overwrite of the persona'); |
| 402 | 401 | return; |
| 403 | 402 | } |
| 404 | 403 | } |
| 405 | 404 | |
| 406 | 405 | if (description.includes('{{char}}') || description.includes('{{user}}')) { |
| 407 | - await delay(500); | |
| 406 | + const confirm = await Popup.show.confirm('Persona Description Macros', 'This character has a description that uses <code>{{char}}</code> or <code>{{user}}</code> macros. Do you want to swap them in the persona description?'); | |
| 408 | - const confirmation = await callPopup('This character has a description that uses {{char}} or {{user}} macros. Do you want to swap them in the persona description?', 'confirm', '', { okButton: 'Yes' }); | |
| 407 | + if (confirm) { | |
| 409 | - | |
| 410 | - if (confirmation) { | |
| 411 | 408 | description = description.replace(/{{char}}/gi, '{{personaChar}}').replace(/{{user}}/gi, '{{personaUser}}'); |
| 412 | 409 | description = description.replace(/{{personaUser}}/gi, '{{char}}').replace(/{{personaChar}}/gi, '{{user}}'); |
| 413 | 410 | } |
| @@ -0,0 +1,17 @@ | ||
| 1 | +<div class="scenario_override range-block flexFlowColumn flex-container"> | |
| 2 | + <div class="range-block-title title_restorable"> | |
| 3 | + <h3><span data-i18n="Chat Scenario Override" class="margin0">Chat Scenario Override</span></h3> | |
| 4 | + <div title="Remove" data-i18n="[title]Remove" | |
| 5 | + class="menu_button fa-solid fa-trash-can remove_scenario_override"></div> | |
| 6 | + </div> | |
| 7 | + <div class="range-block-counter justifyLeft flex-container flexFlowColumn"> | |
| 8 | + <strong>Unique to this chat.</strong> | |
| 9 | + <span data-group="true">All group members will use the following scenario text instead of what is specified in their character cards.</span> | |
| 10 | + <span data-character="true">The following scenario text will be used instead of the value set in the character card.</span> | |
| 11 | + Checkpoints inherit the scenario override from their parent, and can be changed individually after that. | |
| 12 | + </div> | |
| 13 | + <div class="range-block-range wide100p"> | |
| 14 | + <textarea class="wide100p chat_scenario" class="text_pole" rows="15" data-i18n="[placeholder]Type here..." | |
| 15 | + placeholder="Type here..."></textarea> | |
| 16 | + </div> | |
| 17 | +</div> | |