mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-21 14:59:26 +02:00
Possible cursor fixes
This commit is contained in:
parent
1a4420853e
commit
dd893785b5
@ -10,7 +10,7 @@ import { Moves } from "#app/enums/moves";
|
||||
import { PokeballType } from "#app/enums/pokeball";
|
||||
import { FieldPosition, PlayerPokemon } from "#app/field/pokemon";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
import CommandUiHandler, { Command } from "#app/ui/command-ui-handler";
|
||||
import { Command } from "#app/ui/command-ui-handler";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
import i18next from "i18next";
|
||||
import { FieldPhase } from "./field-phase";
|
||||
@ -30,7 +30,14 @@ export class CommandPhase extends FieldPhase {
|
||||
start() {
|
||||
super.start();
|
||||
|
||||
this.repositionCursor();
|
||||
const commandUiHandler = this.scene.ui.handlers[Mode.COMMAND];
|
||||
if (commandUiHandler) {
|
||||
if (this.scene.currentBattle.turn === 1 || commandUiHandler.getCursor() === Command.POKEMON) {
|
||||
commandUiHandler.setCursor(Command.FIGHT);
|
||||
} else {
|
||||
commandUiHandler.setCursor(commandUiHandler.getCursor());
|
||||
}
|
||||
}
|
||||
|
||||
if (this.fieldIndex) {
|
||||
// If we somehow are attempting to check the right pokemon but there's only one pokemon out
|
||||
@ -259,18 +266,6 @@ export class CommandPhase extends FieldPhase {
|
||||
return success!; // TODO: is the bang correct?
|
||||
}
|
||||
|
||||
repositionCursor() {
|
||||
const commandUiHandler = this.scene.ui.handlers[Mode.COMMAND] as CommandUiHandler;
|
||||
if (commandUiHandler) {
|
||||
if (this.scene.currentBattle.turn === 1 || commandUiHandler.getCursor() === Command.POKEMON) {
|
||||
commandUiHandler.setCursor(Command.FIGHT);
|
||||
} else {
|
||||
commandUiHandler.setCursor(commandUiHandler.getCursor());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
cancel() {
|
||||
if (this.fieldIndex) {
|
||||
this.scene.unshiftPhase(new CommandPhase(this.scene, 0));
|
||||
|
@ -16,8 +16,8 @@ export enum Command {
|
||||
}
|
||||
|
||||
export default class CommandUiHandler extends UiHandler {
|
||||
public commandsContainer: Phaser.GameObjects.Container;
|
||||
public cursorObj: Phaser.GameObjects.Image | null;
|
||||
private commandsContainer: Phaser.GameObjects.Container;
|
||||
private cursorObj: Phaser.GameObjects.Image | null;
|
||||
|
||||
protected fieldIndex: integer = 0;
|
||||
protected cursor2: integer = 0;
|
||||
@ -68,14 +68,12 @@ export default class CommandUiHandler extends UiHandler {
|
||||
messageHandler.movesWindowContainer.setVisible(false);
|
||||
messageHandler.message.setWordWrapWidth(1110);
|
||||
messageHandler.showText(i18next.t("commandUiHandler:actionMessage", { pokemonName: getPokemonNameWithAffix(commandPhase.getPokemon()) }), 0);
|
||||
|
||||
if (!this.cursorObj) {
|
||||
this.cursorObj = this.scene.add.image(0, 0, "cursor");
|
||||
this.commandsContainer.add(this.cursorObj);
|
||||
if (this.getCursor() === Command.POKEMON) {
|
||||
this.setCursor(Command.FIGHT);
|
||||
} else {
|
||||
this.setCursor(this.getCursor());
|
||||
}
|
||||
|
||||
const cursorPosition = this.getCursor() === Command.POKEMON ? Command.FIGHT : this.getCursor();
|
||||
this.cursorObj.setPosition(-5 + (cursorPosition % 2 === 1 ? 56 : 0), 8 + (cursorPosition >= 2 ? 16 : 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user