mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 08:16:04 +00:00
Making 3 Option UI real
This commit is contained in:
parent
9af89414b9
commit
beaad44c1e
@ -16,6 +16,7 @@ import i18next from "i18next";
|
|||||||
import { PokemonPhase } from "./pokemon-phase";
|
import { PokemonPhase } from "./pokemon-phase";
|
||||||
import { VictoryPhase } from "./victory-phase";
|
import { VictoryPhase } from "./victory-phase";
|
||||||
import { SubstituteTag } from "#app/data/battler-tags";
|
import { SubstituteTag } from "#app/data/battler-tags";
|
||||||
|
import { PreviewMode } from "#app/ui/confirmPreview-ui-handler";
|
||||||
|
|
||||||
export class AttemptCapturePhase extends PokemonPhase {
|
export class AttemptCapturePhase extends PokemonPhase {
|
||||||
private pokeballType: PokeballType;
|
private pokeballType: PokeballType;
|
||||||
@ -253,7 +254,7 @@ export class AttemptCapturePhase extends PokemonPhase {
|
|||||||
const promptRelease = () => {
|
const promptRelease = () => {
|
||||||
this.scene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.getNameToRender() }), null, () => {
|
this.scene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.getNameToRender() }), null, () => {
|
||||||
this.scene.pokemonInfoContainer.makeRoomForConfirmUi(1, true);
|
this.scene.pokemonInfoContainer.makeRoomForConfirmUi(1, true);
|
||||||
this.scene.ui.setMode(Mode.CONFIRM, () => {
|
this.scene.ui.setMode(Mode.CONFIRM_PREVIEW, () => {
|
||||||
const newPokemon = this.scene.addPlayerPokemon(pokemon.species, pokemon.level, pokemon.abilityIndex, pokemon.formIndex, pokemon.gender, pokemon.shiny, pokemon.variant, pokemon.ivs, pokemon.nature, pokemon);
|
const newPokemon = this.scene.addPlayerPokemon(pokemon.species, pokemon.level, pokemon.abilityIndex, pokemon.formIndex, pokemon.gender, pokemon.shiny, pokemon.variant, pokemon.ivs, pokemon.nature, pokemon);
|
||||||
this.scene.ui.setMode(Mode.SUMMARY, newPokemon, 0, SummaryUiMode.DEFAULT, () => {
|
this.scene.ui.setMode(Mode.SUMMARY, newPokemon, 0, SummaryUiMode.DEFAULT, () => {
|
||||||
this.scene.ui.setMode(Mode.MESSAGE).then(() => {
|
this.scene.ui.setMode(Mode.MESSAGE).then(() => {
|
||||||
@ -275,7 +276,7 @@ export class AttemptCapturePhase extends PokemonPhase {
|
|||||||
removePokemon();
|
removePokemon();
|
||||||
end();
|
end();
|
||||||
});
|
});
|
||||||
}, "fullParty");
|
}, PreviewMode.CATCH_SUMMARY);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
promptRelease();
|
promptRelease();
|
||||||
|
97
src/ui/confirm-preview-ui-handler.ts
Normal file
97
src/ui/confirm-preview-ui-handler.ts
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
import BattleScene from "../battle-scene";
|
||||||
|
import AbstractOptionSelectUiHandler, { OptionSelectConfig } from "./abstact-option-select-ui-handler";
|
||||||
|
import { Mode } from "./ui";
|
||||||
|
import i18next from "i18next";
|
||||||
|
import {Button} from "#enums/buttons";
|
||||||
|
|
||||||
|
export enum PreviewMode {
|
||||||
|
CATCH_SUMMARY,
|
||||||
|
SAVE_PREVIEW
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class ConfirmPreviewUiHandler extends AbstractOptionSelectUiHandler {
|
||||||
|
|
||||||
|
public static readonly windowWidth: integer = 48;
|
||||||
|
|
||||||
|
private switchCheck: boolean;
|
||||||
|
private switchCheckCursor: integer;
|
||||||
|
|
||||||
|
constructor(scene: BattleScene) {
|
||||||
|
super(scene, Mode.CONFIRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
getWindowWidth(): integer {
|
||||||
|
return PreviewUiHandler.windowWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
determineLabels(mode: PreviewMode): string[] {
|
||||||
|
const yes = i18next.t("menu:yes");
|
||||||
|
const no = i18next.t("menu:no");
|
||||||
|
switch (previewMode) {
|
||||||
|
case PreviewMode.CATCH_SUMMARY:
|
||||||
|
return [i18next.t("partyUiHandler:SUMMARY"), yes, no];
|
||||||
|
case PreviewMode.SAVE_PREVIEW:
|
||||||
|
return [yes, i18next.t(""), no];
|
||||||
|
default:
|
||||||
|
return ["", "", ""];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
show(args: any[]): boolean {
|
||||||
|
const labels = this.determineLabels(args[3]);
|
||||||
|
const config: OptionSelectConfig = {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: labels[0],
|
||||||
|
handler: () => {
|
||||||
|
args[0]();
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
label: labels[1],
|
||||||
|
handler: () => {
|
||||||
|
args[1]();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
label: labels[2],
|
||||||
|
handler: () => {
|
||||||
|
args[2]();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
delay: args.length >= 8 && args[7] !== null ? args[7] as integer : 0
|
||||||
|
};
|
||||||
|
|
||||||
|
super.show([ config ]);
|
||||||
|
|
||||||
|
this.switchCheck = args.length >= 5 && args[4] !== null && args[4] as boolean;
|
||||||
|
|
||||||
|
const xOffset = (args.length >= 6 && args[5] !== null ? args[5] as number : 0);
|
||||||
|
const yOffset = (args.length >= 7 && args[6] !== null ? args[6] as number : 0);
|
||||||
|
|
||||||
|
this.optionSelectContainer.setPosition((this.scene.game.canvas.width / 6) - 1 + xOffset, -48 + yOffset);
|
||||||
|
|
||||||
|
this.setCursor(this.switchCheck ? this.switchCheckCursor : 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
processInput(button: Button): boolean {
|
||||||
|
if (button === Button.CANCEL && this.blockInput) {
|
||||||
|
this.unblockInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.processInput(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
setCursor(cursor: integer): boolean {
|
||||||
|
const ret = super.setCursor(cursor);
|
||||||
|
|
||||||
|
if (ret && this.switchCheck) {
|
||||||
|
this.switchCheckCursor = this.cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
@ -54,6 +54,7 @@ import TestDialogueUiHandler from "#app/ui/test-dialogue-ui-handler";
|
|||||||
import AutoCompleteUiHandler from "./autocomplete-ui-handler";
|
import AutoCompleteUiHandler from "./autocomplete-ui-handler";
|
||||||
import { Device } from "#enums/devices";
|
import { Device } from "#enums/devices";
|
||||||
import MysteryEncounterUiHandler from "./mystery-encounter-ui-handler";
|
import MysteryEncounterUiHandler from "./mystery-encounter-ui-handler";
|
||||||
|
import ConfirmPreviewUiHandler from "./confirm-preview-ui-handler";
|
||||||
|
|
||||||
export enum Mode {
|
export enum Mode {
|
||||||
MESSAGE,
|
MESSAGE,
|
||||||
@ -71,6 +72,7 @@ export enum Mode {
|
|||||||
EGG_HATCH_SCENE,
|
EGG_HATCH_SCENE,
|
||||||
EGG_HATCH_SUMMARY,
|
EGG_HATCH_SUMMARY,
|
||||||
CONFIRM,
|
CONFIRM,
|
||||||
|
CONFIRM_PREVIEW,
|
||||||
OPTION_SELECT,
|
OPTION_SELECT,
|
||||||
MENU,
|
MENU,
|
||||||
MENU_OPTION_SELECT,
|
MENU_OPTION_SELECT,
|
||||||
@ -117,6 +119,7 @@ const transitionModes = [
|
|||||||
const noTransitionModes = [
|
const noTransitionModes = [
|
||||||
Mode.TITLE,
|
Mode.TITLE,
|
||||||
Mode.CONFIRM,
|
Mode.CONFIRM,
|
||||||
|
Mode.CONFIRM_PREVIEW,
|
||||||
Mode.OPTION_SELECT,
|
Mode.OPTION_SELECT,
|
||||||
Mode.MENU,
|
Mode.MENU,
|
||||||
Mode.MENU_OPTION_SELECT,
|
Mode.MENU_OPTION_SELECT,
|
||||||
@ -180,6 +183,7 @@ export default class UI extends Phaser.GameObjects.Container {
|
|||||||
new EggHatchSceneHandler(scene),
|
new EggHatchSceneHandler(scene),
|
||||||
new EggSummaryUiHandler(scene),
|
new EggSummaryUiHandler(scene),
|
||||||
new ConfirmUiHandler(scene),
|
new ConfirmUiHandler(scene),
|
||||||
|
new ConfirmPreviewUiHandler(scene),
|
||||||
new OptionSelectUiHandler(scene),
|
new OptionSelectUiHandler(scene),
|
||||||
new MenuUiHandler(scene),
|
new MenuUiHandler(scene),
|
||||||
new OptionSelectUiHandler(scene, Mode.MENU_OPTION_SELECT),
|
new OptionSelectUiHandler(scene, Mode.MENU_OPTION_SELECT),
|
||||||
|
Loading…
Reference in New Issue
Block a user