Making 3 Option UI real

This commit is contained in:
frutescens 2024-09-24 14:41:40 -07:00
parent 9af89414b9
commit beaad44c1e
3 changed files with 104 additions and 2 deletions

View File

@ -16,6 +16,7 @@ import i18next from "i18next";
import { PokemonPhase } from "./pokemon-phase";
import { VictoryPhase } from "./victory-phase";
import { SubstituteTag } from "#app/data/battler-tags";
import { PreviewMode } from "#app/ui/confirmPreview-ui-handler";
export class AttemptCapturePhase extends PokemonPhase {
private pokeballType: PokeballType;
@ -253,7 +254,7 @@ export class AttemptCapturePhase extends PokemonPhase {
const promptRelease = () => {
this.scene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.getNameToRender() }), null, () => {
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);
this.scene.ui.setMode(Mode.SUMMARY, newPokemon, 0, SummaryUiMode.DEFAULT, () => {
this.scene.ui.setMode(Mode.MESSAGE).then(() => {
@ -275,7 +276,7 @@ export class AttemptCapturePhase extends PokemonPhase {
removePokemon();
end();
});
}, "fullParty");
}, PreviewMode.CATCH_SUMMARY);
});
};
promptRelease();

View 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;
}
}

View File

@ -54,6 +54,7 @@ import TestDialogueUiHandler from "#app/ui/test-dialogue-ui-handler";
import AutoCompleteUiHandler from "./autocomplete-ui-handler";
import { Device } from "#enums/devices";
import MysteryEncounterUiHandler from "./mystery-encounter-ui-handler";
import ConfirmPreviewUiHandler from "./confirm-preview-ui-handler";
export enum Mode {
MESSAGE,
@ -71,6 +72,7 @@ export enum Mode {
EGG_HATCH_SCENE,
EGG_HATCH_SUMMARY,
CONFIRM,
CONFIRM_PREVIEW,
OPTION_SELECT,
MENU,
MENU_OPTION_SELECT,
@ -117,6 +119,7 @@ const transitionModes = [
const noTransitionModes = [
Mode.TITLE,
Mode.CONFIRM,
Mode.CONFIRM_PREVIEW,
Mode.OPTION_SELECT,
Mode.MENU,
Mode.MENU_OPTION_SELECT,
@ -180,6 +183,7 @@ export default class UI extends Phaser.GameObjects.Container {
new EggHatchSceneHandler(scene),
new EggSummaryUiHandler(scene),
new ConfirmUiHandler(scene),
new ConfirmPreviewUiHandler(scene),
new OptionSelectUiHandler(scene),
new MenuUiHandler(scene),
new OptionSelectUiHandler(scene, Mode.MENU_OPTION_SELECT),