Update char submenu popups to new popup

- Update 'Scenario Override'
- Update 'Open Source'
- Update 'Replace Character'
- Update 'Convert to Persona' popups
This commit is contained in:
Wolfsblvt 2024-07-14 03:58:27 +02:00
parent 5bb20519b7
commit af15794222
4 changed files with 34 additions and 33 deletions

View File

@ -5123,23 +5123,6 @@
</div>
</div>
<!-- templates for JS to reuse when needed -->
<div id="scenario_override_template" class="template_element">
<div class="scenario_override range-block flexFlowColumn flex-container">
<div class="range-block-title title_restorable">
<h3><span data-i18n="Chat Scenario Override" class="margin0">Chat Scenario Override</span></h3>
<div title="Remove" data-i18n="[title]Remove" class="menu_button fa-solid fa-trash-can remove_scenario_override"></div>
</div>
<div class="range-block-counter justifyLeft flex-container flexFlowColumn">
<strong>Unique to this chat.</strong>
<span data-group="true">All group members will use the following scenario text instead of what is specified in their character cards.</span>
<span data-character="true">The following scenario text will be used instead of the value set in the character card.</span>
Checkpoints inherit the scenario override from their parent, and can be changed individually after that.
</div>
<div class="range-block-range wide100p">
<textarea class="wide100p chat_scenario" class="text_pole" rows="15" data-i18n="[placeholder]Type here..." placeholder="Type here..."></textarea>
</div>
</div>
</div>
<div id="chat_world_template" class="template_element">
<div class="chat_world range-block flexFlowColumn flex-container">
<div class="range-block-title">

View File

@ -7184,20 +7184,23 @@ function updateFavButtonState(state) {
$('#favorite_button').toggleClass('fav_off', !fav_ch_checked);
}
export function setScenarioOverride() {
export async function setScenarioOverride() {
if (!selected_group && !this_chid) {
console.warn('setScenarioOverride() -- no selected group or character');
return;
}
const template = $('#scenario_override_template .scenario_override').clone();
const metadataValue = chat_metadata['scenario'] || '';
const isGroup = !!selected_group;
template.find('[data-group="true"]').toggle(isGroup);
template.find('[data-character="true"]').toggle(!isGroup);
template.find('.chat_scenario').val(metadataValue).on('input', onScenarioOverrideInput);
template.find('.remove_scenario_override').on('click', onScenarioOverrideRemoveClick);
callPopup(template, 'text');
const $template = $(await renderTemplateAsync('scenarioOverride'));
$template.find('[data-group="true"]').toggle(isGroup);
$template.find('[data-character="true"]').toggle(!isGroup);
// TODO: Why does this save on every character input? Save on popup close
$template.find('.chat_scenario').val(metadataValue).on('input', onScenarioOverrideInput);
$template.find('.remove_scenario_override').on('click', onScenarioOverrideRemoveClick);
await callGenericPopup($template, POPUP_TYPE.TEXT, '');
}
function onScenarioOverrideInput() {
@ -10653,7 +10656,7 @@ jQuery(async function () {
openCharacterWorldPopup();
break;
case 'set_chat_scenario':
setScenarioOverride();
await setScenarioOverride();
break;
case 'renameCharButton':
renameCharacter();
@ -10674,7 +10677,7 @@ jQuery(async function () {
const source = getCharacterSource(this_chid);
if (source && isValidUrl(source)) {
const url = new URL(source);
const confirm = await callPopup(`Open ${url.hostname} in a new tab?`, 'confirm');
const confirm = await Popup.show.confirm('Open Source', `<span>Do you want to open the link to ${url.hostname} in a new tab?</span><var>${url}</var>`);
if (confirm) {
window.open(source, '_blank');
}
@ -10683,7 +10686,7 @@ jQuery(async function () {
}
} break;
case 'replace_update': {
const confirm = await callPopup('<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.</p><p>Proceed?</p>', 'confirm', '');
const confirm = await Popup.show.confirm('Replace Character', '<p>Choose a new character card to replace this character with.</p>All chats, assets and group memberships will be preserved, but local changes to the character data will be lost.<br />Proceed?');
if (confirm) {
async function uploadReplacementCard(e) {
const file = e.target.files[0];

View File

@ -395,9 +395,8 @@ export async function convertCharacterToPersona(characterId = null) {
const overwriteName = `${name} (Persona).png`;
if (overwriteName in power_user.personas) {
const confirmation = await callPopup('This character exists as a persona already. Are you sure want to overwrite it?', 'confirm', '', { okButton: 'Yes' });
if (confirmation === false) {
const confirm = await Popup.show.confirm('Overwrite Existing Persona', 'This character exists as a persona already. Do you want to overwrite it?');
if (!confirm) {
console.log('User cancelled the overwrite of the persona');
return;
}
@ -405,9 +404,8 @@ export async function convertCharacterToPersona(characterId = null) {
if (description.includes('{{char}}') || description.includes('{{user}}')) {
await delay(500);
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' });
if (confirmation) {
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?');
if (confirm) {
description = description.replace(/{{char}}/gi, '{{personaChar}}').replace(/{{user}}/gi, '{{personaUser}}');
description = description.replace(/{{personaUser}}/gi, '{{char}}').replace(/{{personaChar}}/gi, '{{user}}');
}

View File

@ -0,0 +1,17 @@
<div class="scenario_override range-block flexFlowColumn flex-container">
<div class="range-block-title title_restorable">
<h3><span data-i18n="Chat Scenario Override" class="margin0">Chat Scenario Override</span></h3>
<div title="Remove" data-i18n="[title]Remove"
class="menu_button fa-solid fa-trash-can remove_scenario_override"></div>
</div>
<div class="range-block-counter justifyLeft flex-container flexFlowColumn">
<strong>Unique to this chat.</strong>
<span data-group="true">All group members will use the following scenario text instead of what is specified in their character cards.</span>
<span data-character="true">The following scenario text will be used instead of the value set in the character card.</span>
Checkpoints inherit the scenario override from their parent, and can be changed individually after that.
</div>
<div class="range-block-range wide100p">
<textarea class="wide100p chat_scenario" class="text_pole" rows="15" data-i18n="[placeholder]Type here..."
placeholder="Type here..."></textarea>
</div>
</div>