This commit is contained in:
33333-33333 2026-06-20 23:27:39 +09:00
commit c6ba3e38a2
21 changed files with 1565 additions and 898 deletions

View file

@ -8,8 +8,8 @@ const imageAssetIndex = new Map();
const scaledSpriteCache = new Map();
const stainOverlayCache = new Map();
const INITIAL_IMAGE_IDS = new Set(["smile", "zunchi", "zunchi_02"]);
const EARLY_IMAGE_IDS = new Set(["smile", "angry", "teary", "jito", "drool", "cry", "sleep", "pokan", "normal_smirk", "normal_tongue", "normal_happy", "weak", "hurt", "hurt2", "zunchi", "zunchi_02"]);
const INITIAL_IMAGE_IDS = new Set(["smile", "zunchi", "zunchi_02", "genkotsu"]);
const EARLY_IMAGE_IDS = new Set(["smile", "angry", "teary", "jito", "drool", "cry", "sleep", "pokan", "normal_smirk", "normal_tongue", "normal_happy", "weak", "hurt", "hurt2", "zunchi", "zunchi_02", "genkotsu"]);
function trimCanvasCache(cache, limit = 420) {
while (cache.size > limit) {
@ -160,14 +160,18 @@ function getRenderableImage(id, fallbackId = "smile") {
return null;
}
function loadImages(ids = null) {
function loadImages(ids = null, onProgress = null) {
setupAssetIndex();
const requested = ids ? new Set(ids) : INITIAL_IMAGE_IDS;
const tasks = [];
for (const id of requested) {
const asset = imageAssetIndex.get(id);
if (asset) tasks.push(loadImageAsset(asset, "high"));
}
const assets = [...requested].map(id => imageAssetIndex.get(id)).filter(Boolean);
const total = Math.max(assets.length, 1);
let done = 0;
if (typeof onProgress === "function") onProgress(done, total, null);
const tasks = assets.map(asset => loadImageAsset(asset, "high").then((img) => {
done += 1;
if (typeof onProgress === "function") onProgress(done, total, asset);
return img;
}));
return Promise.all(tasks).then(() => undefined);
}