mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-20 23:32:19 +02:00
Moving creation of pokémon icon containers from setup() to view(); clearing containers on clear().
This commit is contained in:
parent
5b1950a1ae
commit
553a2e7ba8
@ -141,6 +141,7 @@ interface SpeciesDetails {
|
||||
|
||||
export default class PokedexUiHandler extends MessageUiHandler {
|
||||
private starterSelectContainer: Phaser.GameObjects.Container;
|
||||
private starterBoxContainer: Phaser.GameObjects.Container;
|
||||
private starterSelectScrollBar: ScrollBar;
|
||||
private filterBarContainer: Phaser.GameObjects.Container;
|
||||
private filterBar: FilterBar;
|
||||
@ -425,32 +426,27 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
||||
this.pokemonFormText.setOrigin(0, 0);
|
||||
this.starterSelectContainer.add(this.pokemonFormText);
|
||||
|
||||
const starterBoxContainer = globalScene.add.container(speciesContainerX + 6, 9); //115
|
||||
this.starterBoxContainer = globalScene.add.container(speciesContainerX + 6, 9); //115
|
||||
|
||||
this.starterSelectScrollBar = new ScrollBar(161, 12, 5, pokemonContainerWindow.height - 6, 9);
|
||||
|
||||
starterBoxContainer.add(this.starterSelectScrollBar);
|
||||
this.starterBoxContainer.add(this.starterSelectScrollBar);
|
||||
|
||||
this.pokerusCursorObjs = new Array(POKERUS_STARTER_COUNT).fill(null).map(() => {
|
||||
const cursorObj = globalScene.add.image(0, 0, "select_cursor_pokerus");
|
||||
cursorObj.setVisible(false);
|
||||
cursorObj.setOrigin(0, 0);
|
||||
starterBoxContainer.add(cursorObj);
|
||||
this.starterBoxContainer.add(cursorObj);
|
||||
return cursorObj;
|
||||
});
|
||||
|
||||
this.cursorObj = globalScene.add.image(0, 0, "select_cursor");
|
||||
this.cursorObj.setOrigin(0, 0);
|
||||
starterBoxContainer.add(this.cursorObj);
|
||||
this.starterBoxContainer.add(this.cursorObj);
|
||||
|
||||
for (const species of allSpecies) {
|
||||
this.speciesLoaded.set(species.speciesId, false);
|
||||
this.allSpecies.push(species);
|
||||
|
||||
const pokemonContainer = new PokedexMonContainer(species).setVisible(false);
|
||||
this.iconAnimHandler.addOrUpdate(pokemonContainer.icon, PokemonIconAnimMode.NONE);
|
||||
this.pokemonContainers.push(pokemonContainer);
|
||||
starterBoxContainer.add(pokemonContainer);
|
||||
}
|
||||
|
||||
// Tray to display forms
|
||||
@ -463,11 +459,11 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
||||
this.trayCursorObj = globalScene.add.image(0, 0, "select_cursor");
|
||||
this.trayCursorObj.setOrigin(0, 0);
|
||||
this.formTrayContainer.add(this.trayCursorObj);
|
||||
starterBoxContainer.add(this.formTrayContainer);
|
||||
starterBoxContainer.bringToTop(this.formTrayContainer);
|
||||
this.starterBoxContainer.add(this.formTrayContainer);
|
||||
this.starterBoxContainer.bringToTop(this.formTrayContainer);
|
||||
this.formTrayContainer.setVisible(false);
|
||||
|
||||
this.starterSelectContainer.add(starterBoxContainer);
|
||||
this.starterSelectContainer.add(this.starterBoxContainer);
|
||||
|
||||
this.pokemonSprite = globalScene.add.sprite(96, 143, "pkmn__sub");
|
||||
this.pokemonSprite.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true });
|
||||
@ -545,6 +541,13 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
||||
|
||||
show(args: any[]): boolean {
|
||||
|
||||
for (const species of this.allSpecies) {
|
||||
const pokemonContainer = new PokedexMonContainer(species).setVisible(false);
|
||||
this.iconAnimHandler.addOrUpdate(pokemonContainer.icon, PokemonIconAnimMode.NONE);
|
||||
this.pokemonContainers.push(pokemonContainer);
|
||||
this.starterBoxContainer.add(pokemonContainer);
|
||||
}
|
||||
|
||||
if (!this.starterPreferences) {
|
||||
this.starterPreferences = StarterPrefs.load();
|
||||
}
|
||||
@ -2125,6 +2128,14 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
||||
clear(): void {
|
||||
super.clear();
|
||||
|
||||
this.pokemonContainers.forEach(obj => {
|
||||
this.starterBoxContainer.remove(obj, true); // Removes from container and destroys it
|
||||
});
|
||||
this.pokemonContainers = [];
|
||||
// These arrays must be emptied too, or garbage is not collected properly
|
||||
this.validPokemonContainers = [];
|
||||
this.filteredPokemonContainers = [];
|
||||
|
||||
this.cursor = -1;
|
||||
globalScene.ui.hideTooltip();
|
||||
|
||||
|
@ -216,6 +216,7 @@ interface SpeciesDetails {
|
||||
|
||||
export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||
private starterSelectContainer: Phaser.GameObjects.Container;
|
||||
private starterBoxContainer: Phaser.GameObjects.Container;
|
||||
private starterSelectScrollBar: ScrollBar;
|
||||
private filterBarContainer: Phaser.GameObjects.Container;
|
||||
private filterBar: FilterBar;
|
||||
@ -623,19 +624,17 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||
this.randomCursorObj.setOrigin(0, 0);
|
||||
this.starterSelectContainer.add(this.randomCursorObj);
|
||||
|
||||
const starterSpecies: Species[] = [];
|
||||
|
||||
const starterBoxContainer = globalScene.add.container(speciesContainerX + 6, 9); //115
|
||||
this.starterBoxContainer = globalScene.add.container(speciesContainerX + 6, 9); //115
|
||||
|
||||
this.starterSelectScrollBar = new ScrollBar(161, 12, 5, starterContainerWindow.height - 6, 9);
|
||||
|
||||
starterBoxContainer.add(this.starterSelectScrollBar);
|
||||
this.starterBoxContainer.add(this.starterSelectScrollBar);
|
||||
|
||||
this.pokerusCursorObjs = new Array(POKERUS_STARTER_COUNT).fill(null).map(() => {
|
||||
const cursorObj = globalScene.add.image(0, 0, "select_cursor_pokerus");
|
||||
cursorObj.setVisible(false);
|
||||
cursorObj.setOrigin(0, 0);
|
||||
starterBoxContainer.add(cursorObj);
|
||||
this.starterBoxContainer.add(cursorObj);
|
||||
return cursorObj;
|
||||
});
|
||||
|
||||
@ -643,7 +642,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||
const cursorObj = globalScene.add.image(0, 0, "select_cursor_highlight");
|
||||
cursorObj.setVisible(false);
|
||||
cursorObj.setOrigin(0, 0);
|
||||
starterBoxContainer.add(cursorObj);
|
||||
this.starterBoxContainer.add(cursorObj);
|
||||
return cursorObj;
|
||||
});
|
||||
|
||||
@ -655,25 +654,19 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||
this.starterIconsCursorObj.setOrigin(0, 0);
|
||||
this.starterSelectContainer.add(this.starterIconsCursorObj);
|
||||
|
||||
starterBoxContainer.add(this.cursorObj);
|
||||
this.starterBoxContainer.add(this.cursorObj);
|
||||
|
||||
this.starterSelectContainer.add(this.starterBoxContainer);
|
||||
|
||||
for (const species of allSpecies) {
|
||||
if (!speciesStarterCosts.hasOwnProperty(species.speciesId) || !species.isObtainable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
starterSpecies.push(species.speciesId);
|
||||
this.speciesLoaded.set(species.speciesId, false);
|
||||
this.allSpecies.push(species);
|
||||
|
||||
const starterContainer = new StarterContainer(species).setVisible(false);
|
||||
this.iconAnimHandler.addOrUpdate(starterContainer.icon, PokemonIconAnimMode.NONE);
|
||||
this.starterContainers.push(starterContainer);
|
||||
starterBoxContainer.add(starterContainer);
|
||||
}
|
||||
|
||||
this.starterSelectContainer.add(starterBoxContainer);
|
||||
|
||||
this.starterIcons = new Array(6).fill(null).map((_, i) => {
|
||||
const icon = globalScene.add.sprite(teamWindowX + 7, calcStarterIconY(i), "pokemon_icons_0");
|
||||
icon.setScale(0.5);
|
||||
@ -924,6 +917,14 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||
}
|
||||
|
||||
show(args: any[]): boolean {
|
||||
|
||||
for (const species of this.allSpecies) {
|
||||
const starterContainer = new StarterContainer(species).setVisible(false);
|
||||
this.iconAnimHandler.addOrUpdate(starterContainer.icon, PokemonIconAnimMode.NONE);
|
||||
this.starterContainers.push(starterContainer);
|
||||
this.starterBoxContainer.add(starterContainer);
|
||||
}
|
||||
|
||||
if (!this.starterPreferences) {
|
||||
// starterPreferences haven't been loaded yet
|
||||
this.starterPreferences = StarterPrefs.load();
|
||||
@ -3829,6 +3830,14 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||
this.activeTooltip = undefined;
|
||||
globalScene.ui.hideTooltip();
|
||||
|
||||
this.starterContainers.forEach(obj => {
|
||||
this.starterBoxContainer.remove(obj, true); // Removes from container and destroys it
|
||||
});
|
||||
this.starterContainers = [];
|
||||
// These arrays must be emptied too, or garbage is not collected properly
|
||||
this.validStarterContainers = [];
|
||||
this.filteredStarterContainers = [];
|
||||
|
||||
this.starterSelectContainer.setVisible(false);
|
||||
this.blockInput = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user