pokerogue/src/ui/evolution-scene-handler.ts

99 lines
2.6 KiB
TypeScript
Raw Normal View History

import BattleScene, { Button } from "../battle-scene";
2024-01-10 04:34:43 +00:00
import MessageUiHandler from "./message-ui-handler";
import { TextStyle, addTextObject } from "./text";
2023-04-10 18:54:06 +01:00
import { Mode } from "./ui";
2024-01-10 04:34:43 +00:00
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;
2023-12-14 16:54:56 +00:00
2024-01-10 04:34:43 +00:00
constructor(scene: BattleScene) {
super(scene, Mode.EVOLUTION_SCENE);
}
2023-12-14 16:54:56 +00:00
2024-01-10 04:34:43 +00:00
setup() {
this.canCancel = false;
this.cancelled = false;
2024-01-10 04:34:43 +00:00
const ui = this.getUi();
2023-12-30 23:41:25 +00:00
2024-01-10 04:34:43 +00:00
this.evolutionContainer = this.scene.add.container(0, -this.scene.game.canvas.height / 6);
ui.add(this.evolutionContainer);
2024-04-01 02:23:27 +01:00
const messageBg = this.scene.add.sprite(0, 0, 'bg', this.scene.windowType);
2024-01-10 04:34:43 +00:00
messageBg.setOrigin(0, 1);
messageBg.setVisible(false);
ui.add(messageBg);
this.messageBg = messageBg;
this.messageContainer = this.scene.add.container(12, -39);
this.messageContainer.setVisible(false);
ui.add(this.messageContainer);
const message = addTextObject(this.scene, 0, 0, '', TextStyle.MESSAGE, {
maxLines: 2,
wordWrap: {
width: 1780
2023-12-14 16:54:56 +00:00
}
2024-01-10 04:34:43 +00:00
});
this.messageContainer.add(message);
2023-12-14 16:54:56 +00:00
2024-01-10 04:34:43 +00:00
this.message = message;
const prompt = this.scene.add.sprite(0, 0, 'prompt');
prompt.setVisible(false);
prompt.setOrigin(0, 0);
this.messageContainer.add(prompt);
this.prompt = prompt;
}
show(_args: any[]): boolean {
super.show(_args);
this.scene.ui.bringToTop(this.evolutionContainer);
this.scene.ui.bringToTop(this.messageBg);
this.scene.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;
2023-04-10 18:54:06 +01:00
}
2024-01-10 04:34:43 +00:00
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;
}
}
2023-04-10 18:54:06 +01:00
}
2024-01-10 04:34:43 +00:00
}
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);
}
}