- Add comments to describe what the function does

- Add comments to describe what the function does
This commit is contained in:
Burai Mu 2025-09-23 11:58:32 +08:00
parent 85374f5c1d
commit 2c7bca7e3b
4 changed files with 44 additions and 5 deletions

View File

@ -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 {

View File

@ -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();

View File

@ -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
? ""

View File

@ -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;