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 { PokeballType } from "#app/enums/pokeball";
|
||||||
import { FieldPosition, PlayerPokemon } from "#app/field/pokemon";
|
import { FieldPosition, PlayerPokemon } from "#app/field/pokemon";
|
||||||
import { getPokemonNameWithAffix } from "#app/messages";
|
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 { Mode } from "#app/ui/ui";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { FieldPhase } from "./field-phase";
|
import { FieldPhase } from "./field-phase";
|
||||||
@ -30,7 +30,14 @@ export class CommandPhase extends FieldPhase {
|
|||||||
start() {
|
start() {
|
||||||
super.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 (this.fieldIndex) {
|
||||||
// If we somehow are attempting to check the right pokemon but there's only one pokemon out
|
// 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?
|
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() {
|
cancel() {
|
||||||
if (this.fieldIndex) {
|
if (this.fieldIndex) {
|
||||||
this.scene.unshiftPhase(new CommandPhase(this.scene, 0));
|
this.scene.unshiftPhase(new CommandPhase(this.scene, 0));
|
||||||
|
@ -16,8 +16,8 @@ export enum Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class CommandUiHandler extends UiHandler {
|
export default class CommandUiHandler extends UiHandler {
|
||||||
public commandsContainer: Phaser.GameObjects.Container;
|
private commandsContainer: Phaser.GameObjects.Container;
|
||||||
public cursorObj: Phaser.GameObjects.Image | null;
|
private cursorObj: Phaser.GameObjects.Image | null;
|
||||||
|
|
||||||
protected fieldIndex: integer = 0;
|
protected fieldIndex: integer = 0;
|
||||||
protected cursor2: integer = 0;
|
protected cursor2: integer = 0;
|
||||||
@ -68,14 +68,12 @@ export default class CommandUiHandler extends UiHandler {
|
|||||||
messageHandler.movesWindowContainer.setVisible(false);
|
messageHandler.movesWindowContainer.setVisible(false);
|
||||||
messageHandler.message.setWordWrapWidth(1110);
|
messageHandler.message.setWordWrapWidth(1110);
|
||||||
messageHandler.showText(i18next.t("commandUiHandler:actionMessage", { pokemonName: getPokemonNameWithAffix(commandPhase.getPokemon()) }), 0);
|
messageHandler.showText(i18next.t("commandUiHandler:actionMessage", { pokemonName: getPokemonNameWithAffix(commandPhase.getPokemon()) }), 0);
|
||||||
|
if (this.getCursor() === Command.POKEMON) {
|
||||||
if (!this.cursorObj) {
|
this.setCursor(Command.FIGHT);
|
||||||
this.cursorObj = this.scene.add.image(0, 0, "cursor");
|
} else {
|
||||||
this.commandsContainer.add(this.cursorObj);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user