Added rename pokemon hook

When Action is pressed on the Status tab, switch to Rename mode. For now, it just locks the menu until you press submit or cancel.
This commit is contained in:
Robert Antonius 2024-05-07 00:09:58 +07:00 committed by GitHub
parent bde7620ac0
commit efe35774fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -29,7 +29,8 @@ enum Page {
export enum SummaryUiMode {
DEFAULT,
LEARN_MOVE
LEARN_MOVE,
RENAME,
}
export default class SummaryUiHandler extends UiHandler {
@ -79,6 +80,10 @@ export default class SummaryUiHandler extends UiHandler {
private moveCursor: integer;
private selectedMoveIndex: integer;
private renamePokemon: boolean;
private newName: string;
private isCapitalized: boolean;
constructor(scene: BattleScene) {
super(scene, Mode.SUMMARY);
}
@ -265,6 +270,7 @@ export default class SummaryUiHandler extends UiHandler {
this.pokemon.cry();
this.nameText.setText(this.pokemon.name);
this.newName = this.pokemon.name;
const isFusion = this.pokemon.isFusion();
@ -415,17 +421,31 @@ export default class SummaryUiHandler extends UiHandler {
}
}
}
} else if (this.renamePokemon) {
if (button === Button.SUBMIT) {
this.pokemon.name = this.newName;
this.hideRenamePokemon();
} else if (button === Button.CANCEL) {
this.newName = this.pokemon.name;
this.hideRenamePokemon();
}
} else {
if (button === Button.ACTION) {
if (this.cursor === Page.MOVES) {
this.showMoveSelect();
success = true;
} else if (this.cursor === Page.STATUS) {
this.showRenamePokemon();
success = true;
}
} else if (button === Button.CANCEL) {
if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE)
if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) {
this.hideMoveSelect();
else
} else if (this.summaryUiMode === SummaryUiMode.RENAME) {
this.hideRenamePokemon();
} else {
ui.setMode(Mode.PARTY);
}
success = true;
} else {
const pages = Utils.getEnumValues(Page);
@ -902,6 +922,13 @@ export default class SummaryUiHandler extends UiHandler {
return null;
}
showRenamePokemon() {
this.renamePokemon = true;
}
hideRenamePokemon() {
this.renamePokemon = false;
}
showMoveSelect() {
this.moveSelect = true;
this.extraMoveRowContainer.setVisible(true);