Fixed different resolutions (#1362)

* Fixed different resolutions

* Fixed replacing shapezio vanilla sprites
This commit is contained in:
Thomas (DJ1TJOO) 2022-02-01 17:33:18 +01:00 committed by GitHub
parent e9c26a71e2
commit cb5df2473e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 5 deletions

View File

@ -127,8 +127,13 @@ export class ModInterface {
for (const spriteName in sourceData) {
const { frame, sourceSize, spriteSourceSize } = sourceData[spriteName];
const sprite = new AtlasSprite(spriteName);
Loader.sprites.set(spriteName, sprite);
let sprite = /** @type {AtlasSprite} */ (Loader.sprites.get(spriteName));
if (!sprite) {
sprite = new AtlasSprite(spriteName);
Loader.sprites.set(spriteName, sprite);
}
sprite.frozen = true;
const link = new SpriteAtlasLink({
@ -142,9 +147,14 @@ export class ModInterface {
w: sourceSize.w,
h: sourceSize.h,
});
sprite.linksByResolution["0.25"] = link;
sprite.linksByResolution["0.5"] = link;
sprite.linksByResolution["0.75"] = link;
if (atlasData.meta && atlasData.meta.scale) {
sprite.linksByResolution[atlasData.meta.scale] = link;
} else {
sprite.linksByResolution["0.25"] = link;
sprite.linksByResolution["0.5"] = link;
sprite.linksByResolution["0.75"] = link;
}
}
}