diff --git a/src/configs/inputs/config-handler.ts b/src/configs/inputs/config-handler.ts index 40ac5b65b14..cce222d4eaa 100644 --- a/src/configs/inputs/config-handler.ts +++ b/src/configs/inputs/config-handler.ts @@ -92,8 +92,16 @@ export function getIconWithSettingName(config, settingName) { return getIconWithKey(config, key); } +/** + * Retrieve key from input keys eg: return "R" from "KEY_R" + * @param configs + * @param source Source of last input type. Eg: "gamepad" + * @param devices List of all devices. + * @param settingName Action for the input key. + * @returns + */ export function getKeyForLatestInput(configs, source, devices, settingName) { - let config: any; // TODO: refine type + let config: any; if (source === "gamepad") { config = configs[devices[Device.GAMEPAD]]; } else { diff --git a/src/ui-inputs.ts b/src/ui-inputs.ts index 07047f7b08b..05a9c8c41e5 100644 --- a/src/ui-inputs.ts +++ b/src/ui-inputs.ts @@ -134,6 +134,11 @@ export class UiInputs { buttonAB(button: Button): void { if (this.isInSettings()) { + /** + * When exiting the settings menu, this function + * will update the the UI to update the text. + * Eg: (E) Throw Poke ball -> (Shift) Throw Poke ball + */ const whiteListUIModes: UiMode[] = [UiMode.MODIFIER_SELECT, UiMode.COMMAND]; for (const uiMode of whiteListUIModes) { globalScene.ui.handlers[uiMode].updateTipsText(); diff --git a/src/ui/handlers/command-ui-handler.ts b/src/ui/handlers/command-ui-handler.ts index 9c884a618e9..2d8febef6f4 100644 --- a/src/ui/handlers/command-ui-handler.ts +++ b/src/ui/handlers/command-ui-handler.ts @@ -240,7 +240,11 @@ export class CommandUiHandler extends UiHandler { } break; case Button.CYCLE_SHINY: { - // Used to throw the last pokeball + /** + * When the Cycle Shiny button is pressed, + * the last pokeball will be thrown. + * This can only be used in the UiMode.COMMAND. + */ const commandPhase = globalScene.phaseManager.getCurrentPhase() as CommandPhase; if ( globalScene.currentBattle.battleType === BattleType.WILD @@ -255,7 +259,13 @@ export class CommandUiHandler extends UiHandler { } break; } - case Button.CYCLE_ABILITY: // Used to restart the battle + case Button.CYCLE_ABILITY: + /** + * When the Cycle Ability button is pressed, + * the UI will request the user if they would like + * to restart the battle. This can only be used in + * the UiMode.COMMAND. + */ if (!globalScene.enableRetries) { break; } @@ -376,6 +386,10 @@ export class CommandUiHandler extends UiHandler { this.cursorObj = null; } + /** + * To update text in the command when globalScene.enableHotkeyTips + * is turned off or when action keys are changed. + */ updateTipsText(): void { const throwBallKey = globalScene.enableHotkeyTips ? "" diff --git a/src/ui/handlers/modifier-select-ui-handler.ts b/src/ui/handlers/modifier-select-ui-handler.ts index 237a9b35831..2d570969ff7 100644 --- a/src/ui/handlers/modifier-select-ui-handler.ts +++ b/src/ui/handlers/modifier-select-ui-handler.ts @@ -173,6 +173,10 @@ export class ModifierSelectUiHandler extends AwaitableUiHandler { globalScene.addInfoToggle(this.moveInfoOverlay); } + /** + * To update text in the command when globalScene.enableHotkeyTips + * is turned off or when action keys are changed. + */ updateTipsText(): void { this.updateRerollText(); this.updateRerollCostPosition(); @@ -541,7 +545,11 @@ export class ModifierSelectUiHandler extends AwaitableUiHandler { success = this.setCursor(0); } break; - case Button.CYCLE_SHINY: // R key, by default to reroll the shop + case Button.CYCLE_SHINY: + /** + * When the Cycle Shiny button is pressed, + * a reroll command will be played. + */ if (this.onActionInput && globalScene.money >= this.rerollCost) { const originalOnActionInput = this.onActionInput; this.awaitingActionInput = true; @@ -549,7 +557,11 @@ export class ModifierSelectUiHandler extends AwaitableUiHandler { originalOnActionInput(0, 0); } break; - case Button.CYCLE_ABILITY: // E key, by default to lock rarity + case Button.CYCLE_ABILITY: + /** + * When the Cycle Ability button is pressed, + * the lock rarity will be enabled/disabled. + */ if (this.onActionInput && this.lockRarityButtonContainer.visible) { const originalOnActionInput = this.onActionInput; this.awaitingActionInput = true;