mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-11 18:09:29 +02:00
[Fix] Fixed referenced bug and added similar confirmation box to release
This commit is contained in:
parent
6d87014a71
commit
d3ca336bef
@ -315,7 +315,7 @@ export class PartyUiHandler extends MessageUiHandler {
|
|||||||
this.iconAnimHandler = new PokemonIconAnimHandler();
|
this.iconAnimHandler = new PokemonIconAnimHandler();
|
||||||
this.iconAnimHandler.setup();
|
this.iconAnimHandler.setup();
|
||||||
|
|
||||||
const partyDiscardModeButton = new PartyDiscardModeButton(60, -globalScene.game.canvas.height / 15 - 1);
|
const partyDiscardModeButton = new PartyDiscardModeButton(60, -globalScene.game.canvas.height / 15 - 1, this);
|
||||||
|
|
||||||
partyContainer.add(partyDiscardModeButton);
|
partyContainer.add(partyDiscardModeButton);
|
||||||
|
|
||||||
@ -368,12 +368,9 @@ export class PartyUiHandler extends MessageUiHandler {
|
|||||||
this.partyBg.setTexture(`party_bg${globalScene.currentBattle.double ? "_double" : ""}`);
|
this.partyBg.setTexture(`party_bg${globalScene.currentBattle.double ? "_double" : ""}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showPartyText();
|
|
||||||
this.populatePartySlots();
|
this.populatePartySlots();
|
||||||
// If we are currently transferring items, set the icon to its proper state and reveal the button.
|
this.partyDiscardModeButton.toggleIcon(this.partyUiMode);
|
||||||
if (this.isItemManageMode()) {
|
this.showPartyText();
|
||||||
this.partyDiscardModeButton.toggleIcon(this.partyUiMode as PartyUiMode.MODIFIER_TRANSFER | PartyUiMode.DISCARD);
|
|
||||||
}
|
|
||||||
this.setCursor(0);
|
this.setCursor(0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -663,24 +660,40 @@ export class PartyUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private processDiscardMenuInput(pokemon: PlayerPokemon) {
|
private processDiscardMenuInput(pokemon: PlayerPokemon) {
|
||||||
|
const ui = this.getUi();
|
||||||
|
const option = this.options[this.optionsCursor];
|
||||||
this.clearOptions();
|
this.clearOptions();
|
||||||
|
|
||||||
|
this.blockInput = true;
|
||||||
|
this.showText(i18next.t("partyUiHandler:discardConfirmation"), null, () => {
|
||||||
|
this.blockInput = false;
|
||||||
|
ui.setModeWithoutClear(
|
||||||
|
UiMode.CONFIRM,
|
||||||
|
() => {
|
||||||
|
ui.setMode(UiMode.PARTY);
|
||||||
|
this.doDiscard(option, pokemon);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
ui.setMode(UiMode.PARTY);
|
||||||
|
this.showPartyText();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private doDiscard(option: PartyOption, pokemon: PlayerPokemon) {
|
||||||
const itemModifiers = this.getTransferrableItemsFromPokemon(pokemon);
|
const itemModifiers = this.getTransferrableItemsFromPokemon(pokemon);
|
||||||
|
|
||||||
if (this.optionsCursor === itemModifiers.length) {
|
if (option === PartyOption.ALL) {
|
||||||
// Discard all currently held items, erroring if any cannot be discarded
|
|
||||||
let success = true;
|
|
||||||
for (let i = 0; i < itemModifiers.length; i++) {
|
for (let i = 0; i < itemModifiers.length; i++) {
|
||||||
success &&= globalScene.tryDiscardHeldItemModifier(itemModifiers[i], this.transferQuantities[i]);
|
globalScene.tryDiscardHeldItemModifier(itemModifiers[i], this.transferQuantities[i]);
|
||||||
}
|
}
|
||||||
return success;
|
} else {
|
||||||
|
globalScene.tryDiscardHeldItemModifier(itemModifiers[option], this.transferQuantities[option]);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
// Discard the currently selected item
|
|
||||||
return globalScene.tryDiscardHeldItemModifier(
|
|
||||||
itemModifiers[this.optionsCursor],
|
|
||||||
this.transferQuantities[this.optionsCursor],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private moveOptionCursor(button: Button.UP | Button.DOWN): boolean {
|
private moveOptionCursor(button: Button.UP | Button.DOWN): boolean {
|
||||||
@ -1003,14 +1016,11 @@ export class PartyUiHandler extends MessageUiHandler {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ui.playError();
|
ui.playError();
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
this.partyDiscardModeButton.toggleIcon(this.partyUiMode);
|
this.partyDiscardModeButton.toggleIcon(this.partyUiMode);
|
||||||
this.showPartyText();
|
|
||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pressing return button
|
// Pressing return button
|
||||||
if (this.cursor === 6) {
|
if (this.cursor === 6) {
|
||||||
if (!this.allowCancel()) {
|
if (!this.allowCancel()) {
|
||||||
@ -1059,9 +1069,6 @@ export class PartyUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
switch (button) {
|
switch (button) {
|
||||||
// Item manage mode adds an extra 8th "toggle mode" button to the UI, located *below* both active party members.
|
|
||||||
// The following logic serves to ensure its menu behaviour matches its in-game position,
|
|
||||||
// being selected when scrolling up from the first inactive party member or down from the last active one.
|
|
||||||
case Button.UP:
|
case Button.UP:
|
||||||
if (this.isItemManageMode()) {
|
if (this.isItemManageMode()) {
|
||||||
if (this.cursor === 1) {
|
if (this.cursor === 1) {
|
||||||
@ -1111,12 +1118,11 @@ export class PartyUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Button.RIGHT:
|
case Button.RIGHT:
|
||||||
// Scrolling right from item transfer button or with no backup party members goes to cancel
|
|
||||||
if (this.cursor === 7 || slotCount <= battlerCount) {
|
if (this.cursor === 7 || slotCount <= battlerCount) {
|
||||||
success = this.setCursor(6);
|
success = this.setCursor(6);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this.cursor < battlerCount) {
|
if (slotCount > battlerCount && this.cursor < battlerCount) {
|
||||||
success = this.setCursor(this.lastRightPokemonCursor || battlerCount);
|
success = this.setCursor(this.lastRightPokemonCursor || battlerCount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1285,7 +1291,7 @@ export class PartyUiHandler extends MessageUiHandler {
|
|||||||
this.setCursor(0);
|
this.setCursor(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private showPartyText() {
|
showPartyText() {
|
||||||
switch (this.partyUiMode) {
|
switch (this.partyUiMode) {
|
||||||
case PartyUiMode.MODIFIER_TRANSFER:
|
case PartyUiMode.MODIFIER_TRANSFER:
|
||||||
this.showText(i18next.t("partyUiHandler:PartyTransfer"));
|
this.showText(i18next.t("partyUiHandler:PartyTransfer"));
|
||||||
@ -2112,21 +2118,26 @@ class PartyCancelButton extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class PartyDiscardModeButton extends Phaser.GameObjects.Container {
|
class PartyDiscardModeButton extends Phaser.GameObjects.Container {
|
||||||
private selected = false;
|
private selected: boolean;
|
||||||
|
|
||||||
private transferIcon: Phaser.GameObjects.Sprite;
|
private transferIcon: Phaser.GameObjects.Sprite;
|
||||||
private discardIcon: Phaser.GameObjects.Sprite;
|
private discardIcon: Phaser.GameObjects.Sprite;
|
||||||
private textBox: Phaser.GameObjects.Text;
|
private textBox: Phaser.GameObjects.Text;
|
||||||
|
private party: PartyUiHandler;
|
||||||
|
private currentMode: PartyUiMode;
|
||||||
|
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number, party: PartyUiHandler) {
|
||||||
super(globalScene, x, y);
|
super(globalScene, x, y);
|
||||||
|
|
||||||
this.setup();
|
this.setup(party);
|
||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
setup(party: PartyUiHandler) {
|
||||||
this.transferIcon = globalScene.add.sprite(0, 0, "party_transfer");
|
this.transferIcon = globalScene.add.sprite(0, 0, "party_transfer");
|
||||||
this.discardIcon = globalScene.add.sprite(0, 0, "party_discard");
|
this.discardIcon = globalScene.add.sprite(0, 0, "party_discard");
|
||||||
this.textBox = addTextObject(-8, -7, i18next.t("partyUiHandler:TRANSFER"), TextStyle.PARTY);
|
this.textBox = addTextObject(-8, -7, i18next.t("partyUiHandler:TRANSFER"), TextStyle.PARTY);
|
||||||
|
this.currentMode = PartyUiMode.MODIFIER_TRANSFER;
|
||||||
|
this.party = party;
|
||||||
|
|
||||||
this.add(this.transferIcon);
|
this.add(this.transferIcon);
|
||||||
this.add(this.discardIcon);
|
this.add(this.discardIcon);
|
||||||
@ -2142,6 +2153,8 @@ class PartyDiscardModeButton extends Phaser.GameObjects.Container {
|
|||||||
|
|
||||||
this.selected = true;
|
this.selected = true;
|
||||||
|
|
||||||
|
this.party.showText(i18next.t("partyUiHandler:changeMode"));
|
||||||
|
|
||||||
this.transferIcon.setFrame("selected");
|
this.transferIcon.setFrame("selected");
|
||||||
this.discardIcon.setFrame("selected");
|
this.discardIcon.setFrame("selected");
|
||||||
}
|
}
|
||||||
@ -2152,19 +2165,13 @@ class PartyDiscardModeButton extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.selected = false;
|
this.selected = false;
|
||||||
|
this.party.showPartyText();
|
||||||
|
|
||||||
this.transferIcon.setFrame("normal");
|
this.transferIcon.setFrame("normal");
|
||||||
this.discardIcon.setFrame("normal");
|
this.discardIcon.setFrame("normal");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
toggleIcon(partyMode: number) {
|
||||||
* If the current mode deals with transferring items, toggle the discard items button's name and assets.
|
|
||||||
* @param partyMode - The current {@linkcode PartyUiMode}
|
|
||||||
* @remarks
|
|
||||||
* This will also reveal the button if it is currently hidden.
|
|
||||||
*/
|
|
||||||
public toggleIcon(partyMode: PartyUiMode.MODIFIER_TRANSFER | PartyUiMode.DISCARD): void {
|
|
||||||
this.setActive(true).setVisible(true);
|
|
||||||
switch (partyMode) {
|
switch (partyMode) {
|
||||||
case PartyUiMode.MODIFIER_TRANSFER:
|
case PartyUiMode.MODIFIER_TRANSFER:
|
||||||
this.transferIcon.setVisible(true);
|
this.transferIcon.setVisible(true);
|
||||||
@ -2188,11 +2195,13 @@ class PartyDiscardModeButton extends Phaser.GameObjects.Container {
|
|||||||
);
|
);
|
||||||
this.discardIcon.displayWidth = this.textBox.text.length * 9 + 3;
|
this.discardIcon.displayWidth = this.textBox.text.length * 9 + 3;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
this.currentMode = partyMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
this.setActive(false).setVisible(false);
|
|
||||||
this.transferIcon.setVisible(false);
|
this.transferIcon.setVisible(false);
|
||||||
this.discardIcon.setVisible(false);
|
this.discardIcon.setVisible(false);
|
||||||
this.textBox.setVisible(false);
|
this.textBox.setVisible(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user