mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-13 10:30:14 +01:00
Add settings for multiple expressions
This commit is contained in:
parent
adede8b6be
commit
239c3f1db7
@ -152,8 +152,18 @@ export const extension_settings = {
|
||||
refine_mode: false,
|
||||
},
|
||||
expressions: {
|
||||
/** @type {number} see `EXPRESSION_API` */
|
||||
api: undefined,
|
||||
/** @type {string[]} */
|
||||
custom: [],
|
||||
showDefault: false,
|
||||
translate: false,
|
||||
/** @type {string} */
|
||||
fallback_expression: undefined,
|
||||
/** @type {string} */
|
||||
llmPrompt: undefined,
|
||||
allowMultiple: true,
|
||||
rerollIfSame: false,
|
||||
},
|
||||
connectionManager: {
|
||||
selectedProfile: '',
|
||||
|
@ -1588,10 +1588,10 @@ async function setExpression(character, expression, force = false) {
|
||||
|
||||
let spriteFile = sprite.files[0];
|
||||
|
||||
// Calculate next expression
|
||||
if (sprite.files.length > 1) {
|
||||
// Calculate next expression, if multiple are allowed
|
||||
if (extension_settings.expressions.allowMultiple && sprite.files.length > 1) {
|
||||
let possibleFiles = sprite.files;
|
||||
if (extension_settings.expressions_reroll_if_same) {
|
||||
if (extension_settings.expressions.rerollIfSame) {
|
||||
possibleFiles = possibleFiles.filter(x => x.imageSrc !== prevExpressionSrc);
|
||||
}
|
||||
spriteFile = possibleFiles[Math.floor(Math.random() * possibleFiles.length)];
|
||||
@ -2141,6 +2141,14 @@ function migrateSettings() {
|
||||
extension_settings.expressions.translate = !!$(this).prop('checked');
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
$('#expressions_allow_multiple').prop('checked', extension_settings.expressions.allowMultiple).on('input', function () {
|
||||
extension_settings.expressions.allowMultiple = !!$(this).prop('checked');
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
$('#expressions_reroll_if_same').prop('checked', extension_settings.expressions.rerollIfSame).on('input', function () {
|
||||
extension_settings.expressions.rerollIfSame = !!$(this).prop('checked');
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
$('#expression_override_cleanup_button').on('click', onClickExpressionOverrideRemoveAllButton);
|
||||
$(document).on('dragstart', '.expression', (e) => {
|
||||
e.preventDefault();
|
||||
|
@ -52,6 +52,16 @@
|
||||
<i id="expression_custom_remove" class="menu_button fa-solid fa-xmark margin0" title="Remove"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-b-1 m-t-1">
|
||||
<label class="checkbox_label" for="expressions_allow_multiple">
|
||||
<input id="expressions_allow_multiple" type="checkbox">
|
||||
<span data-i18n="Allow multiple files per expression">Allow multiple files per expression</span>
|
||||
</label>
|
||||
<label class="checkbox_label" for="expressions_reroll_if_same">
|
||||
<input id="expressions_reroll_if_same" type="checkbox">
|
||||
<span data-i18n="Re-roll if same expression is used again">Re-roll if same expression is used again</span>
|
||||
</label>
|
||||
</div>
|
||||
<div id="no_chat_expressions" data-i18n="Open a chat to see the character expressions.">
|
||||
Open a chat to see the character expressions.
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user