mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-03-09 19:41:37 +00:00
* Replace various `scene` pass-arounds with global scene variable * Modify tests * Add scene back to `fade[in|out]()` calls Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com> * Fix Bug Superfan ME test Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com> * Re-enable fixed test Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com> * Rename `gScene` to `globalScene` * Move `globalScene` to its own file to fix import/async issues * Fix `SelectModifierPhase` tests * Fix ME tests by removing `scene` from `expect()`s * Resolve merge issues * Remove tsdocs referencing `scene` params Remove missed instances of `.scene` * Remove unnecessary `globalScene` usage in `loading-scene.ts` * Fix merge conflicts * Attempt to fix circular import issue * Found the source of the import issue * Fix merge issues --------- Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com>
98 lines
2.5 KiB
TypeScript
98 lines
2.5 KiB
TypeScript
import MessageUiHandler from "./message-ui-handler";
|
|
import { TextStyle, addTextObject } from "./text";
|
|
import { Mode } from "./ui";
|
|
import { Button } from "#enums/buttons";
|
|
import { globalScene } from "#app/global-scene";
|
|
|
|
export default class EvolutionSceneHandler extends MessageUiHandler {
|
|
public evolutionContainer: Phaser.GameObjects.Container;
|
|
public messageBg: Phaser.GameObjects.Image;
|
|
public messageContainer: Phaser.GameObjects.Container;
|
|
public canCancel: boolean;
|
|
public cancelled: boolean;
|
|
|
|
constructor() {
|
|
super(Mode.EVOLUTION_SCENE);
|
|
}
|
|
|
|
setup() {
|
|
this.canCancel = false;
|
|
this.cancelled = false;
|
|
|
|
const ui = this.getUi();
|
|
|
|
this.evolutionContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6);
|
|
ui.add(this.evolutionContainer);
|
|
|
|
const messageBg = globalScene.add.sprite(0, 0, "bg", globalScene.windowType);
|
|
messageBg.setOrigin(0, 1);
|
|
messageBg.setVisible(false);
|
|
ui.add(messageBg);
|
|
|
|
this.messageBg = messageBg;
|
|
|
|
this.messageContainer = globalScene.add.container(12, -39);
|
|
this.messageContainer.setVisible(false);
|
|
ui.add(this.messageContainer);
|
|
|
|
const message = addTextObject(0, 0, "", TextStyle.MESSAGE, {
|
|
maxLines: 2,
|
|
wordWrap: {
|
|
width: 1780
|
|
}
|
|
});
|
|
this.messageContainer.add(message);
|
|
|
|
this.message = message;
|
|
|
|
this.initPromptSprite(this.messageContainer);
|
|
}
|
|
|
|
show(_args: any[]): boolean {
|
|
super.show(_args);
|
|
|
|
globalScene.ui.bringToTop(this.evolutionContainer);
|
|
globalScene.ui.bringToTop(this.messageBg);
|
|
globalScene.ui.bringToTop(this.messageContainer);
|
|
this.messageBg.setVisible(true);
|
|
this.messageContainer.setVisible(true);
|
|
|
|
return true;
|
|
}
|
|
|
|
processInput(button: Button): boolean {
|
|
if (this.canCancel && !this.cancelled && button === Button.CANCEL) {
|
|
this.cancelled = true;
|
|
return true;
|
|
}
|
|
|
|
const ui = this.getUi();
|
|
if (this.awaitingActionInput) {
|
|
if (button === Button.CANCEL || button === Button.ACTION) {
|
|
if (this.onActionInput) {
|
|
ui.playSelect();
|
|
const originalOnActionInput = this.onActionInput;
|
|
this.onActionInput = null;
|
|
originalOnActionInput();
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
setCursor(_cursor: integer): boolean {
|
|
return false;
|
|
}
|
|
|
|
clear() {
|
|
this.clearText();
|
|
this.canCancel = false;
|
|
this.cancelled = false;
|
|
this.evolutionContainer.removeAll(true);
|
|
this.messageContainer.setVisible(false);
|
|
this.messageBg.setVisible(false);
|
|
}
|
|
}
|