pokerogue/src/ui/saving-icon-handler.ts
Sirz Benjie 5854b21da0
[Refactor] Remove circular imports part 1 (#5663)
* Extract Mode enum out of UI and into its own file

Reduces circular imports from 909 to 773

* Move around utility files

Reduces cyclical dependencies from 773 to 765

* Remove starterColors and bypassLogin from battle-scene

Reduces cyclical dependencies from 765 to 623

* Fix test runner error

* Update import for bypassLogin in test

* Update mocks for utils in tests

* Fix broken tests

* Update selectWithTera override

* Update path for utils in ab-attr.ts

* Update path for utils in ability-class.ts

* Fix utils import path in healer.test.ts
2025-04-19 11:57:03 +00:00

81 lines
1.6 KiB
TypeScript

import { globalScene } from "#app/global-scene";
import { fixedInt } from "#app/utils/common";
export default class SavingIconHandler extends Phaser.GameObjects.Container {
private icon: Phaser.GameObjects.Sprite;
private animActive: boolean;
private shown: boolean;
constructor() {
super(globalScene, globalScene.game.canvas.width / 6 - 4, globalScene.game.canvas.height / 6 - 4);
}
setup(): void {
this.icon = globalScene.add.sprite(0, 0, "saving_icon");
this.icon.setOrigin(1, 1);
this.add(this.icon);
this.animActive = false;
this.shown = false;
this.setAlpha(0);
this.setVisible(false);
}
show(): void {
this.shown = true;
if (this.animActive) {
return;
}
this.animActive = true;
globalScene.tweens.add({
targets: this,
alpha: 1,
duration: fixedInt(250),
ease: "Sine.easeInOut",
onComplete: () => {
globalScene.time.delayedCall(fixedInt(500), () => {
this.animActive = false;
if (!this.shown) {
this.hide();
}
});
},
});
this.setVisible(true);
this.shown = true;
}
hide(): void {
this.shown = false;
if (this.animActive) {
return;
}
this.animActive = true;
globalScene.tweens.add({
targets: this,
alpha: 0,
duration: fixedInt(250),
ease: "Sine.easeInOut",
onComplete: () => {
this.animActive = false;
this.setVisible(false);
if (this.shown) {
this.show();
}
},
});
this.shown = false;
}
}