Dynamically resizing ability box, showing ability description on first hover. Removed debug logs.

This commit is contained in:
Wlowscha 2025-01-04 19:48:17 +01:00
parent bb2aea40b9
commit 25e23decd4
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
4 changed files with 55 additions and 130 deletions

View File

@ -1690,8 +1690,6 @@ export function initPokemonPrevolutions(): void {
pokemonPrevolutions[ev.speciesId] = parseInt(pk) as Species; pokemonPrevolutions[ev.speciesId] = parseInt(pk) as Species;
} }
}); });
console.log("Prevo", pokemonPrevolutions[Species.IVYSAUR]);
console.log("Prevo", pokemonPrevolutions[Species.VENUSAUR]);
} }

View File

@ -116,10 +116,6 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
).join("\n"), ).join("\n"),
TextStyle.WINDOW, { maxLines: options.length, lineSpacing: 12 } TextStyle.WINDOW, { maxLines: options.length, lineSpacing: 12 }
); );
console.log(options.map(o => o.item
? `[color=${o.color || "white"}] ${o.label}[/color]`
: `[color=${o.color || "white"}]${o.label}[/color]`
).join("\n"));
this.optionSelectText.setOrigin(0, 0); this.optionSelectText.setOrigin(0, 0);
this.optionSelectText.setName("text-option-select"); this.optionSelectText.setName("text-option-select");
this.optionSelectContainer.add(this.optionSelectText); this.optionSelectContainer.add(this.optionSelectText);
@ -199,8 +195,6 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
let playSound = true; let playSound = true;
console.log(button);
if (button === Button.ACTION || button === Button.CANCEL) { if (button === Button.ACTION || button === Button.CANCEL) {
if (this.blockInput) { if (this.blockInput) {
ui.playError(); ui.playError();
@ -209,29 +203,22 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
success = true; success = true;
if (button === Button.CANCEL) { if (button === Button.CANCEL) {
console.log("Pressed CANCEL");
if (this.config?.maxOptions && this.config.options.length > this.config.maxOptions) { if (this.config?.maxOptions && this.config.options.length > this.config.maxOptions) {
this.scrollCursor = (this.config.options.length - this.config.maxOptions) + 1; this.scrollCursor = (this.config.options.length - this.config.maxOptions) + 1;
this.cursor = unskippedIndices.length - 1; this.cursor = unskippedIndices.length - 1;
console.log("A", this.scrollCursor, this.cursor);
} else if (!this.config?.noCancel) { } else if (!this.config?.noCancel) {
this.setCursor(unskippedIndices.length - 1); this.setCursor(unskippedIndices.length - 1);
console.log("B", this.scrollCursor, this.cursor);
} else { } else {
console.log("C", this.scrollCursor, this.cursor);
return false; return false;
} }
} }
const option = this.config?.options[unskippedIndices[this.cursor] + (this.scrollCursor - (this.scrollCursor ? 1 : 0))]; const option = this.config?.options[unskippedIndices[this.cursor] + (this.scrollCursor - (this.scrollCursor ? 1 : 0))];
console.log("CD", option);
if (option?.handler()) { if (option?.handler()) {
if (!option.keepOpen) { if (!option.keepOpen) {
console.log("D", this.scrollCursor, this.cursor);
this.clear(); this.clear();
} }
playSound = !option.overrideSound; playSound = !option.overrideSound;
} else { } else {
console.log("E", this.scrollCursor, this.cursor);
ui.playError(); ui.playError();
} }
} else if (button === Button.SUBMIT && ui.getMode() === Mode.AUTO_COMPLETE) { } else if (button === Button.SUBMIT && ui.getMode() === Mode.AUTO_COMPLETE) {

View File

@ -7,9 +7,6 @@ import i18next from "i18next";
export interface PokedexInfoOverlaySettings { export interface PokedexInfoOverlaySettings {
delayVisibility?: boolean; // if true, showing the overlay will only set it to active and populate the fields and the handler using this field has to manually call setVisible later. delayVisibility?: boolean; // if true, showing the overlay will only set it to active and populate the fields and the handler using this field has to manually call setVisible later.
scale?:number; // scale the box? A scale of 0.5 is recommended scale?:number; // scale the box? A scale of 0.5 is recommended
top?: boolean; // should the effect box be on top?
right?: boolean; // should the effect box be on the right?
onSide?: boolean; // should the effect be on the side? ignores top argument if true
//location and width of the component; unaffected by scaling //location and width of the component; unaffected by scaling
x?: number; x?: number;
y?: number; y?: number;
@ -20,9 +17,7 @@ export interface PokedexInfoOverlaySettings {
hideBg?: boolean; hideBg?: boolean;
} }
const EFF_HEIGHT = 36; const DESC_HEIGHT = 48;
const EFF_WIDTH = 82;
const DESC_HEIGHT = 36;
const BORDER = 8; const BORDER = 8;
const GLOBAL_SCALE = 6; const GLOBAL_SCALE = 6;
@ -36,47 +31,50 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp
private options: PokedexInfoOverlaySettings; private options: PokedexInfoOverlaySettings;
private textMaskRect: Phaser.GameObjects.Graphics;
private maskPointOriginX: number;
private maskPointOriginY: number;
public scale: number;
public width: number;
constructor(scene: BattleScene, options?: PokedexInfoOverlaySettings) { constructor(scene: BattleScene, options?: PokedexInfoOverlaySettings) {
if (options?.onSide) {
options.top = false;
}
super(scene, options?.x, options?.y); super(scene, options?.x, options?.y);
const scale = options?.scale || 1; // set up the scale this.scale = options?.scale || 1; // set up the scale
this.setScale(scale); this.setScale(this.scale);
this.options = options || {}; this.options = options || {};
// prepare the description box // prepare the description box
const width = (options?.width || PokedexInfoOverlay.getWidth(scale, scene)) / scale; // divide by scale as we always want this to be half a window wide this.width = (options?.width || PokedexInfoOverlay.getWidth(this.scale, scene)) / this.scale; // divide by scale as we always want this to be half a window wide
this.descBg = addWindow(scene, (options?.onSide && !options?.right ? EFF_WIDTH : 0), options?.top ? EFF_HEIGHT : 0, width - (options?.onSide ? EFF_WIDTH : 0), DESC_HEIGHT); this.descBg = addWindow(scene, 0, 0, this.width, DESC_HEIGHT);
this.descBg.setOrigin(0, 0); this.descBg.setOrigin(0, 0);
this.add(this.descBg); this.add(this.descBg);
// set up the description; wordWrap uses true pixels, unaffected by any scaling, while other values are affected // set up the description; wordWrap uses true pixels, unaffected by any scaling, while other values are affected
this.desc = addTextObject(scene, (options?.onSide && !options?.right ? EFF_WIDTH : 0) + BORDER, (options?.top ? EFF_HEIGHT : 0) + BORDER - 2, "", TextStyle.BATTLE_INFO, { wordWrap: { width: (width - (BORDER - 2) * 2 - (options?.onSide ? EFF_WIDTH : 0)) * GLOBAL_SCALE }}); this.desc = addTextObject(scene, BORDER, BORDER - 2, "", TextStyle.BATTLE_INFO, { wordWrap: { width: (this.width - (BORDER - 2) * 2) * GLOBAL_SCALE }});
this.desc.setLineSpacing(i18next.resolvedLanguage === "ja" ? 25 : 5); this.desc.setLineSpacing(i18next.resolvedLanguage === "ja" ? 25 : 5);
// limit the text rendering, required for scrolling later on // limit the text rendering, required for scrolling later on
const maskPointOrigin = { this.maskPointOriginX = options?.x || 0;
x: (options?.x || 0), this.maskPointOriginY = options?.y || 0;
y: (options?.y || 0),
}; if (this.maskPointOriginX < 0) {
if (maskPointOrigin.x < 0) { this.maskPointOriginX += this.scene.game.canvas.width / GLOBAL_SCALE;
maskPointOrigin.x += this.scene.game.canvas.width / GLOBAL_SCALE;
} }
if (maskPointOrigin.y < 0) { if (this.maskPointOriginY < 0) {
maskPointOrigin.y += this.scene.game.canvas.height / GLOBAL_SCALE; this.maskPointOriginY += this.scene.game.canvas.height / GLOBAL_SCALE;
} }
const moveDescriptionTextMaskRect = this.scene.make.graphics(); this.textMaskRect = this.scene.make.graphics();
moveDescriptionTextMaskRect.fillStyle(0xFF0000); this.textMaskRect.fillStyle(0xFF0000);
moveDescriptionTextMaskRect.fillRect( this.textMaskRect.fillRect(
maskPointOrigin.x + ((options?.onSide && !options?.right ? EFF_WIDTH : 0) + BORDER) * scale, maskPointOrigin.y + ((options?.top ? EFF_HEIGHT : 0) + BORDER - 2) * scale, this.maskPointOriginX + BORDER * this.scale, this.maskPointOriginY + (BORDER - 2) * this.scale,
width - ((options?.onSide ? EFF_WIDTH : 0) - BORDER * 2) * scale, (DESC_HEIGHT - (BORDER - 2) * 2) * scale); this.width - (BORDER * 2) * this.scale, (DESC_HEIGHT - (BORDER - 2) * 2) * this.scale);
moveDescriptionTextMaskRect.setScale(6); this.textMaskRect.setScale(6);
const moveDescriptionTextMask = this.createGeometryMask(moveDescriptionTextMaskRect); const textMask = this.createGeometryMask(this.textMaskRect);
this.add(this.desc); this.add(this.desc);
this.desc.setMask(moveDescriptionTextMask); this.desc.setMask(textMask);
if (options?.hideBg) { if (options?.hideBg) {
this.descBg.setVisible(false); this.descBg.setVisible(false);
@ -98,20 +96,37 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp
if (this.descScroll) { if (this.descScroll) {
this.descScroll.remove(); this.descScroll.remove();
this.descScroll = null; this.descScroll = null;
this.desc.y = (this.options?.top ? EFF_HEIGHT : 0) + BORDER - 2; this.desc.y = BORDER - 2;
} }
// determine if we need to add new scrolling effects // determine if we need to add new scrolling effects
const moveDescriptionLineCount = Math.floor(this.desc.displayHeight * (96 / 72) / 14.83); const lineCount = Math.floor(this.desc.displayHeight * (96 / 72) / 14.83);
if (moveDescriptionLineCount > 3) {
const newHeight = lineCount >= 3 ? 48 : (lineCount === 2 ? 36 : 24);
this.textMaskRect.clear();
this.textMaskRect.fillStyle(0xFF0000);
this.textMaskRect.fillRect(
this.maskPointOriginX + BORDER * this.scale,
this.maskPointOriginY + (BORDER - 2) * this.scale + (48 - newHeight),
this.width - (BORDER * 2) * this.scale,
(newHeight - (BORDER - 2) * 2) * this.scale
);
const updatedMask = this.createGeometryMask(this.textMaskRect);
this.desc.setMask(updatedMask);
this.descBg.setSize(this.descBg.width, newHeight);
this.descBg.setY(48 - newHeight);
this.desc.setY(BORDER - 2 + (48 - newHeight));
if (lineCount > 3) {
// generate scrolling effects // generate scrolling effects
this.descScroll = this.scene.tweens.add({ this.descScroll = this.scene.tweens.add({
targets: this.desc, targets: this.desc,
delay: Utils.fixedInt(2000), delay: Utils.fixedInt(2000),
loop: -1, loop: -1,
hold: Utils.fixedInt(2000), hold: Utils.fixedInt(2000),
duration: Utils.fixedInt((moveDescriptionLineCount - 3) * 2000), duration: Utils.fixedInt((lineCount - 3) * 2000),
y: `-=${14.83 * (72 / 96) * (moveDescriptionLineCount - 3)}` y: `-=${14.83 * (72 / 96) * (lineCount - 3)}`
}); });
} }
@ -153,6 +168,6 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp
// height of this element // height of this element
static getHeight(scale:number, onSide?: boolean):number { static getHeight(scale:number, onSide?: boolean):number {
return (onSide ? Math.max(EFF_HEIGHT, DESC_HEIGHT) : (EFF_HEIGHT + DESC_HEIGHT)) * scale; return DESC_HEIGHT * scale;
} }
} }

View File

@ -205,7 +205,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
private evolutions: SpeciesFormEvolution[]; private evolutions: SpeciesFormEvolution[];
private battleForms: PokemonForm[]; private battleForms: PokemonForm[];
private prevolution: SpeciesFormEvolution; private prevolution: SpeciesFormEvolution;
private baseForm: PokemonForm;
private speciesStarterDexEntry: DexEntry | null; private speciesStarterDexEntry: DexEntry | null;
private canCycleShiny: boolean; private canCycleShiny: boolean;
@ -488,7 +487,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.optionSelectText.displayWidth + 19 + 24 * this.scale, this.optionSelectText.displayWidth + 19 + 24 * this.scale,
(this.scene.game.canvas.height / 6) - 2 (this.scene.game.canvas.height / 6) - 2
); );
console.log("Logging sizes", this.optionSelectText.displayWidth + 25, this.scene.game.canvas.width / 6);
this.menuBg.setOrigin(0, 0); this.menuBg.setOrigin(0, 0);
this.optionSelectText.setPositionRelative(this.menuBg, 10 + 24 * this.scale, 6); this.optionSelectText.setPositionRelative(this.menuBg, 10 + 24 * this.scale, 6);
@ -514,7 +512,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.infoOverlay = new PokedexInfoOverlay(this.scene, { this.infoOverlay = new PokedexInfoOverlay(this.scene, {
scale: overlayScale, scale: overlayScale,
top: true,
x: 1, x: 1,
y: this.scene.game.canvas.height / 6 - PokedexInfoOverlay.getHeight(overlayScale) - 29, y: this.scene.game.canvas.height / 6 - PokedexInfoOverlay.getHeight(overlayScale) - 29,
}); });
@ -529,21 +526,14 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
show(args: any[]): boolean { show(args: any[]): boolean {
console.log("POKEDEX PAGE calling show");
if (args.length >= 1 && args[0] === "refresh") { if (args.length >= 1 && args[0] === "refresh") {
console.log("this.lastSpecies", this.lastSpecies);
console.log("this.lastFormIndex", this.lastFormIndex);
return false; return false;
} else { } else {
console.log("Calling", args[0], args[1] ?? 0);
this.lastSpecies = args[0]; this.lastSpecies = args[0];
this.lastFormIndex = args[1] ?? 0; this.lastFormIndex = args[1] ?? 0;
this.starterAttributes = args[2] ?? { shiny:false, female:true, variant:0, form:0 }; this.starterAttributes = args[2] ?? { shiny:false, female:true, variant:0, form:0 };
this.starterSetup(); this.starterSetup();
console.log("this.lastSpecies", this.lastSpecies);
console.log("this.lastFormIndex", this.lastFormIndex);
console.log("A this.starterAttributes", this.starterAttributes);
} }
this.moveInfoOverlay.clear(); // clear this when removing a menu; the cancel button doesn't seem to trigger this automatically on controllers this.moveInfoOverlay.clear(); // clear this when removing a menu; the cancel button doesn't seem to trigger this automatically on controllers
@ -551,23 +541,17 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
super.show(args); super.show(args);
console.log("B this.starterAttributes", this.starterAttributes);
this.starterSelectContainer.setVisible(true); this.starterSelectContainer.setVisible(true);
this.getUi().bringToTop(this.starterSelectContainer); this.getUi().bringToTop(this.starterSelectContainer);
this.starterAttributes = this.initStarterPrefs(); this.starterAttributes = this.initStarterPrefs();
console.log("C this.starterAttributes", this.starterAttributes);
this.menuOptions = Utils.getEnumKeys(MenuOptions).map(m => parseInt(MenuOptions[m]) as MenuOptions); this.menuOptions = Utils.getEnumKeys(MenuOptions).map(m => parseInt(MenuOptions[m]) as MenuOptions);
this.menuContainer.setVisible(true); this.menuContainer.setVisible(true);
this.setCursor(0); this.setCursor(0);
console.log("D this.starterAttributes", this.starterAttributes);
this.setSpecies(this.lastSpecies); this.setSpecies(this.lastSpecies);
this.updateInstructions(); this.updateInstructions();
@ -582,8 +566,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
const allEvolutions = pokemonEvolutions.hasOwnProperty(species.speciesId) ? pokemonEvolutions[species.speciesId] : []; const allEvolutions = pokemonEvolutions.hasOwnProperty(species.speciesId) ? pokemonEvolutions[species.speciesId] : [];
console.log(species.speciesId, Species[species.speciesId], formIndex);
if (species.forms.length > 0) { if (species.forms.length > 0) {
const form = species.forms[formIndex]; const form = species.forms[formIndex];
@ -635,15 +617,11 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.prevolution = null; this.prevolution = null;
const preSpecies = pokemonPrevolutions.hasOwnProperty(this.lastSpecies.speciesId) ? allSpecies.find(sp => sp.speciesId === pokemonPrevolutions[this.lastSpecies.speciesId]) : null; const preSpecies = pokemonPrevolutions.hasOwnProperty(this.lastSpecies.speciesId) ? allSpecies.find(sp => sp.speciesId === pokemonPrevolutions[this.lastSpecies.speciesId]) : null;
console.log("Prespecies", preSpecies?.name);
if (preSpecies) { if (preSpecies) {
const preEvolutions = pokemonEvolutions.hasOwnProperty(preSpecies.speciesId) ? pokemonEvolutions[preSpecies.speciesId] : []; const preEvolutions = pokemonEvolutions.hasOwnProperty(preSpecies.speciesId) ? pokemonEvolutions[preSpecies.speciesId] : [];
console.log(preEvolutions);
if (species.forms.length > 0) { if (species.forms.length > 0) {
console.log("A");
this.prevolution = preEvolutions.filter(e => (e.evoFormKey === species.forms[formIndex].formKey || e.evoFormKey === null))[0]; this.prevolution = preEvolutions.filter(e => (e.evoFormKey === species.forms[formIndex].formKey || e.evoFormKey === null))[0];
} else { } else {
console.log("B");
this.prevolution = preEvolutions[0]; this.prevolution = preEvolutions[0];
} }
@ -948,9 +926,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.toggleStatsMode(false); this.toggleStatsMode(false);
success = true; success = true;
} else { } else {
console.log(this.getUi().getModeChain());
this.getUi().revertMode(); this.getUi().revertMode();
console.log(this.getUi().getModeChain());
success = true; success = true;
} }
} else { } else {
@ -962,14 +938,11 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
if (button === Button.ACTION) { if (button === Button.ACTION) {
console.log("Cursor", this.cursor);
switch (this.cursor) { switch (this.cursor) {
case MenuOptions.BASE_STATS: case MenuOptions.BASE_STATS:
this.blockInput = true; this.blockInput = true;
console.log("level moves", MenuOptions.LEVEL_MOVES);
ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => {
ui.showText(i18next.t("pokedexUiHandler:baseStats"), null, () => { ui.showText(i18next.t("pokedexUiHandler:baseStats"), null, () => {
@ -1017,13 +990,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
case MenuOptions.LEVEL_MOVES: case MenuOptions.LEVEL_MOVES:
this.blockInput = true; this.blockInput = true;
console.log("level moves", MenuOptions.LEVEL_MOVES);
ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => {
ui.showText(i18next.t("pokedexUiHandler:movesLearntOnLevelUp"), null, () => { ui.showText(i18next.t("pokedexUiHandler:movesLearntOnLevelUp"), null, () => {
console.log(this.levelMoves);
console.log(this.levelMoves[0]);
this.moveInfoOverlay.show(allMoves[this.levelMoves[0][1]]); this.moveInfoOverlay.show(allMoves[this.levelMoves[0][1]]);
ui.setModeWithoutClear(Mode.OPTION_SELECT, { ui.setModeWithoutClear(Mode.OPTION_SELECT, {
@ -1054,7 +1024,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
maxOptions: 8, maxOptions: 8,
yOffset: 19 yOffset: 19
}); });
console.log("We did the thing");
this.blockInput = false; this.blockInput = false;
}); });
}); });
@ -1175,6 +1144,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
ui.showText(i18next.t("pokedexUiHandler:showAbilities"), null, () => { ui.showText(i18next.t("pokedexUiHandler:showAbilities"), null, () => {
this.infoOverlay.show(allAbilities[this.ability1].description);
const options: any[] = []; const options: any[] = [];
if (this.ability1) { if (this.ability1) {
@ -1301,7 +1272,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
ui.showText(i18next.t("pokedexUiHandler:evolutionsAndForms"), null, () => { ui.showText(i18next.t("pokedexUiHandler:evolutionsAndForms"), null, () => {
if (!this.prevolution && !this.baseForm && !this.evolutions && !this.battleForms) { if (!this.prevolution && !this.evolutions && !this.battleForms) {
this.blockInput = false; this.blockInput = false;
return true; return true;
} }
@ -1314,7 +1285,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
}); });
const pre = this.prevolution; const pre = this.prevolution;
console.log("Prevolution", pre);
options.push({ options.push({
label: i18next.t(`pokemon:${Species[pokemonPrevolutions[pre.speciesId]].toUpperCase()}`), label: i18next.t(`pokemon:${Species[pokemonPrevolutions[pre.speciesId]].toUpperCase()}`),
color: "#ccbe00", color: "#ccbe00",
@ -1346,36 +1316,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
skip: true, skip: true,
handler: () => false handler: () => false
}); });
} else if (this.baseForm) {
options.push({
label: i18next.t("pokedexUiHandler:baseForm") + ":",
skip: true,
handler: () => false
});
const bf = this.baseForm;
const formText = capitalizeString(bf.formKey, "-", false, false);
const speciesName = capitalizeString(this.getStarterSpecies(this.lastSpecies).name, "_", true, false);
const label = Object.values(SpeciesFormKey).includes(bf.formKey as SpeciesFormKey) ?
i18next.t(`battlePokemonForm:${bf.formKey}`, { pokemonName:this.lastSpecies.name }) : (
this.lastSpecies.speciesId === Species.ARCEUS ?
i18next.t(`pokemonInfo:Type.${formText?.toUpperCase()}`) :
formText ? i18next.t(`pokemonForm:${speciesName}${formText}`) : ""
);
options.push({
label: label,
color: "#ccbe00",
handler: () => {
const newSpecies = this.lastSpecies;
const newFormIndex = bf.formIndex;
this.starterAttributes.form = newFormIndex;
this.moveInfoOverlay.clear();
this.clearText();
console.log("Pressing form", newSpecies, newFormIndex);
ui.setMode(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.starterAttributes);
return true;
}
});
} }
if (this.evolutions.length > 0) { if (this.evolutions.length > 0) {
@ -1385,8 +1325,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
handler: () => false handler: () => false
}); });
this.evolutions.map(evo => { this.evolutions.map(evo => {
console.log(evo);
console.log(Species[evo.speciesId]);
options.push({ options.push({
label: i18next.t(`pokemon:${Species[evo.speciesId].toUpperCase()}`), label: i18next.t(`pokemon:${Species[evo.speciesId].toUpperCase()}`),
color: "#ccbe00", color: "#ccbe00",
@ -1448,7 +1386,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.starterAttributes.form = newFormIndex; this.starterAttributes.form = newFormIndex;
this.moveInfoOverlay.clear(); this.moveInfoOverlay.clear();
this.clearText(); this.clearText();
console.log("Pressing form", newSpecies, newFormIndex);
ui.setMode(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.starterAttributes); ui.setMode(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.starterAttributes);
return true; return true;
} }
@ -1690,7 +1627,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
const props = this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId)); const props = this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId));
switch (button) { switch (button) {
case Button.CYCLE_SHINY: case Button.CYCLE_SHINY:
console.log("Pressing Button.CYCLE_SHINY");
if (this.canCycleShiny) { if (this.canCycleShiny) {
starterAttributes.shiny = starterAttributes.shiny !== undefined ? !starterAttributes.shiny : false; starterAttributes.shiny = starterAttributes.shiny !== undefined ? !starterAttributes.shiny : false;
@ -1705,7 +1641,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.pokemonShinyIcon.setFrame(getVariantIcon(newVariant)); this.pokemonShinyIcon.setFrame(getVariantIcon(newVariant));
this.pokemonShinyIcon.setTint(tint); this.pokemonShinyIcon.setTint(tint);
this.pokemonShinyIcon.setVisible(true); this.pokemonShinyIcon.setVisible(true);
console.log(starterAttributes.shiny, starterAttributes.variant);
} else { } else {
this.setSpeciesDetails(this.lastSpecies, { shiny: false, variant: 0 }); this.setSpeciesDetails(this.lastSpecies, { shiny: false, variant: 0 });
this.pokemonShinyIcon.setVisible(false); this.pokemonShinyIcon.setVisible(false);
@ -1714,7 +1649,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
} }
break; break;
case Button.V: case Button.V:
console.log("before", starterAttributes.shiny, starterAttributes.variant);
if (this.canCycleVariant) { if (this.canCycleVariant) {
let newVariant = props.variant; let newVariant = props.variant;
do { do {
@ -1739,7 +1673,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
const tint = getVariantTint(newVariant as Variant); const tint = getVariantTint(newVariant as Variant);
this.pokemonShinyIcon.setFrame(getVariantIcon(newVariant as Variant)); this.pokemonShinyIcon.setFrame(getVariantIcon(newVariant as Variant));
this.pokemonShinyIcon.setTint(tint); this.pokemonShinyIcon.setTint(tint);
console.log("after", starterAttributes.shiny, starterAttributes.variant);
success = true; success = true;
} }
break; break;
@ -2136,8 +2069,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
const forSeen: boolean = options.forSeen ?? false; const forSeen: boolean = options.forSeen ?? false;
const oldProps = species ? this.starterAttributes : null; const oldProps = species ? this.starterAttributes : null;
console.log("A new beginning", shiny, formIndex, female, variant);
// We will only update the sprite if there is a change to form, shiny/variant // We will only update the sprite if there is a change to form, shiny/variant
// or gender for species with gender sprite differences // or gender for species with gender sprite differences
const shouldUpdateSprite = (species?.genderDiffs && !isNullOrUndefined(female)) const shouldUpdateSprite = (species?.genderDiffs && !isNullOrUndefined(female))
@ -2196,7 +2127,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
if (shiny === undefined || shiny !== props.shiny) { if (shiny === undefined || shiny !== props.shiny) {
shiny = props.shiny; shiny = props.shiny;
console.log("Uh oh shiny:", shiny);
} }
if (formIndex === undefined || formIndex !== props.form) { if (formIndex === undefined || formIndex !== props.form) {
formIndex = props.form; formIndex = props.form;
@ -2218,23 +2148,18 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
const assetLoadCancelled = new BooleanHolder(false); const assetLoadCancelled = new BooleanHolder(false);
this.assetLoadCancelled = assetLoadCancelled; this.assetLoadCancelled = assetLoadCancelled;
console.log("Updating sprite?", shouldUpdateSprite);
if (shouldUpdateSprite) { if (shouldUpdateSprite) {
species.loadAssets(this.scene, female!, formIndex, shiny, variant, true).then(() => { // TODO: is this bang correct? species.loadAssets(this.scene, female!, formIndex, shiny, variant, true).then(() => { // TODO: is this bang correct?
if (assetLoadCancelled.value) { if (assetLoadCancelled.value) {
return; return;
} }
console.log("Updating sprite...");
this.assetLoadCancelled = null; this.assetLoadCancelled = null;
this.speciesLoaded.set(species.speciesId, true); this.speciesLoaded.set(species.speciesId, true);
this.pokemonSprite.play(species.getSpriteKey(female!, formIndex, shiny, variant)); // TODO: is this bang correct? this.pokemonSprite.play(species.getSpriteKey(female!, formIndex, shiny, variant)); // TODO: is this bang correct?
console.log(female, formIndex, shiny, variant); // TODO: is this bang correct?
console.log(species.getSpriteKey(female!, formIndex, shiny, variant));
this.pokemonSprite.setPipelineData("shiny", shiny); this.pokemonSprite.setPipelineData("shiny", shiny);
this.pokemonSprite.setPipelineData("variant", variant); this.pokemonSprite.setPipelineData("variant", variant);
this.pokemonSprite.setPipelineData("spriteKey", species.getSpriteKey(female!, formIndex, shiny, variant)); // TODO: is this bang correct? this.pokemonSprite.setPipelineData("spriteKey", species.getSpriteKey(female!, formIndex, shiny, variant)); // TODO: is this bang correct?
this.pokemonSprite.setVisible(!this.statsMode); this.pokemonSprite.setVisible(!this.statsMode);
console.log("Was it updated?");
}); });
} else { } else {
this.pokemonSprite.setVisible(!this.statsMode); this.pokemonSprite.setVisible(!this.statsMode);