动态缩略图生成
This commit is contained in:
1 parent
4ff35ce352
commit
eb2a7f7d91
7 files changed
+73
-25
No files matched your search
+13
-5
@@ -112,16 +112,24 @@
|
||||
}
|
||||
.thumb-dialog-input.hidden { display: none; }
|
||||
.thumb-dialog-error { color: var(--error); min-height: 18px; }
|
||||
.animated-thumb-card { width: min(520px, 92vw); }
|
||||
.animated-thumb-card { width: min(480px, 92vw); gap: 10px; padding: 16px; }
|
||||
.thumb-dialog-note.warning { color: #e6b35c; }
|
||||
.animated-thumb-form { display: grid; gap: 12px; padding: 4px 0; }
|
||||
.animated-thumb-card .thumb-dialog-note { font-size: 13px; }
|
||||
.animated-thumb-form { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 10px 14px; padding: 2px 0; }
|
||||
.animated-thumb-label { color: var(--text-dim); }
|
||||
.animated-thumb-range { display: flex; align-items: center; gap: 8px; }
|
||||
.animated-thumb-range { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
|
||||
.animated-thumb-range label { display: flex; align-items: center; gap: 6px; }
|
||||
.animated-thumb-range input { width: 88px; }
|
||||
.animated-thumb-quality { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--text-dim); }
|
||||
.animated-thumb-quality { grid-column: 1 / -1; display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 14px; color: var(--text-dim); }
|
||||
.animated-thumb-size { display: flex; align-items: center; gap: 7px; color: var(--text); }
|
||||
.animated-thumb-size input { width: 108px; }
|
||||
.animated-thumb-size input { width: 88px; }
|
||||
.animated-thumb-form input[type="number"] {
|
||||
box-sizing: border-box; height: 32px; padding: 4px 8px;
|
||||
background: var(--panel-2); color: var(--text);
|
||||
border: 1px solid var(--border); border-radius: 4px;
|
||||
}
|
||||
.animated-thumb-form input[type="number"]:focus { outline: none; border-color: var(--accent); }
|
||||
.animated-thumb-card .thumb-dialog-actions { margin-top: 2px; }
|
||||
/* 收窄下拉,避免在窄窗口下把右侧按钮挤到第二行(展开后的选项不受影响)*/
|
||||
#toolbar #suffixSelect { max-width: 140px; }
|
||||
#stage { position: absolute; inset: 0; display: flex; overflow: hidden; }
|
||||
|
||||
+18
-5
@@ -29,7 +29,7 @@
|
||||
<span data-i18n="viewer.suffix">尾缀</span>
|
||||
<select id="suffixSelect"></select>
|
||||
</label>
|
||||
<button id="groupThumbBtn" data-i18n="viewer.groupThumbnail" data-i18n-title="viewer.groupThumbnailTitle" title="为关联资源生成缩略图">为关联资源生成缩略图</button>
|
||||
<button id="groupThumbBtn" data-i18n="viewer.groupThumbnail" data-i18n-title="viewer.groupThumbnailTitle" title="左键生成静帧缩略图,右键生成动画缩略图">为关联资源生成缩略图</button>
|
||||
<button id="thumbBtn" data-i18n="viewer.thumbnail" data-i18n-title="viewer.thumbnailTitle" title="将当前帧设为当前素材的缩略图">设为当前素材缩略图</button>
|
||||
<label id="verLabel" style="color: var(--text-dim);" data-i18n-title="viewer.versionTitle" title="Spine 版本"></label>
|
||||
<button id="reloadBtn" title="重新加载目录" data-i18n-title="viewer.reloadTitle">↻</button>
|
||||
@@ -1042,7 +1042,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function generateGroupThumbnails() {
|
||||
async function generateGroupThumbnails(animated = false) {
|
||||
if (!skeleton || !renderer || !activeAssets) { setStatus(t('viewer.noSkeletonForThumb')); return; }
|
||||
const groupThumbBtn = document.getElementById('groupThumbBtn');
|
||||
groupThumbBtn.disabled = true;
|
||||
@@ -1056,8 +1056,17 @@
|
||||
if (rows.length && rows.every((row) => row.state === 'unavailable')) setStatus(t('viewer.groupNoTargets'), 4000);
|
||||
return;
|
||||
}
|
||||
setStatus(t('viewer.generating'), Infinity);
|
||||
const rendered = await renderCurrentFrameThumbnail();
|
||||
let rendered;
|
||||
const animation = (skeletonData.animations || [])[currentAnim];
|
||||
if (animated && !isStaticAnimation && currentAnim !== SETUP_POSE_INDEX && animation && animationDuration(animation) > STATIC_EPSILON) {
|
||||
const options = await confirmAnimatedThumbnail(animation);
|
||||
if (!options) return;
|
||||
setStatus(t('viewer.animatedGenerating', { current: 0, total: '…' }), Infinity);
|
||||
rendered = await renderAnimatedThumbnail(animation, options);
|
||||
} else {
|
||||
setStatus(t('viewer.generating'), Infinity);
|
||||
rendered = await renderCurrentFrameThumbnail();
|
||||
}
|
||||
const result = await groupThumbnails.applyThumbnailTargets({
|
||||
targets,
|
||||
initialSkipped: rows.length - targets.length,
|
||||
@@ -1858,7 +1867,11 @@
|
||||
document.getElementById('reloadBtn').addEventListener('click', () => {
|
||||
window.location.reload();
|
||||
});
|
||||
document.getElementById('groupThumbBtn').addEventListener('click', generateGroupThumbnails);
|
||||
document.getElementById('groupThumbBtn').addEventListener('click', () => generateGroupThumbnails());
|
||||
document.getElementById('groupThumbBtn').addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault();
|
||||
generateGroupThumbnails(true);
|
||||
});
|
||||
document.getElementById('thumbBtn').addEventListener('click', generateThumbnail);
|
||||
document.getElementById('thumbBtn').addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
Reference in new issue
Block a user