A texture was fetched only when it was drawn for the first time. Until the file arrived, the tilemap skipped the cell for that frame. An animated tile whose next step sat in another picture therefore blinked away once on its first cycle, and sprite animations did the same. - FileLibrary gets preload(files). It requests every file that is not held, loading or known to have failed. Each library reports what it holds through holds(). - src/core/model/projectFiles.ts lists the files a project names per library: uploaded textures, fonts and pixel art cels. - App.ts runs the preload on every project event. That covers opening a project, new assets and edits from a collaborator. - A new test hook __gm.heldPictures() reports which textures of the project are in memory. Not done on purpose: - The tilemap keeps no fallback frame while a step is still loading. - Sounds still load on first play. Not checked: the flicker itself was not reproduced in the browser, the e2e check measures "held in memory". Modules 42, 44 and 47 read textures from the project and were not run locally. Tests: - ./check.sh: 174 files, 2518 tests, CHECK EXIT 0 - e2e 39 + 40: ALL PASSED, 96 checks - 3 new unit tests for preload and the project file list - New e2e check 40k-ii: an unplaced picture is held after a reload - Counter-probe: without the preload 40k-ii fails with "Autotiles: held false, unworn: held false" Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import { isFontFile } from './font';
|
||
import { celFilesOf } from './pixelart';
|
||
import type { Project } from './Project';
|
||
import { isTextureFile } from './texture';
|
||
|
||
/** The stored files a project draws with, per library – what is loaded before anything asks. */
|
||
export interface ProjectFiles {
|
||
textures: string[];
|
||
fonts: string[];
|
||
cels: string[];
|
||
}
|
||
|
||
/**
|
||
* Every file an asset names, used or not: which frame an animation or a tile reaches next is only
|
||
* known while it plays, and a file fetched then shows as a gap. A name that is no stored file –
|
||
* an upload that failed – is left out, as the libraries would never get it anyway.
|
||
*/
|
||
export function projectFiles(project: Project): ProjectFiles {
|
||
const files: ProjectFiles = { textures: [], fonts: [], cels: [] };
|
||
for (const asset of project.assets) {
|
||
if (asset.type === 'texture' && isTextureFile(asset.file)) files.textures.push(asset.file);
|
||
else if (asset.type === 'font' && isFontFile(asset.file)) files.fonts.push(asset.file);
|
||
else if (asset.type === 'pixelart') files.cels.push(...celFilesOf(asset));
|
||
}
|
||
return files;
|
||
}
|