mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-21 15:52:18 +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 {
|
export default class PokedexUiHandler extends MessageUiHandler {
|
||||||
private starterSelectContainer: Phaser.GameObjects.Container;
|
private starterSelectContainer: Phaser.GameObjects.Container;
|
||||||
|
private starterBoxContainer: Phaser.GameObjects.Container;
|
||||||
private starterSelectScrollBar: ScrollBar;
|
private starterSelectScrollBar: ScrollBar;
|
||||||
private filterBarContainer: Phaser.GameObjects.Container;
|
private filterBarContainer: Phaser.GameObjects.Container;
|
||||||
private filterBar: FilterBar;
|
private filterBar: FilterBar;
|
||||||
@ -425,32 +426,27 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
this.pokemonFormText.setOrigin(0, 0);
|
this.pokemonFormText.setOrigin(0, 0);
|
||||||
this.starterSelectContainer.add(this.pokemonFormText);
|
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);
|
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(() => {
|
this.pokerusCursorObjs = new Array(POKERUS_STARTER_COUNT).fill(null).map(() => {
|
||||||
const cursorObj = globalScene.add.image(0, 0, "select_cursor_pokerus");
|
const cursorObj = globalScene.add.image(0, 0, "select_cursor_pokerus");
|
||||||
cursorObj.setVisible(false);
|
cursorObj.setVisible(false);
|
||||||
cursorObj.setOrigin(0, 0);
|
cursorObj.setOrigin(0, 0);
|
||||||
starterBoxContainer.add(cursorObj);
|
this.starterBoxContainer.add(cursorObj);
|
||||||
return cursorObj;
|
return cursorObj;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.cursorObj = globalScene.add.image(0, 0, "select_cursor");
|
this.cursorObj = globalScene.add.image(0, 0, "select_cursor");
|
||||||
this.cursorObj.setOrigin(0, 0);
|
this.cursorObj.setOrigin(0, 0);
|
||||||
starterBoxContainer.add(this.cursorObj);
|
this.starterBoxContainer.add(this.cursorObj);
|
||||||
|
|
||||||
for (const species of allSpecies) {
|
for (const species of allSpecies) {
|
||||||
this.speciesLoaded.set(species.speciesId, false);
|
this.speciesLoaded.set(species.speciesId, false);
|
||||||
this.allSpecies.push(species);
|
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
|
// 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 = globalScene.add.image(0, 0, "select_cursor");
|
||||||
this.trayCursorObj.setOrigin(0, 0);
|
this.trayCursorObj.setOrigin(0, 0);
|
||||||
this.formTrayContainer.add(this.trayCursorObj);
|
this.formTrayContainer.add(this.trayCursorObj);
|
||||||
starterBoxContainer.add(this.formTrayContainer);
|
this.starterBoxContainer.add(this.formTrayContainer);
|
||||||
starterBoxContainer.bringToTop(this.formTrayContainer);
|
this.starterBoxContainer.bringToTop(this.formTrayContainer);
|
||||||
this.formTrayContainer.setVisible(false);
|
this.formTrayContainer.setVisible(false);
|
||||||
|
|
||||||
this.starterSelectContainer.add(starterBoxContainer);
|
this.starterSelectContainer.add(this.starterBoxContainer);
|
||||||
|
|
||||||
this.pokemonSprite = globalScene.add.sprite(96, 143, "pkmn__sub");
|
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 });
|
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 {
|
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) {
|
if (!this.starterPreferences) {
|
||||||
this.starterPreferences = StarterPrefs.load();
|
this.starterPreferences = StarterPrefs.load();
|
||||||
}
|
}
|
||||||
@ -2125,6 +2128,14 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
clear(): void {
|
clear(): void {
|
||||||
super.clear();
|
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;
|
this.cursor = -1;
|
||||||
globalScene.ui.hideTooltip();
|
globalScene.ui.hideTooltip();
|
||||||
|
|
||||||
|
@ -216,6 +216,7 @@ interface SpeciesDetails {
|
|||||||
|
|
||||||
export default class StarterSelectUiHandler extends MessageUiHandler {
|
export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||||
private starterSelectContainer: Phaser.GameObjects.Container;
|
private starterSelectContainer: Phaser.GameObjects.Container;
|
||||||
|
private starterBoxContainer: Phaser.GameObjects.Container;
|
||||||
private starterSelectScrollBar: ScrollBar;
|
private starterSelectScrollBar: ScrollBar;
|
||||||
private filterBarContainer: Phaser.GameObjects.Container;
|
private filterBarContainer: Phaser.GameObjects.Container;
|
||||||
private filterBar: FilterBar;
|
private filterBar: FilterBar;
|
||||||
@ -623,19 +624,17 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
this.randomCursorObj.setOrigin(0, 0);
|
this.randomCursorObj.setOrigin(0, 0);
|
||||||
this.starterSelectContainer.add(this.randomCursorObj);
|
this.starterSelectContainer.add(this.randomCursorObj);
|
||||||
|
|
||||||
const starterSpecies: Species[] = [];
|
this.starterBoxContainer = globalScene.add.container(speciesContainerX + 6, 9); //115
|
||||||
|
|
||||||
const starterBoxContainer = globalScene.add.container(speciesContainerX + 6, 9); //115
|
|
||||||
|
|
||||||
this.starterSelectScrollBar = new ScrollBar(161, 12, 5, starterContainerWindow.height - 6, 9);
|
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(() => {
|
this.pokerusCursorObjs = new Array(POKERUS_STARTER_COUNT).fill(null).map(() => {
|
||||||
const cursorObj = globalScene.add.image(0, 0, "select_cursor_pokerus");
|
const cursorObj = globalScene.add.image(0, 0, "select_cursor_pokerus");
|
||||||
cursorObj.setVisible(false);
|
cursorObj.setVisible(false);
|
||||||
cursorObj.setOrigin(0, 0);
|
cursorObj.setOrigin(0, 0);
|
||||||
starterBoxContainer.add(cursorObj);
|
this.starterBoxContainer.add(cursorObj);
|
||||||
return cursorObj;
|
return cursorObj;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -643,7 +642,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
const cursorObj = globalScene.add.image(0, 0, "select_cursor_highlight");
|
const cursorObj = globalScene.add.image(0, 0, "select_cursor_highlight");
|
||||||
cursorObj.setVisible(false);
|
cursorObj.setVisible(false);
|
||||||
cursorObj.setOrigin(0, 0);
|
cursorObj.setOrigin(0, 0);
|
||||||
starterBoxContainer.add(cursorObj);
|
this.starterBoxContainer.add(cursorObj);
|
||||||
return cursorObj;
|
return cursorObj;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -655,25 +654,19 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
this.starterIconsCursorObj.setOrigin(0, 0);
|
this.starterIconsCursorObj.setOrigin(0, 0);
|
||||||
this.starterSelectContainer.add(this.starterIconsCursorObj);
|
this.starterSelectContainer.add(this.starterIconsCursorObj);
|
||||||
|
|
||||||
starterBoxContainer.add(this.cursorObj);
|
this.starterBoxContainer.add(this.cursorObj);
|
||||||
|
|
||||||
|
this.starterSelectContainer.add(this.starterBoxContainer);
|
||||||
|
|
||||||
for (const species of allSpecies) {
|
for (const species of allSpecies) {
|
||||||
if (!speciesStarterCosts.hasOwnProperty(species.speciesId) || !species.isObtainable()) {
|
if (!speciesStarterCosts.hasOwnProperty(species.speciesId) || !species.isObtainable()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
starterSpecies.push(species.speciesId);
|
|
||||||
this.speciesLoaded.set(species.speciesId, false);
|
this.speciesLoaded.set(species.speciesId, false);
|
||||||
this.allSpecies.push(species);
|
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) => {
|
this.starterIcons = new Array(6).fill(null).map((_, i) => {
|
||||||
const icon = globalScene.add.sprite(teamWindowX + 7, calcStarterIconY(i), "pokemon_icons_0");
|
const icon = globalScene.add.sprite(teamWindowX + 7, calcStarterIconY(i), "pokemon_icons_0");
|
||||||
icon.setScale(0.5);
|
icon.setScale(0.5);
|
||||||
@ -924,6 +917,14 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show(args: any[]): boolean {
|
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) {
|
if (!this.starterPreferences) {
|
||||||
// starterPreferences haven't been loaded yet
|
// starterPreferences haven't been loaded yet
|
||||||
this.starterPreferences = StarterPrefs.load();
|
this.starterPreferences = StarterPrefs.load();
|
||||||
@ -3829,6 +3830,14 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
this.activeTooltip = undefined;
|
this.activeTooltip = undefined;
|
||||||
globalScene.ui.hideTooltip();
|
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.starterSelectContainer.setVisible(false);
|
||||||
this.blockInput = false;
|
this.blockInput = false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user