mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-16 23:05:23 +01:00
* Add destroy method to pokemon-sprite-sparkle-handler * Move TextStyle to enums, convert into const object * Cleanup text.ts file * Add necessary explicit types for TextStyle let vars * Fix locales submodule commit * Fix merge issue --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
93 lines
2.5 KiB
TypeScript
93 lines
2.5 KiB
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import { Button } from "#enums/buttons";
|
|
import { TextStyle } from "#enums/text-style";
|
|
import { UiMode } from "#enums/ui-mode";
|
|
import { MessageUiHandler } from "#ui/message-ui-handler";
|
|
import { addTextObject } from "#ui/text";
|
|
|
|
export 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(UiMode.EVOLUTION_SCENE);
|
|
}
|
|
|
|
setup() {
|
|
this.canCancel = false;
|
|
this.cancelled = false;
|
|
|
|
const ui = this.getUi();
|
|
|
|
this.evolutionContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6);
|
|
|
|
const messageBg = globalScene.add.sprite(0, 0, "bg", globalScene.windowType).setOrigin(0, 1).setVisible(false);
|
|
|
|
this.messageBg = messageBg;
|
|
|
|
this.messageContainer = globalScene.add.container(12, -39).setVisible(false);
|
|
|
|
const message = addTextObject(0, 0, "", TextStyle.MESSAGE, {
|
|
maxLines: 2,
|
|
wordWrap: {
|
|
width: 1780,
|
|
},
|
|
});
|
|
this.messageContainer.add(message);
|
|
|
|
ui.add([this.evolutionContainer, this.messageBg, this.messageContainer]);
|
|
|
|
this.message = message;
|
|
|
|
this.initPromptSprite(this.messageContainer);
|
|
}
|
|
|
|
show(_args: any[]): boolean {
|
|
super.show(_args);
|
|
|
|
globalScene.ui.bringToTop(this.evolutionContainer);
|
|
globalScene.ui.bringToTop(this.messageBg.setVisible(true));
|
|
globalScene.ui.bringToTop(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: number): boolean {
|
|
return false;
|
|
}
|
|
|
|
clear() {
|
|
this.clearText();
|
|
this.canCancel = false;
|
|
this.cancelled = false;
|
|
this.evolutionContainer.removeAll(true);
|
|
this.messageContainer.setVisible(false);
|
|
this.messageBg.setVisible(false);
|
|
}
|
|
}
|