Fix expression sprite sorting, fade additional - Sort alphabetically, but keep the main expression file first - Fade additional sprite images if "allow multiple" is not chosen
| @@ -1349,7 +1349,7 @@ function getExpressionImageData(sprite) { | ||
| 1349 | 1349 | fileName: fileName, |
| 1350 | 1350 | title: fileNameWithoutExtension, |
| 1351 | 1351 | imageSrc: sprite.path, |
| 1352 | - type: fileNameWithoutExtension == sprite.label ? 'success' : 'additional', | |
| 1352 | + type: 'success', | |
| 1353 | 1353 | isCustom: extension_settings.expressions.custom?.includes(sprite.label), |
| 1354 | 1354 | }; |
| 1355 | 1355 | } |
| @@ -1380,8 +1380,7 @@ async function drawSpritesList(character, labels, sprites) { | ||
| 1380 | 1380 | const images = sprites |
| 1381 | 1381 | .filter(s => s.label === expression) |
| 1382 | 1382 | .map(s => s.files) |
| 1383 | 1383 | .flat(); |
| 1384 | - .sort((a, b) => a.title.localeCompare(b.title)); | |
| 1385 | 1384 | |
| 1386 | 1385 | if (images.length === 0) { |
| 1387 | 1386 | const listItem = await getListItem(expression, { |
| @@ -1444,6 +1443,21 @@ async function getSpritesList(name) { | ||
| 1444 | 1443 | |
| 1445 | 1444 | return acc; |
| 1446 | 1445 | }, []); |
| 1446 | + | |
| 1447 | + // Sort the sprites for each expression alphabetically, but keep the main expression file at the front | |
| 1448 | + for (const expression of grouped) { | |
| 1449 | + expression.files.sort((a, b) => { | |
| 1450 | + if (a.title === expression.label) return -1; | |
| 1451 | + if (b.title === expression.label) return 1; | |
| 1452 | + return a.title.localeCompare(b.title); | |
| 1453 | + }); | |
| 1454 | + | |
| 1455 | + // Mark all besides the first sprite as 'additional' | |
| 1456 | + for (let i = 1; i < expression.files.length; i++) { | |
| 1457 | + expression.files[i].type = 'additional'; | |
| 1458 | + } | |
| 1459 | + } | |
| 1460 | + | |
| 1447 | 1461 | return grouped; |
| 1448 | 1462 | } |
| 1449 | 1463 | catch (err) { |
| @@ -1584,7 +1598,7 @@ async function setExpression(character, expression, force = false) { | ||
| 1584 | 1598 | /** @type {Expression} */ |
| 1585 | 1599 | const sprite = (spriteCache[character] && spriteCache[character].find(x => x.label === expression)); |
| 1586 | 1600 | console.debug('checking for expression images to show..'); |
| 1587 | 1601 | if (sprite && sprite.files.length > 0) { |
| 1588 | 1602 | console.debug('setting expression from character images folder'); |
| 1589 | 1603 | |
| 1590 | 1604 | let spriteFile = sprite.files[0]; |
| @@ -204,3 +204,12 @@ img.expression.default { | ||
| 204 | 204 | align-items: baseline; |
| 205 | 205 | flex-direction: row; |
| 206 | 206 | } |
| 207 | + | |
| 208 | +#expressions_container:has(#expressions_allow_multiple:not(:checked)) #image_list .expression_list_item[data-expression-type="additional"] { | |
| 209 | + opacity: 0.3; | |
| 210 | + transition: opacity var(--animation-duration) ease; | |
| 211 | +} | |
| 212 | +#expressions_container:has(#expressions_allow_multiple:not(:checked)) #image_list .expression_list_item[data-expression-type="additional"]:hover, | |
| 213 | +#expressions_container:has(#expressions_allow_multiple:not(:checked)) #image_list .expression_list_item[data-expression-type="additional"]:focus { | |
| 214 | + opacity: unset; | |
| 215 | +} | |