Fix crash with certain animated variant sprites
This commit is contained in:
1 parent
b863ab88a7
commit
ef552c7ffd
5 files changed
+212
-6
No files matched your search
+19
-1
@@ -272,7 +272,7 @@ export default class BattleScene extends SceneBase {
|
||||
|
||||
populateAnims();
|
||||
|
||||
await this.cachedFetch('./images/pokemon/variant/_masterlist.json').then(res => res.json()).then(v => Object.keys(v).forEach(k => variantData[k] = v[k]));
|
||||
await this.initVariantData();
|
||||
}
|
||||
|
||||
create() {
|
||||
@@ -513,6 +513,21 @@ export default class BattleScene extends SceneBase {
|
||||
});
|
||||
}
|
||||
|
||||
async initVariantData(): Promise<void> {
|
||||
Object.keys(variantData).forEach(key => delete variantData[key]);
|
||||
await this.cachedFetch('./images/pokemon/variant/_masterlist.json').then(res => res.json())
|
||||
.then(v => {
|
||||
Object.keys(v).forEach(k => variantData[k] = v[k]);
|
||||
if (this.experimentalSprites) {
|
||||
const expTree = variantData['exp'];
|
||||
Object.keys(expTree).forEach(ek => {
|
||||
variantData[ek] = expTree[ek];
|
||||
});
|
||||
}
|
||||
Promise.resolve();
|
||||
});
|
||||
}
|
||||
|
||||
cachedFetch(url: string, init?: RequestInit): Promise<Response> {
|
||||
const manifest = this.game['manifest'];
|
||||
if (manifest) {
|
||||
@@ -817,6 +832,9 @@ export default class BattleScene extends SceneBase {
|
||||
}
|
||||
|
||||
if (clearScene) {
|
||||
// Reload variant data in case sprite set has changed
|
||||
this.initVariantData();
|
||||
|
||||
this.fadeOutBgm(250, false);
|
||||
this.tweens.add({
|
||||
targets: [ this.uiContainer ],
|
||||
|
||||
@@ -312,12 +312,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
const battleSpritePath = this.getBattleSpriteAtlasPath(back, ignoreOverride).replace('variant/', '').replace(/_[1-3]$/, '');
|
||||
let variantSet: VariantSet;
|
||||
let config = variantData;
|
||||
const useExpSprite = this.scene.experimentalSprites && this.scene.hasExpSprite(this.getBattleSpriteKey(back, ignoreOverride));
|
||||
battleSpritePath.split('/').map(p => config ? config = config[p] : null);
|
||||
variantSet = config as VariantSet;
|
||||
if (variantSet && variantSet[this.variant] === 1) {
|
||||
if (variantColorCache.hasOwnProperty(key))
|
||||
return resolve();
|
||||
this.scene.cachedFetch(`./images/pokemon/variant/${battleSpritePath}.json`).then(res => res.json()).then(c => {
|
||||
this.scene.cachedFetch(`./images/pokemon/variant/${useExpSprite ? 'exp/' : ''}${battleSpritePath}.json`).then(res => res.json()).then(c => {
|
||||
variantColorCache[key] = c;
|
||||
resolve();
|
||||
});
|
||||
|
||||
@@ -48,7 +48,7 @@ export const settingOptions: SettingOptions = {
|
||||
[Setting.Window_Type]: new Array(5).fill(null).map((_, i) => (i + 1).toString()),
|
||||
[Setting.Tutorials]: [ 'Off', 'On' ],
|
||||
[Setting.Enable_Retries]: [ 'Off', 'On' ],
|
||||
[Setting.Sprite_Set]: [ 'Consistent', 'Prioritize Animation' ],
|
||||
[Setting.Sprite_Set]: [ 'Consistent', 'Mixed Animated' ],
|
||||
[Setting.Move_Animations]: [ 'Off', 'On' ],
|
||||
[Setting.Show_Stats_on_Level_Up]: [ 'Off', 'On' ],
|
||||
[Setting.EXP_Gains_Speed]: [ 'Normal', 'Fast', 'Faster', 'Skip' ],
|
||||
@@ -83,7 +83,7 @@ export const settingDefaults: SettingDefaults = {
|
||||
[Setting.Vibration]: 0
|
||||
};
|
||||
|
||||
export const reloadSettings: Setting[] = [ Setting.UI_Theme, Setting.Language ];
|
||||
export const reloadSettings: Setting[] = [ Setting.UI_Theme, Setting.Language, Setting.Sprite_Set ];
|
||||
|
||||
export function setSetting(scene: BattleScene, setting: Setting, value: integer): boolean {
|
||||
switch (setting) {
|
||||
|
||||
Reference in new issue
Block a user