Use Gen 5 animated sprites if available (#2495)
Some checks are pending
Node.js CI / build (22.x) (push) Waiting to run

This commit is contained in:
André Bastos Dias 2025-08-07 10:39:24 +01:00 committed by GitHub
parent 79c19fcf95
commit 0f678fde33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -634,19 +634,11 @@ export const Dex = new class implements ModdedDex {
spriteData.gen = Math.max(graphicsGen, Math.min(species.gen, 5));
const baseDir = ['', 'gen1', 'gen2', 'gen3', 'gen4', 'gen5', '', '', '', ''][spriteData.gen];
let animationData = null;
let miscData = null;
let speciesid = species.id;
if (species.isTotem) speciesid = toID(name);
if (baseDir === '' && window.BattlePokemonSprites) {
animationData = BattlePokemonSprites[speciesid];
}
if (baseDir === 'gen5' && window.BattlePokemonSpritesBW) {
animationData = BattlePokemonSpritesBW[speciesid];
}
if (window.BattlePokemonSprites) miscData = BattlePokemonSprites[speciesid];
if (!miscData && window.BattlePokemonSpritesBW) miscData = BattlePokemonSpritesBW[speciesid];
if (!animationData) animationData = {};
if (!miscData) miscData = {};
if (miscData.num !== 0 && miscData.num > -5000) {
@ -715,17 +707,29 @@ export const Dex = new class implements ModdedDex {
spriteData.cryurl += '.mp3';
}
if (animationData[facing + 'f'] && options.gender === 'F') facing += 'f';
let allowAnim = !Dex.prefs('noanim') && !Dex.prefs('nogif');
if (allowAnim && spriteData.gen >= 6) spriteData.pixelated = false;
if (allowAnim && animationData[facing] && spriteData.gen >= 5) {
if (facing.endsWith('f')) name += '-f';
dir = baseDir + 'ani' + dir;
spriteData.w = animationData[facing].w;
spriteData.h = animationData[facing].h;
spriteData.url += dir + '/' + name + '.gif';
} else {
let animatedSprite = false;
if (!Dex.prefs('noanim') && !Dex.prefs('nogif') && spriteData.gen >= 5) {
const animationArray: [AnyObject, string][] = [];
if (baseDir === '' && window.BattlePokemonSprites) {
animationArray.push([BattlePokemonSprites[speciesid], '']);
}
if (window.BattlePokemonSpritesBW) {
animationArray.push([BattlePokemonSpritesBW[speciesid], 'gen5']);
}
for (const [animationData, animDir] of animationArray) {
if (animationData[facing + 'f'] && options.gender === 'F') facing += 'f';
if (!animationData[facing]) continue;
if (facing.endsWith('f')) name += '-f';
if (spriteData.gen >= 6) spriteData.pixelated = false;
dir = animDir + 'ani' + dir;
spriteData.w = animationData[facing].w;
spriteData.h = animationData[facing].h;
spriteData.url += dir + '/' + name + '.gif';
animatedSprite = true;
break;
}
}
if (!animatedSprite) {
// There is no entry or enough data in pokedex-mini.js
// Handle these in case-by-case basis; either using BW sprites or matching the played gen.
dir = (baseDir || 'gen5') + dir;