Splitting up processing of transfer and move recall mode; ensuring that the cancel option works properly

This commit is contained in:
Wlowscha 2025-05-15 22:57:30 +02:00
parent f876dcf76d
commit 85b92bffed
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04

View File

@ -532,15 +532,16 @@ export default class PartyUiHandler extends MessageUiHandler {
}
// TODO: This will be largely changed with the modifier rework
processModifierTransferModeInput(button: Button) {
let success = false;
processModifierTransferModeInput(pokemon: PlayerPokemon) {
const ui = this.getUi();
const option = this.options[this.optionsCursor];
if (button === Button.ACTION) {
const pokemon = globalScene.getPlayerParty()[this.cursor];
if (option === PartyOption.TRANSFER) {
return this.processTransferOption();
}
// TODO: Revise this condition
if (!this.transferMode && option !== PartyOption.CANCEL) {
if (!this.transferMode) {
this.startTransfer();
let ableToTransferText: string;
@ -584,8 +585,13 @@ export default class PartyUiHandler extends MessageUiHandler {
ui.playSelect();
return true;
}
return false;
}
// TODO: Might need a check here actually for when this.transferMode is active...
processModifierTransferModeLeftRightInput(button: Button) {
let success = false;
const option = this.options[this.optionsCursor];
if (button === Button.LEFT) {
/** Decrease quantity for the current item and update UI */
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
@ -613,8 +619,14 @@ export default class PartyUiHandler extends MessageUiHandler {
); /** Place again the cursor at the same position. Necessary, otherwise the cursor disappears */
}
}
return success;
}
// TODO: Might need a check here actually for when this.transferMode is active...
processModifierTransferModeUpDownInput(button: Button.UP | Button.DOWN) {
let success = false;
const option = this.options[this.optionsCursor];
if (button === Button.UP || button === Button.DOWN) {
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
if (option !== PartyOption.ALL) {
this.transferQuantities[option] = this.transferQuantitiesMax[option];
@ -622,7 +634,6 @@ export default class PartyUiHandler extends MessageUiHandler {
this.updateOptions();
}
success = this.moveOptionCursor(button);
}
return success;
}
@ -634,14 +645,10 @@ export default class PartyUiHandler extends MessageUiHandler {
return this.setCursor(this.optionsCursor < this.options.length - 1 ? this.optionsCursor + 1 : 0);
}
processRememberMoveModeInput(button: Button) {
let success = false;
processRememberMoveModeInput(pokemon: PlayerPokemon) {
const ui = this.getUi();
const option = this.options[this.optionsCursor];
if (button === Button.ACTION) {
const pokemon = globalScene.getPlayerParty()[this.cursor];
if (option !== PartyOption.CANCEL) {
// clear overlay on cancel
this.moveInfoOverlay.clear();
const filterResult = (this.selectFilter as PokemonSelectFilter)(pokemon);
@ -655,9 +662,10 @@ export default class PartyUiHandler extends MessageUiHandler {
ui.playSelect();
return true;
}
}
if (button === Button.UP || button === Button.DOWN) {
processRememberMoveModeUpDownInput(button: Button.UP | Button.DOWN) {
let success = false;
success = this.moveOptionCursor(button);
// show move description
@ -670,7 +678,6 @@ export default class PartyUiHandler extends MessageUiHandler {
// or hide the overlay, in case it's the cancel button
this.moveInfoOverlay.clear();
}
}
return success;
}
@ -703,39 +710,35 @@ export default class PartyUiHandler extends MessageUiHandler {
}
processOptionMenuInput(button: Button) {
let success = false;
const ui = this.getUi();
const option = this.options[this.optionsCursor];
// Button.CANCEL has no special behavior for any option
if (button === Button.CANCEL || option === PartyOption.CANCEL) {
if (button === Button.CANCEL) {
this.clearOptions();
ui.playSelect();
return true;
}
console.log(PartyUiMode[this.partyUiMode]);
console.log(PartyOption[option]);
console.log(this.selectCallback);
if (button === Button.ACTION) {
if (option === PartyOption.CANCEL) {
return this.processOptionMenuInput(Button.CANCEL);
}
// If the input has been already processed we are done, otherwise move on until the correct option is found
const pokemon = globalScene.getPlayerParty()[this.cursor];
// TODO: Careful about using success for the return values here. Find a better way
// PartyOption.ALL, and options specific to the mode (held items)
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
success = this.processModifierTransferModeInput(button);
return this.processModifierTransferModeInput(pokemon);
}
// options specific to the mode (moves)
if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER) {
success = this.processRememberMoveModeInput(button);
return this.processRememberMoveModeInput(pokemon);
}
// If the input has been already processed we are done, otherwise move on until the correct option is found
if (success) {
return true;
}
if (button === Button.ACTION) {
const pokemon = globalScene.getPlayerParty()[this.cursor];
// These are the options that do not involve a callback
if (option === PartyOption.SUMMARY) {
return this.processSummaryOption(pokemon);
@ -786,10 +789,6 @@ export default class PartyUiHandler extends MessageUiHandler {
// PartyUiMode.POST_BATTLE_SWITCH (SEND_OUT)
// These are the options that need a callback
if (option === PartyOption.TRANSFER) {
return this.processTransferOption();
}
if (option === PartyOption.RELEASE) {
return this.processReleaseOption(pokemon);
}
@ -857,10 +856,24 @@ export default class PartyUiHandler extends MessageUiHandler {
}
if (button === Button.UP || button === Button.DOWN) {
success = this.moveOptionCursor(button);
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
return this.processModifierTransferModeUpDownInput(button);
}
return success;
if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER) {
return this.processRememberMoveModeUpDownInput(button);
}
return this.moveOptionCursor(button);
}
if (button === Button.LEFT || button === Button.RIGHT) {
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
return this.processModifierTransferModeLeftRightInput(button);
}
}
return false;
}
processInput(button: Button): boolean {