Added Candy Progress UI (#463)

* Added Candy Progress UI

* GetRootSpecies rather than colors of current Species
pull/429/head
Akuma-Reiki 2024-05-04 17:29:48 -05:00 committed by GitHub
parent 620a92aace
commit 92fb8b715e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 41 additions and 1 deletions

BIN
public/images/ui/candy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

View File

@ -31,6 +31,8 @@ export class LoadingScene extends SceneBase {
this.loadAtlas('bg', 'ui');
this.loadImage('command_fight_labels', 'ui');
this.loadAtlas('prompt', 'ui');
this.loadImage('candy', 'ui');
this.loadImage('candy_overlay', 'ui');
this.loadImage('cursor', 'ui');
this.loadImage('cursor_reverse', 'ui');
for (let wv of Utils.getEnumValues(WindowVariant)) {

View File

@ -1,8 +1,10 @@
import BattleScene, { Button } from "../battle-scene";
import BattleScene, { Button, starterColors } from "../battle-scene";
import { Mode } from "./ui";
import UiHandler from "./ui-handler";
import * as Utils from "../utils";
import { PlayerPokemon } from "../field/pokemon";
import { default as PokemonSpecies, PokemonSpeciesForm, SpeciesFormKey, getFusedSpeciesName, getPokemonSpecies, getPokemonSpeciesForm, getStarterValueFriendshipCap, speciesStarters, starterPassiveAbilities } from '../data/pokemon-species';
import { argbFromRgba } from "@material/material-color-utilities";
import { Type, getTypeRgb } from "../data/type";
import { TextStyle, addBBCodeTextObject, addTextObject, getBBCodeFrag, getTextColor } from "./text";
import Move, { MoveCategory } from "../data/move";
@ -44,6 +46,9 @@ export default class SummaryUiHandler extends UiHandler {
private genderText: Phaser.GameObjects.Text;
private shinyIcon: Phaser.GameObjects.Image;
private fusionShinyIcon: Phaser.GameObjects.Image;
private candyShadow: Phaser.GameObjects.Sprite;
private candyIcon: Phaser.GameObjects.Sprite;
private candyOverlay: Phaser.GameObjects.Sprite;
private statusContainer: Phaser.GameObjects.Container;
private status: Phaser.GameObjects.Image;
private summaryPageContainer: Phaser.GameObjects.Container;
@ -136,6 +141,20 @@ export default class SummaryUiHandler extends UiHandler {
this.pokeball.setOrigin(0, 1);
this.summaryContainer.add(this.pokeball);
this.candyShadow = this.scene.add.sprite(13, -140, 'candy');
this.candyShadow.setTint(0x141414)
this.candyShadow.setScale(0.8);
this.candyShadow.setInteractive(new Phaser.Geom.Rectangle(0, 0, 16, 16), Phaser.Geom.Rectangle.Contains);
this.summaryContainer.add(this.candyShadow);
this.candyIcon = this.scene.add.sprite(13, -140, 'candy');
this.candyIcon.setScale(0.8);
this.summaryContainer.add(this.candyIcon);
this.candyOverlay = this.scene.add.sprite(13, -140, 'candy_overlay');
this.candyOverlay.setScale(0.8);
this.summaryContainer.add(this.candyOverlay);
this.levelText = addTextObject(this.scene, 36, -17, '', TextStyle.SUMMARY_ALT);
this.levelText.setOrigin(0, 1);
this.summaryContainer.add(this.levelText);
@ -222,6 +241,10 @@ export default class SummaryUiHandler extends UiHandler {
this.shinyOverlay.setVisible(this.pokemon.isShiny());
const colorScheme = starterColors[this.pokemon.species.getRootSpeciesId()];
this.candyIcon.setTint(argbFromRgba(Utils.rgbHexToRgba(colorScheme[0])));
this.candyOverlay.setTint(argbFromRgba(Utils.rgbHexToRgba(colorScheme[1])));
this.numberText.setText(Utils.padInt(this.pokemon.species.speciesId, 4));
this.numberText.setColor(this.getTextColor(!this.pokemon.isShiny() ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD));
this.numberText.setShadowColor(this.getTextColor(!this.pokemon.isShiny() ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD, true));
@ -251,6 +274,21 @@ export default class SummaryUiHandler extends UiHandler {
this.splicedIcon.on('pointerout', () => (this.scene as BattleScene).ui.hideTooltip());
}
var currentFriendship = this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId()].friendship;
if (!currentFriendship || currentFriendship === undefined)
currentFriendship = 0;
const friendshipCap = getStarterValueFriendshipCap(speciesStarters[this.pokemon.species.getRootSpeciesId()]);
const candyCropY = 16 - (16 * (currentFriendship / friendshipCap));
if (this.candyShadow.visible) {
this.candyShadow.on('pointerover', () => (this.scene as BattleScene).ui.showTooltip(null, `${currentFriendship}/${friendshipCap}`, true));
this.candyShadow.on('pointerout', () => (this.scene as BattleScene).ui.hideTooltip());
}
this.candyIcon.setCrop(0,candyCropY,16, 16);
this.candyOverlay.setCrop(0,candyCropY,16, 16);
const doubleShiny = isFusion && this.pokemon.shiny && this.pokemon.fusionShiny;
const baseVariant = !doubleShiny ? this.pokemon.getVariant() : this.pokemon.variant;