Removed unused scale parameter from InfoOverlay s

This commit is contained in:
Wlowscha 2025-07-28 22:31:41 +02:00
parent 48db9491c6
commit 6c5277854b
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
8 changed files with 31 additions and 50 deletions

View File

@ -715,14 +715,12 @@ function doBugTypeMoveTutor(): Promise<void> {
const moveOptions = globalScene.currentBattle.mysteryEncounter!.misc.moveTutorOptions;
await showEncounterDialogue(`${namespace}:battle_won`, `${namespace}:speaker`);
const overlayScale = 1;
const moveInfoOverlay = new MoveInfoOverlay({
delayVisibility: false,
scale: overlayScale,
onSide: true,
right: true,
x: 1,
y: -MoveInfoOverlay.getHeight(overlayScale, true) - 1,
y: -MoveInfoOverlay.getHeight(true) - 1,
width: globalScene.game.canvas.width / 6 - 2,
});
globalScene.ui.add(moveInfoOverlay);

View File

@ -105,14 +105,12 @@ export class FightUiHandler extends UiHandler implements InfoToggle {
]);
// prepare move overlay
const overlayScale = 1;
this.moveInfoOverlay = new MoveInfoOverlay({
delayVisibility: true,
scale: overlayScale,
onSide: true,
right: true,
x: 0,
y: -MoveInfoOverlay.getHeight(overlayScale, true),
y: -MoveInfoOverlay.getHeight(true),
width: globalScene.game.canvas.width / 6 + 4,
hideEffectBox: true,
hideBg: true,

View File

@ -146,14 +146,12 @@ export class ModifierSelectUiHandler extends AwaitableUiHandler {
this.continueButtonContainer.add(continueButtonText);
// prepare move overlay
const overlayScale = 1;
this.moveInfoOverlay = new MoveInfoOverlay({
delayVisibility: true,
scale: overlayScale,
onSide: true,
right: true,
x: 1,
y: -MoveInfoOverlay.getHeight(overlayScale, true) - 1,
y: -MoveInfoOverlay.getHeight(true) - 1,
width: globalScene.game.canvas.width / 6 - 2,
});
ui.add(this.moveInfoOverlay);

View File

@ -11,16 +11,15 @@ import i18next from "i18next";
export interface MoveInfoOverlaySettings {
delayVisibility?: boolean; // if true, showing the overlay will only set it to active and populate the fields and the handler using this field has to manually call setVisible later.
scale?: number; // scale the box? A scale of 0.5 is recommended
top?: boolean; // should the effect box be on top?
right?: boolean; // should the effect box be on the right?
onSide?: boolean; // should the effect be on the side? ignores top argument if true
//location and width of the component; unaffected by scaling
x?: number;
y?: number;
/** Default is always half the screen, regardless of scale */
// Default width is half the screen
width?: number;
/** Determines whether to display the small secondary box */
// Determines whether to display the small secondary box
hideEffectBox?: boolean;
hideBg?: boolean;
}
@ -54,12 +53,11 @@ export class MoveInfoOverlay extends Phaser.GameObjects.Container implements Inf
options.top = false;
}
super(globalScene, options?.x, options?.y);
const scale = options?.scale || 1; // set up the scale
this.setScale(scale);
this.setScale(1);
this.options = options || {};
// prepare the description box
const width = (options?.width || MoveInfoOverlay.getWidth(scale)) / scale; // divide by scale as we always want this to be half a window wide
const width = options?.width || MoveInfoOverlay.getWidth(); // we always want this to be half a window wide
this.descBg = addWindow(
options?.onSide && !options?.right ? EFF_WIDTH : 0,
options?.top ? EFF_HEIGHT : 0,
@ -97,10 +95,10 @@ export class MoveInfoOverlay extends Phaser.GameObjects.Container implements Inf
const moveDescriptionTextMaskRect = globalScene.make.graphics();
moveDescriptionTextMaskRect.fillStyle(0xff0000);
moveDescriptionTextMaskRect.fillRect(
maskPointOrigin.x + ((options?.onSide && !options?.right ? EFF_WIDTH : 0) + BORDER) * scale,
maskPointOrigin.y + ((options?.top ? EFF_HEIGHT : 0) + BORDER - 2) * scale,
width - ((options?.onSide ? EFF_WIDTH : 0) - BORDER * 2) * scale,
(DESC_HEIGHT - (BORDER - 2) * 2) * scale,
maskPointOrigin.x + ((options?.onSide && !options?.right ? EFF_WIDTH : 0) + BORDER),
maskPointOrigin.y + ((options?.top ? EFF_HEIGHT : 0) + BORDER - 2),
width - ((options?.onSide ? EFF_WIDTH : 0) - BORDER * 2),
DESC_HEIGHT - (BORDER - 2) * 2,
);
moveDescriptionTextMaskRect.setScale(6);
const moveDescriptionTextMask = this.createGeometryMask(moveDescriptionTextMaskRect);
@ -233,12 +231,12 @@ export class MoveInfoOverlay extends Phaser.GameObjects.Container implements Inf
}
// width of this element
static getWidth(_scale: number): number {
static getWidth(): number {
return globalScene.game.canvas.width / GLOBAL_SCALE / 2;
}
// height of this element
static getHeight(scale: number, onSide?: boolean): number {
return (onSide ? Math.max(EFF_HEIGHT, DESC_HEIGHT) : EFF_HEIGHT + DESC_HEIGHT) * scale;
static getHeight(onSide?: boolean): number {
return onSide ? Math.max(EFF_HEIGHT, DESC_HEIGHT) : EFF_HEIGHT + DESC_HEIGHT;
}
}

View File

@ -308,13 +308,10 @@ export class PartyUiHandler extends MessageUiHandler {
this.iconAnimHandler = new PokemonIconAnimHandler();
this.iconAnimHandler.setup();
// prepare move overlay. in case it appears to be too big, set the overlayScale to .5
const overlayScale = 1;
this.moveInfoOverlay = new MoveInfoOverlay({
scale: overlayScale,
top: true,
x: 1,
y: -MoveInfoOverlay.getHeight(overlayScale) - 1,
y: -MoveInfoOverlay.getHeight() - 1,
width: globalScene.game.canvas.width / 12 - 30,
});
ui.add(this.moveInfoOverlay);

View File

@ -7,7 +7,6 @@ import { fixedInt } from "#utils/common";
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.
scale?: number; // scale the box? A scale of 0.5 is recommended
//location and width of the component; unaffected by scaling
x?: number;
y?: number;
@ -36,17 +35,15 @@ export class PokedexInfoOverlay extends Phaser.GameObjects.Container implements
private maskPointOriginX: number;
private maskPointOriginY: number;
public scale: number;
public width: number;
constructor(options?: PokedexInfoOverlaySettings) {
super(globalScene, options?.x, options?.y);
this.scale = options?.scale || 1; // set up the scale
this.setScale(this.scale);
this.setScale(1);
this.options = options || {};
// prepare the description box
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.width = options?.width || PokedexInfoOverlay.getWidth(); // we always want this to be half a window wide
this.descBg = addWindow(0, 0, this.width, DESC_HEIGHT);
this.descBg.setOrigin(0, 0);
this.add(this.descBg);
@ -70,10 +67,10 @@ export class PokedexInfoOverlay extends Phaser.GameObjects.Container implements
this.textMaskRect = globalScene.make.graphics();
this.textMaskRect.fillStyle(0xff0000);
this.textMaskRect.fillRect(
this.maskPointOriginX + BORDER * this.scale,
this.maskPointOriginY + (BORDER - 2) * this.scale,
this.width - BORDER * 2 * this.scale,
(DESC_HEIGHT - (BORDER - 2) * 2) * this.scale,
this.maskPointOriginX + BORDER,
this.maskPointOriginY + (BORDER - 2),
this.width - BORDER * 2,
DESC_HEIGHT - (BORDER - 2) * 2,
);
this.textMaskRect.setScale(6);
const textMask = this.createGeometryMask(this.textMaskRect);
@ -111,10 +108,10 @@ export class PokedexInfoOverlay extends Phaser.GameObjects.Container implements
this.textMaskRect.clear();
this.textMaskRect.fillStyle(0xff0000);
this.textMaskRect.fillRect(
this.maskPointOriginX + BORDER * this.scale,
this.maskPointOriginY + (BORDER - 2) * this.scale + (48 - newHeight),
this.width - BORDER * 2 * this.scale,
(newHeight - (BORDER - 2) * 2) * this.scale,
this.maskPointOriginX + BORDER,
this.maskPointOriginY + (BORDER - 2) + (48 - newHeight),
this.width - BORDER * 2,
newHeight - (BORDER - 2) * 2,
);
const updatedMask = this.createGeometryMask(this.textMaskRect);
this.desc.setMask(updatedMask);
@ -167,12 +164,12 @@ export class PokedexInfoOverlay extends Phaser.GameObjects.Container implements
}
// width of this element
static getWidth(_scale: number): number {
static getWidth(): number {
return globalScene.game.canvas.width / GLOBAL_SCALE / 2;
}
// height of this element
static getHeight(scale: number, _onSide?: boolean): number {
return DESC_HEIGHT * scale;
static getHeight(): number {
return DESC_HEIGHT;
}
}

View File

@ -682,19 +682,16 @@ export class PokedexPageUiHandler extends MessageUiHandler {
this.menuContainer.bringToTop(this.baseStatsOverlay);
// add the info overlay last to be the top most ui element and prevent the IVs from overlaying this
const overlayScale = 1;
this.moveInfoOverlay = new MoveInfoOverlay({
scale: overlayScale,
top: true,
x: 1,
y: globalScene.game.canvas.height / 6 - MoveInfoOverlay.getHeight(overlayScale) - 29,
y: globalScene.game.canvas.height / 6 - MoveInfoOverlay.getHeight() - 29,
});
this.starterSelectContainer.add(this.moveInfoOverlay);
this.infoOverlay = new PokedexInfoOverlay({
scale: overlayScale,
x: 1,
y: globalScene.game.canvas.height / 6 - PokedexInfoOverlay.getHeight(overlayScale) - 29,
y: globalScene.game.canvas.height / 6 - PokedexInfoOverlay.getHeight() - 29,
});
this.starterSelectContainer.add(this.infoOverlay);

View File

@ -1184,12 +1184,10 @@ export class StarterSelectUiHandler extends MessageUiHandler {
this.starterSelectContainer.add(this.statsContainer);
// add the info overlay last to be the top most ui element and prevent the IVs from overlaying this
const overlayScale = 1;
this.moveInfoOverlay = new MoveInfoOverlay({
scale: overlayScale,
top: true,
x: 1,
y: globalScene.game.canvas.height / 6 - MoveInfoOverlay.getHeight(overlayScale) - 29,
y: globalScene.game.canvas.height / 6 - MoveInfoOverlay.getHeight() - 29,
});
this.starterSelectContainer.add(this.moveInfoOverlay);