[QoL] Add ALL option when transferring items to Pokemons (#1694)
* Add ALL option to transfer menu It adds a new attribute to the PartyUiHandler to track whether the transfer is meant for all items of only for a particular one It also introduces translations for PartyUiHandler, even though only the 'ALL' option can be translated for now. * Use updated translation key for i18n for partyUiHandler:ALL * Fix duplicated import * Use optionCursor instead of optionCursorWithScroll to check if we need to transfer ALL
This commit is contained in:
parent
16084878c3
commit
a4b07158f9
|
@ -27,6 +27,7 @@ import { menuUiHandler } from "./menu-ui-handler";
|
||||||
import { modifierType } from "./modifier-type";
|
import { modifierType } from "./modifier-type";
|
||||||
import { move } from "./move";
|
import { move } from "./move";
|
||||||
import { nature } from "./nature";
|
import { nature } from "./nature";
|
||||||
|
import { partyUiHandler } from "./party-ui-handler";
|
||||||
import { pokeball } from "./pokeball";
|
import { pokeball } from "./pokeball";
|
||||||
import { pokemon } from "./pokemon";
|
import { pokemon } from "./pokemon";
|
||||||
import { pokemonInfo } from "./pokemon-info";
|
import { pokemonInfo } from "./pokemon-info";
|
||||||
|
@ -38,7 +39,6 @@ import { titles, trainerClasses, trainerNames } from "./trainers";
|
||||||
import { tutorial } from "./tutorial";
|
import { tutorial } from "./tutorial";
|
||||||
import { voucher } from "./voucher";
|
import { voucher } from "./voucher";
|
||||||
import { weather } from "./weather";
|
import { weather } from "./weather";
|
||||||
import { partyUiHandler } from "./party-ui-handler";
|
|
||||||
|
|
||||||
export const enConfig = {
|
export const enConfig = {
|
||||||
ability: ability,
|
ability: ability,
|
||||||
|
@ -69,6 +69,7 @@ export const enConfig = {
|
||||||
modifierType: modifierType,
|
modifierType: modifierType,
|
||||||
move: move,
|
move: move,
|
||||||
nature: nature,
|
nature: nature,
|
||||||
|
partyUiHandler: partyUiHandler,
|
||||||
pokeball: pokeball,
|
pokeball: pokeball,
|
||||||
pokemon: pokemon,
|
pokemon: pokemon,
|
||||||
pokemonInfo: pokemonInfo,
|
pokemonInfo: pokemonInfo,
|
||||||
|
@ -82,5 +83,4 @@ export const enConfig = {
|
||||||
tutorial: tutorial,
|
tutorial: tutorial,
|
||||||
voucher: voucher,
|
voucher: voucher,
|
||||||
weather: weather,
|
weather: weather,
|
||||||
partyUiHandler: partyUiHandler
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { SimpleTranslationEntries } from "#app/plugins/i18n";
|
import { SimpleTranslationEntries } from "#app/plugins/i18n";
|
||||||
|
|
||||||
export const partyUiHandler: SimpleTranslationEntries = {
|
export const partyUiHandler: SimpleTranslationEntries = {
|
||||||
|
"ALL": "All",
|
||||||
"SEND_OUT": "Send Out",
|
"SEND_OUT": "Send Out",
|
||||||
"SUMMARY": "Summary",
|
"SUMMARY": "Summary",
|
||||||
"CANCEL": "Cancel",
|
"CANCEL": "Cancel",
|
||||||
|
|
|
@ -57,7 +57,8 @@ export enum PartyOption {
|
||||||
MOVE_1 = 3000,
|
MOVE_1 = 3000,
|
||||||
MOVE_2,
|
MOVE_2,
|
||||||
MOVE_3,
|
MOVE_3,
|
||||||
MOVE_4
|
MOVE_4,
|
||||||
|
ALL = 4000
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PartySelectCallback = (cursor: integer, option: PartyOption) => void;
|
export type PartySelectCallback = (cursor: integer, option: PartyOption) => void;
|
||||||
|
@ -96,6 +97,8 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||||
private transferQuantities: integer[];
|
private transferQuantities: integer[];
|
||||||
/** Stack size of every item that the selected pokemon is holding */
|
/** Stack size of every item that the selected pokemon is holding */
|
||||||
private transferQuantitiesMax: integer[];
|
private transferQuantitiesMax: integer[];
|
||||||
|
/** Whether to transfer all items */
|
||||||
|
private transferAll: boolean;
|
||||||
|
|
||||||
private lastCursor: integer = 0;
|
private lastCursor: integer = 0;
|
||||||
private selectCallback: PartySelectCallback | PartyModifierTransferSelectCallback;
|
private selectCallback: PartySelectCallback | PartyModifierTransferSelectCallback;
|
||||||
|
@ -294,6 +297,8 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||||
} else if ((option !== PartyOption.SUMMARY && option !== PartyOption.UNPAUSE_EVOLUTION && option !== PartyOption.UNSPLICE && option !== PartyOption.RELEASE && option !== PartyOption.CANCEL)
|
} else if ((option !== PartyOption.SUMMARY && option !== PartyOption.UNPAUSE_EVOLUTION && option !== PartyOption.UNSPLICE && option !== PartyOption.RELEASE && option !== PartyOption.CANCEL)
|
||||||
|| (option === PartyOption.RELEASE && this.partyUiMode === PartyUiMode.RELEASE)) {
|
|| (option === PartyOption.RELEASE && this.partyUiMode === PartyUiMode.RELEASE)) {
|
||||||
let filterResult: string;
|
let filterResult: string;
|
||||||
|
const getTransferrableItemsFromPokemon = (pokemon: PlayerPokemon) =>
|
||||||
|
this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier && (m as PokemonHeldItemModifier).getTransferrable(true) && (m as PokemonHeldItemModifier).pokemonId === pokemon.id) as PokemonHeldItemModifier[];
|
||||||
if (option !== PartyOption.TRANSFER && option !== PartyOption.SPLICE) {
|
if (option !== PartyOption.TRANSFER && option !== PartyOption.SPLICE) {
|
||||||
filterResult = (this.selectFilter as PokemonSelectFilter)(pokemon);
|
filterResult = (this.selectFilter as PokemonSelectFilter)(pokemon);
|
||||||
if (filterResult === null && (option === PartyOption.SEND_OUT || option === PartyOption.PASS_BATON)) {
|
if (filterResult === null && (option === PartyOption.SEND_OUT || option === PartyOption.PASS_BATON)) {
|
||||||
|
@ -303,10 +308,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||||
filterResult = this.moveSelectFilter(pokemon.moveset[this.optionsCursor]);
|
filterResult = this.moveSelectFilter(pokemon.moveset[this.optionsCursor]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const transferPokemon = this.scene.getParty()[this.transferCursor];
|
filterResult = (this.selectFilter as PokemonModifierTransferSelectFilter)(pokemon, getTransferrableItemsFromPokemon(this.scene.getParty()[this.transferCursor])[this.transferOptionCursor]);
|
||||||
const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
|
||||||
&& (m as PokemonHeldItemModifier).getTransferrable(true) && (m as PokemonHeldItemModifier).pokemonId === transferPokemon.id) as PokemonHeldItemModifier[];
|
|
||||||
filterResult = (this.selectFilter as PokemonModifierTransferSelectFilter)(pokemon, itemModifiers[this.transferOptionCursor]);
|
|
||||||
}
|
}
|
||||||
if (filterResult === null) {
|
if (filterResult === null) {
|
||||||
if (this.partyUiMode !== PartyUiMode.SPLICE) {
|
if (this.partyUiMode !== PartyUiMode.SPLICE) {
|
||||||
|
@ -315,8 +317,12 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||||
if (this.selectCallback && this.partyUiMode !== PartyUiMode.CHECK) {
|
if (this.selectCallback && this.partyUiMode !== PartyUiMode.CHECK) {
|
||||||
if (option === PartyOption.TRANSFER) {
|
if (option === PartyOption.TRANSFER) {
|
||||||
if (this.transferCursor !== this.cursor) {
|
if (this.transferCursor !== this.cursor) {
|
||||||
|
if (this.transferAll) {
|
||||||
|
getTransferrableItemsFromPokemon(this.scene.getParty()[this.transferCursor]).forEach((_, i) => (this.selectCallback as PartyModifierTransferSelectCallback)(this.transferCursor, i, this.transferQuantitiesMax[i], this.cursor));
|
||||||
|
} else {
|
||||||
(this.selectCallback as PartyModifierTransferSelectCallback)(this.transferCursor, this.transferOptionCursor, this.transferQuantities[this.transferOptionCursor], this.cursor);
|
(this.selectCallback as PartyModifierTransferSelectCallback)(this.transferCursor, this.transferOptionCursor, this.transferQuantities[this.transferOptionCursor], this.cursor);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.clearTransfer();
|
this.clearTransfer();
|
||||||
} else if (this.partyUiMode === PartyUiMode.SPLICE) {
|
} else if (this.partyUiMode === PartyUiMode.SPLICE) {
|
||||||
if (option === PartyOption.SPLICE) {
|
if (option === PartyOption.SPLICE) {
|
||||||
|
@ -430,7 +436,9 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||||
case Button.UP:
|
case Button.UP:
|
||||||
/** If currently selecting items to transfer, reset quantity selection */
|
/** If currently selecting items to transfer, reset quantity selection */
|
||||||
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
||||||
|
if (option !== PartyOption.ALL) {
|
||||||
this.transferQuantities[option] = this.transferQuantitiesMax[option];
|
this.transferQuantities[option] = this.transferQuantitiesMax[option];
|
||||||
|
}
|
||||||
this.updateOptions();
|
this.updateOptions();
|
||||||
}
|
}
|
||||||
success = this.setCursor(this.optionsCursor ? this.optionsCursor - 1 : this.options.length - 1); /** Move cursor */
|
success = this.setCursor(this.optionsCursor ? this.optionsCursor - 1 : this.options.length - 1); /** Move cursor */
|
||||||
|
@ -438,7 +446,9 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||||
case Button.DOWN:
|
case Button.DOWN:
|
||||||
/** If currently selecting items to transfer, reset quantity selection */
|
/** If currently selecting items to transfer, reset quantity selection */
|
||||||
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
||||||
|
if (option !== PartyOption.ALL) {
|
||||||
this.transferQuantities[option] = this.transferQuantitiesMax[option];
|
this.transferQuantities[option] = this.transferQuantitiesMax[option];
|
||||||
|
}
|
||||||
this.updateOptions();
|
this.updateOptions();
|
||||||
}
|
}
|
||||||
success = this.setCursor(this.optionsCursor < this.options.length - 1 ? this.optionsCursor + 1 : 0); /** Move cursor */
|
success = this.setCursor(this.optionsCursor < this.options.length - 1 ? this.optionsCursor + 1 : 0); /** Move cursor */
|
||||||
|
@ -770,6 +780,9 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||||
for (let im = 0; im < itemModifiers.length; im++) {
|
for (let im = 0; im < itemModifiers.length; im++) {
|
||||||
this.options.push(im);
|
this.options.push(im);
|
||||||
}
|
}
|
||||||
|
if (itemModifiers.length > 1) {
|
||||||
|
this.options.push(PartyOption.ALL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.optionsScrollTotal = this.options.length;
|
this.optionsScrollTotal = this.options.length;
|
||||||
|
@ -842,6 +855,9 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||||
const move = learnableLevelMoves[option];
|
const move = learnableLevelMoves[option];
|
||||||
optionName = allMoves[move].name;
|
optionName = allMoves[move].name;
|
||||||
altText = !pokemon.getSpeciesForm().getLevelMoves().find(plm => plm[1] === move);
|
altText = !pokemon.getSpeciesForm().getLevelMoves().find(plm => plm[1] === move);
|
||||||
|
} else {
|
||||||
|
if (option === PartyOption.ALL) {
|
||||||
|
optionName = i18next.t("partyUiHandler:ALL");
|
||||||
} else {
|
} else {
|
||||||
const itemModifier = itemModifiers[option];
|
const itemModifier = itemModifiers[option];
|
||||||
optionName = itemModifier.type.name;
|
optionName = itemModifier.type.name;
|
||||||
|
@ -850,6 +866,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||||
optionName += ` (${this.transferQuantities[option]})`;
|
optionName += ` (${this.transferQuantities[option]})`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const yCoord = -6 - 16 * o;
|
const yCoord = -6 - 16 * o;
|
||||||
const optionText = addTextObject(this.scene, 0, yCoord - 16, optionName, TextStyle.WINDOW);
|
const optionText = addTextObject(this.scene, 0, yCoord - 16, optionName, TextStyle.WINDOW);
|
||||||
|
@ -876,12 +893,14 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||||
this.transferMode = true;
|
this.transferMode = true;
|
||||||
this.transferCursor = this.cursor;
|
this.transferCursor = this.cursor;
|
||||||
this.transferOptionCursor = this.getOptionsCursorWithScroll();
|
this.transferOptionCursor = this.getOptionsCursorWithScroll();
|
||||||
|
this.transferAll = this.options[this.optionsCursor] === PartyOption.ALL;
|
||||||
|
|
||||||
this.partySlots[this.transferCursor].setTransfer(true);
|
this.partySlots[this.transferCursor].setTransfer(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTransfer(): void {
|
clearTransfer(): void {
|
||||||
this.transferMode = false;
|
this.transferMode = false;
|
||||||
|
this.transferAll = false;
|
||||||
this.partySlots[this.transferCursor].setTransfer(false);
|
this.partySlots[this.transferCursor].setTransfer(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue