Add settings for multiple expressions
| @@ -152,8 +152,18 @@ export const extension_settings = { | |||
| 152 | refine_mode: false, | 152 | refine_mode: false, |
| 153 | }, | 153 | }, |
| 154 | expressions: { | 154 | expressions: { |
| 155 | /** @type {number} see `EXPRESSION_API` */ | ||
| 156 | api: undefined, | ||
| 155 | /** @type {string[]} */ | 157 | /** @type {string[]} */ |
| 156 | custom: [], | 158 | custom: [], |
| 159 | showDefault: false, | ||
| 160 | translate: false, | ||
| 161 | /** @type {string} */ | ||
| 162 | fallback_expression: undefined, | ||
| 163 | /** @type {string} */ | ||
| 164 | llmPrompt: undefined, | ||
| 165 | allowMultiple: true, | ||
| 166 | rerollIfSame: false, | ||
| 157 | }, | 167 | }, |
| 158 | connectionManager: { | 168 | connectionManager: { |
| 159 | selectedProfile: '', | 169 | selectedProfile: '', |
| @@ -1588,10 +1588,10 @@ async function setExpression(character, expression, force = false) { | |||
| 1588 | 1588 | ||
| 1589 | let spriteFile = sprite.files[0]; | 1589 | let spriteFile = sprite.files[0]; |
| 1590 | 1590 | ||
| 1591 | // Calculate next expression | 1591 | // Calculate next expression, if multiple are allowed |
| 1592 | if (sprite.files.length > 1) { | 1592 | if (extension_settings.expressions.allowMultiple && sprite.files.length > 1) { |
| 1593 | let possibleFiles = sprite.files; | 1593 | let possibleFiles = sprite.files; |
| 1594 | if (extension_settings.expressions_reroll_if_same) { | 1594 | if (extension_settings.expressions.rerollIfSame) { |
| 1595 | possibleFiles = possibleFiles.filter(x => x.imageSrc !== prevExpressionSrc); | 1595 | possibleFiles = possibleFiles.filter(x => x.imageSrc !== prevExpressionSrc); |
| 1596 | } | 1596 | } |
| 1597 | spriteFile = possibleFiles[Math.floor(Math.random() * possibleFiles.length)]; | 1597 | spriteFile = possibleFiles[Math.floor(Math.random() * possibleFiles.length)]; |
| @@ -2141,6 +2141,14 @@ function migrateSettings() { | |||
| 2141 | extension_settings.expressions.translate = !!$(this).prop('checked'); | 2141 | extension_settings.expressions.translate = !!$(this).prop('checked'); |
| 2142 | saveSettingsDebounced(); | 2142 | saveSettingsDebounced(); |
| 2143 | }); | 2143 | }); |
| 2144 | $('#expressions_allow_multiple').prop('checked', extension_settings.expressions.allowMultiple).on('input', function () { | ||
| 2145 | extension_settings.expressions.allowMultiple = !!$(this).prop('checked'); | ||
| 2146 | saveSettingsDebounced(); | ||
| 2147 | }); | ||
| 2148 | $('#expressions_reroll_if_same').prop('checked', extension_settings.expressions.rerollIfSame).on('input', function () { | ||
| 2149 | extension_settings.expressions.rerollIfSame = !!$(this).prop('checked'); | ||
| 2150 | saveSettingsDebounced(); | ||
| 2151 | }); | ||
| 2144 | $('#expression_override_cleanup_button').on('click', onClickExpressionOverrideRemoveAllButton); | 2152 | $('#expression_override_cleanup_button').on('click', onClickExpressionOverrideRemoveAllButton); |
| 2145 | $(document).on('dragstart', '.expression', (e) => { | 2153 | $(document).on('dragstart', '.expression', (e) => { |
| 2146 | e.preventDefault(); | 2154 | e.preventDefault(); |
| @@ -52,6 +52,16 @@ | |||
| 52 | <i id="expression_custom_remove" class="menu_button fa-solid fa-xmark margin0" title="Remove"></i> | 52 | <i id="expression_custom_remove" class="menu_button fa-solid fa-xmark margin0" title="Remove"></i> |
| 53 | </div> | 53 | </div> |
| 54 | </div> | 54 | </div> |
| 55 | <div class="m-b-1 m-t-1"> | ||
| 56 | <label class="checkbox_label" for="expressions_allow_multiple"> | ||
| 57 | <input id="expressions_allow_multiple" type="checkbox"> | ||
| 58 | <span data-i18n="Allow multiple files per expression">Allow multiple files per expression</span> | ||
| 59 | </label> | ||
| 60 | <label class="checkbox_label" for="expressions_reroll_if_same"> | ||
| 61 | <input id="expressions_reroll_if_same" type="checkbox"> | ||
| 62 | <span data-i18n="Re-roll if same expression is used again">Re-roll if same expression is used again</span> | ||
| 63 | </label> | ||
| 64 | </div> | ||
| 55 | <div id="no_chat_expressions" data-i18n="Open a chat to see the character expressions."> | 65 | <div id="no_chat_expressions" data-i18n="Open a chat to see the character expressions."> |
| 56 | Open a chat to see the character expressions. | 66 | Open a chat to see the character expressions. |
| 57 | </div> | 67 | </div> |