Fixed position of enemy modifier bar

This commit is contained in:
Wlowscha 2025-06-20 08:33:56 +02:00
parent f26cb11e0b
commit 3ea89de9c1
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
3 changed files with 23 additions and 12 deletions

View File

@ -2058,7 +2058,7 @@ export default class BattleScene extends SceneBase {
}
updateUIPositions(): void {
const enemyModifierCount = this.enemyModifiers.filter(m => m.isIconVisible()).length;
const enemyModifierCount = this.enemyModifierBar.totalVisibleLength;
const biomeWaveTextHeight = this.biomeWaveText.getBottomLeft().y - this.biomeWaveText.getTopLeft().y;
this.biomeWaveText.setY(
-(this.game.canvas.height / 6) +
@ -2888,7 +2888,7 @@ export default class BattleScene extends SceneBase {
}
// TODO: Document this
updateModifiers(player = true): void {
updateModifiers(player = true, showHeldItems = true): void {
const modifiers = player ? this.modifiers : (this.enemyModifiers as PersistentModifier[]);
for (const modifier of modifiers) {
@ -2909,7 +2909,14 @@ export default class BattleScene extends SceneBase {
const pokemonA = player ? this.getPlayerParty()[0] : this.getEnemyParty()[0];
(player ? this.modifierBar : this.enemyModifierBar).updateModifiers(modifiers, pokemonA);
const bar = player ? this.modifierBar : this.enemyModifierBar;
if (showHeldItems) {
bar.updateModifiers(modifiers, pokemonA);
} else {
bar.updateModifiers(modifiers);
}
if (!player) {
this.updateUIPositions();
}

View File

@ -48,7 +48,7 @@ export const formChangeItemSortFunc = (a: FormChangeItem, b: FormChangeItem): nu
export class ModifierBar extends Phaser.GameObjects.Container {
private player: boolean;
private modifierCache: (PersistentModifier | HeldItemId)[];
private totalVisibleLength = 0;
public totalVisibleLength = 0;
constructor(enemy?: boolean) {
super(globalScene, 1 + (enemy ? 302 : 0), 2);
@ -72,19 +72,23 @@ export class ModifierBar extends Phaser.GameObjects.Container {
this.totalVisibleLength = sortedVisibleModifiers.length + heldItemsA.length + heldItemsB.length;
sortedVisibleModifiers.forEach((modifier: PersistentModifier, i: number) => {
let iconCount = 0;
sortedVisibleModifiers.forEach(modifier => {
const icon = modifier.getIcon();
this.addIcon(icon, i, modifier.type.name, modifier.type.getDescription());
iconCount += 1;
this.addIcon(icon, iconCount, modifier.type.name, modifier.type.getDescription());
});
heldItemsA.forEach((item: HeldItemId, i: number) => {
heldItemsA.forEach(item => {
const icon = allHeldItems[item].createPokemonIcon(pokemonA);
this.addIcon(icon, i, allHeldItems[item].name, allHeldItems[item].description);
iconCount += 1;
this.addIcon(icon, iconCount, allHeldItems[item].name, allHeldItems[item].description);
});
heldItemsB.forEach((item: HeldItemId, i: number) => {
heldItemsB.forEach(item => {
const icon = allHeldItems[item].createPokemonIcon(pokemonB);
this.addIcon(icon, i, allHeldItems[item].name, allHeldItems[item].description);
iconCount += 1;
this.addIcon(icon, iconCount, allHeldItems[item].name, allHeldItems[item].description);
});
for (const icon of this.getAll()) {

View File

@ -269,7 +269,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
const maxUpgradeCount = 0;
/* Force updateModifiers without pokemon held items */
globalScene.getModifierBar().updateModifiers(globalScene.modifiers);
globalScene.updateModifiers(true, false);
/* 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);
@ -692,7 +692,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
globalScene.hideLuckText(250);
/* Normally already called just after the shop, but not sure if it happens in 100% of cases */
globalScene.getModifierBar().updateModifiers(globalScene.modifiers);
globalScene.updateModifiers(true);
const options = this.options.concat(this.shopOptionsRows.flat());
this.options.splice(0, this.options.length);