From efe35774fe25f877cc60d1a9ec4212791e6cf356 Mon Sep 17 00:00:00 2001 From: Robert Antonius <40657895+roberika@users.noreply.github.com> Date: Tue, 7 May 2024 00:09:58 +0700 Subject: [PATCH] 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. --- src/ui/summary-ui-handler.ts | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index ac04d41be5f..8a1babe4bb4 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -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);