Introducing globalScene everywhere

This commit is contained in:
Wlowscha 2025-01-15 17:11:12 +01:00
parent 13177ae619
commit 70f7ab89f3
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
7 changed files with 330 additions and 353 deletions

View File

@ -1,8 +1,9 @@
import BattleScene, { InfoToggle } from "../battle-scene"; import type { InfoToggle } from "../battle-scene";
import { TextStyle, addTextObject } from "./text"; import { TextStyle, addTextObject } from "./text";
import { addWindow } from "./ui-theme"; import { addWindow } from "./ui-theme";
import * as Utils from "../utils"; import * as Utils from "../utils";
import i18next from "i18next"; import i18next from "i18next";
import { globalScene } from "#app/global-scene";
export interface BaseStatsOverlaySettings { export interface BaseStatsOverlaySettings {
scale?:number; // scale the box? A scale of 0.5 is recommended scale?:number; // scale the box? A scale of 0.5 is recommended
@ -33,35 +34,35 @@ export default class BaseStatsOverlay extends Phaser.GameObjects.Container imple
public scale: number; public scale: number;
public width: number; public width: number;
constructor(scene: BattleScene, options?: BaseStatsOverlaySettings) { constructor(options?: BaseStatsOverlaySettings) {
super(scene, options?.x, options?.y); super(globalScene, options?.x, options?.y);
this.scale = options?.scale || 1; // set up the scale this.scale = options?.scale || 1; // set up the scale
this.setScale(this.scale); this.setScale(this.scale);
this.options = options || {}; this.options = options || {};
// prepare the description box // prepare the description box
this.width = (options?.width || BaseStatsOverlay.getWidth(this.scale, scene)) / this.scale; // divide by scale as we always want this to be half a window wide this.width = (options?.width || BaseStatsOverlay.getWidth(this.scale)) / this.scale; // divide by scale as we always want this to be half a window wide
this.statsBg = addWindow(scene, 0, 0, this.width, HEIGHT); this.statsBg = addWindow(0, 0, this.width, HEIGHT);
this.statsBg.setOrigin(0, 0); this.statsBg.setOrigin(0, 0);
this.add(this.statsBg); this.add(this.statsBg);
for (let i = 0; i < 6; i++) { for (let i = 0; i < 6; i++) {
const shadow = this.scene.add.rectangle(this.width - BORDER + 1, BORDER + 3 + i * 15, 100, 5, 0x006860); const shadow = globalScene.add.rectangle(this.width - BORDER + 1, BORDER + 3 + i * 15, 100, 5, 0x006860);
shadow.setOrigin(1, 0); shadow.setOrigin(1, 0);
this.statsShadows.push(shadow); this.statsShadows.push(shadow);
this.add(shadow); this.add(shadow);
const rectangle = this.scene.add.rectangle(this.width - BORDER, BORDER + 2 + i * 15, 100, 5, 0x66aa99); const rectangle = globalScene.add.rectangle(this.width - BORDER, BORDER + 2 + i * 15, 100, 5, 0x66aa99);
rectangle.setOrigin(1, 0); rectangle.setOrigin(1, 0);
this.statsRectangles.push(rectangle); this.statsRectangles.push(rectangle);
this.add(rectangle); this.add(rectangle);
const label = addTextObject(scene, BORDER, BORDER - 2 + i * 15, "A", TextStyle.BATTLE_INFO); const label = addTextObject(BORDER, BORDER - 2 + i * 15, "A", TextStyle.BATTLE_INFO);
this.statsLabels.push(label); this.statsLabels.push(label);
this.add(label); this.add(label);
} }
this.statsTotalLabel = addTextObject(scene, BORDER, BORDER + 6 * 15, "A", TextStyle.MONEY_WINDOW); this.statsTotalLabel = addTextObject(BORDER, BORDER + 6 * 15, "A", TextStyle.MONEY_WINDOW);
this.add(this.statsTotalLabel); this.add(this.statsTotalLabel);
// hide this component for now // hide this component for now
@ -96,7 +97,7 @@ export default class BaseStatsOverlay extends Phaser.GameObjects.Container imple
if (visible) { if (visible) {
this.setVisible(true); this.setVisible(true);
} }
this.scene.tweens.add({ globalScene.tweens.add({
targets: this.statsLabels, targets: this.statsLabels,
duration: Utils.fixedInt(125), duration: Utils.fixedInt(125),
ease: "Sine.easeInOut", ease: "Sine.easeInOut",
@ -112,8 +113,8 @@ export default class BaseStatsOverlay extends Phaser.GameObjects.Container imple
} }
// width of this element // width of this element
static getWidth(scale:number, scene: BattleScene):number { static getWidth(scale:number):number {
return scene.game.canvas.width / GLOBAL_SCALE / 2; return globalScene.game.canvas.width / GLOBAL_SCALE / 2;
} }
// height of this element // height of this element

View File

@ -48,8 +48,6 @@ export class FilterBar extends Phaser.GameObjects.Container {
this.cursorObj.setVisible(false); this.cursorObj.setVisible(false);
this.cursorObj.setOrigin(0, 0); this.cursorObj.setOrigin(0, 0);
this.add(this.cursorObj); this.add(this.cursorObj);
this.uiTheme = globalScene.uiTheme;
} }
/** /**
@ -94,9 +92,9 @@ export class FilterBar extends Phaser.GameObjects.Container {
updateFilterLabels(): void { updateFilterLabels(): void {
for (let i = 0; i < this.numFilters; i++) { for (let i = 0; i < this.numFilters; i++) {
if (this.dropDowns[i].hasDefaultValues()) { if (this.dropDowns[i].hasDefaultValues()) {
this.labels[i].setColor(getTextColor(TextStyle.TOOLTIP_CONTENT, false, this.uiTheme)); this.labels[i].setColor(getTextColor(TextStyle.TOOLTIP_CONTENT, false, globalScene.uiTheme));
} else { } else {
this.labels[i].setColor(getTextColor(TextStyle.STATS_LABEL, false, this.uiTheme)); this.labels[i].setColor(getTextColor(TextStyle.STATS_LABEL, false, globalScene.uiTheme));
} }
} }
} }

View File

@ -1,11 +1,12 @@
import BattleScene from "#app/battle-scene"; import type { StarterContainer } from "./starter-container";
import { StarterContainer } from "./starter-container";
import { addTextObject, getTextColor, TextStyle } from "./text"; import { addTextObject, getTextColor, TextStyle } from "./text";
import { UiTheme } from "#enums/ui-theme"; import type { UiTheme } from "#enums/ui-theme";
import { addWindow, WindowVariant } from "./ui-theme"; import { addWindow, WindowVariant } from "./ui-theme";
import i18next from "i18next"; import i18next from "i18next";
import AwaitableUiHandler from "./awaitable-ui-handler"; import type AwaitableUiHandler from "./awaitable-ui-handler";
import UI, { Mode } from "./ui"; import type UI from "./ui";
import { Mode } from "./ui";
import { globalScene } from "#app/global-scene";
export enum FilterTextRow{ export enum FilterTextRow{
NAME, NAME,
@ -38,36 +39,33 @@ export class FilterText extends Phaser.GameObjects.Container {
public defaultText: string = "---"; public defaultText: string = "---";
constructor(scene: BattleScene, x: number, y: number, width: number, height: number, onChange: () => void,) { constructor(x: number, y: number, width: number, height: number, onChange: () => void,) {
super(scene, x, y); super(globalScene, x, y);
this.onChange = onChange; this.onChange = onChange;
this.width = width; this.width = width;
this.height = height; this.height = height;
this.window = addWindow(scene, 0, 0, width, height, false, false, undefined, undefined, WindowVariant.THIN); this.window = addWindow(0, 0, width, height, false, false, undefined, undefined, WindowVariant.THIN);
this.add(this.window); this.add(this.window);
this.cursorObj = this.scene.add.image(1, 1, "cursor"); this.cursorObj = globalScene.add.image(1, 1, "cursor");
this.cursorObj.setScale(0.5); this.cursorObj.setScale(0.5);
this.cursorObj.setVisible(false); this.cursorObj.setVisible(false);
this.cursorObj.setOrigin(0, 0); this.cursorObj.setOrigin(0, 0);
this.add(this.cursorObj); this.add(this.cursorObj);
this.uiTheme = scene.uiTheme; this.menuMessageBoxContainer = globalScene.add.container(0, 130);
this.menuMessageBoxContainer = this.scene.add.container(0, 130);
this.menuMessageBoxContainer.setName("menu-message-box"); this.menuMessageBoxContainer.setName("menu-message-box");
this.menuMessageBoxContainer.setVisible(false); this.menuMessageBoxContainer.setVisible(false);
// Full-width window used for testing dialog messages in debug mode // Full-width window used for testing dialog messages in debug mode
this.dialogueMessageBox = addWindow(scene, -this.textPadding, 0, this.scene.game.canvas.width / 6 + this.textPadding * 2, 49, false, false, 0, 0, WindowVariant.THIN); this.dialogueMessageBox = addWindow(-this.textPadding, 0, globalScene.game.canvas.width / 6 + this.textPadding * 2, 49, false, false, 0, 0, WindowVariant.THIN);
this.dialogueMessageBox.setOrigin(0, 0); this.dialogueMessageBox.setOrigin(0, 0);
this.menuMessageBoxContainer.add(this.dialogueMessageBox); this.menuMessageBoxContainer.add(this.dialogueMessageBox);
const menuMessageText = addTextObject(this.scene, this.textPadding, this.textPadding, "", TextStyle.WINDOW, { maxLines: 2 }); const menuMessageText = addTextObject(this.textPadding, this.textPadding, "", TextStyle.WINDOW, { maxLines: 2 });
menuMessageText.setName("menu-message"); menuMessageText.setName("menu-message");
menuMessageText.setOrigin(0, 0); menuMessageText.setOrigin(0, 0);
this.menuMessageBoxContainer.add(menuMessageText); this.menuMessageBoxContainer.add(menuMessageText);
@ -99,11 +97,11 @@ export class FilterText extends Phaser.GameObjects.Container {
this.rows.push(row); this.rows.push(row);
const filterTypesLabel = addTextObject(this.scene, paddingX + cursorOffset, 3, title, TextStyle.TOOLTIP_CONTENT); const filterTypesLabel = addTextObject(paddingX + cursorOffset, 3, title, TextStyle.TOOLTIP_CONTENT);
this.labels.push(filterTypesLabel); this.labels.push(filterTypesLabel);
this.add(filterTypesLabel); this.add(filterTypesLabel);
const filterTypesSelection = addTextObject(this.scene, paddingX + cursorOffset + extraSpaceX, 3, this.defaultText, TextStyle.TOOLTIP_CONTENT); const filterTypesSelection = addTextObject(paddingX + cursorOffset + extraSpaceX, 3, this.defaultText, TextStyle.TOOLTIP_CONTENT);
this.selections.push(filterTypesSelection); this.selections.push(filterTypesSelection);
this.add(filterTypesSelection); this.add(filterTypesSelection);
@ -170,9 +168,9 @@ export class FilterText extends Phaser.GameObjects.Container {
updateFilterLabels(): void { updateFilterLabels(): void {
for (let i = 0; i < this.numFilters; i++) { for (let i = 0; i < this.numFilters; i++) {
if (this.selections[i].text === this.defaultText) { if (this.selections[i].text === this.defaultText) {
this.labels[i].setColor(getTextColor(TextStyle.TOOLTIP_CONTENT, false, this.uiTheme)); this.labels[i].setColor(getTextColor(TextStyle.TOOLTIP_CONTENT, false, globalScene.uiTheme));
} else { } else {
this.labels[i].setColor(getTextColor(TextStyle.STATS_LABEL, false, this.uiTheme)); this.labels[i].setColor(getTextColor(TextStyle.STATS_LABEL, false, globalScene.uiTheme));
} }
} }
} }

View File

@ -1,8 +1,9 @@
import BattleScene, { InfoToggle } from "../battle-scene"; import type { InfoToggle } from "../battle-scene";
import { TextStyle, addTextObject } from "./text"; import { TextStyle, addTextObject } from "./text";
import { addWindow } from "./ui-theme"; import { addWindow } from "./ui-theme";
import * as Utils from "../utils"; import * as Utils from "../utils";
import i18next from "i18next"; import i18next from "i18next";
import { globalScene } from "#app/global-scene";
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.
@ -38,20 +39,20 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp
public scale: number; public scale: number;
public width: number; public width: number;
constructor(scene: BattleScene, options?: PokedexInfoOverlaySettings) { constructor(options?: PokedexInfoOverlaySettings) {
super(scene, options?.x, options?.y); super(globalScene, options?.x, options?.y);
this.scale = options?.scale || 1; // set up the scale this.scale = options?.scale || 1; // set up the scale
this.setScale(this.scale); this.setScale(this.scale);
this.options = options || {}; this.options = options || {};
// prepare the description box // prepare the description box
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.width = (options?.width || PokedexInfoOverlay.getWidth(this.scale)) / this.scale; // divide by scale as we always want this to be half a window wide
this.descBg = addWindow(scene, 0, 0, this.width, DESC_HEIGHT); this.descBg = addWindow(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, BORDER, BORDER - 2, "", TextStyle.BATTLE_INFO, { wordWrap: { width: (this.width - (BORDER - 2) * 2) * GLOBAL_SCALE }}); this.desc = addTextObject(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
@ -59,13 +60,13 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp
this.maskPointOriginY = options?.y || 0; this.maskPointOriginY = options?.y || 0;
if (this.maskPointOriginX < 0) { if (this.maskPointOriginX < 0) {
this.maskPointOriginX += this.scene.game.canvas.width / GLOBAL_SCALE; this.maskPointOriginX += globalScene.game.canvas.width / GLOBAL_SCALE;
} }
if (this.maskPointOriginY < 0) { if (this.maskPointOriginY < 0) {
this.maskPointOriginY += this.scene.game.canvas.height / GLOBAL_SCALE; this.maskPointOriginY += globalScene.game.canvas.height / GLOBAL_SCALE;
} }
this.textMaskRect = this.scene.make.graphics(); this.textMaskRect = globalScene.make.graphics();
this.textMaskRect.fillStyle(0xFF0000); this.textMaskRect.fillStyle(0xFF0000);
this.textMaskRect.fillRect( this.textMaskRect.fillRect(
this.maskPointOriginX + BORDER * this.scale, this.maskPointOriginY + (BORDER - 2) * this.scale, this.maskPointOriginX + BORDER * this.scale, this.maskPointOriginY + (BORDER - 2) * this.scale,
@ -86,7 +87,7 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp
// show this component with infos for the specific move // show this component with infos for the specific move
show(text: string):boolean { show(text: string):boolean {
if (!(this.scene as BattleScene).enableMoveInfo) { if (!globalScene.enableMoveInfo) {
return false; // move infos have been disabled // TODO:: is `false` correct? i used to be `undeefined` return false; // move infos have been disabled // TODO:: is `false` correct? i used to be `undeefined`
} }
@ -120,7 +121,7 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp
if (lineCount > 3) { if (lineCount > 3) {
// generate scrolling effects // generate scrolling effects
this.descScroll = this.scene.tweens.add({ this.descScroll = globalScene.tweens.add({
targets: this.desc, targets: this.desc,
delay: Utils.fixedInt(2000), delay: Utils.fixedInt(2000),
loop: -1, loop: -1,
@ -146,7 +147,7 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp
if (visible) { if (visible) {
this.setVisible(true); this.setVisible(true);
} }
this.scene.tweens.add({ globalScene.tweens.add({
targets: this.desc, targets: this.desc,
duration: Utils.fixedInt(125), duration: Utils.fixedInt(125),
ease: "Sine.easeInOut", ease: "Sine.easeInOut",
@ -162,8 +163,8 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp
} }
// width of this element // width of this element
static getWidth(scale:number, scene: BattleScene):number { static getWidth(scale:number):number {
return scene.game.canvas.width / GLOBAL_SCALE / 2; return globalScene.game.canvas.width / GLOBAL_SCALE / 2;
} }
// height of this element // height of this element

View File

@ -1,8 +1,11 @@
import { EvolutionItem, pokemonEvolutions, pokemonPrevolutions, pokemonStarters, SpeciesFormEvolution } from "#app/data/balance/pokemon-evolutions"; import type { SpeciesFormEvolution } from "#app/data/balance/pokemon-evolutions";
import { Variant, getVariantTint, getVariantIcon } from "#app/data/variant"; import { EvolutionItem, pokemonEvolutions, pokemonPrevolutions, pokemonStarters } from "#app/data/balance/pokemon-evolutions";
import type { Variant } from "#app/data/variant";
import { getVariantTint, getVariantIcon } from "#app/data/variant";
import { argbFromRgba } from "@material/material-color-utilities"; import { argbFromRgba } from "@material/material-color-utilities";
import i18next from "i18next"; import i18next from "i18next";
import BattleScene, { AnySound, starterColors } from "#app/battle-scene"; import type { AnySound } from "#app/battle-scene";
import { starterColors } from "#app/battle-scene";
import { allAbilities } from "#app/data/ability"; import { allAbilities } from "#app/data/ability";
import { speciesEggMoves } from "#app/data/balance/egg-moves"; import { speciesEggMoves } from "#app/data/balance/egg-moves";
import { GrowthRate, getGrowthRateColor } from "#app/data/exp"; import { GrowthRate, getGrowthRateColor } from "#app/data/exp";
@ -10,14 +13,18 @@ import { Gender, getGenderColor, getGenderSymbol } from "#app/data/gender";
import { allMoves } from "#app/data/move"; import { allMoves } from "#app/data/move";
import { getNatureName } from "#app/data/nature"; import { getNatureName } from "#app/data/nature";
import { pokemonFormChanges } from "#app/data/pokemon-forms"; import { pokemonFormChanges } from "#app/data/pokemon-forms";
import { LevelMoves, pokemonFormLevelMoves, pokemonSpeciesLevelMoves } from "#app/data/balance/pokemon-level-moves"; import type { LevelMoves } from "#app/data/balance/pokemon-level-moves";
import PokemonSpecies, { allSpecies, getPokemonSpeciesForm, PokemonForm } from "#app/data/pokemon-species"; import { pokemonFormLevelMoves, pokemonSpeciesLevelMoves } from "#app/data/balance/pokemon-level-moves";
import type { PokemonForm } from "#app/data/pokemon-species";
import type PokemonSpecies from "#app/data/pokemon-species";
import { allSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species";
import { getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/balance/starters"; import { getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/balance/starters";
import { starterPassiveAbilities } from "#app/data/balance/passives"; import { starterPassiveAbilities } from "#app/data/balance/passives";
import { Type } from "#enums/type"; import { Type } from "#enums/type";
import { GameModes } from "#app/game-mode"; import { GameModes } from "#app/game-mode";
import { AbilityAttr, DexAttr, DexEntry, StarterAttributes } from "#app/system/game-data"; import type { DexEntry, StarterAttributes } from "#app/system/game-data";
import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import { AbilityAttr, DexAttr } from "#app/system/game-data";
import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
import MessageUiHandler from "#app/ui/message-ui-handler"; import MessageUiHandler from "#app/ui/message-ui-handler";
import { StatsContainer } from "#app/ui/stats-container"; import { StatsContainer } from "#app/ui/stats-container";
import { TextStyle, addTextObject, getTextStyleOptions } from "#app/ui/text"; import { TextStyle, addTextObject, getTextStyleOptions } from "#app/ui/text";
@ -32,7 +39,7 @@ import MoveInfoOverlay from "#app/ui/move-info-overlay";
import PokedexInfoOverlay from "#app/ui/pokedex-info-overlay"; import PokedexInfoOverlay from "#app/ui/pokedex-info-overlay";
import { getEggTierForSpecies } from "#app/data/egg"; import { getEggTierForSpecies } from "#app/data/egg";
import { Device } from "#enums/devices"; import { Device } from "#enums/devices";
import { Moves } from "#enums/moves"; import type { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { Button } from "#enums/buttons"; import { Button } from "#enums/buttons";
import { EggSourceType } from "#enums/egg-source-types"; import { EggSourceType } from "#enums/egg-source-types";
@ -43,11 +50,13 @@ import type { Nature } from "#enums/nature";
import BgmBar from "./bgm-bar"; import BgmBar from "./bgm-bar";
import * as Utils from "../utils"; import * as Utils from "../utils";
import { speciesTmMoves } from "#app/data/balance/tms"; import { speciesTmMoves } from "#app/data/balance/tms";
import { BiomePoolTier, BiomeTierTod, catchableSpecies } from "#app/data/balance/biomes"; import type { BiomeTierTod } from "#app/data/balance/biomes";
import { BiomePoolTier, catchableSpecies } from "#app/data/balance/biomes";
import { Biome } from "#app/enums/biome"; import { Biome } from "#app/enums/biome";
import { TimeOfDay } from "#app/enums/time-of-day"; import { TimeOfDay } from "#app/enums/time-of-day";
import { Abilities } from "#app/enums/abilities"; import type { Abilities } from "#app/enums/abilities";
import BaseStatsOverlay from "./base-stats-overlay"; import BaseStatsOverlay from "./base-stats-overlay";
import { globalScene } from "#app/global-scene";
interface LanguageSetting { interface LanguageSetting {
@ -238,8 +247,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
protected scale: number = 0.1666666667; protected scale: number = 0.1666666667;
private menuDescriptions: string[]; private menuDescriptions: string[];
constructor(scene: BattleScene) { constructor() {
super(scene, Mode.POKEDEX_PAGE); super(Mode.POKEDEX_PAGE);
} }
setup() { setup() {
@ -248,49 +257,49 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
const langSettingKey = Object.keys(languageSettings).find(lang => currentLanguage.includes(lang)) ?? "en"; const langSettingKey = Object.keys(languageSettings).find(lang => currentLanguage.includes(lang)) ?? "en";
const textSettings = languageSettings[langSettingKey]; const textSettings = languageSettings[langSettingKey];
this.starterSelectContainer = this.scene.add.container(0, -this.scene.game.canvas.height / 6); this.starterSelectContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6);
this.starterSelectContainer.setVisible(false); this.starterSelectContainer.setVisible(false);
ui.add(this.starterSelectContainer); ui.add(this.starterSelectContainer);
const bgColor = this.scene.add.rectangle(0, 0, this.scene.game.canvas.width / 6, this.scene.game.canvas.height / 6, 0x006860); const bgColor = globalScene.add.rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6, 0x006860);
bgColor.setOrigin(0, 0); bgColor.setOrigin(0, 0);
this.starterSelectContainer.add(bgColor); this.starterSelectContainer.add(bgColor);
const starterSelectBg = this.scene.add.image(0, 0, "pokedex_summary_bg"); const starterSelectBg = globalScene.add.image(0, 0, "pokedex_summary_bg");
starterSelectBg.setOrigin(0, 0); starterSelectBg.setOrigin(0, 0);
this.starterSelectContainer.add(starterSelectBg); this.starterSelectContainer.add(starterSelectBg);
this.shinyOverlay = this.scene.add.image(6, 6, "summary_overlay_shiny"); this.shinyOverlay = globalScene.add.image(6, 6, "summary_overlay_shiny");
this.shinyOverlay.setOrigin(0, 0); this.shinyOverlay.setOrigin(0, 0);
this.shinyOverlay.setVisible(false); this.shinyOverlay.setVisible(false);
this.starterSelectContainer.add(this.shinyOverlay); this.starterSelectContainer.add(this.shinyOverlay);
this.pokemonNumberText = addTextObject(this.scene, 17, 1, "0000", TextStyle.SUMMARY); this.pokemonNumberText = addTextObject(17, 1, "0000", TextStyle.SUMMARY);
this.pokemonNumberText.setOrigin(0, 0); this.pokemonNumberText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonNumberText); this.starterSelectContainer.add(this.pokemonNumberText);
this.pokemonNameText = addTextObject(this.scene, 6, 112, "", TextStyle.SUMMARY); this.pokemonNameText = addTextObject(6, 112, "", TextStyle.SUMMARY);
this.pokemonNameText.setOrigin(0, 0); this.pokemonNameText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonNameText); this.starterSelectContainer.add(this.pokemonNameText);
this.pokemonGrowthRateLabelText = addTextObject(this.scene, 8, 106, i18next.t("pokedexUiHandler:growthRate"), TextStyle.SUMMARY_ALT, { fontSize: "36px" }); this.pokemonGrowthRateLabelText = addTextObject(8, 106, i18next.t("pokedexUiHandler:growthRate"), TextStyle.SUMMARY_ALT, { fontSize: "36px" });
this.pokemonGrowthRateLabelText.setOrigin(0, 0); this.pokemonGrowthRateLabelText.setOrigin(0, 0);
this.pokemonGrowthRateLabelText.setVisible(false); this.pokemonGrowthRateLabelText.setVisible(false);
this.starterSelectContainer.add(this.pokemonGrowthRateLabelText); this.starterSelectContainer.add(this.pokemonGrowthRateLabelText);
this.pokemonGrowthRateText = addTextObject(this.scene, 34, 106, "", TextStyle.SUMMARY_PINK, { fontSize: "36px" }); this.pokemonGrowthRateText = addTextObject(34, 106, "", TextStyle.SUMMARY_PINK, { fontSize: "36px" });
this.pokemonGrowthRateText.setOrigin(0, 0); this.pokemonGrowthRateText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonGrowthRateText); this.starterSelectContainer.add(this.pokemonGrowthRateText);
this.pokemonGenderText = addTextObject(this.scene, 96, 112, "", TextStyle.SUMMARY_ALT); this.pokemonGenderText = addTextObject(96, 112, "", TextStyle.SUMMARY_ALT);
this.pokemonGenderText.setOrigin(0, 0); this.pokemonGenderText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonGenderText); this.starterSelectContainer.add(this.pokemonGenderText);
this.pokemonUncaughtText = addTextObject(this.scene, 6, 127, i18next.t("pokedexUiHandler:uncaught"), TextStyle.WINDOW, { fontSize: "56px" }); this.pokemonUncaughtText = addTextObject(6, 127, i18next.t("pokedexUiHandler:uncaught"), TextStyle.WINDOW, { fontSize: "56px" });
this.pokemonUncaughtText.setOrigin(0, 0); this.pokemonUncaughtText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonUncaughtText); this.starterSelectContainer.add(this.pokemonUncaughtText);
const starterBoxContainer = this.scene.add.container(speciesContainerX + 6, 9); //115 const starterBoxContainer = globalScene.add.container(speciesContainerX + 6, 9); //115
for (const species of allSpecies) { for (const species of allSpecies) {
if (!speciesStarterCosts.hasOwnProperty(species.speciesId) || !species.isObtainable()) { if (!speciesStarterCosts.hasOwnProperty(species.speciesId) || !species.isObtainable()) {
@ -300,161 +309,161 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.speciesLoaded.set(species.speciesId, false); this.speciesLoaded.set(species.speciesId, false);
this.allSpecies.push(species); this.allSpecies.push(species);
const starterContainer = new StarterContainer(this.scene, species).setVisible(false); const starterContainer = new StarterContainer(species).setVisible(false);
this.starterContainers.push(starterContainer); this.starterContainers.push(starterContainer);
starterBoxContainer.add(starterContainer); starterBoxContainer.add(starterContainer);
} }
this.starterSelectContainer.add(starterBoxContainer); this.starterSelectContainer.add(starterBoxContainer);
this.pokemonSprite = this.scene.add.sprite(53, 63, "pkmn__sub"); this.pokemonSprite = globalScene.add.sprite(53, 63, "pkmn__sub");
this.pokemonSprite.setPipeline(this.scene.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 });
this.starterSelectContainer.add(this.pokemonSprite); this.starterSelectContainer.add(this.pokemonSprite);
this.type1Icon = this.scene.add.sprite(8, 98, getLocalizedSpriteKey("types")); this.type1Icon = globalScene.add.sprite(8, 98, getLocalizedSpriteKey("types"));
this.type1Icon.setScale(0.5); this.type1Icon.setScale(0.5);
this.type1Icon.setOrigin(0, 0); this.type1Icon.setOrigin(0, 0);
this.starterSelectContainer.add(this.type1Icon); this.starterSelectContainer.add(this.type1Icon);
this.type2Icon = this.scene.add.sprite(26, 98, getLocalizedSpriteKey("types")); this.type2Icon = globalScene.add.sprite(26, 98, getLocalizedSpriteKey("types"));
this.type2Icon.setScale(0.5); this.type2Icon.setScale(0.5);
this.type2Icon.setOrigin(0, 0); this.type2Icon.setOrigin(0, 0);
this.starterSelectContainer.add(this.type2Icon); this.starterSelectContainer.add(this.type2Icon);
this.pokemonLuckLabelText = addTextObject(this.scene, 8, 89, i18next.t("common:luckIndicator"), TextStyle.WINDOW_ALT, { fontSize: "56px" }); this.pokemonLuckLabelText = addTextObject(8, 89, i18next.t("common:luckIndicator"), TextStyle.WINDOW_ALT, { fontSize: "56px" });
this.pokemonLuckLabelText.setOrigin(0, 0); this.pokemonLuckLabelText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonLuckLabelText); this.starterSelectContainer.add(this.pokemonLuckLabelText);
this.pokemonLuckText = addTextObject(this.scene, 8 + this.pokemonLuckLabelText.displayWidth + 2, 89, "0", TextStyle.WINDOW, { fontSize: "56px" }); this.pokemonLuckText = addTextObject(8 + this.pokemonLuckLabelText.displayWidth + 2, 89, "0", TextStyle.WINDOW, { fontSize: "56px" });
this.pokemonLuckText.setOrigin(0, 0); this.pokemonLuckText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonLuckText); this.starterSelectContainer.add(this.pokemonLuckText);
// Candy icon and count // Candy icon and count
this.pokemonCandyContainer = this.scene.add.container(4.5, 18); this.pokemonCandyContainer = globalScene.add.container(4.5, 18);
this.pokemonCandyIcon = this.scene.add.sprite(0, 0, "candy"); this.pokemonCandyIcon = globalScene.add.sprite(0, 0, "candy");
this.pokemonCandyIcon.setScale(0.5); this.pokemonCandyIcon.setScale(0.5);
this.pokemonCandyIcon.setOrigin(0, 0); this.pokemonCandyIcon.setOrigin(0, 0);
this.pokemonCandyContainer.add(this.pokemonCandyIcon); this.pokemonCandyContainer.add(this.pokemonCandyIcon);
this.pokemonCandyOverlayIcon = this.scene.add.sprite(0, 0, "candy_overlay"); this.pokemonCandyOverlayIcon = globalScene.add.sprite(0, 0, "candy_overlay");
this.pokemonCandyOverlayIcon.setScale(0.5); this.pokemonCandyOverlayIcon.setScale(0.5);
this.pokemonCandyOverlayIcon.setOrigin(0, 0); this.pokemonCandyOverlayIcon.setOrigin(0, 0);
this.pokemonCandyContainer.add(this.pokemonCandyOverlayIcon); this.pokemonCandyContainer.add(this.pokemonCandyOverlayIcon);
this.pokemonCandyDarknessOverlay = this.scene.add.sprite(0, 0, "candy"); this.pokemonCandyDarknessOverlay = globalScene.add.sprite(0, 0, "candy");
this.pokemonCandyDarknessOverlay.setScale(0.5); this.pokemonCandyDarknessOverlay.setScale(0.5);
this.pokemonCandyDarknessOverlay.setOrigin(0, 0); this.pokemonCandyDarknessOverlay.setOrigin(0, 0);
this.pokemonCandyDarknessOverlay.setTint(0x000000); this.pokemonCandyDarknessOverlay.setTint(0x000000);
this.pokemonCandyDarknessOverlay.setAlpha(0.50); this.pokemonCandyDarknessOverlay.setAlpha(0.50);
this.pokemonCandyContainer.add(this.pokemonCandyDarknessOverlay); this.pokemonCandyContainer.add(this.pokemonCandyDarknessOverlay);
this.pokemonCandyCountText = addTextObject(this.scene, 9.5, 0, "x0", TextStyle.WINDOW_ALT, { fontSize: "56px" }); this.pokemonCandyCountText = addTextObject(9.5, 0, "x0", TextStyle.WINDOW_ALT, { fontSize: "56px" });
this.pokemonCandyCountText.setOrigin(0, 0); this.pokemonCandyCountText.setOrigin(0, 0);
this.pokemonCandyContainer.add(this.pokemonCandyCountText); this.pokemonCandyContainer.add(this.pokemonCandyCountText);
this.pokemonCandyContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, 30, 20), Phaser.Geom.Rectangle.Contains); this.pokemonCandyContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, 30, 20), Phaser.Geom.Rectangle.Contains);
this.starterSelectContainer.add(this.pokemonCandyContainer); this.starterSelectContainer.add(this.pokemonCandyContainer);
this.pokemonFormText = addTextObject(this.scene, 6, 42, "Form", TextStyle.WINDOW_ALT, { fontSize: "42px" }); this.pokemonFormText = addTextObject(6, 42, "Form", TextStyle.WINDOW_ALT, { fontSize: "42px" });
this.pokemonFormText.setOrigin(0, 0); this.pokemonFormText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonFormText); this.starterSelectContainer.add(this.pokemonFormText);
this.pokemonCaughtHatchedContainer = this.scene.add.container(2, 25); this.pokemonCaughtHatchedContainer = globalScene.add.container(2, 25);
this.pokemonCaughtHatchedContainer.setScale(0.5); this.pokemonCaughtHatchedContainer.setScale(0.5);
this.starterSelectContainer.add(this.pokemonCaughtHatchedContainer); this.starterSelectContainer.add(this.pokemonCaughtHatchedContainer);
const pokemonCaughtIcon = this.scene.add.sprite(1, 0, "items", "pb"); const pokemonCaughtIcon = globalScene.add.sprite(1, 0, "items", "pb");
pokemonCaughtIcon.setOrigin(0, 0); pokemonCaughtIcon.setOrigin(0, 0);
pokemonCaughtIcon.setScale(0.75); pokemonCaughtIcon.setScale(0.75);
this.pokemonCaughtHatchedContainer.add(pokemonCaughtIcon); this.pokemonCaughtHatchedContainer.add(pokemonCaughtIcon);
this.pokemonCaughtCountText = addTextObject(this.scene, 24, 4, "0", TextStyle.SUMMARY_ALT); this.pokemonCaughtCountText = addTextObject(24, 4, "0", TextStyle.SUMMARY_ALT);
this.pokemonCaughtCountText.setOrigin(0, 0); this.pokemonCaughtCountText.setOrigin(0, 0);
this.pokemonCaughtHatchedContainer.add(this.pokemonCaughtCountText); this.pokemonCaughtHatchedContainer.add(this.pokemonCaughtCountText);
this.pokemonHatchedIcon = this.scene.add.sprite(1, 14, "egg_icons"); this.pokemonHatchedIcon = globalScene.add.sprite(1, 14, "egg_icons");
this.pokemonHatchedIcon.setOrigin(0.15, 0.2); this.pokemonHatchedIcon.setOrigin(0.15, 0.2);
this.pokemonHatchedIcon.setScale(0.8); this.pokemonHatchedIcon.setScale(0.8);
this.pokemonCaughtHatchedContainer.add(this.pokemonHatchedIcon); this.pokemonCaughtHatchedContainer.add(this.pokemonHatchedIcon);
this.pokemonShinyIcon = this.scene.add.sprite(14, 76, "shiny_icons"); this.pokemonShinyIcon = globalScene.add.sprite(14, 76, "shiny_icons");
this.pokemonShinyIcon.setOrigin(0.15, 0.2); this.pokemonShinyIcon.setOrigin(0.15, 0.2);
this.pokemonShinyIcon.setScale(1); this.pokemonShinyIcon.setScale(1);
this.pokemonCaughtHatchedContainer.add(this.pokemonShinyIcon); this.pokemonCaughtHatchedContainer.add(this.pokemonShinyIcon);
this.pokemonHatchedCountText = addTextObject(this.scene, 24, 19, "0", TextStyle.SUMMARY_ALT); this.pokemonHatchedCountText = addTextObject(24, 19, "0", TextStyle.SUMMARY_ALT);
this.pokemonHatchedCountText.setOrigin(0, 0); this.pokemonHatchedCountText.setOrigin(0, 0);
this.pokemonCaughtHatchedContainer.add(this.pokemonHatchedCountText); this.pokemonCaughtHatchedContainer.add(this.pokemonHatchedCountText);
// The font size should be set per language // The font size should be set per language
const instructionTextSize = textSettings.instructionTextSize; const instructionTextSize = textSettings.instructionTextSize;
this.instructionsContainer = this.scene.add.container(4, 128); this.instructionsContainer = globalScene.add.container(4, 128);
this.instructionsContainer.setVisible(true); this.instructionsContainer.setVisible(true);
this.starterSelectContainer.add(this.instructionsContainer); this.starterSelectContainer.add(this.instructionsContainer);
this.candyUpgradeIconElement = new Phaser.GameObjects.Sprite(this.scene, this.instructionRowX, this.instructionRowY, "keyboard", "C.png"); this.candyUpgradeIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "C.png");
this.candyUpgradeIconElement.setName("sprite-candyUpgrade-icon-element"); this.candyUpgradeIconElement.setName("sprite-candyUpgrade-icon-element");
this.candyUpgradeIconElement.setScale(0.675); this.candyUpgradeIconElement.setScale(0.675);
this.candyUpgradeIconElement.setOrigin(0.0, 0.0); this.candyUpgradeIconElement.setOrigin(0.0, 0.0);
this.candyUpgradeLabel = addTextObject(this.scene, this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:candyUpgrade"), TextStyle.PARTY, { fontSize: instructionTextSize }); this.candyUpgradeLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:candyUpgrade"), TextStyle.PARTY, { fontSize: instructionTextSize });
this.candyUpgradeLabel.setName("text-candyUpgrade-label"); this.candyUpgradeLabel.setName("text-candyUpgrade-label");
// instruction rows that will be pushed into the container dynamically based on need // instruction rows that will be pushed into the container dynamically based on need
// creating new sprites since they will be added to the scene later // creating new sprites since they will be added to the scene later
this.shinyIconElement = new Phaser.GameObjects.Sprite(this.scene, this.instructionRowX, this.instructionRowY, "keyboard", "R.png"); this.shinyIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "R.png");
this.shinyIconElement.setName("sprite-shiny-icon-element"); this.shinyIconElement.setName("sprite-shiny-icon-element");
this.shinyIconElement.setScale(0.675); this.shinyIconElement.setScale(0.675);
this.shinyIconElement.setOrigin(0.0, 0.0); this.shinyIconElement.setOrigin(0.0, 0.0);
this.shinyLabel = addTextObject(this.scene, this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:cycleShiny"), TextStyle.PARTY, { fontSize: instructionTextSize }); this.shinyLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:cycleShiny"), TextStyle.PARTY, { fontSize: instructionTextSize });
this.shinyLabel.setName("text-shiny-label"); this.shinyLabel.setName("text-shiny-label");
this.formIconElement = new Phaser.GameObjects.Sprite(this.scene, this.instructionRowX, this.instructionRowY, "keyboard", "F.png"); this.formIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "F.png");
this.formIconElement.setName("sprite-form-icon-element"); this.formIconElement.setName("sprite-form-icon-element");
this.formIconElement.setScale(0.675); this.formIconElement.setScale(0.675);
this.formIconElement.setOrigin(0.0, 0.0); this.formIconElement.setOrigin(0.0, 0.0);
this.formLabel = addTextObject(this.scene, this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:cycleForm"), TextStyle.PARTY, { fontSize: instructionTextSize }); this.formLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:cycleForm"), TextStyle.PARTY, { fontSize: instructionTextSize });
this.formLabel.setName("text-form-label"); this.formLabel.setName("text-form-label");
this.genderIconElement = new Phaser.GameObjects.Sprite(this.scene, this.instructionRowX, this.instructionRowY, "keyboard", "G.png"); this.genderIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "G.png");
this.genderIconElement.setName("sprite-gender-icon-element"); this.genderIconElement.setName("sprite-gender-icon-element");
this.genderIconElement.setScale(0.675); this.genderIconElement.setScale(0.675);
this.genderIconElement.setOrigin(0.0, 0.0); this.genderIconElement.setOrigin(0.0, 0.0);
this.genderLabel = addTextObject(this.scene, this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:cycleGender"), TextStyle.PARTY, { fontSize: instructionTextSize }); this.genderLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:cycleGender"), TextStyle.PARTY, { fontSize: instructionTextSize });
this.genderLabel.setName("text-gender-label"); this.genderLabel.setName("text-gender-label");
this.variantIconElement = new Phaser.GameObjects.Sprite(this.scene, this.instructionRowX, this.instructionRowY, "keyboard", "V.png"); this.variantIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "V.png");
this.variantIconElement.setName("sprite-variant-icon-element"); this.variantIconElement.setName("sprite-variant-icon-element");
this.variantIconElement.setScale(0.675); this.variantIconElement.setScale(0.675);
this.variantIconElement.setOrigin(0.0, 0.0); this.variantIconElement.setOrigin(0.0, 0.0);
this.variantLabel = addTextObject(this.scene, this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:cycleVariant"), TextStyle.PARTY, { fontSize: instructionTextSize }); this.variantLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:cycleVariant"), TextStyle.PARTY, { fontSize: instructionTextSize });
this.variantLabel.setName("text-variant-label"); this.variantLabel.setName("text-variant-label");
this.hideInstructions(); this.hideInstructions();
this.filterInstructionsContainer = this.scene.add.container(50, 5); this.filterInstructionsContainer = globalScene.add.container(50, 5);
this.filterInstructionsContainer.setVisible(true); this.filterInstructionsContainer.setVisible(true);
this.starterSelectContainer.add(this.filterInstructionsContainer); this.starterSelectContainer.add(this.filterInstructionsContainer);
this.starterSelectMessageBoxContainer = this.scene.add.container(0, this.scene.game.canvas.height / 6); this.starterSelectMessageBoxContainer = globalScene.add.container(0, globalScene.game.canvas.height / 6);
this.starterSelectMessageBoxContainer.setVisible(false); this.starterSelectMessageBoxContainer.setVisible(false);
this.starterSelectContainer.add(this.starterSelectMessageBoxContainer); this.starterSelectContainer.add(this.starterSelectMessageBoxContainer);
this.starterSelectMessageBox = addWindow(this.scene, 1, -1, 318, 28); this.starterSelectMessageBox = addWindow(1, -1, 318, 28);
this.starterSelectMessageBox.setOrigin(0, 1); this.starterSelectMessageBox.setOrigin(0, 1);
this.starterSelectMessageBoxContainer.add(this.starterSelectMessageBox); this.starterSelectMessageBoxContainer.add(this.starterSelectMessageBox);
this.message = addTextObject(this.scene, 8, 8, "", TextStyle.WINDOW, { maxLines: 2 }); this.message = addTextObject(8, 8, "", TextStyle.WINDOW, { maxLines: 2 });
this.message.setOrigin(0, 0); this.message.setOrigin(0, 0);
this.starterSelectMessageBoxContainer.add(this.message); this.starterSelectMessageBoxContainer.add(this.message);
// arrow icon for the message box // arrow icon for the message box
this.initPromptSprite(this.starterSelectMessageBoxContainer); this.initPromptSprite(this.starterSelectMessageBoxContainer);
this.statsContainer = new StatsContainer(this.scene, 6, 16); this.statsContainer = new StatsContainer(6, 16);
this.scene.add.existing(this.statsContainer); globalScene.add.existing(this.statsContainer);
this.statsContainer.setVisible(false); this.statsContainer.setVisible(false);
@ -462,11 +471,11 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
// Adding menu container // Adding menu container
this.menuContainer = this.scene.add.container(-130, 0); this.menuContainer = globalScene.add.container(-130, 0);
this.menuContainer.setName("menu"); this.menuContainer.setName("menu");
this.menuContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, this.scene.game.canvas.width / 6, this.scene.game.canvas.height / 6), Phaser.Geom.Rectangle.Contains); this.menuContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), Phaser.Geom.Rectangle.Contains);
this.bgmBar = new BgmBar(this.scene); this.bgmBar = new BgmBar();
this.bgmBar.setup(); this.bgmBar.setup();
ui.bgmBar = this.bgmBar; ui.bgmBar = this.bgmBar;
this.menuContainer.add(this.bgmBar); this.menuContainer.add(this.bgmBar);
@ -474,7 +483,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
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.optionSelectText = addTextObject(this.scene, 0, 0, this.menuOptions.map(o => `${i18next.t(`pokedexUiHandler:${MenuOptions[o]}`)}`).join("\n"), TextStyle.WINDOW, { maxLines: this.menuOptions.length }); this.optionSelectText = addTextObject(0, 0, this.menuOptions.map(o => `${i18next.t(`pokedexUiHandler:${MenuOptions[o]}`)}`).join("\n"), TextStyle.WINDOW, { maxLines: this.menuOptions.length });
this.optionSelectText.setLineSpacing(12); this.optionSelectText.setLineSpacing(12);
this.menuDescriptions = [ this.menuDescriptions = [
@ -489,12 +498,12 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
i18next.t("pokedexUiHandler:showEvolutions") i18next.t("pokedexUiHandler:showEvolutions")
]; ];
this.scale = getTextStyleOptions(TextStyle.WINDOW, (this.scene as BattleScene).uiTheme).scale; this.scale = getTextStyleOptions(TextStyle.WINDOW, globalScene.uiTheme).scale;
this.menuBg = addWindow(this.scene, this.menuBg = addWindow(
(this.scene.game.canvas.width / 6) - (this.optionSelectText.displayWidth + 25), (globalScene.game.canvas.width / 6) - (this.optionSelectText.displayWidth + 25),
0, 0,
this.optionSelectText.displayWidth + 19 + 24 * this.scale, this.optionSelectText.displayWidth + 19 + 24 * this.scale,
(this.scene.game.canvas.height / 6) - 2 (globalScene.game.canvas.height / 6) - 2
); );
this.menuBg.setOrigin(0, 0); this.menuBg.setOrigin(0, 0);
@ -510,24 +519,24 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
// adding base stats // adding base stats
this.baseStatsOverlay = new BaseStatsOverlay(this.scene, { x: 317, y: 0, width:133 }); this.baseStatsOverlay = new BaseStatsOverlay({ x: 317, y: 0, width:133 });
this.menuContainer.add(this.baseStatsOverlay); this.menuContainer.add(this.baseStatsOverlay);
this.menuContainer.bringToTop(this.baseStatsOverlay); this.menuContainer.bringToTop(this.baseStatsOverlay);
// add the info overlay last to be the top most ui element and prevent the IVs from overlaying this // add the info overlay last to be the top most ui element and prevent the IVs from overlaying this
const overlayScale = 1; const overlayScale = 1;
this.moveInfoOverlay = new MoveInfoOverlay(this.scene, { this.moveInfoOverlay = new MoveInfoOverlay({
scale: overlayScale, scale: overlayScale,
top: true, top: true,
x: 1, x: 1,
y: this.scene.game.canvas.height / 6 - MoveInfoOverlay.getHeight(overlayScale) - 29, y: globalScene.game.canvas.height / 6 - MoveInfoOverlay.getHeight(overlayScale) - 29,
}); });
this.starterSelectContainer.add(this.moveInfoOverlay); this.starterSelectContainer.add(this.moveInfoOverlay);
this.infoOverlay = new PokedexInfoOverlay(this.scene, { this.infoOverlay = new PokedexInfoOverlay({
scale: overlayScale, scale: overlayScale,
x: 1, x: 1,
y: this.scene.game.canvas.height / 6 - PokedexInfoOverlay.getHeight(overlayScale) - 29, y: globalScene.game.canvas.height / 6 - PokedexInfoOverlay.getHeight(overlayScale) - 29,
}); });
this.starterSelectContainer.add(this.infoOverlay); this.starterSelectContainer.add(this.infoOverlay);
@ -570,7 +579,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
const key = this.lastSpecies.getCryKey(this.lastFormIndex); const key = this.lastSpecies.getCryKey(this.lastFormIndex);
const rate = 0.85; const rate = 0.85;
this.scene.playSound(key, { rate: rate }) as AnySound; globalScene.playSound(key, { rate: rate }) as AnySound;
return true; return true;
@ -612,13 +621,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
} }
this.eggMoves = speciesEggMoves[this.getStarterSpeciesId(species.speciesId)] ?? []; this.eggMoves = speciesEggMoves[this.getStarterSpeciesId(species.speciesId)] ?? [];
this.hasEggMoves = Array.from({ length: 4 }, (_, em) => (this.scene.gameData.starterData[this.getStarterSpeciesId(species.speciesId)].eggMoves & (1 << em)) !== 0); this.hasEggMoves = Array.from({ length: 4 }, (_, em) => (globalScene.gameData.starterData[this.getStarterSpeciesId(species.speciesId)].eggMoves & (1 << em)) !== 0);
this.tmMoves = (speciesTmMoves[species.speciesId] ?? []).sort((a, b) => allMoves[a].name > allMoves[b].name ? 1 : -1); this.tmMoves = (speciesTmMoves[species.speciesId] ?? []).sort((a, b) => allMoves[a].name > allMoves[b].name ? 1 : -1);
this.passive = starterPassiveAbilities[this.getStarterSpeciesId(species.speciesId)]; this.passive = starterPassiveAbilities[this.getStarterSpeciesId(species.speciesId)];
const starterData = this.scene.gameData.starterData[this.getStarterSpeciesId(species.speciesId)]; const starterData = globalScene.gameData.starterData[this.getStarterSpeciesId(species.speciesId)];
const abilityAttr = starterData.abilityAttr; const abilityAttr = starterData.abilityAttr;
this.hasPassive = starterData.passiveAttr > 0; this.hasPassive = starterData.passiveAttr > 0;
@ -728,8 +737,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
*/ */
initStarterPrefs(): StarterAttributes { initStarterPrefs(): StarterAttributes {
const starterAttributes = this.starterAttributes; const starterAttributes = this.starterAttributes;
const dexEntry = this.scene.gameData.dexData[this.lastSpecies.speciesId]; const dexEntry = globalScene.gameData.dexData[this.lastSpecies.speciesId];
const starterData = this.scene.gameData.starterData[this.getStarterSpeciesId(this.lastSpecies.speciesId)]; const starterData = globalScene.gameData.starterData[this.getStarterSpeciesId(this.lastSpecies.speciesId)];
// no preferences or Pokemon wasn't caught, return empty attribute // no preferences or Pokemon wasn't caught, return empty attribute
if (!starterAttributes || !dexEntry.caughtAttr) { if (!starterAttributes || !dexEntry.caughtAttr) {
@ -788,13 +797,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
} }
const selectedForm = starterAttributes.form; const selectedForm = starterAttributes.form;
if (selectedForm !== undefined && (this.lastSpecies.forms[selectedForm]?.isStarterSelectable && !(caughtAttr & this.scene.gameData.getFormAttr(selectedForm)))) { if (selectedForm !== undefined && (this.lastSpecies.forms[selectedForm]?.isStarterSelectable && !(caughtAttr & globalScene.gameData.getFormAttr(selectedForm)))) {
// requested form wasn't unlocked and is selectable as a starter // requested form wasn't unlocked and is selectable as a starter
delete starterAttributes.form; delete starterAttributes.form;
} }
if (starterAttributes.nature !== undefined) { if (starterAttributes.nature !== undefined) {
const unlockedNatures = this.scene.gameData.getNaturesForAttr(dexEntry.natureAttr); const unlockedNatures = globalScene.gameData.getNaturesForAttr(dexEntry.natureAttr);
if (unlockedNatures.indexOf(starterAttributes.nature as unknown as Nature) < 0) { if (unlockedNatures.indexOf(starterAttributes.nature as unknown as Nature) < 0) {
// requested nature wasn't unlocked, purging setting // requested nature wasn't unlocked, purging setting
delete starterAttributes.nature; delete starterAttributes.nature;
@ -816,7 +825,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.starterSelectMessageBoxContainer.setY(0); this.starterSelectMessageBoxContainer.setY(0);
this.message.setY(4); this.message.setY(4);
} else { } else {
this.starterSelectMessageBoxContainer.setY(this.scene.game.canvas.height / 6); this.starterSelectMessageBoxContainer.setY(globalScene.game.canvas.height / 6);
this.starterSelectMessageBox.setOrigin(0, 1); this.starterSelectMessageBox.setOrigin(0, 1);
this.message.setY(singleLine ? -22 : -37); this.message.setY(singleLine ? -22 : -37);
} }
@ -829,18 +838,18 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
* @returns true if upgrade notifications are enabled and set to display an 'Icon' * @returns true if upgrade notifications are enabled and set to display an 'Icon'
*/ */
isUpgradeIconEnabled(): boolean { isUpgradeIconEnabled(): boolean {
return this.scene.candyUpgradeNotification !== 0 && this.scene.candyUpgradeDisplay === 0; return globalScene.candyUpgradeNotification !== 0 && globalScene.candyUpgradeDisplay === 0;
} }
/** /**
* Determines if 'Animation' based upgrade notifications should be shown * Determines if 'Animation' based upgrade notifications should be shown
* @returns true if upgrade notifications are enabled and set to display an 'Animation' * @returns true if upgrade notifications are enabled and set to display an 'Animation'
*/ */
isUpgradeAnimationEnabled(): boolean { isUpgradeAnimationEnabled(): boolean {
return this.scene.candyUpgradeNotification !== 0 && this.scene.candyUpgradeDisplay === 1; return globalScene.candyUpgradeNotification !== 0 && globalScene.candyUpgradeDisplay === 1;
} }
getStarterSpeciesId(speciesId): number { getStarterSpeciesId(speciesId): number {
if (this.scene.gameData.starterData.hasOwnProperty(speciesId)) { if (globalScene.gameData.starterData.hasOwnProperty(speciesId)) {
return speciesId; return speciesId;
} else { } else {
return pokemonStarters[speciesId]; return pokemonStarters[speciesId];
@ -848,7 +857,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
} }
getStarterSpecies(species): PokemonSpecies { getStarterSpecies(species): PokemonSpecies {
if (this.scene.gameData.starterData.hasOwnProperty(species.speciesId)) { if (globalScene.gameData.starterData.hasOwnProperty(species.speciesId)) {
return species; return species;
} else { } else {
return allSpecies.find(sp => sp.speciesId === pokemonStarters[species.speciesId]) ?? species; return allSpecies.find(sp => sp.speciesId === pokemonStarters[species.speciesId]) ?? species;
@ -917,7 +926,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
} }
} else { } else {
const starterData = this.scene.gameData.starterData[this.getStarterSpeciesId(this.lastSpecies.speciesId)]; const starterData = globalScene.gameData.starterData[this.getStarterSpeciesId(this.lastSpecies.speciesId)];
// prepare persistent starter data to store changes // prepare persistent starter data to store changes
const starterAttributes = this.starterAttributes; const starterAttributes = this.starterAttributes;
@ -1357,7 +1366,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
}); });
this.evolutions.map(evo => { this.evolutions.map(evo => {
const evoSpecies = allSpecies.find(species => species.speciesId === evo.speciesId); const evoSpecies = allSpecies.find(species => species.speciesId === evo.speciesId);
const evoSpeciesStarterDexEntry = evoSpecies ? this.scene.gameData.dexData[evoSpecies.speciesId] : null; const evoSpeciesStarterDexEntry = evoSpecies ? globalScene.gameData.dexData[evoSpecies.speciesId] : null;
const isCaughtEvo = evoSpeciesStarterDexEntry?.caughtAttr ? true : false; const isCaughtEvo = evoSpeciesStarterDexEntry?.caughtAttr ? true : false;
options.push({ options.push({
label: evo.evoFormKey ? label: evo.evoFormKey ?
@ -1467,11 +1476,11 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.blockInput = true; this.blockInput = true;
ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => {
ui.showText(i18next.t("pokedexUiHandler:showNature"), null, () => { ui.showText(i18next.t("pokedexUiHandler:showNature"), null, () => {
const natures = this.scene.gameData.getNaturesForAttr(this.speciesStarterDexEntry?.natureAttr); const natures = globalScene.gameData.getNaturesForAttr(this.speciesStarterDexEntry?.natureAttr);
ui.setModeWithoutClear(Mode.OPTION_SELECT, { ui.setModeWithoutClear(Mode.OPTION_SELECT, {
options: natures.map((n: Nature, i: number) => { options: natures.map((n: Nature, i: number) => {
const option: OptionSelectItem = { const option: OptionSelectItem = {
label: getNatureName(n, true, true, true, this.scene.uiTheme), label: getNatureName(n, true, true, true, globalScene.uiTheme),
handler: () => { handler: () => {
return false; return false;
} }
@ -1497,7 +1506,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
} }
} else { } else {
const props = this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId)); const props = globalScene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId));
switch (button) { switch (button) {
case Button.CYCLE_SHINY: case Button.CYCLE_SHINY:
if (this.canCycleShiny) { if (this.canCycleShiny) {
@ -1508,7 +1517,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
const newVariant = starterAttributes.variant ? starterAttributes.variant as Variant : 0; const newVariant = starterAttributes.variant ? starterAttributes.variant as Variant : 0;
this.setSpeciesDetails(this.lastSpecies, { shiny: true, variant: newVariant }); this.setSpeciesDetails(this.lastSpecies, { shiny: true, variant: newVariant });
this.scene.playSound("se/sparkle"); globalScene.playSound("se/sparkle");
// Set the variant label to the shiny tint // Set the variant label to the shiny tint
const tint = getVariantTint(newVariant); const tint = getVariantTint(newVariant);
this.pokemonShinyIcon.setFrame(getVariantIcon(newVariant)); this.pokemonShinyIcon.setFrame(getVariantIcon(newVariant));
@ -1555,7 +1564,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
let newFormIndex = this.lastFormIndex; let newFormIndex = this.lastFormIndex;
do { do {
newFormIndex = (newFormIndex + 1) % formCount; newFormIndex = (newFormIndex + 1) % formCount;
if (this.speciesStarterDexEntry!.caughtAttr! & this.scene.gameData.getFormAttr(newFormIndex)) { // TODO: are those bangs correct? if (this.speciesStarterDexEntry!.caughtAttr! & globalScene.gameData.getFormAttr(newFormIndex)) { // TODO: are those bangs correct?
break; break;
} }
} while (newFormIndex !== props.formIndex); } while (newFormIndex !== props.formIndex);
@ -1596,14 +1605,14 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
starterData.candyCount -= passiveCost; starterData.candyCount -= passiveCost;
} }
this.pokemonCandyCountText.setText(`x${starterData.candyCount}`); this.pokemonCandyCountText.setText(`x${starterData.candyCount}`);
this.scene.gameData.saveSystem().then(success => { globalScene.gameData.saveSystem().then(success => {
if (!success) { if (!success) {
return this.scene.reset(true); return globalScene.reset(true);
} }
}); });
ui.setMode(Mode.POKEDEX_PAGE, "refresh"); ui.setMode(Mode.POKEDEX_PAGE, "refresh");
this.setSpeciesDetails(this.lastSpecies); this.setSpeciesDetails(this.lastSpecies);
this.scene.playSound("se/buy"); globalScene.playSound("se/buy");
return true; return true;
} }
@ -1627,13 +1636,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
starterData.candyCount -= reductionCost; starterData.candyCount -= reductionCost;
} }
this.pokemonCandyCountText.setText(`x${starterData.candyCount}`); this.pokemonCandyCountText.setText(`x${starterData.candyCount}`);
this.scene.gameData.saveSystem().then(success => { globalScene.gameData.saveSystem().then(success => {
if (!success) { if (!success) {
return this.scene.reset(true); return globalScene.reset(true);
} }
}); });
ui.setMode(Mode.POKEDEX_PAGE, "refresh"); ui.setMode(Mode.POKEDEX_PAGE, "refresh");
this.scene.playSound("se/buy"); globalScene.playSound("se/buy");
return true; return true;
} }
@ -1650,7 +1659,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
label: `x${sameSpeciesEggCost} ${i18next.t("pokedexUiHandler:sameSpeciesEgg")}`, label: `x${sameSpeciesEggCost} ${i18next.t("pokedexUiHandler:sameSpeciesEgg")}`,
handler: () => { handler: () => {
if (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= sameSpeciesEggCost) { if (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= sameSpeciesEggCost) {
if (this.scene.gameData.eggs.length >= 99 && !Overrides.UNLIMITED_EGG_COUNT_OVERRIDE) { if (globalScene.gameData.eggs.length >= 99 && !Overrides.UNLIMITED_EGG_COUNT_OVERRIDE) {
// Egg list full, show error message at the top of the screen and abort // Egg list full, show error message at the top of the screen and abort
this.showText(i18next.t("egg:tooManyEggs"), undefined, () => this.showText("", 0, () => this.tutorialActive = false), 2000, false, undefined, true); this.showText(i18next.t("egg:tooManyEggs"), undefined, () => this.showText("", 0, () => this.tutorialActive = false), 2000, false, undefined, true);
return false; return false;
@ -1660,16 +1669,16 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
} }
this.pokemonCandyCountText.setText(`x${starterData.candyCount}`); this.pokemonCandyCountText.setText(`x${starterData.candyCount}`);
const egg = new Egg({ scene: this.scene, species: this.lastSpecies.speciesId, sourceType: EggSourceType.SAME_SPECIES_EGG }); const egg = new Egg({ scene: globalScene, species: this.lastSpecies.speciesId, sourceType: EggSourceType.SAME_SPECIES_EGG });
egg.addEggToGameData(this.scene); egg.addEggToGameData();
this.scene.gameData.saveSystem().then(success => { globalScene.gameData.saveSystem().then(success => {
if (!success) { if (!success) {
return this.scene.reset(true); return globalScene.reset(true);
} }
}); });
ui.setMode(Mode.POKEDEX_PAGE, "refresh"); ui.setMode(Mode.POKEDEX_PAGE, "refresh");
this.scene.playSound("se/buy"); globalScene.playSound("se/buy");
return true; return true;
} }
@ -1750,7 +1759,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
break; break;
} }
} else { } else {
iconPath = this.scene.inputController?.getIconForLatestInputRecorded(iconSetting); iconPath = globalScene.inputController?.getIconForLatestInputRecorded(iconSetting);
} }
iconElement.setTexture(gamepadType, iconPath); iconElement.setTexture(gamepadType, iconPath);
iconElement.setPosition(this.instructionRowX, this.instructionRowY); iconElement.setPosition(this.instructionRowX, this.instructionRowY);
@ -1774,10 +1783,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.instructionsContainer.removeAll(); this.instructionsContainer.removeAll();
this.filterInstructionsContainer.removeAll(); this.filterInstructionsContainer.removeAll();
let gamepadType; let gamepadType;
if (this.scene.inputMethod === "gamepad") { if (globalScene.inputMethod === "gamepad") {
gamepadType = this.scene.inputController.getConfig(this.scene.inputController.selectedDevice[Device.GAMEPAD]).padType; gamepadType = globalScene.inputController.getConfig(globalScene.inputController.selectedDevice[Device.GAMEPAD]).padType;
} else { } else {
gamepadType = this.scene.inputMethod; gamepadType = globalScene.inputMethod;
} }
if (!gamepadType) { if (!gamepadType) {
@ -1805,7 +1814,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
getValueLimit(): number { getValueLimit(): number {
const valueLimit = new NumberHolder(0); const valueLimit = new NumberHolder(0);
switch (this.scene.gameMode.modeId) { switch (globalScene.gameMode.modeId) {
case GameModes.ENDLESS: case GameModes.ENDLESS:
case GameModes.SPLICED_ENDLESS: case GameModes.SPLICED_ENDLESS:
valueLimit.value = 15; valueLimit.value = 15;
@ -1814,7 +1823,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
valueLimit.value = 10; valueLimit.value = 10;
} }
Challenge.applyChallenges(this.scene.gameMode, Challenge.ChallengeType.STARTER_POINTS, valueLimit); Challenge.applyChallenges(globalScene.gameMode, Challenge.ChallengeType.STARTER_POINTS, valueLimit);
return valueLimit.value; return valueLimit.value;
} }
@ -1824,7 +1833,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
const ret = super.setCursor(cursor); const ret = super.setCursor(cursor);
if (!this.cursorObj) { if (!this.cursorObj) {
this.cursorObj = this.scene.add.image(0, 0, "cursor"); this.cursorObj = globalScene.add.image(0, 0, "cursor");
this.cursorObj.setOrigin(0, 0); this.cursorObj.setOrigin(0, 0);
this.menuContainer.add(this.cursorObj); this.menuContainer.add(this.cursorObj);
} }
@ -1843,7 +1852,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
} }
getFriendship(speciesId: number) { getFriendship(speciesId: number) {
let currentFriendship = this.scene.gameData.starterData[this.getStarterSpeciesId(speciesId)].friendship; let currentFriendship = globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)].friendship;
if (!currentFriendship || currentFriendship === undefined) { if (!currentFriendship || currentFriendship === undefined) {
currentFriendship = 0; currentFriendship = 0;
} }
@ -1854,10 +1863,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
} }
setSpecies(species: PokemonSpecies | null) { setSpecies(species: PokemonSpecies | null) {
this.speciesStarterDexEntry = species ? this.scene.gameData.dexData[species.speciesId] : null; this.speciesStarterDexEntry = species ? globalScene.gameData.dexData[species.speciesId] : null;
if (!species && this.scene.ui.getTooltip().visible) { if (!species && globalScene.ui.getTooltip().visible) {
this.scene.ui.hideTooltip(); globalScene.ui.hideTooltip();
} }
const starterAttributes : StarterAttributes | null = species ? { ...this.starterAttributes } : null; const starterAttributes : StarterAttributes | null = species ? { ...this.starterAttributes } : null;
@ -1887,7 +1896,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
if (this.speciesStarterDexEntry?.caughtAttr) { if (this.speciesStarterDexEntry?.caughtAttr) {
const colorScheme = starterColors[species.speciesId]; const colorScheme = starterColors[species.speciesId];
const luck = this.scene.gameData.getDexAttrLuck(this.speciesStarterDexEntry.caughtAttr); const luck = globalScene.gameData.getDexAttrLuck(this.speciesStarterDexEntry.caughtAttr);
this.pokemonLuckText.setVisible(!!luck); this.pokemonLuckText.setVisible(!!luck);
this.pokemonLuckText.setText(luck.toString()); this.pokemonLuckText.setText(luck.toString());
this.pokemonLuckText.setTint(getVariantTint(Math.min(luck - 1, 2) as Variant)); this.pokemonLuckText.setTint(getVariantTint(Math.min(luck - 1, 2) as Variant));
@ -1914,7 +1923,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.pokemonHatchedCountText.setText(`${this.speciesStarterDexEntry.hatchedCount}`); this.pokemonHatchedCountText.setText(`${this.speciesStarterDexEntry.hatchedCount}`);
const defaultDexAttr = this.getCurrentDexProps(species.speciesId); const defaultDexAttr = this.getCurrentDexProps(species.speciesId);
const defaultProps = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr); const defaultProps = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
const variant = defaultProps.variant; const variant = defaultProps.variant;
const tint = getVariantTint(variant); const tint = getVariantTint(variant);
this.pokemonShinyIcon.setFrame(getVariantIcon(variant)); this.pokemonShinyIcon.setFrame(getVariantIcon(variant));
@ -1938,7 +1947,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.pokemonShinyIcon.setY(117); this.pokemonShinyIcon.setY(117);
this.pokemonCandyIcon.setTint(argbFromRgba(rgbHexToRgba(colorScheme[0]))); this.pokemonCandyIcon.setTint(argbFromRgba(rgbHexToRgba(colorScheme[0])));
this.pokemonCandyOverlayIcon.setTint(argbFromRgba(rgbHexToRgba(colorScheme[1]))); this.pokemonCandyOverlayIcon.setTint(argbFromRgba(rgbHexToRgba(colorScheme[1])));
this.pokemonCandyCountText.setText(`x${this.scene.gameData.starterData[this.getStarterSpeciesId(species.speciesId)].candyCount}`); this.pokemonCandyCountText.setText(`x${globalScene.gameData.starterData[this.getStarterSpeciesId(species.speciesId)].candyCount}`);
this.pokemonCandyContainer.setVisible(true); this.pokemonCandyContainer.setVisible(true);
this.pokemonFormText.setY(42); this.pokemonFormText.setY(42);
this.pokemonHatchedIcon.setVisible(true); this.pokemonHatchedIcon.setVisible(true);
@ -1949,18 +1958,18 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.pokemonCandyDarknessOverlay.setCrop(0, 0, 16, candyCropY); this.pokemonCandyDarknessOverlay.setCrop(0, 0, 16, candyCropY);
this.pokemonCandyContainer.on("pointerover", () => { this.pokemonCandyContainer.on("pointerover", () => {
this.scene.ui.showTooltip("", `${currentFriendship}/${friendshipCap}`, true); globalScene.ui.showTooltip("", `${currentFriendship}/${friendshipCap}`, true);
this.activeTooltip = "CANDY"; this.activeTooltip = "CANDY";
}); });
this.pokemonCandyContainer.on("pointerout", () => { this.pokemonCandyContainer.on("pointerout", () => {
this.scene.ui.hideTooltip(); globalScene.ui.hideTooltip();
this.activeTooltip = undefined; this.activeTooltip = undefined;
}); });
} }
// load default nature from stater save data, if set // load default nature from stater save data, if set
const props: StarterAttributes = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr); const props: StarterAttributes = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
if (starterAttributes?.variant && !isNaN(starterAttributes.variant)) { if (starterAttributes?.variant && !isNaN(starterAttributes.variant)) {
if (props.shiny) { if (props.shiny) {
props.variant = starterAttributes.variant as Variant; props.variant = starterAttributes.variant as Variant;
@ -1993,8 +2002,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.pokemonCandyContainer.setVisible(false); this.pokemonCandyContainer.setVisible(false);
this.pokemonFormText.setVisible(false); this.pokemonFormText.setVisible(false);
const defaultDexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(species, true, true); const defaultDexAttr = globalScene.gameData.getSpeciesDefaultDexAttr(species, true, true);
const props = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr); const props = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
this.setSpeciesDetails(species, { this.setSpeciesDetails(species, {
shiny: props.shiny, shiny: props.shiny,
@ -2043,9 +2052,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
if (this.activeTooltip === "CANDY") { if (this.activeTooltip === "CANDY") {
if (this.lastSpecies && this.pokemonCandyContainer.visible) { if (this.lastSpecies && this.pokemonCandyContainer.visible) {
const { currentFriendship, friendshipCap } = this.getFriendship(this.lastSpecies.speciesId); const { currentFriendship, friendshipCap } = this.getFriendship(this.lastSpecies.speciesId);
this.scene.ui.editTooltip("", `${currentFriendship}/${friendshipCap}`); globalScene.ui.editTooltip("", `${currentFriendship}/${friendshipCap}`);
} else { } else {
this.scene.ui.hideTooltip(); globalScene.ui.hideTooltip();
} }
} }
@ -2081,9 +2090,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
} }
if (species) { if (species) {
const dexEntry = this.scene.gameData.dexData[species.speciesId]; const dexEntry = globalScene.gameData.dexData[species.speciesId];
const caughtAttr = this.scene.gameData.dexData[species.speciesId]?.caughtAttr || BigInt(0); const caughtAttr = globalScene.gameData.dexData[species.speciesId]?.caughtAttr || BigInt(0);
if (!dexEntry.caughtAttr) { if (!dexEntry.caughtAttr) {
const props = this.starterAttributes; const props = this.starterAttributes;
@ -2111,7 +2120,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.assetLoadCancelled = assetLoadCancelled; this.assetLoadCancelled = assetLoadCancelled;
if (shouldUpdateSprite) { if (shouldUpdateSprite) {
species.loadAssets(this.scene, female!, formIndex, shiny, variant as Variant, true).then(() => { // TODO: is this bang correct? species.loadAssets(female!, formIndex, shiny, variant as Variant, true).then(() => { // TODO: is this bang correct?
if (assetLoadCancelled.value) { if (assetLoadCancelled.value) {
return; return;
} }
@ -2148,7 +2157,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.canCycleGender = isMaleCaught && isFemaleCaught; this.canCycleGender = isMaleCaught && isFemaleCaught;
this.canCycleForm = species.forms.filter(f => f.isStarterSelectable || !pokemonFormChanges[species.speciesId]?.find(fc => fc.formKey)) this.canCycleForm = species.forms.filter(f => f.isStarterSelectable || !pokemonFormChanges[species.speciesId]?.find(fc => fc.formKey))
.map((_, f) => dexEntry.caughtAttr & this.scene.gameData.getFormAttr(f)).filter(f => f).length > 1; .map((_, f) => dexEntry.caughtAttr & globalScene.gameData.getFormAttr(f)).filter(f => f).length > 1;
if (dexEntry.caughtAttr && species.malePercent !== null) { if (dexEntry.caughtAttr && species.malePercent !== null) {
@ -2206,7 +2215,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
*/ */
getCurrentDexProps(speciesId: number): bigint { getCurrentDexProps(speciesId: number): bigint {
let props = 0n; let props = 0n;
const caughtAttr = this.scene.gameData.dexData[speciesId].caughtAttr; const caughtAttr = globalScene.gameData.dexData[speciesId].caughtAttr;
/* this checks the gender of the pokemon; this works by checking a) that the starter preferences for the species exist, and if so, is it female. If so, it'll add DexAttr.FEMALE to our temp props /* this checks the gender of the pokemon; this works by checking a) that the starter preferences for the species exist, and if so, is it female. If so, it'll add DexAttr.FEMALE to our temp props
* It then checks b) if the caughtAttr for the pokemon is female and NOT male - this means that the ONLY gender we've gotten is female, and we need to add DexAttr.FEMALE to our temp props * It then checks b) if the caughtAttr for the pokemon is female and NOT male - this means that the ONLY gender we've gotten is female, and we need to add DexAttr.FEMALE to our temp props
@ -2244,7 +2253,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
props += BigInt(Math.pow(2, this.starterAttributes?.form)) * DexAttr.DEFAULT_FORM; props += BigInt(Math.pow(2, this.starterAttributes?.form)) * DexAttr.DEFAULT_FORM;
} else { } else {
// Get the first unlocked form // Get the first unlocked form
props += this.scene.gameData.getFormAttr(this.scene.gameData.getFormIndex(caughtAttr)); props += globalScene.gameData.getFormAttr(globalScene.gameData.getFormIndex(caughtAttr));
} }
return props; return props;
@ -2301,7 +2310,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.cursor = -1; this.cursor = -1;
this.hideInstructions(); this.hideInstructions();
this.activeTooltip = undefined; this.activeTooltip = undefined;
this.scene.ui.hideTooltip(); globalScene.ui.hideTooltip();
this.starterSelectContainer.setVisible(false); this.starterSelectContainer.setVisible(false);
this.blockInput = false; this.blockInput = false;

View File

@ -1,7 +1,8 @@
import { FormModalUiHandler, InputFieldConfig } from "./form-modal-ui-handler"; import type { InputFieldConfig } from "./form-modal-ui-handler";
import { ModalConfig } from "./modal-ui-handler"; import { FormModalUiHandler } from "./form-modal-ui-handler";
import { PlayerPokemon } from "#app/field/pokemon"; import type { ModalConfig } from "./modal-ui-handler";
import { OptionSelectItem } from "./abstact-option-select-ui-handler"; import type { PlayerPokemon } from "#app/field/pokemon";
import type { OptionSelectItem } from "./abstact-option-select-ui-handler";
import { isNullOrUndefined } from "#app/utils"; import { isNullOrUndefined } from "#app/utils";
import { Mode } from "./ui"; import { Mode } from "./ui";
import { FilterTextRow } from "./filter-text"; import { FilterTextRow } from "./filter-text";
@ -21,7 +22,7 @@ export default class PokedexScanUiHandler extends FormModalUiHandler {
row: number; row: number;
constructor(scene, mode) { constructor(scene, mode) {
super(scene, mode); super(mode);
} }
setup() { setup() {

View File

@ -1,25 +1,26 @@
import { BattleSceneEventType, CandyUpgradeNotificationChangedEvent } from "#app/events/battle-scene"; import type { Variant } from "#app/data/variant";
import { Variant, getVariantTint, getVariantIcon } from "#app/data/variant"; import { getVariantTint, getVariantIcon } from "#app/data/variant";
import { argbFromRgba } from "@material/material-color-utilities"; import { argbFromRgba } from "@material/material-color-utilities";
import i18next from "i18next"; import i18next from "i18next";
import BattleScene, { starterColors } from "#app/battle-scene"; import { starterColors } from "#app/battle-scene";
import { speciesEggMoves } from "#app/data/balance/egg-moves"; import { speciesEggMoves } from "#app/data/balance/egg-moves";
import { pokemonFormLevelMoves, pokemonSpeciesLevelMoves } from "#app/data/balance/pokemon-level-moves"; import { pokemonFormLevelMoves, pokemonSpeciesLevelMoves } from "#app/data/balance/pokemon-level-moves";
import PokemonSpecies, { allSpecies, getPokemonSpeciesForm, getPokerusStarters, PokemonForm } from "#app/data/pokemon-species"; import type { PokemonForm } from "#app/data/pokemon-species";
import type PokemonSpecies from "#app/data/pokemon-species";
import { allSpecies, getPokemonSpeciesForm, getPokerusStarters } from "#app/data/pokemon-species";
import { getStarterValueFriendshipCap, speciesStarterCosts, POKERUS_STARTER_COUNT } from "#app/data/balance/starters"; import { getStarterValueFriendshipCap, speciesStarterCosts, POKERUS_STARTER_COUNT } from "#app/data/balance/starters";
import { catchableSpecies } from "#app/data/balance/biomes"; import { catchableSpecies } from "#app/data/balance/biomes";
import { Type } from "#enums/type"; import { Type } from "#enums/type";
import { AbilityAttr, DexAttr, DexAttrProps, DexEntry, StarterMoveset, StarterAttributes, StarterPreferences, StarterPrefs } from "#app/system/game-data"; import type { DexAttrProps, DexEntry, StarterMoveset, StarterAttributes, StarterPreferences } from "#app/system/game-data";
import { Tutorial, handleTutorial } from "#app/tutorial"; import { AbilityAttr, DexAttr, StarterPrefs } from "#app/system/game-data";
import MessageUiHandler from "#app/ui/message-ui-handler"; import MessageUiHandler from "#app/ui/message-ui-handler";
import PokemonIconAnimHandler, { PokemonIconAnimMode } from "#app/ui/pokemon-icon-anim-handler"; import PokemonIconAnimHandler, { PokemonIconAnimMode } from "#app/ui/pokemon-icon-anim-handler";
import { TextStyle, addTextObject } from "#app/ui/text"; import { TextStyle, addTextObject } from "#app/ui/text";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
//import { addWindow } from "#app/ui/ui-theme";
import { SettingKeyboard } from "#app/system/settings/settings-keyboard"; import { SettingKeyboard } from "#app/system/settings/settings-keyboard";
import { Passive as PassiveAttr } from "#enums/passive"; import { Passive as PassiveAttr } from "#enums/passive";
import { Moves } from "#enums/moves"; import type { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import type { Species } from "#enums/species";
import { Button } from "#enums/buttons"; import { Button } from "#enums/buttons";
import { DropDown, DropDownLabel, DropDownOption, DropDownState, DropDownType, SortCriteria } from "#app/ui/dropdown"; import { DropDown, DropDownLabel, DropDownOption, DropDownState, DropDownType, SortCriteria } from "#app/ui/dropdown";
import { StarterContainer } from "#app/ui/starter-container"; import { StarterContainer } from "#app/ui/starter-container";
@ -30,7 +31,7 @@ import { getPassiveCandyCount, getValueReductionCandyCounts, getSameSpeciesEggCa
import { BooleanHolder, fixedInt, getLocalizedSpriteKey, padInt, randIntRange, rgbHexToRgba } from "#app/utils"; import { BooleanHolder, fixedInt, getLocalizedSpriteKey, padInt, randIntRange, rgbHexToRgba } from "#app/utils";
import type { Nature } from "#enums/nature"; import type { Nature } from "#enums/nature";
import { addWindow } from "./ui-theme"; import { addWindow } from "./ui-theme";
import { OptionSelectConfig } from "./abstact-option-select-ui-handler"; import type { OptionSelectConfig } from "./abstact-option-select-ui-handler";
import { FilterText, FilterTextRow } from "./filter-text"; import { FilterText, FilterTextRow } from "./filter-text";
import { allAbilities } from "#app/data/ability"; import { allAbilities } from "#app/data/ability";
import { starterPassiveAbilities } from "#app/data/balance/passives"; import { starterPassiveAbilities } from "#app/data/balance/passives";
@ -38,6 +39,7 @@ import { allMoves } from "#app/data/move";
import { speciesTmMoves } from "#app/data/balance/tms"; import { speciesTmMoves } from "#app/data/balance/tms";
import { pokemonStarters } from "#app/data/balance/pokemon-evolutions"; import { pokemonStarters } from "#app/data/balance/pokemon-evolutions";
import { Biome } from "#enums/biome"; import { Biome } from "#enums/biome";
import { globalScene } from "#app/global-scene";
// We don't need this interface here // We don't need this interface here
@ -223,8 +225,8 @@ export default class PokedexUiHandler extends MessageUiHandler {
private toggleDecorationsIconElement: Phaser.GameObjects.Sprite; private toggleDecorationsIconElement: Phaser.GameObjects.Sprite;
private toggleDecorationsLabel: Phaser.GameObjects.Text; private toggleDecorationsLabel: Phaser.GameObjects.Text;
constructor(scene: BattleScene) { constructor() {
super(scene, Mode.POKEDEX); super(Mode.POKEDEX);
} }
setup() { setup() {
@ -233,27 +235,25 @@ export default class PokedexUiHandler extends MessageUiHandler {
const langSettingKey = Object.keys(languageSettings).find(lang => currentLanguage.includes(lang)) ?? "en"; const langSettingKey = Object.keys(languageSettings).find(lang => currentLanguage.includes(lang)) ?? "en";
const textSettings = languageSettings[langSettingKey]; const textSettings = languageSettings[langSettingKey];
this.starterSelectContainer = this.scene.add.container(0, -this.scene.game.canvas.height / 6); this.starterSelectContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6);
this.starterSelectContainer.setVisible(false); this.starterSelectContainer.setVisible(false);
ui.add(this.starterSelectContainer); ui.add(this.starterSelectContainer);
const bgColor = this.scene.add.rectangle(0, 0, this.scene.game.canvas.width / 6, this.scene.game.canvas.height / 6, 0x006860); const bgColor = globalScene.add.rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6, 0x006860);
bgColor.setOrigin(0, 0); bgColor.setOrigin(0, 0);
this.starterSelectContainer.add(bgColor); this.starterSelectContainer.add(bgColor);
const starterContainerWindow = addWindow(this.scene, speciesContainerX, filterBarHeight + 1, 175, 161); const starterContainerWindow = addWindow(speciesContainerX, filterBarHeight + 1, 175, 161);
const starterContainerBg = this.scene.add.image(speciesContainerX + 1, filterBarHeight + 2, "starter_container_bg"); const starterContainerBg = globalScene.add.image(speciesContainerX + 1, filterBarHeight + 2, "starter_container_bg");
starterContainerBg.setOrigin(0, 0); starterContainerBg.setOrigin(0, 0);
this.starterSelectContainer.add(starterContainerBg); this.starterSelectContainer.add(starterContainerBg);
this.starterSelectContainer.add(starterContainerWindow); this.starterSelectContainer.add(starterContainerWindow);
// Create and initialise filter text fields // Create and initialise filter text fields
this.filterTextContainer = globalScene.add.container(0, 0);
this.filterText = new FilterText(1, filterBarHeight + 2, 140, 100, this.updateStarters);
this.filterTextContainer = this.scene.add.container(0, 0);
this.filterText = new FilterText(this.scene, 1, filterBarHeight + 2, 140, 100, this.updateStarters);
// const nameTextField: TextField = new TextField(this.scene, 0, 0, genOptions, this.updateStarters, DropDownType.HYBRID);
this.filterText.addFilter(FilterTextRow.NAME, i18next.t("filterText:nameField")); this.filterText.addFilter(FilterTextRow.NAME, i18next.t("filterText:nameField"));
this.filterText.addFilter(FilterTextRow.MOVE_1, i18next.t("filterText:move1Field")); this.filterText.addFilter(FilterTextRow.MOVE_1, i18next.t("filterText:move1Field"));
this.filterText.addFilter(FilterTextRow.MOVE_2, i18next.t("filterText:move2Field")); this.filterText.addFilter(FilterTextRow.MOVE_2, i18next.t("filterText:move2Field"));
@ -265,22 +265,22 @@ export default class PokedexUiHandler extends MessageUiHandler {
// Create and initialise filter bar // Create and initialise filter bar
this.filterBarContainer = this.scene.add.container(0, 0); this.filterBarContainer = globalScene.add.container(0, 0);
this.filterBar = new FilterBar(this.scene, speciesContainerX, 1, 175, filterBarHeight, 2, 0, 6); this.filterBar = new FilterBar(speciesContainerX, 1, 175, filterBarHeight, 2, 0, 6);
// gen filter // gen filter
const genOptions: DropDownOption[] = [ const genOptions: DropDownOption[] = [
new DropDownOption(this.scene, 1, new DropDownLabel(i18next.t("pokedexUiHandler:gen1"))), new DropDownOption(1, new DropDownLabel(i18next.t("pokedexUiHandler:gen1"))),
new DropDownOption(this.scene, 2, new DropDownLabel(i18next.t("pokedexUiHandler:gen2"))), new DropDownOption(2, new DropDownLabel(i18next.t("pokedexUiHandler:gen2"))),
new DropDownOption(this.scene, 3, new DropDownLabel(i18next.t("pokedexUiHandler:gen3"))), new DropDownOption(3, new DropDownLabel(i18next.t("pokedexUiHandler:gen3"))),
new DropDownOption(this.scene, 4, new DropDownLabel(i18next.t("pokedexUiHandler:gen4"))), new DropDownOption(4, new DropDownLabel(i18next.t("pokedexUiHandler:gen4"))),
new DropDownOption(this.scene, 5, new DropDownLabel(i18next.t("pokedexUiHandler:gen5"))), new DropDownOption(5, new DropDownLabel(i18next.t("pokedexUiHandler:gen5"))),
new DropDownOption(this.scene, 6, new DropDownLabel(i18next.t("pokedexUiHandler:gen6"))), new DropDownOption(6, new DropDownLabel(i18next.t("pokedexUiHandler:gen6"))),
new DropDownOption(this.scene, 7, new DropDownLabel(i18next.t("pokedexUiHandler:gen7"))), new DropDownOption(7, new DropDownLabel(i18next.t("pokedexUiHandler:gen7"))),
new DropDownOption(this.scene, 8, new DropDownLabel(i18next.t("pokedexUiHandler:gen8"))), new DropDownOption(8, new DropDownLabel(i18next.t("pokedexUiHandler:gen8"))),
new DropDownOption(this.scene, 9, new DropDownLabel(i18next.t("pokedexUiHandler:gen9"))), new DropDownOption(9, new DropDownLabel(i18next.t("pokedexUiHandler:gen9"))),
]; ];
const genDropDown: DropDown = new DropDown(this.scene, 0, 0, genOptions, this.updateStarters, DropDownType.HYBRID); const genDropDown: DropDown = new DropDown(0, 0, genOptions, this.updateStarters, DropDownType.HYBRID);
this.filterBar.addFilter(DropDownColumn.GEN, i18next.t("filterBar:genFilter"), genDropDown); this.filterBar.addFilter(DropDownColumn.GEN, i18next.t("filterBar:genFilter"), genDropDown);
// type filter // type filter
@ -290,49 +290,49 @@ export default class PokedexUiHandler extends MessageUiHandler {
if (index === 0 || index === 19) { if (index === 0 || index === 19) {
return; return;
} }
const typeSprite = this.scene.add.sprite(0, 0, getLocalizedSpriteKey("types")); const typeSprite = globalScene.add.sprite(0, 0, getLocalizedSpriteKey("types"));
typeSprite.setScale(0.5); typeSprite.setScale(0.5);
typeSprite.setFrame(type.toLowerCase()); typeSprite.setFrame(type.toLowerCase());
typeOptions.push(new DropDownOption(this.scene, index, new DropDownLabel("", typeSprite))); typeOptions.push(new DropDownOption( index, new DropDownLabel("", typeSprite)));
}); });
this.filterBar.addFilter(DropDownColumn.TYPES, i18next.t("filterBar:typeFilter"), new DropDown(this.scene, 0, 0, typeOptions, this.updateStarters, DropDownType.HYBRID, 0.5)); this.filterBar.addFilter(DropDownColumn.TYPES, i18next.t("filterBar:typeFilter"), new DropDown(0, 0, typeOptions, this.updateStarters, DropDownType.HYBRID, 0.5));
// biome filter, making an entry in the dropdown for each biome // biome filter, making an entry in the dropdown for each biome
const biomeOptions = Object.values(Biome) const biomeOptions = Object.values(Biome)
.filter((value) => typeof value === "number") // Filter numeric values from the enum .filter((value) => typeof value === "number") // Filter numeric values from the enum
.map((biomeValue, index) => .map((biomeValue, index) =>
new DropDownOption(this.scene, index, new DropDownLabel(i18next.t(`biome:${Biome[biomeValue].toUpperCase()}`))) new DropDownOption( index, new DropDownLabel(i18next.t(`biome:${Biome[biomeValue].toUpperCase()}`)))
); );
biomeOptions.push(new DropDownOption(this.scene, biomeOptions.length, new DropDownLabel(i18next.t("filterBar:uncatchable")))); biomeOptions.push(new DropDownOption( biomeOptions.length, new DropDownLabel(i18next.t("filterBar:uncatchable"))));
const biomeDropDown: DropDown = new DropDown(this.scene, 0, 0, biomeOptions, this.updateStarters, DropDownType.HYBRID); const biomeDropDown: DropDown = new DropDown(0, 0, biomeOptions, this.updateStarters, DropDownType.HYBRID);
this.filterBar.addFilter(DropDownColumn.BIOME, i18next.t("filterBar:biomeFilter"), biomeDropDown); this.filterBar.addFilter(DropDownColumn.BIOME, i18next.t("filterBar:biomeFilter"), biomeDropDown);
// caught filter // caught filter
const shiny1Sprite = this.scene.add.sprite(0, 0, "shiny_icons"); const shiny1Sprite = globalScene.add.sprite(0, 0, "shiny_icons");
shiny1Sprite.setOrigin(0.15, 0.2); shiny1Sprite.setOrigin(0.15, 0.2);
shiny1Sprite.setScale(0.6); shiny1Sprite.setScale(0.6);
shiny1Sprite.setFrame(getVariantIcon(0)); shiny1Sprite.setFrame(getVariantIcon(0));
shiny1Sprite.setTint(getVariantTint(0)); shiny1Sprite.setTint(getVariantTint(0));
const shiny2Sprite = this.scene.add.sprite(0, 0, "shiny_icons"); const shiny2Sprite = globalScene.add.sprite(0, 0, "shiny_icons");
shiny2Sprite.setOrigin(0.15, 0.2); shiny2Sprite.setOrigin(0.15, 0.2);
shiny2Sprite.setScale(0.6); shiny2Sprite.setScale(0.6);
shiny2Sprite.setFrame(getVariantIcon(1)); shiny2Sprite.setFrame(getVariantIcon(1));
shiny2Sprite.setTint(getVariantTint(1)); shiny2Sprite.setTint(getVariantTint(1));
const shiny3Sprite = this.scene.add.sprite(0, 0, "shiny_icons"); const shiny3Sprite = globalScene.add.sprite(0, 0, "shiny_icons");
shiny3Sprite.setOrigin(0.15, 0.2); shiny3Sprite.setOrigin(0.15, 0.2);
shiny3Sprite.setScale(0.6); shiny3Sprite.setScale(0.6);
shiny3Sprite.setFrame(getVariantIcon(2)); shiny3Sprite.setFrame(getVariantIcon(2));
shiny3Sprite.setTint(getVariantTint(2)); shiny3Sprite.setTint(getVariantTint(2));
const caughtOptions = [ const caughtOptions = [
new DropDownOption(this.scene, "SHINY3", new DropDownLabel("", shiny3Sprite)), new DropDownOption("SHINY3", new DropDownLabel("", shiny3Sprite)),
new DropDownOption(this.scene, "SHINY2", new DropDownLabel("", shiny2Sprite)), new DropDownOption("SHINY2", new DropDownLabel("", shiny2Sprite)),
new DropDownOption(this.scene, "SHINY", new DropDownLabel("", shiny1Sprite)), new DropDownOption("SHINY", new DropDownLabel("", shiny1Sprite)),
new DropDownOption(this.scene, "NORMAL", new DropDownLabel(i18next.t("filterBar:normal"))), new DropDownOption("NORMAL", new DropDownLabel(i18next.t("filterBar:normal"))),
new DropDownOption(this.scene, "UNCAUGHT", new DropDownLabel(i18next.t("filterBar:uncaught"))) new DropDownOption("UNCAUGHT", new DropDownLabel(i18next.t("filterBar:uncaught")))
]; ];
this.filterBar.addFilter(DropDownColumn.CAUGHT, i18next.t("filterBar:caughtFilter"), new DropDown(this.scene, 0, 0, caughtOptions, this.updateStarters, DropDownType.HYBRID)); this.filterBar.addFilter(DropDownColumn.CAUGHT, i18next.t("filterBar:caughtFilter"), new DropDown(0, 0, caughtOptions, this.updateStarters, DropDownType.HYBRID));
// unlocks filter // unlocks filter
const passiveLabels = [ const passiveLabels = [
@ -350,11 +350,11 @@ export default class PokedexUiHandler extends MessageUiHandler {
]; ];
const unlocksOptions = [ const unlocksOptions = [
new DropDownOption(this.scene, "PASSIVE", passiveLabels), new DropDownOption("PASSIVE", passiveLabels),
new DropDownOption(this.scene, "COST_REDUCTION", costReductionLabels), new DropDownOption("COST_REDUCTION", costReductionLabels),
]; ];
this.filterBar.addFilter(DropDownColumn.UNLOCKS, i18next.t("filterBar:unlocksFilter"), new DropDown(this.scene, 0, 0, unlocksOptions, this.updateStarters, DropDownType.RADIAL)); this.filterBar.addFilter(DropDownColumn.UNLOCKS, i18next.t("filterBar:unlocksFilter"), new DropDown(0, 0, unlocksOptions, this.updateStarters, DropDownType.RADIAL));
// misc filter // misc filter
const starters = [ const starters = [
@ -386,24 +386,24 @@ export default class PokedexUiHandler extends MessageUiHandler {
new DropDownLabel(i18next.t("filterBar:hasPokerus"), undefined, DropDownState.ON), new DropDownLabel(i18next.t("filterBar:hasPokerus"), undefined, DropDownState.ON),
]; ];
const miscOptions = [ const miscOptions = [
new DropDownOption(this.scene, "STARTER", starters), new DropDownOption("STARTER", starters),
new DropDownOption(this.scene, "FAVORITE", favoriteLabels), new DropDownOption("FAVORITE", favoriteLabels),
new DropDownOption(this.scene, "WIN", winLabels), new DropDownOption("WIN", winLabels),
new DropDownOption(this.scene, "HIDDEN_ABILITY", hiddenAbilityLabels), new DropDownOption("HIDDEN_ABILITY", hiddenAbilityLabels),
new DropDownOption(this.scene, "EGG", eggLabels), new DropDownOption("EGG", eggLabels),
new DropDownOption(this.scene, "POKERUS", pokerusLabels), new DropDownOption("POKERUS", pokerusLabels),
]; ];
this.filterBar.addFilter(DropDownColumn.MISC, i18next.t("filterBar:miscFilter"), new DropDown(this.scene, 0, 0, miscOptions, this.updateStarters, DropDownType.RADIAL)); this.filterBar.addFilter(DropDownColumn.MISC, i18next.t("filterBar:miscFilter"), new DropDown(0, 0, miscOptions, this.updateStarters, DropDownType.RADIAL));
// sort filter // sort filter
const sortOptions = [ const sortOptions = [
new DropDownOption(this.scene, SortCriteria.NUMBER, new DropDownLabel(i18next.t("filterBar:sortByNumber"), undefined, DropDownState.ON)), new DropDownOption(SortCriteria.NUMBER, new DropDownLabel(i18next.t("filterBar:sortByNumber"), undefined, DropDownState.ON)),
new DropDownOption(this.scene, SortCriteria.COST, new DropDownLabel(i18next.t("filterBar:sortByCost"))), new DropDownOption(SortCriteria.COST, new DropDownLabel(i18next.t("filterBar:sortByCost"))),
new DropDownOption(this.scene, SortCriteria.CANDY, new DropDownLabel(i18next.t("filterBar:sortByCandies"))), new DropDownOption(SortCriteria.CANDY, new DropDownLabel(i18next.t("filterBar:sortByCandies"))),
new DropDownOption(this.scene, SortCriteria.IV, new DropDownLabel(i18next.t("filterBar:sortByIVs"))), new DropDownOption(SortCriteria.IV, new DropDownLabel(i18next.t("filterBar:sortByIVs"))),
new DropDownOption(this.scene, SortCriteria.NAME, new DropDownLabel(i18next.t("filterBar:sortByName"))) new DropDownOption(SortCriteria.NAME, new DropDownLabel(i18next.t("filterBar:sortByName")))
]; ];
this.filterBar.addFilter(DropDownColumn.SORT, i18next.t("filterBar:sortFilter"), new DropDown(this.scene, 0, 0, sortOptions, this.updateStarters, DropDownType.SINGLE)); this.filterBar.addFilter(DropDownColumn.SORT, i18next.t("filterBar:sortFilter"), new DropDown(0, 0, sortOptions, this.updateStarters, DropDownType.SINGLE));
this.filterBarContainer.add(this.filterBar); this.filterBarContainer.add(this.filterBar);
this.starterSelectContainer.add(this.filterBarContainer); this.starterSelectContainer.add(this.filterBarContainer);
@ -411,36 +411,36 @@ export default class PokedexUiHandler extends MessageUiHandler {
// Offset the generation filter dropdown to avoid covering the filtered pokemon // Offset the generation filter dropdown to avoid covering the filtered pokemon
this.filterBar.offsetHybridFilters(); this.filterBar.offsetHybridFilters();
if (!this.scene.uiTheme) { if (!globalScene.uiTheme) {
starterContainerWindow.setVisible(false); starterContainerWindow.setVisible(false);
} }
this.iconAnimHandler = new PokemonIconAnimHandler(); this.iconAnimHandler = new PokemonIconAnimHandler();
this.iconAnimHandler.setup(this.scene); this.iconAnimHandler.setup();
this.pokemonNumberText = addTextObject(this.scene, 6, 140, "", TextStyle.SUMMARY); this.pokemonNumberText = addTextObject(6, 140, "", TextStyle.SUMMARY);
this.pokemonNumberText.setOrigin(0, 0); this.pokemonNumberText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonNumberText); this.starterSelectContainer.add(this.pokemonNumberText);
this.pokemonNameText = addTextObject(this.scene, 6, 127, "", TextStyle.SUMMARY); this.pokemonNameText = addTextObject(6, 127, "", TextStyle.SUMMARY);
this.pokemonNameText.setOrigin(0, 0); this.pokemonNameText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonNameText); this.starterSelectContainer.add(this.pokemonNameText);
const starterBoxContainer = this.scene.add.container(speciesContainerX + 6, 9); //115 const starterBoxContainer = globalScene.add.container(speciesContainerX + 6, 9); //115
this.starterSelectScrollBar = new ScrollBar(this.scene, 161, 12, 5, starterContainerWindow.height - 6, 9); this.starterSelectScrollBar = new ScrollBar(161, 12, 5, starterContainerWindow.height - 6, 9);
starterBoxContainer.add(this.starterSelectScrollBar); 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 = this.scene.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); starterBoxContainer.add(cursorObj);
return cursorObj; return cursorObj;
}); });
this.cursorObj = this.scene.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); starterBoxContainer.add(this.cursorObj);
@ -449,7 +449,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
this.speciesLoaded.set(species.speciesId, false); this.speciesLoaded.set(species.speciesId, false);
this.allSpecies.push(species); this.allSpecies.push(species);
const starterContainer = new StarterContainer(this.scene, species).setVisible(false); const starterContainer = new StarterContainer(species).setVisible(false);
this.iconAnimHandler.addOrUpdate(starterContainer.icon, PokemonIconAnimMode.NONE); this.iconAnimHandler.addOrUpdate(starterContainer.icon, PokemonIconAnimMode.NONE);
this.starterContainers.push(starterContainer); this.starterContainers.push(starterContainer);
starterBoxContainer.add(starterContainer); starterBoxContainer.add(starterContainer);
@ -457,55 +457,55 @@ export default class PokedexUiHandler extends MessageUiHandler {
this.starterSelectContainer.add(starterBoxContainer); this.starterSelectContainer.add(starterBoxContainer);
this.pokemonSprite = this.scene.add.sprite(96, 143, "pkmn__sub"); this.pokemonSprite = globalScene.add.sprite(96, 143, "pkmn__sub");
this.pokemonSprite.setPipeline(this.scene.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 });
this.starterSelectContainer.add(this.pokemonSprite); this.starterSelectContainer.add(this.pokemonSprite);
this.type1Icon = this.scene.add.sprite(10, 158, getLocalizedSpriteKey("types")); this.type1Icon = globalScene.add.sprite(10, 158, getLocalizedSpriteKey("types"));
this.type1Icon.setScale(0.5); this.type1Icon.setScale(0.5);
this.type1Icon.setOrigin(0, 0); this.type1Icon.setOrigin(0, 0);
this.starterSelectContainer.add(this.type1Icon); this.starterSelectContainer.add(this.type1Icon);
this.type2Icon = this.scene.add.sprite(10, 166, getLocalizedSpriteKey("types")); this.type2Icon = globalScene.add.sprite(10, 166, getLocalizedSpriteKey("types"));
this.type2Icon.setScale(0.5); this.type2Icon.setScale(0.5);
this.type2Icon.setOrigin(0, 0); this.type2Icon.setOrigin(0, 0);
this.starterSelectContainer.add(this.type2Icon); this.starterSelectContainer.add(this.type2Icon);
this.starterSelectMessageBoxContainer = this.scene.add.container(0, this.scene.game.canvas.height / 6); this.starterSelectMessageBoxContainer = globalScene.add.container(0, globalScene.game.canvas.height / 6);
this.starterSelectMessageBoxContainer.setVisible(false); this.starterSelectMessageBoxContainer.setVisible(false);
this.starterSelectContainer.add(this.starterSelectMessageBoxContainer); this.starterSelectContainer.add(this.starterSelectMessageBoxContainer);
this.starterSelectMessageBox = addWindow(this.scene, 1, -1, 318, 28); this.starterSelectMessageBox = addWindow(1, -1, 318, 28);
this.starterSelectMessageBox.setOrigin(0, 1); this.starterSelectMessageBox.setOrigin(0, 1);
this.starterSelectMessageBoxContainer.add(this.starterSelectMessageBox); this.starterSelectMessageBoxContainer.add(this.starterSelectMessageBox);
// Instruction for "C" button to toggle showDecorations // Instruction for "C" button to toggle showDecorations
const instructionTextSize = textSettings.instructionTextSize; const instructionTextSize = textSettings.instructionTextSize;
this.goFilterIconElement1 = new Phaser.GameObjects.Sprite(this.scene, 10, 2, "keyboard", "C.png"); this.goFilterIconElement1 = new Phaser.GameObjects.Sprite(globalScene, 10, 2, "keyboard", "C.png");
this.goFilterIconElement1.setName("sprite-goFilter1-icon-element"); this.goFilterIconElement1.setName("sprite-goFilter1-icon-element");
this.goFilterIconElement1.setScale(0.675); this.goFilterIconElement1.setScale(0.675);
this.goFilterIconElement1.setOrigin(0.0, 0.0); this.goFilterIconElement1.setOrigin(0.0, 0.0);
this.goFilterIconElement2 = new Phaser.GameObjects.Sprite(this.scene, 20, 2, "keyboard", "V.png"); this.goFilterIconElement2 = new Phaser.GameObjects.Sprite(globalScene, 20, 2, "keyboard", "V.png");
this.goFilterIconElement2.setName("sprite-goFilter2-icon-element"); this.goFilterIconElement2.setName("sprite-goFilter2-icon-element");
this.goFilterIconElement2.setScale(0.675); this.goFilterIconElement2.setScale(0.675);
this.goFilterIconElement2.setOrigin(0.0, 0.0); this.goFilterIconElement2.setOrigin(0.0, 0.0);
this.goFilterLabel = addTextObject(this.scene, 30, 2, i18next.t("pokedexUiHandler:goFilters"), TextStyle.PARTY, { fontSize: instructionTextSize }); this.goFilterLabel = addTextObject(30, 2, i18next.t("pokedexUiHandler:goFilters"), TextStyle.PARTY, { fontSize: instructionTextSize });
this.goFilterLabel.setName("text-goFilter-label"); this.goFilterLabel.setName("text-goFilter-label");
this.starterSelectContainer.add(this.goFilterIconElement1); this.starterSelectContainer.add(this.goFilterIconElement1);
this.starterSelectContainer.add(this.goFilterIconElement2); this.starterSelectContainer.add(this.goFilterIconElement2);
this.starterSelectContainer.add(this.goFilterLabel); this.starterSelectContainer.add(this.goFilterLabel);
this.toggleDecorationsIconElement = new Phaser.GameObjects.Sprite(this.scene, 10, 10, "keyboard", "R.png"); this.toggleDecorationsIconElement = new Phaser.GameObjects.Sprite(globalScene, 10, 10, "keyboard", "R.png");
this.toggleDecorationsIconElement.setName("sprite-toggleDecorations-icon-element"); this.toggleDecorationsIconElement.setName("sprite-toggleDecorations-icon-element");
this.toggleDecorationsIconElement.setScale(0.675); this.toggleDecorationsIconElement.setScale(0.675);
this.toggleDecorationsIconElement.setOrigin(0.0, 0.0); this.toggleDecorationsIconElement.setOrigin(0.0, 0.0);
this.toggleDecorationsLabel = addTextObject(this.scene, 20, 10, i18next.t("pokedexUiHandler:toggleDecorations"), TextStyle.PARTY, { fontSize: instructionTextSize }); this.toggleDecorationsLabel = addTextObject(20, 10, i18next.t("pokedexUiHandler:toggleDecorations"), TextStyle.PARTY, { fontSize: instructionTextSize });
this.toggleDecorationsLabel.setName("text-toggleDecorations-label"); this.toggleDecorationsLabel.setName("text-toggleDecorations-label");
this.starterSelectContainer.add(this.toggleDecorationsIconElement); this.starterSelectContainer.add(this.toggleDecorationsIconElement);
this.starterSelectContainer.add(this.toggleDecorationsLabel); this.starterSelectContainer.add(this.toggleDecorationsLabel);
this.message = addTextObject(this.scene, 8, 8, "", TextStyle.WINDOW, { maxLines: 2 }); this.message = addTextObject(8, 8, "", TextStyle.WINDOW, { maxLines: 2 });
this.message.setOrigin(0, 0); this.message.setOrigin(0, 0);
this.starterSelectMessageBoxContainer.add(this.message); this.starterSelectMessageBoxContainer.add(this.message);
@ -516,8 +516,6 @@ export default class PokedexUiHandler extends MessageUiHandler {
this.starterSelectContainer.bringToTop(this.filterBarContainer); this.starterSelectContainer.bringToTop(this.filterBarContainer);
this.initTutorialOverlay(this.starterSelectContainer); this.initTutorialOverlay(this.starterSelectContainer);
this.starterSelectContainer.bringToTop(this.starterSelectMessageBoxContainer); this.starterSelectContainer.bringToTop(this.starterSelectMessageBoxContainer);
this.scene.eventTarget.addEventListener(BattleSceneEventType.CANDY_UPGRADE_NOTIFICATION_CHANGED, (e) => this.onCandyUpgradeDisplayChanged(e));
} }
show(args: any[]): boolean { show(args: any[]): boolean {
@ -526,7 +524,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
this.starterPreferences = StarterPrefs.load(); this.starterPreferences = StarterPrefs.load();
} }
this.pokerusSpecies = getPokerusStarters(this.scene); this.pokerusSpecies = getPokerusStarters();
// When calling with "refresh", we do not reset the cursor and filters // When calling with "refresh", we do not reset the cursor and filters
if (args.length >= 1 && args[0] === "refresh") { if (args.length >= 1 && args[0] === "refresh") {
@ -542,7 +540,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
// Making caught pokemon visible icons, etc // Making caught pokemon visible icons, etc
this.allSpecies.forEach((species, s) => { this.allSpecies.forEach((species, s) => {
const icon = this.starterContainers[s].icon; const icon = this.starterContainers[s].icon;
const dexEntry = this.scene.gameData.dexData[species.speciesId]; const dexEntry = globalScene.gameData.dexData[species.speciesId];
this.starterPreferences[species.speciesId] = this.initStarterPrefs(species); this.starterPreferences[species.speciesId] = this.initStarterPrefs(species);
@ -564,8 +562,6 @@ export default class PokedexUiHandler extends MessageUiHandler {
this.filterTextCursor = 0; this.filterTextCursor = 0;
this.setCursor(0); this.setCursor(0);
handleTutorial(this.scene, Tutorial.Pokedex);
this.filterTextContainer.setVisible(true); this.filterTextContainer.setVisible(true);
return true; return true;
@ -581,8 +577,8 @@ export default class PokedexUiHandler extends MessageUiHandler {
*/ */
initStarterPrefs(species: PokemonSpecies): StarterAttributes { initStarterPrefs(species: PokemonSpecies): StarterAttributes {
const starterAttributes = this.starterPreferences[species.speciesId]; const starterAttributes = this.starterPreferences[species.speciesId];
const dexEntry = this.scene.gameData.dexData[species.speciesId]; const dexEntry = globalScene.gameData.dexData[species.speciesId];
const starterData = this.scene.gameData.starterData[species.speciesId]; const starterData = globalScene.gameData.starterData[species.speciesId];
// no preferences or Pokemon wasn't caught, return empty attribute // no preferences or Pokemon wasn't caught, return empty attribute
if (!starterAttributes || !dexEntry.caughtAttr) { if (!starterAttributes || !dexEntry.caughtAttr) {
@ -641,13 +637,13 @@ export default class PokedexUiHandler extends MessageUiHandler {
} }
const selectedForm = starterAttributes.form; const selectedForm = starterAttributes.form;
if (selectedForm !== undefined && (!species.forms[selectedForm]?.isStarterSelectable || !(caughtAttr & this.scene.gameData.getFormAttr(selectedForm)))) { if (selectedForm !== undefined && (!species.forms[selectedForm]?.isStarterSelectable || !(caughtAttr & globalScene.gameData.getFormAttr(selectedForm)))) {
// requested form wasn't unlocked/isn't a starter form, purging setting // requested form wasn't unlocked/isn't a starter form, purging setting
delete starterAttributes.form; delete starterAttributes.form;
} }
if (starterAttributes.nature !== undefined) { if (starterAttributes.nature !== undefined) {
const unlockedNatures = this.scene.gameData.getNaturesForAttr(dexEntry.natureAttr); const unlockedNatures = globalScene.gameData.getNaturesForAttr(dexEntry.natureAttr);
if (unlockedNatures.indexOf(starterAttributes.nature as unknown as Nature) < 0) { if (unlockedNatures.indexOf(starterAttributes.nature as unknown as Nature) < 0) {
// requested nature wasn't unlocked, purging setting // requested nature wasn't unlocked, purging setting
delete starterAttributes.nature; delete starterAttributes.nature;
@ -677,7 +673,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
this.starterSelectMessageBoxContainer.setY(0); this.starterSelectMessageBoxContainer.setY(0);
this.message.setY(4); this.message.setY(4);
} else { } else {
this.starterSelectMessageBoxContainer.setY(this.scene.game.canvas.height / 6); this.starterSelectMessageBoxContainer.setY(globalScene.game.canvas.height / 6);
this.starterSelectMessageBox.setOrigin(0, 1); this.starterSelectMessageBox.setOrigin(0, 1);
this.message.setY(singleLine ? -22 : -37); this.message.setY(singleLine ? -22 : -37);
} }
@ -690,14 +686,14 @@ export default class PokedexUiHandler extends MessageUiHandler {
* @returns true if upgrade notifications are enabled and set to display an 'Icon' * @returns true if upgrade notifications are enabled and set to display an 'Icon'
*/ */
isUpgradeIconEnabled(): boolean { isUpgradeIconEnabled(): boolean {
return this.scene.candyUpgradeNotification !== 0 && this.scene.candyUpgradeDisplay === 0; return globalScene.candyUpgradeNotification !== 0 && globalScene.candyUpgradeDisplay === 0;
} }
/** /**
* Determines if 'Animation' based upgrade notifications should be shown * Determines if 'Animation' based upgrade notifications should be shown
* @returns true if upgrade notifications are enabled and set to display an 'Animation' * @returns true if upgrade notifications are enabled and set to display an 'Animation'
*/ */
isUpgradeAnimationEnabled(): boolean { isUpgradeAnimationEnabled(): boolean {
return this.scene.candyUpgradeNotification !== 0 && this.scene.candyUpgradeDisplay === 1; return globalScene.candyUpgradeNotification !== 0 && globalScene.candyUpgradeDisplay === 1;
} }
getStarterSpeciesId(speciesId): number { getStarterSpeciesId(speciesId): number {
@ -715,7 +711,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
*/ */
isPassiveAvailable(speciesId: number): boolean { isPassiveAvailable(speciesId: number): boolean {
// Get this species ID's starter data // Get this species ID's starter data
const starterData = this.scene.gameData.starterData[this.getStarterSpeciesId(speciesId)]; const starterData = globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)];
return starterData.candyCount >= getPassiveCandyCount(speciesStarterCosts[this.getStarterSpeciesId(speciesId)]) return starterData.candyCount >= getPassiveCandyCount(speciesStarterCosts[this.getStarterSpeciesId(speciesId)])
&& !(starterData.passiveAttr & PassiveAttr.UNLOCKED); && !(starterData.passiveAttr & PassiveAttr.UNLOCKED);
@ -728,7 +724,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
*/ */
isValueReductionAvailable(speciesId: number): boolean { isValueReductionAvailable(speciesId: number): boolean {
// Get this species ID's starter data // Get this species ID's starter data
const starterData = this.scene.gameData.starterData[this.getStarterSpeciesId(speciesId)]; const starterData = globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)];
return starterData.candyCount >= getValueReductionCandyCounts(speciesStarterCosts[this.getStarterSpeciesId(speciesId)])[starterData.valueReduction] return starterData.candyCount >= getValueReductionCandyCounts(speciesStarterCosts[this.getStarterSpeciesId(speciesId)])[starterData.valueReduction]
&& starterData.valueReduction < valueReductionMax; && starterData.valueReduction < valueReductionMax;
@ -741,7 +737,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
*/ */
isSameSpeciesEggAvailable(speciesId: number): boolean { isSameSpeciesEggAvailable(speciesId: number): boolean {
// Get this species ID's starter data // Get this species ID's starter data
const starterData = this.scene.gameData.starterData[this.getStarterSpeciesId(speciesId)]; const starterData = globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)];
return starterData.candyCount >= getSameSpeciesEggCandyCounts(speciesStarterCosts[this.getStarterSpeciesId(speciesId)]); return starterData.candyCount >= getSameSpeciesEggCandyCounts(speciesStarterCosts[this.getStarterSpeciesId(speciesId)]);
} }
@ -753,9 +749,9 @@ export default class PokedexUiHandler extends MessageUiHandler {
* @param startPaused Should this animation be paused after it is added? * @param startPaused Should this animation be paused after it is added?
*/ */
setUpgradeAnimation(icon: Phaser.GameObjects.Sprite, species: PokemonSpecies, startPaused: boolean = false): void { setUpgradeAnimation(icon: Phaser.GameObjects.Sprite, species: PokemonSpecies, startPaused: boolean = false): void {
this.scene.tweens.killTweensOf(icon); globalScene.tweens.killTweensOf(icon);
// Skip animations if they are disabled // Skip animations if they are disabled
if (this.scene.candyUpgradeDisplay === 0 || species.speciesId !== species.getRootSpeciesId(false)) { if (globalScene.candyUpgradeDisplay === 0 || species.speciesId !== species.getRootSpeciesId(false)) {
return; return;
} }
@ -789,14 +785,14 @@ export default class PokedexUiHandler extends MessageUiHandler {
const isSameSpeciesEggAvailable = this.isSameSpeciesEggAvailable(species.speciesId); const isSameSpeciesEggAvailable = this.isSameSpeciesEggAvailable(species.speciesId);
// 'Passives Only' mode // 'Passives Only' mode
if (this.scene.candyUpgradeNotification === 1) { if (globalScene.candyUpgradeNotification === 1) {
if (isPassiveAvailable) { if (isPassiveAvailable) {
this.scene.tweens.chain(tweenChain).paused = startPaused; globalScene.tweens.chain(tweenChain).paused = startPaused;
} }
// 'On' mode // 'On' mode
} else if (this.scene.candyUpgradeNotification === 2) { } else if (globalScene.candyUpgradeNotification === 2) {
if (isPassiveAvailable || isValueReductionAvailable || isSameSpeciesEggAvailable) { if (isPassiveAvailable || isValueReductionAvailable || isSameSpeciesEggAvailable) {
this.scene.tweens.chain(tweenChain).paused = startPaused; globalScene.tweens.chain(tweenChain).paused = startPaused;
} }
} }
} }
@ -808,7 +804,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
const species = starter.species; const species = starter.species;
const slotVisible = !!species?.speciesId; const slotVisible = !!species?.speciesId;
if (!species || this.scene.candyUpgradeNotification === 0 || species.speciesId !== species.getRootSpeciesId(false)) { if (!species || globalScene.candyUpgradeNotification === 0 || species.speciesId !== species.getRootSpeciesId(false)) {
starter.candyUpgradeIcon.setVisible(false); starter.candyUpgradeIcon.setVisible(false);
starter.candyUpgradeOverlayIcon.setVisible(false); starter.candyUpgradeOverlayIcon.setVisible(false);
return; return;
@ -819,12 +815,12 @@ export default class PokedexUiHandler extends MessageUiHandler {
const isSameSpeciesEggAvailable = this.isSameSpeciesEggAvailable(species.speciesId); const isSameSpeciesEggAvailable = this.isSameSpeciesEggAvailable(species.speciesId);
// 'Passive Only' mode // 'Passive Only' mode
if (this.scene.candyUpgradeNotification === 1) { if (globalScene.candyUpgradeNotification === 1) {
starter.candyUpgradeIcon.setVisible(slotVisible && isPassiveAvailable); starter.candyUpgradeIcon.setVisible(slotVisible && isPassiveAvailable);
starter.candyUpgradeOverlayIcon.setVisible(slotVisible && starter.candyUpgradeIcon.visible); starter.candyUpgradeOverlayIcon.setVisible(slotVisible && starter.candyUpgradeIcon.visible);
// 'On' mode // 'On' mode
} else if (this.scene.candyUpgradeNotification === 2) { } else if (globalScene.candyUpgradeNotification === 2) {
starter.candyUpgradeIcon.setVisible( starter.candyUpgradeIcon.setVisible(
slotVisible && ( isPassiveAvailable || isValueReductionAvailable || isSameSpeciesEggAvailable )); slotVisible && ( isPassiveAvailable || isValueReductionAvailable || isSameSpeciesEggAvailable ));
starter.candyUpgradeOverlayIcon.setVisible(slotVisible && starter.candyUpgradeIcon.visible); starter.candyUpgradeOverlayIcon.setVisible(slotVisible && starter.candyUpgradeIcon.visible);
@ -844,33 +840,6 @@ export default class PokedexUiHandler extends MessageUiHandler {
} }
} }
/**
* Processes an {@linkcode CandyUpgradeNotificationChangedEvent} sent when the corresponding setting changes
* @param event {@linkcode Event} sent by the callback
*/
onCandyUpgradeDisplayChanged(event: Event): void {
const candyUpgradeDisplayEvent = event as CandyUpgradeNotificationChangedEvent;
if (!candyUpgradeDisplayEvent) {
return;
}
// Loop through all visible candy icons when set to 'Icon' mode
if (this.scene.candyUpgradeDisplay === 0) {
this.filteredStarterContainers.forEach((starter) => {
this.setUpgradeIcon(starter);
});
return;
}
// Loop through all animations when set to 'Animation' mode
this.filteredStarterContainers.forEach((starter, s) => {
const icon = this.filteredStarterContainers[s].icon;
this.setUpgradeAnimation(icon, starter.species);
});
}
processInput(button: Button): boolean { processInput(button: Button): boolean {
if (this.blockInput) { if (this.blockInput) {
return false; return false;
@ -1136,7 +1105,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
break; break;
} }
} else { } else {
iconPath = this.scene.inputController?.getIconForLatestInputRecorded(iconSetting); iconPath = globalScene.inputController?.getIconForLatestInputRecorded(iconSetting);
} }
iconElement.setTexture(gamepadType, iconPath); iconElement.setTexture(gamepadType, iconPath);
iconElement.setVisible(true); iconElement.setVisible(true);
@ -1151,7 +1120,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
gamepadType = "keyboard"; gamepadType = "keyboard";
iconPath = "C.png"; iconPath = "C.png";
} else { } else {
iconPath = this.scene.inputController?.getIconForLatestInputRecorded(iconSetting); iconPath = globalScene.inputController?.getIconForLatestInputRecorded(iconSetting);
} }
iconElement.setTexture(gamepadType, iconPath); iconElement.setTexture(gamepadType, iconPath);
iconElement.setVisible(true); iconElement.setVisible(true);
@ -1197,7 +1166,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
const starterSprite = currentFilteredContainer.icon as Phaser.GameObjects.Sprite; const starterSprite = currentFilteredContainer.icon as Phaser.GameObjects.Sprite;
const currentDexAttr = this.getCurrentDexProps(currentFilteredContainer.species.speciesId); const currentDexAttr = this.getCurrentDexProps(currentFilteredContainer.species.speciesId);
const props = this.getSanitizedProps(this.scene.gameData.getSpeciesDexAttrProps(currentFilteredContainer.species, currentDexAttr)); const props = this.getSanitizedProps(globalScene.gameData.getSpeciesDexAttrProps(currentFilteredContainer.species, currentDexAttr));
starterSprite.setTexture(currentFilteredContainer.species.getIconAtlasKey(props.formIndex, props.shiny, props.variant), currentFilteredContainer.species.getIconId(props.female!, props.formIndex, props.shiny, props.variant)); starterSprite.setTexture(currentFilteredContainer.species.getIconAtlasKey(props.formIndex, props.shiny, props.variant), currentFilteredContainer.species.getIconId(props.female!, props.formIndex, props.shiny, props.variant));
currentFilteredContainer.checkIconId(props.female, props.formIndex, props.shiny, props.variant); currentFilteredContainer.checkIconId(props.female, props.formIndex, props.shiny, props.variant);
@ -1207,12 +1176,12 @@ export default class PokedexUiHandler extends MessageUiHandler {
this.validStarterContainers.forEach(container => { this.validStarterContainers.forEach(container => {
container.setVisible(false); container.setVisible(false);
container.cost = this.scene.gameData.getSpeciesStarterValue(this.getStarterSpeciesId(container.species.speciesId)); container.cost = globalScene.gameData.getSpeciesStarterValue(this.getStarterSpeciesId(container.species.speciesId));
// First, ensure you have the caught attributes for the species else default to bigint 0 // First, ensure you have the caught attributes for the species else default to bigint 0
// TODO: This might be removed depending on how accessible we want the pokedex function to be // TODO: This might be removed depending on how accessible we want the pokedex function to be
const caughtAttr = this.scene.gameData.dexData[container.species.speciesId]?.caughtAttr || BigInt(0); const caughtAttr = globalScene.gameData.dexData[container.species.speciesId]?.caughtAttr || BigInt(0);
const starterData = this.scene.gameData.starterData[this.getStarterSpeciesId(container.species.speciesId)]; const starterData = globalScene.gameData.starterData[this.getStarterSpeciesId(container.species.speciesId)];
const isStarterProgressable = speciesEggMoves.hasOwnProperty(this.getStarterSpeciesId(container.species.speciesId)); const isStarterProgressable = speciesEggMoves.hasOwnProperty(this.getStarterSpeciesId(container.species.speciesId));
// Name filter // Name filter
@ -1425,12 +1394,12 @@ export default class PokedexUiHandler extends MessageUiHandler {
case SortCriteria.COST: case SortCriteria.COST:
return (a.cost - b.cost) * -sort.dir; return (a.cost - b.cost) * -sort.dir;
case SortCriteria.CANDY: case SortCriteria.CANDY:
const candyCountA = this.scene.gameData.starterData[a.species.speciesId].candyCount; const candyCountA = globalScene.gameData.starterData[a.species.speciesId].candyCount;
const candyCountB = this.scene.gameData.starterData[b.species.speciesId].candyCount; const candyCountB = globalScene.gameData.starterData[b.species.speciesId].candyCount;
return (candyCountA - candyCountB) * -sort.dir; return (candyCountA - candyCountB) * -sort.dir;
case SortCriteria.IV: case SortCriteria.IV:
const avgIVsA = this.scene.gameData.dexData[a.species.speciesId].ivs.reduce((a, b) => a + b, 0) / this.scene.gameData.dexData[a.species.speciesId].ivs.length; const avgIVsA = globalScene.gameData.dexData[a.species.speciesId].ivs.reduce((a, b) => a + b, 0) / globalScene.gameData.dexData[a.species.speciesId].ivs.length;
const avgIVsB = this.scene.gameData.dexData[b.species.speciesId].ivs.reduce((a, b) => a + b, 0) / this.scene.gameData.dexData[b.species.speciesId].ivs.length; const avgIVsB = globalScene.gameData.dexData[b.species.speciesId].ivs.reduce((a, b) => a + b, 0) / globalScene.gameData.dexData[b.species.speciesId].ivs.length;
return (avgIVsA - avgIVsB) * -sort.dir; return (avgIVsA - avgIVsB) * -sort.dir;
case SortCriteria.NAME: case SortCriteria.NAME:
return a.species.name.localeCompare(b.species.name) * -sort.dir; return a.species.name.localeCompare(b.species.name) * -sort.dir;
@ -1476,8 +1445,8 @@ export default class PokedexUiHandler extends MessageUiHandler {
this.updateStarterValueLabel(container); this.updateStarterValueLabel(container);
container.label.setVisible(true); container.label.setVisible(true);
const speciesVariants = speciesId && this.scene.gameData.dexData[speciesId].caughtAttr & DexAttr.SHINY const speciesVariants = speciesId && globalScene.gameData.dexData[speciesId].caughtAttr & DexAttr.SHINY
? [ DexAttr.DEFAULT_VARIANT, DexAttr.VARIANT_2, DexAttr.VARIANT_3 ].filter(v => !!(this.scene.gameData.dexData[speciesId].caughtAttr & v)) ? [ DexAttr.DEFAULT_VARIANT, DexAttr.VARIANT_2, DexAttr.VARIANT_3 ].filter(v => !!(globalScene.gameData.dexData[speciesId].caughtAttr & v))
: []; : [];
for (let v = 0; v < 3; v++) { for (let v = 0; v < 3; v++) {
const hasVariant = speciesVariants.length > v; const hasVariant = speciesVariants.length > v;
@ -1487,13 +1456,13 @@ export default class PokedexUiHandler extends MessageUiHandler {
} }
} }
container.starterPassiveBgs.setVisible(!!this.scene.gameData.starterData[this.getStarterSpeciesId(speciesId)].passiveAttr); container.starterPassiveBgs.setVisible(!!globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)].passiveAttr);
container.hiddenAbilityIcon.setVisible(!!this.scene.gameData.dexData[speciesId].caughtAttr && !!(this.scene.gameData.starterData[this.getStarterSpeciesId(speciesId)].abilityAttr & 4)); container.hiddenAbilityIcon.setVisible(!!globalScene.gameData.dexData[speciesId].caughtAttr && !!(globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)].abilityAttr & 4));
container.classicWinIcon.setVisible(this.scene.gameData.starterData[this.getStarterSpeciesId(speciesId)].classicWinCount > 0); container.classicWinIcon.setVisible(globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)].classicWinCount > 0);
container.favoriteIcon.setVisible(this.starterPreferences[speciesId]?.favorite ?? false); container.favoriteIcon.setVisible(this.starterPreferences[speciesId]?.favorite ?? false);
// 'Candy Icon' mode // 'Candy Icon' mode
if (this.scene.candyUpgradeDisplay === 0) { if (globalScene.candyUpgradeDisplay === 0) {
if (!starterColors[this.getStarterSpeciesId(speciesId)]) { if (!starterColors[this.getStarterSpeciesId(speciesId)]) {
// Default to white if no colors are found // Default to white if no colors are found
@ -1504,7 +1473,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
container.candyUpgradeIcon.setTint(argbFromRgba(rgbHexToRgba(starterColors[this.getStarterSpeciesId(speciesId)][0]))); container.candyUpgradeIcon.setTint(argbFromRgba(rgbHexToRgba(starterColors[this.getStarterSpeciesId(speciesId)][0])));
container.candyUpgradeOverlayIcon.setTint(argbFromRgba(rgbHexToRgba(starterColors[this.getStarterSpeciesId(speciesId)][1]))); container.candyUpgradeOverlayIcon.setTint(argbFromRgba(rgbHexToRgba(starterColors[this.getStarterSpeciesId(speciesId)][1])));
} else if (this.scene.candyUpgradeDisplay === 1) { } else if (globalScene.candyUpgradeDisplay === 1) {
container.candyUpgradeIcon.setVisible(false); container.candyUpgradeIcon.setVisible(false);
container.candyUpgradeOverlayIcon.setVisible(false); container.candyUpgradeOverlayIcon.setVisible(false);
} }
@ -1586,7 +1555,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
} }
getFriendship(speciesId: number) { getFriendship(speciesId: number) {
let currentFriendship = this.scene.gameData.starterData[this.getStarterSpeciesId(speciesId)].friendship; let currentFriendship = globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)].friendship;
if (!currentFriendship || currentFriendship === undefined) { if (!currentFriendship || currentFriendship === undefined) {
currentFriendship = 0; currentFriendship = 0;
} }
@ -1598,15 +1567,15 @@ export default class PokedexUiHandler extends MessageUiHandler {
setSpecies(species: PokemonSpecies | null) { setSpecies(species: PokemonSpecies | null) {
this.speciesStarterDexEntry = species ? this.scene.gameData.dexData[species.speciesId] : null; this.speciesStarterDexEntry = species ? globalScene.gameData.dexData[species.speciesId] : null;
if (!species && this.scene.ui.getTooltip().visible) { if (!species && globalScene.ui.getTooltip().visible) {
this.scene.ui.hideTooltip(); globalScene.ui.hideTooltip();
} }
if (this.lastSpecies) { if (this.lastSpecies) {
const dexAttr = this.getCurrentDexProps(this.lastSpecies.speciesId); const dexAttr = this.getCurrentDexProps(this.lastSpecies.speciesId);
const props = this.getSanitizedProps(this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, dexAttr)); const props = this.getSanitizedProps(globalScene.gameData.getSpeciesDexAttrProps(this.lastSpecies, dexAttr));
const speciesIndex = this.allSpecies.indexOf(this.lastSpecies); const speciesIndex = this.allSpecies.indexOf(this.lastSpecies);
const lastSpeciesIcon = this.starterContainers[speciesIndex].icon; const lastSpeciesIcon = this.starterContainers[speciesIndex].icon;
this.checkIconId(lastSpeciesIcon, this.lastSpecies, props.female, props.formIndex, props.shiny, props.variant); this.checkIconId(lastSpeciesIcon, this.lastSpecies, props.female, props.formIndex, props.shiny, props.variant);
@ -1614,7 +1583,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
// Resume the animation for the previously selected species // Resume the animation for the previously selected species
const icon = this.starterContainers[speciesIndex].icon; const icon = this.starterContainers[speciesIndex].icon;
this.scene.tweens.getTweensOf(icon).forEach(tween => tween.resume()); globalScene.tweens.getTweensOf(icon).forEach(tween => tween.resume());
} }
this.lastSpecies = species!; // TODO: is this bang correct? this.lastSpecies = species!; // TODO: is this bang correct?
@ -1632,7 +1601,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
const icon = this.starterContainers[speciesIndex].icon; const icon = this.starterContainers[speciesIndex].icon;
if (this.isUpgradeAnimationEnabled()) { if (this.isUpgradeAnimationEnabled()) {
this.scene.tweens.getTweensOf(icon).forEach(tween => tween.pause()); globalScene.tweens.getTweensOf(icon).forEach(tween => tween.pause());
// Reset the position of the icon // Reset the position of the icon
icon.x = -2; icon.x = -2;
icon.y = 2; icon.y = 2;
@ -1698,10 +1667,10 @@ export default class PokedexUiHandler extends MessageUiHandler {
this.speciesStarterMoves = []; this.speciesStarterMoves = [];
if (species) { if (species) {
const dexEntry = this.scene.gameData.dexData[species.speciesId]; const dexEntry = globalScene.gameData.dexData[species.speciesId];
if (!dexEntry.caughtAttr) { if (!dexEntry.caughtAttr) {
const props = this.getSanitizedProps(this.scene.gameData.getSpeciesDexAttrProps(species, this.getCurrentDexProps(species.speciesId))); const props = this.getSanitizedProps(globalScene.gameData.getSpeciesDexAttrProps(species, this.getCurrentDexProps(species.speciesId)));
if (shiny === undefined || shiny !== props.shiny) { if (shiny === undefined || shiny !== props.shiny) {
shiny = props.shiny; shiny = props.shiny;
@ -1722,7 +1691,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
if (shouldUpdateSprite) { if (shouldUpdateSprite) {
species.loadAssets(this.scene, female!, formIndex, shiny, variant, true).then(() => { // TODO: is this bang correct? species.loadAssets(female!, formIndex, shiny, variant, true).then(() => { // TODO: is this bang correct?
if (assetLoadCancelled.value) { if (assetLoadCancelled.value) {
return; return;
} }
@ -1773,7 +1742,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
updateStarterValueLabel(starter: StarterContainer): void { updateStarterValueLabel(starter: StarterContainer): void {
const speciesId = starter.species.speciesId; const speciesId = starter.species.speciesId;
const baseStarterValue = speciesStarterCosts[speciesId]; const baseStarterValue = speciesStarterCosts[speciesId];
const starterValue = this.scene.gameData.getSpeciesStarterValue(this.getStarterSpeciesId(speciesId)); const starterValue = globalScene.gameData.getSpeciesStarterValue(this.getStarterSpeciesId(speciesId));
starter.cost = starterValue; starter.cost = starterValue;
let valueStr = starterValue.toString(); let valueStr = starterValue.toString();
if (valueStr.startsWith("0.")) { if (valueStr.startsWith("0.")) {
@ -1811,7 +1780,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
ui.showText(i18next.t("pokedexUiHandler:confirmExit"), null, () => { ui.showText(i18next.t("pokedexUiHandler:confirmExit"), null, () => {
ui.setModeWithoutClear(Mode.CONFIRM, () => { ui.setModeWithoutClear(Mode.CONFIRM, () => {
ui.setMode(Mode.POKEDEX, "refresh"); ui.setMode(Mode.POKEDEX, "refresh");
this.scene.clearPhaseQueue(); globalScene.clearPhaseQueue();
this.clearText(); this.clearText();
this.clear(); this.clear();
ui.revertMode(); ui.revertMode();
@ -1831,7 +1800,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
*/ */
getCurrentDexProps(speciesId: number): bigint { getCurrentDexProps(speciesId: number): bigint {
let props = 0n; let props = 0n;
const caughtAttr = this.scene.gameData.dexData[speciesId].caughtAttr; const caughtAttr = globalScene.gameData.dexData[speciesId].caughtAttr;
/* this checks the gender of the pokemon; this works by checking a) that the starter preferences for the species exist, and if so, is it female. If so, it'll add DexAttr.FEMALE to our temp props /* this checks the gender of the pokemon; this works by checking a) that the starter preferences for the species exist, and if so, is it female. If so, it'll add DexAttr.FEMALE to our temp props
* It then checks b) if the caughtAttr for the pokemon is female and NOT male - this means that the ONLY gender we've gotten is female, and we need to add DexAttr.FEMALE to our temp props * It then checks b) if the caughtAttr for the pokemon is female and NOT male - this means that the ONLY gender we've gotten is female, and we need to add DexAttr.FEMALE to our temp props
@ -1869,7 +1838,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
props += BigInt(Math.pow(2, this.starterPreferences[speciesId]?.form)) * DexAttr.DEFAULT_FORM; props += BigInt(Math.pow(2, this.starterPreferences[speciesId]?.form)) * DexAttr.DEFAULT_FORM;
} else { } else {
// Get the first unlocked form // Get the first unlocked form
props += this.scene.gameData.getFormAttr(this.scene.gameData.getFormIndex(caughtAttr)); props += globalScene.gameData.getFormAttr(globalScene.gameData.getFormIndex(caughtAttr));
} }
return props; return props;
@ -1885,7 +1854,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
// StarterPrefs.save(this.starterPreferences); // StarterPrefs.save(this.starterPreferences);
this.cursor = -1; this.cursor = -1;
this.scene.ui.hideTooltip(); globalScene.ui.hideTooltip();
this.starterSelectContainer.setVisible(false); this.starterSelectContainer.setVisible(false);
this.blockInput = false; this.blockInput = false;