Merge branch 'beta' into terrain-fail-msg

This commit is contained in:
Bertie690 2025-06-06 16:38:38 -04:00 committed by GitHub
commit 83efdda0a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 82 additions and 69 deletions

View File

@ -78,10 +78,15 @@ export class FaintPhase extends PokemonPhase {
} }
} }
/** In case the current pokemon was just switched in, make sure it is counted as participating in the combat */ /**
* In case the current pokemon was just switched in, make sure it is counted as participating in the combat.
* For EXP_SHARE purposes, if the current pokemon faints as the combat ends and it was the ONLY player pokemon
* involved in combat, it needs to be counted as a participant so the other party pokemon can get their EXP,
* so the fainted pokemon has been included.
*/
for (const pokemon of globalScene.getPlayerField()) { for (const pokemon of globalScene.getPlayerField()) {
if (pokemon?.isActive(true) && pokemon.isPlayer()) { if (pokemon?.isActive() || pokemon?.isFainted()) {
globalScene.currentBattle.addParticipant(pokemon as PlayerPokemon); globalScene.currentBattle.addParticipant(pokemon);
} }
} }

View File

@ -4,6 +4,7 @@ import { truncateString } from "../../utils/common";
import { Button } from "#enums/buttons"; import { Button } from "#enums/buttons";
import { SettingKeyboard } from "#app/system/settings/settings-keyboard"; import { SettingKeyboard } from "#app/system/settings/settings-keyboard";
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
import i18next from "i18next";
export enum SettingGamepad { export enum SettingGamepad {
Controller = "CONTROLLER", Controller = "CONTROLLER",
@ -27,11 +28,11 @@ export enum SettingGamepad {
Button_Submit = "BUTTON_SUBMIT", Button_Submit = "BUTTON_SUBMIT",
} }
const pressAction = "Press action to assign"; const pressAction = i18next.t("settings:pressActionToAssign");
export const settingGamepadOptions = { export const settingGamepadOptions = {
[SettingGamepad.Controller]: ["Default", "Change"], [SettingGamepad.Controller]: [i18next.t("settings:controllerDefault"), i18next.t("settings:controllerChange")],
[SettingGamepad.Gamepad_Support]: ["Auto", "Disabled"], [SettingGamepad.Gamepad_Support]: [i18next.t("settings:gamepadSupportAuto"), i18next.t("settings:gamepadSupportDisabled")],
[SettingGamepad.Button_Up]: [`KEY ${Button.UP.toString()}`, pressAction], [SettingGamepad.Button_Up]: [`KEY ${Button.UP.toString()}`, pressAction],
[SettingGamepad.Button_Down]: [`KEY ${Button.DOWN.toString()}`, pressAction], [SettingGamepad.Button_Down]: [`KEY ${Button.DOWN.toString()}`, pressAction],
[SettingGamepad.Button_Left]: [`KEY ${Button.LEFT.toString()}`, pressAction], [SettingGamepad.Button_Left]: [`KEY ${Button.LEFT.toString()}`, pressAction],
@ -140,7 +141,7 @@ export function setSettingGamepad(setting: SettingGamepad, value: number): boole
handler: () => changeGamepadHandler(g), handler: () => changeGamepadHandler(g),
})), })),
{ {
label: "Cancel", label: i18next.t("settings:cancelContollerChoice"),
handler: cancelHandler, handler: cancelHandler,
}, },
], ],

View File

@ -108,7 +108,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
let pokemonIconX = -20; let pokemonIconX = -20;
let pokemonIconY = 6; let pokemonIconY = 6;
if (["de", "es-ES", "es-MX", "fr", "ko", "pt-BR"].includes(currentLanguage)) { if (["de", "es-ES", "es-MX", "fr", "ko", "pt-BR", "ru"].includes(currentLanguage)) {
gachaTextStyle = TextStyle.SMALLER_WINDOW_ALT; gachaTextStyle = TextStyle.SMALLER_WINDOW_ALT;
gachaX = 2; gachaX = 2;
gachaY = 2; gachaY = 2;
@ -150,7 +150,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
gachaInfoContainer.add(pokemonIcon); gachaInfoContainer.add(pokemonIcon);
break; break;
case GachaType.MOVE: case GachaType.MOVE:
if (["de", "es-ES", "fr", "pt-BR"].includes(currentLanguage)) { if (["de", "es-ES", "fr", "pt-BR", "ru"].includes(currentLanguage)) {
gachaUpLabel.setAlign("center"); gachaUpLabel.setAlign("center");
gachaUpLabel.setY(0); gachaUpLabel.setY(0);
} }
@ -160,7 +160,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
gachaUpLabel.setOrigin(0.5, 0); gachaUpLabel.setOrigin(0.5, 0);
break; break;
case GachaType.SHINY: case GachaType.SHINY:
if (["de", "fr", "ko"].includes(currentLanguage)) { if (["de", "fr", "ko", "ru"].includes(currentLanguage)) {
gachaUpLabel.setAlign("center"); gachaUpLabel.setAlign("center");
gachaUpLabel.setY(0); gachaUpLabel.setY(0);
} }
@ -206,7 +206,17 @@ export default class EggGachaUiHandler extends MessageUiHandler {
this.eggGachaOptionsContainer = globalScene.add.container(globalScene.game.canvas.width / 6, 148); this.eggGachaOptionsContainer = globalScene.add.container(globalScene.game.canvas.width / 6, 148);
this.eggGachaContainer.add(this.eggGachaOptionsContainer); this.eggGachaContainer.add(this.eggGachaOptionsContainer);
this.eggGachaOptionSelectBg = addWindow(0, 0, 96, 16 + 576 * this.scale); // Increase egg box width on certain languages
let eggGachaOptionSelectWidth = 0;
switch (i18next.resolvedLanguage) {
case "ru":
eggGachaOptionSelectWidth = 100;
break;
default:
eggGachaOptionSelectWidth = 96;
}
this.eggGachaOptionSelectBg = addWindow(0, 0, eggGachaOptionSelectWidth, 16 + 576 * this.scale);
this.eggGachaOptionSelectBg.setOrigin(1, 1); this.eggGachaOptionSelectBg.setOrigin(1, 1);
this.eggGachaOptionsContainer.add(this.eggGachaOptionSelectBg); this.eggGachaOptionsContainer.add(this.eggGachaOptionSelectBg);

View File

@ -35,81 +35,70 @@ export default class EggListUiHandler extends MessageUiHandler {
setup() { setup() {
const ui = this.getUi(); const ui = this.getUi();
this.eggListContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6); this.eggListContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6).setVisible(false);
this.eggListContainer.setVisible(false);
ui.add(this.eggListContainer); ui.add(this.eggListContainer);
const bgColor = globalScene.add.rectangle( const bgColor = globalScene.add
0, .rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6, 0x006860)
0, .setOrigin(0);
globalScene.game.canvas.width / 6,
globalScene.game.canvas.height / 6,
0x006860,
);
bgColor.setOrigin(0, 0);
this.eggListContainer.add(bgColor);
const eggListBg = globalScene.add.image(0, 0, "egg_list_bg"); const eggListBg = globalScene.add.image(0, 0, "egg_list_bg").setOrigin(0);
eggListBg.setOrigin(0, 0);
this.eggListContainer.add(eggListBg);
this.eggListContainer.add(addWindow(1, 85, 106, 22));
this.eggListContainer.add(addWindow(1, 102, 106, 50, true));
this.eggListContainer.add(addWindow(1, 147, 106, 32, true));
this.eggListContainer.add(addWindow(107, 1, 212, 178));
this.iconAnimHandler = new PokemonIconAnimHandler(); this.iconAnimHandler = new PokemonIconAnimHandler();
this.iconAnimHandler.setup(); this.iconAnimHandler.setup();
this.eggNameText = addTextObject(8, 68, "", TextStyle.SUMMARY); this.eggNameText = addTextObject(8, 68, "", TextStyle.SUMMARY).setOrigin(0);
this.eggNameText.setOrigin(0, 0);
this.eggListContainer.add(this.eggNameText);
this.eggDateText = addTextObject(8, 91, "", TextStyle.TOOLTIP_CONTENT); this.eggDateText = addTextObject(8, 91, "", TextStyle.TOOLTIP_CONTENT);
this.eggListContainer.add(this.eggDateText);
this.eggHatchWavesText = addTextObject(8, 108, "", TextStyle.TOOLTIP_CONTENT); this.eggHatchWavesText = addTextObject(8, 108, "", TextStyle.TOOLTIP_CONTENT).setWordWrapWidth(540);
this.eggHatchWavesText.setWordWrapWidth(540);
this.eggListContainer.add(this.eggHatchWavesText);
this.eggGachaInfoText = addTextObject(8, 152, "", TextStyle.TOOLTIP_CONTENT); this.eggGachaInfoText = addTextObject(8, 152, "", TextStyle.TOOLTIP_CONTENT).setWordWrapWidth(540);
this.eggGachaInfoText.setWordWrapWidth(540);
this.eggListContainer.add(this.eggGachaInfoText);
this.eggListIconContainer = globalScene.add.container(113, 5); this.eggListIconContainer = globalScene.add.container(113, 5);
this.eggListContainer.add(this.eggListIconContainer);
this.cursorObj = globalScene.add.image(0, 0, "select_cursor"); this.cursorObj = globalScene.add.image(0, 0, "select_cursor").setOrigin(0);
this.cursorObj.setOrigin(0, 0);
this.eggListContainer.add(this.cursorObj);
this.eggSprite = globalScene.add.sprite(54, 37, "egg"); this.eggSprite = globalScene.add.sprite(54, 37, "egg");
this.eggListContainer.add(this.eggSprite);
const scrollBar = new ScrollBar(310, 5, 4, 170, this.ROWS); const scrollBar = new ScrollBar(310, 5, 4, 170, this.ROWS);
this.eggListContainer.add(scrollBar);
this.scrollGridHandler = new ScrollableGridUiHandler(this, this.ROWS, this.COLUMNS) this.scrollGridHandler = new ScrollableGridUiHandler(this, this.ROWS, this.COLUMNS)
.withScrollBar(scrollBar) .withScrollBar(scrollBar)
.withUpdateGridCallBack(() => this.updateEggIcons()) .withUpdateGridCallBack(() => this.updateEggIcons())
.withUpdateSingleElementCallback((i: number) => this.setEggDetails(i)); .withUpdateSingleElementCallback((i: number) => this.setEggDetails(i));
this.eggListMessageBoxContainer = globalScene.add.container(0, globalScene.game.canvas.height / 6); this.eggListMessageBoxContainer = globalScene.add
this.eggListMessageBoxContainer.setVisible(false); .container(0, globalScene.game.canvas.height / 6)
this.eggListContainer.add(this.eggListMessageBoxContainer); .setVisible(false);
const eggListMessageBox = addWindow(1, -1, 318, 28); const eggListMessageBox = addWindow(1, -1, 318, 28).setOrigin(0, 1);
eggListMessageBox.setOrigin(0, 1);
this.eggListMessageBoxContainer.add(eggListMessageBox); this.eggListMessageBoxContainer.add(eggListMessageBox);
this.message = addTextObject(8, -8, "", TextStyle.WINDOW, { maxLines: 1 }); // Message isn't used, but is expected to exist as this subclasses MessageUiHandler
this.message.setOrigin(0, 1); this.message = addTextObject(8, -8, "", TextStyle.WINDOW, { maxLines: 1 }).setActive(false).setVisible(false);
this.eggListMessageBoxContainer.add(this.message);
this.cursor = -1; this.cursor = -1;
this.eggListContainer.add([
bgColor,
eggListBg,
addWindow(1, 85, 106, 22),
addWindow(1, 102, 106, 50, true),
addWindow(1, 147, 106, 32, true),
addWindow(107, 1, 212, 178),
this.eggNameText,
this.eggDateText,
this.eggHatchWavesText,
this.eggGachaInfoText,
this.eggListIconContainer,
this.cursorObj,
this.eggSprite,
scrollBar,
]);
} }
show(args: any[]): boolean { override show(args: any[]): boolean {
super.show(args); super.show(args);
this.initEggIcons(); this.initEggIcons();
@ -134,9 +123,10 @@ export default class EggListUiHandler extends MessageUiHandler {
for (let i = 0; i < Math.min(this.ROWS * this.COLUMNS, globalScene.gameData.eggs.length); i++) { for (let i = 0; i < Math.min(this.ROWS * this.COLUMNS, globalScene.gameData.eggs.length); i++) {
const x = (i % this.COLUMNS) * 18; const x = (i % this.COLUMNS) * 18;
const y = Math.floor(i / this.COLUMNS) * 18; const y = Math.floor(i / this.COLUMNS) * 18;
const icon = globalScene.add.sprite(x - 2, y + 2, "egg_icons"); const icon = globalScene.add
icon.setScale(0.5); .sprite(x - 2, y + 2, "egg_icons")
icon.setOrigin(0, 0); .setScale(0.5)
.setOrigin(0);
this.eggListIconContainer.add(icon); this.eggListIconContainer.add(icon);
this.eggIcons.push(icon); this.eggIcons.push(icon);
} }
@ -148,15 +138,13 @@ export default class EggListUiHandler extends MessageUiHandler {
private updateEggIcons() { private updateEggIcons() {
const indexOffset = this.scrollGridHandler.getItemOffset(); const indexOffset = this.scrollGridHandler.getItemOffset();
const eggsToShow = Math.min(this.eggIcons.length, globalScene.gameData.eggs.length - indexOffset); const eggsToShow = Math.min(this.eggIcons.length, globalScene.gameData.eggs.length - indexOffset);
this.eggIcons.forEach((icon, i) => { this.eggIcons.forEach((icon, i) => {
if (i !== this.cursor) { if (i !== this.cursor) {
this.iconAnimHandler.addOrUpdate(icon, PokemonIconAnimMode.NONE); this.iconAnimHandler.addOrUpdate(icon, PokemonIconAnimMode.NONE);
} }
if (i < eggsToShow) { if (i < eggsToShow) {
const egg = globalScene.gameData.eggs[i + indexOffset]; const egg = globalScene.gameData.eggs[i + indexOffset];
icon.setFrame(egg.getKey()); icon.setFrame(egg.getKey()).setVisible(true);
icon.setVisible(true);
} else { } else {
icon.setVisible(false); icon.setVisible(false);
} }
@ -187,7 +175,6 @@ export default class EggListUiHandler extends MessageUiHandler {
const ui = this.getUi(); const ui = this.getUi();
let success = false; let success = false;
const error = false;
if (button === Button.CANCEL) { if (button === Button.CANCEL) {
ui.revertMode(); ui.revertMode();
@ -198,11 +185,9 @@ export default class EggListUiHandler extends MessageUiHandler {
if (success) { if (success) {
ui.playSelect(); ui.playSelect();
} else if (error) {
ui.playError();
} }
return success || error; return success;
} }
setCursor(cursor: number): boolean { setCursor(cursor: number): boolean {

View File

@ -108,10 +108,12 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler {
this.reloadSettings = this.settings.filter(s => s?.requireReload); this.reloadSettings = this.settings.filter(s => s?.requireReload);
let anyReloadRequired = false;
this.settings.forEach((setting, s) => { this.settings.forEach((setting, s) => {
let settingName = setting.label; let settingName = setting.label;
if (setting?.requireReload) { if (setting?.requireReload) {
settingName += ` (${i18next.t("settings:requireReload")})`; settingName += "*";
anyReloadRequired = true;
} }
this.settingLabels[s] = addTextObject(8, 28 + s * 16, settingName, TextStyle.SETTINGS_LABEL); this.settingLabels[s] = addTextObject(8, 28 + s * 16, settingName, TextStyle.SETTINGS_LABEL);
@ -187,6 +189,14 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler {
this.settingsContainer.add(iconAction); this.settingsContainer.add(iconAction);
this.settingsContainer.add(iconCancel); this.settingsContainer.add(iconCancel);
this.settingsContainer.add(actionText); this.settingsContainer.add(actionText);
// Only add the ReloadRequired text on pages that have settings that require a reload.
if (anyReloadRequired) {
const reloadRequired = addTextObject(0, 0, `*${i18next.t("settings:requireReload")}`, TextStyle.SETTINGS_LABEL)
.setOrigin(0, 0.15)
.setPositionRelative(actionsBg, 6, 0)
.setY(actionText.y);
this.settingsContainer.add(reloadRequired);
}
this.settingsContainer.add(cancelText); this.settingsContainer.add(cancelText);
this.settingsContainer.add(this.messageBoxContainer); this.settingsContainer.add(this.messageBoxContainer);

View File

@ -4,6 +4,7 @@ import { Device } from "#enums/devices";
import { getIconWithSettingName, getKeyWithKeycode } from "#app/configs/inputs/configHandler"; import { getIconWithSettingName, getKeyWithKeycode } from "#app/configs/inputs/configHandler";
import { addTextObject, TextStyle } from "#app/ui/text"; import { addTextObject, TextStyle } from "#app/ui/text";
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
import i18next from "i18next";
export default class GamepadBindingUiHandler extends AbstractBindingUiHandler { export default class GamepadBindingUiHandler extends AbstractBindingUiHandler {
constructor(mode: UiMode | null = null) { constructor(mode: UiMode | null = null) {
@ -19,7 +20,7 @@ export default class GamepadBindingUiHandler extends AbstractBindingUiHandler {
this.newButtonIcon.setOrigin(0.5); this.newButtonIcon.setOrigin(0.5);
this.newButtonIcon.setVisible(false); this.newButtonIcon.setVisible(false);
this.swapText = addTextObject(0, 0, "will swap with", TextStyle.WINDOW); this.swapText = addTextObject(0, 0, i18next.t("settings:willSwapWith"), TextStyle.WINDOW);
this.swapText.setOrigin(0.5); this.swapText.setOrigin(0.5);
this.swapText.setPositionRelative( this.swapText.setPositionRelative(
this.optionSelectBg, this.optionSelectBg,
@ -33,7 +34,7 @@ export default class GamepadBindingUiHandler extends AbstractBindingUiHandler {
this.targetButtonIcon.setOrigin(0.5); this.targetButtonIcon.setOrigin(0.5);
this.targetButtonIcon.setVisible(false); this.targetButtonIcon.setVisible(false);
this.actionLabel = addTextObject(0, 0, "Confirm swap", TextStyle.SETTINGS_LABEL); this.actionLabel = addTextObject(0, 0, i18next.t("settings:confirmSwap"), TextStyle.SETTINGS_LABEL);
this.actionLabel.setOrigin(0, 0.5); this.actionLabel.setOrigin(0, 0.5);
this.actionLabel.setPositionRelative(this.actionBg, this.actionBg.width - 75, this.actionBg.height / 2); this.actionLabel.setPositionRelative(this.actionBg, this.actionBg.width - 75, this.actionBg.height / 2);
this.actionsContainer.add(this.actionLabel); this.actionsContainer.add(this.actionLabel);

View File

@ -4,6 +4,7 @@ import { getKeyWithKeycode } from "#app/configs/inputs/configHandler";
import { Device } from "#enums/devices"; import { Device } from "#enums/devices";
import { addTextObject, TextStyle } from "#app/ui/text"; import { addTextObject, TextStyle } from "#app/ui/text";
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
import i18next from "i18next";
export default class KeyboardBindingUiHandler extends AbstractBindingUiHandler { export default class KeyboardBindingUiHandler extends AbstractBindingUiHandler {
constructor(mode: UiMode | null = null) { constructor(mode: UiMode | null = null) {
@ -21,7 +22,7 @@ export default class KeyboardBindingUiHandler extends AbstractBindingUiHandler {
this.newButtonIcon.setOrigin(0.5); this.newButtonIcon.setOrigin(0.5);
this.newButtonIcon.setVisible(false); this.newButtonIcon.setVisible(false);
this.actionLabel = addTextObject(0, 0, "Assign button", TextStyle.SETTINGS_LABEL); this.actionLabel = addTextObject(0, 0, i18next.t("settings:assignButton"), TextStyle.SETTINGS_LABEL);
this.actionLabel.setOrigin(0, 0.5); this.actionLabel.setOrigin(0, 0.5);
this.actionLabel.setPositionRelative(this.actionBg, this.actionBg.width - 80, this.actionBg.height / 2); this.actionLabel.setPositionRelative(this.actionBg, this.actionBg.width - 80, this.actionBg.height / 2);
this.actionsContainer.add(this.actionLabel); this.actionsContainer.add(this.actionLabel);