Fixed some ui handlers

This commit is contained in:
Wlowscha 2025-06-17 19:28:40 +02:00
parent 74349d431b
commit 847b938480
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
3 changed files with 12 additions and 11 deletions

View File

@ -62,18 +62,15 @@ export class ModifierBar extends Phaser.GameObjects.Container {
* @param {PersistentModifier[]} modifiers - The list of modifiers to be displayed in the {@linkcode ModifierBar} * @param {PersistentModifier[]} modifiers - The list of modifiers to be displayed in the {@linkcode ModifierBar}
* @param {boolean} hideHeldItems - If set to "true", only modifiers not assigned to a Pokémon are displayed * @param {boolean} hideHeldItems - If set to "true", only modifiers not assigned to a Pokémon are displayed
*/ */
updateModifiers(modifiers: PersistentModifier[], pokemonA: Pokemon, pokemonB?: Pokemon, hideHeldItems = false) { updateModifiers(modifiers: PersistentModifier[], pokemonA?: Pokemon, pokemonB?: Pokemon) {
this.removeAll(true); this.removeAll(true);
const sortedVisibleModifiers = modifiers.filter(m => m.isIconVisible()).sort(modifierSortFunc); const sortedVisibleModifiers = modifiers.filter(m => m.isIconVisible()).sort(modifierSortFunc);
const heldItemsA = pokemonA.getHeldItems().sort(heldItemSortFunc); const heldItemsA = pokemonA ? pokemonA.getHeldItems().sort(heldItemSortFunc) : [];
const heldItemsB = pokemonB ? pokemonB.getHeldItems().sort(heldItemSortFunc) : []; const heldItemsB = pokemonB ? pokemonB.getHeldItems().sort(heldItemSortFunc) : [];
this.totalVisibleLength = sortedVisibleModifiers.length; this.totalVisibleLength = sortedVisibleModifiers.length + heldItemsA.length + heldItemsB.length;
if (!hideHeldItems) {
this.totalVisibleLength += heldItemsA.length + heldItemsB.length;
}
sortedVisibleModifiers.forEach((modifier: PersistentModifier, i: number) => { sortedVisibleModifiers.forEach((modifier: PersistentModifier, i: number) => {
const icon = modifier.getIcon(); const icon = modifier.getIcon();

View File

@ -5,7 +5,7 @@ import { getPokeballAtlasKey } from "#app/data/pokeball";
import { addTextObject, getTextStyleOptions, getModifierTierTextTint, getTextColor, TextStyle } from "./text"; import { addTextObject, getTextStyleOptions, getModifierTierTextTint, getTextColor, TextStyle } from "./text";
import AwaitableUiHandler from "./awaitable-ui-handler"; import AwaitableUiHandler from "./awaitable-ui-handler";
import { UiMode } from "#enums/ui-mode"; import { UiMode } from "#enums/ui-mode";
import { LockModifierTiersModifier, PokemonHeldItemModifier, HealShopCostModifier } from "../modifier/modifier"; import { LockModifierTiersModifier, HealShopCostModifier } from "../modifier/modifier";
import { handleTutorial, Tutorial } from "../tutorial"; import { handleTutorial, Tutorial } from "../tutorial";
import { Button } from "#enums/buttons"; import { Button } from "#enums/buttons";
import MoveInfoOverlay from "./move-info-overlay"; import MoveInfoOverlay from "./move-info-overlay";
@ -183,7 +183,10 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
this.player = args[0]; this.player = args[0];
const partyHasHeldItem = const partyHasHeldItem =
this.player && !!globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier && m.isTransferable).length; globalScene
.getPlayerParty()
.map(p => p.heldItemManager.getTransferableHeldItems().length)
.reduce((tot, i) => tot + i, 0) > 0;
const canLockRarities = !!globalScene.findModifier(m => m instanceof LockModifierTiersModifier); const canLockRarities = !!globalScene.findModifier(m => m instanceof LockModifierTiersModifier);
this.transferButtonContainer.setVisible(false); this.transferButtonContainer.setVisible(false);
@ -265,8 +268,8 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
// const maxUpgradeCount = typeOptions.map(to => to.upgradeCount).reduce((max, current) => Math.max(current, max), 0); // const maxUpgradeCount = typeOptions.map(to => to.upgradeCount).reduce((max, current) => Math.max(current, max), 0);
const maxUpgradeCount = 0; const maxUpgradeCount = 0;
/* Force updateModifiers without pokemonSpecificModifiers */ /* Force updateModifiers without pokemon held items */
globalScene.getModifierBar().updateModifiers(globalScene.modifiers, true); globalScene.getModifierBar().updateModifiers(globalScene.modifiers);
/* Multiplies the appearance duration by the speed parameter so that it is always constant, and avoids "flashbangs" at game speed x5 */ /* Multiplies the appearance duration by the speed parameter so that it is always constant, and avoids "flashbangs" at game speed x5 */
globalScene.showShopOverlay(750 * globalScene.gameSpeed); globalScene.showShopOverlay(750 * globalScene.gameSpeed);

View File

@ -1369,7 +1369,8 @@ export default class PartyUiHandler extends MessageUiHandler {
optionName = move.getName(); optionName = move.getName();
} }
break; break;
default: }
default: {
const formChangeItems = this.getFormChangeItems(pokemon); const formChangeItems = this.getFormChangeItems(pokemon);
if (formChangeItems && option >= PartyOption.FORM_CHANGE_ITEM) { if (formChangeItems && option >= PartyOption.FORM_CHANGE_ITEM) {
const item = formChangeItems[option - PartyOption.FORM_CHANGE_ITEM]; const item = formChangeItems[option - PartyOption.FORM_CHANGE_ITEM];