Skip to content

Commit

Permalink
[QoL] Move Info Overlay (pagefaultgames#1585)
Browse files Browse the repository at this point in the history
* move info implemented for starter selection

a move info box is displayed when editing the starter moveset.

also menus have now onHover triggers.

todo:
- show ui when selecting TMs
- show ui when selecting moves to remember (memory mushroom)

* More Move Info Overlays

Added overlays during Memory Mushroom use and when viewing TMs.
Furthermore a settings option can enable/disable those overlays.

* Added missing ko language entry

... though translation still remains necessary

* updated ui

also added overrides for item rewards

* minor ui update

moved values to the right in the tm move info box

* fixed typedoc issues

* removed settings in to prepare for merge

* updated settings option

added settings option to new settings implementation

* minor changes

removed unused graphic
moved settings option to accessibility
  • Loading branch information
prime-dialga authored and Korwai committed Jun 14, 2024
1 parent a09e2ae commit 037cda5
Show file tree
Hide file tree
Showing 20 changed files with 429 additions and 44 deletions.
88 changes: 53 additions & 35 deletions src/battle-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,20 @@ const expSpriteKeys: string[] = [];

export let starterColors: StarterColors;
interface StarterColors {
[key: string]: [string, string]
[key: string]: [string, string]
}

export interface PokeballCounts {
[pb: string]: integer;
[pb: string]: integer;
}

export type AnySound = Phaser.Sound.WebAudioSound | Phaser.Sound.HTML5AudioSound | Phaser.Sound.NoAudioSound;

export interface InfoToggle {
toggleInfo(force?: boolean): void;
isActive(): boolean;
}

export default class BattleScene extends SceneBase {
public rexUI: UIPlugin;
public inputController: InputsController;
Expand All @@ -97,6 +102,7 @@ export default class BattleScene extends SceneBase {
public showArenaFlyout: boolean = true;
public showLevelUpStats: boolean = true;
public enableTutorials: boolean = import.meta.env.VITE_BYPASS_TUTORIAL === "1";
public enableMoveInfo: boolean = true;
public enableRetries: boolean = false;
/**
* Determines the condition for a notification should be shown for Candy Upgrades
Expand All @@ -120,17 +126,17 @@ export default class BattleScene extends SceneBase {
public skipSeenDialogues: boolean = false;

/**
* Defines the experience gain display mode.
*
* @remarks
* The `expParty` can have several modes:
* - `0` - Default: The normal experience gain display, nothing changed.
* - `1` - Level Up Notification: Displays the level up in the small frame instead of a message.
* - `2` - Skip: No level up frame nor message.
*
* Modes `1` and `2` are still compatible with stats display, level up, new move, etc.
* @default 0 - Uses the default normal experience gain display.
*/
* Defines the experience gain display mode.
*
* @remarks
* The `expParty` can have several modes:
* - `0` - Default: The normal experience gain display, nothing changed.
* - `1` - Level Up Notification: Displays the level up in the small frame instead of a message.
* - `2` - Skip: No level up frame nor message.
*
* Modes `1` and `2` are still compatible with stats display, level up, new move, etc.
* @default 0 - Uses the default normal experience gain display.
*/
public expParty: integer = 0;
public hpBarSpeed: integer = 0;
public fusionPaletteSwaps: boolean = true;
Expand Down Expand Up @@ -209,6 +215,8 @@ export default class BattleScene extends SceneBase {
public rngSeedOverride: string = "";
public rngOffset: integer = 0;

private infoToggles: InfoToggle[] = [];

/**
* Allows subscribers to listen for events
*
Expand Down Expand Up @@ -515,7 +523,7 @@ export default class BattleScene extends SceneBase {
this.playTimeTimer = this.time.addEvent({
delay: Utils.fixedInt(1000),
repeat: -1,
callback: () => {
callback: () => {
if (this.gameData) {
this.gameData.gameStats.playTime++;
}
Expand Down Expand Up @@ -599,25 +607,25 @@ export default class BattleScene extends SceneBase {

/*const loadPokemonAssets: Promise<void>[] = [];
for (let s of Object.keys(speciesStarters)) {
const species = getPokemonSpecies(parseInt(s));
loadPokemonAssets.push(species.loadAssets(this, false, 0, false));
}
for (let s of Object.keys(speciesStarters)) {
const species = getPokemonSpecies(parseInt(s));
loadPokemonAssets.push(species.loadAssets(this, false, 0, false));
}
Promise.all(loadPokemonAssets).then(() => {
const starterCandyColors = {};
const rgbaToHexFunc = (r, g, b) => [r, g, b].map(x => x.toString(16).padStart(2, '0')).join('');
Promise.all(loadPokemonAssets).then(() => {
const starterCandyColors = {};
const rgbaToHexFunc = (r, g, b) => [r, g, b].map(x => x.toString(16).padStart(2, '0')).join('');
for (let s of Object.keys(speciesStarters)) {
const species = getPokemonSpecies(parseInt(s));
for (let s of Object.keys(speciesStarters)) {
const species = getPokemonSpecies(parseInt(s));
starterCandyColors[species.speciesId] = species.generateCandyColors(this).map(c => rgbaToHexFunc(c[0], c[1], c[2]));
}
starterCandyColors[species.speciesId] = species.generateCandyColors(this).map(c => rgbaToHexFunc(c[0], c[1], c[2]));
}
console.log(JSON.stringify(starterCandyColors));
console.log(JSON.stringify(starterCandyColors));
resolve();
});*/
resolve();
});*/

resolve();
});
Expand Down Expand Up @@ -682,6 +690,16 @@ export default class BattleScene extends SceneBase {
: ret;
}

// store info toggles to be accessible by the ui
addInfoToggle(infoToggle: InfoToggle): void {
this.infoToggles.push(infoToggle);
}

// return the stored info toggles; used by ui-inputs
getInfoToggles(activeOnly: boolean = false): InfoToggle[] {
return activeOnly ? this.infoToggles.filter(t => t?.isActive()) : this.infoToggles;
}

getPokemonById(pokemonId: integer): Pokemon {
const findInParty = (party: Pokemon[]) => party.find(p => p.id === pokemonId);
return findInParty(this.getParty()) || findInParty(this.getEnemyParty());
Expand Down Expand Up @@ -728,7 +746,7 @@ export default class BattleScene extends SceneBase {
const container = this.add.container(x, y);

const icon = this.add.sprite(0, 0, pokemon.getIconAtlasKey(ignoreOverride));
icon.setFrame(pokemon.getIconId(true));
icon.setFrame(pokemon.getIconId(true));
// Temporary fix to show pokemon's default icon if variant icon doesn't exist
if (icon.frame.name !== pokemon.getIconId(true)) {
console.log(`${pokemon.name}'s variant icon does not exist. Replacing with default.`);
Expand Down Expand Up @@ -1336,7 +1354,7 @@ export default class BattleScene extends SceneBase {
return;
}
const formattedMoney =
this.moneyFormat === MoneyFormat.ABBREVIATED ? Utils.formatFancyLargeNumber(this.money, 3) : this.money.toLocaleString();
this.moneyFormat === MoneyFormat.ABBREVIATED ? Utils.formatFancyLargeNumber(this.money, 3) : this.money.toLocaleString();
this.moneyText.setText(`₽${formattedMoney}`);
this.fieldUI.moveAbove(this.moneyText, this.luckText);
if (forceVisible) {
Expand Down Expand Up @@ -1926,7 +1944,7 @@ export default class BattleScene extends SceneBase {
const newItemModifier = itemModifier.clone() as PokemonHeldItemModifier;
newItemModifier.pokemonId = target.id;
const matchingModifier = target.scene.findModifier(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).matchType(itemModifier) && m.pokemonId === target.id, target.isPlayer()) as PokemonHeldItemModifier;
&& (m as PokemonHeldItemModifier).matchType(itemModifier) && m.pokemonId === target.id, target.isPlayer()) as PokemonHeldItemModifier;
let removeOld = true;
if (matchingModifier) {
const maxStackCount = matchingModifier.getMaxStackCount(target.scene);
Expand Down Expand Up @@ -2030,8 +2048,8 @@ export default class BattleScene extends SceneBase {
}

/**
* Removes all modifiers from enemy of PersistentModifier type
*/
* Removes all modifiers from enemy of PersistentModifier type
*/
clearEnemyModifiers(): void {
const modifiersToRemove = this.enemyModifiers.filter(m => m instanceof PersistentModifier);
for (const m of modifiersToRemove) {
Expand All @@ -2041,8 +2059,8 @@ export default class BattleScene extends SceneBase {
}

/**
* Removes all modifiers from enemy of PokemonHeldItemModifier type
*/
* Removes all modifiers from enemy of PokemonHeldItemModifier type
*/
clearEnemyHeldItemModifiers(): void {
const modifiersToRemove = this.enemyModifiers.filter(m => m instanceof PokemonHeldItemModifier);
for (const m of modifiersToRemove) {
Expand Down
1 change: 1 addition & 0 deletions src/loading-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export class LoadingScene extends SceneBase {
this.loadImage("summary_stats_overlay_exp", "ui");
this.loadImage("summary_moves", "ui");
this.loadImage("summary_moves_effect", "ui");
this.loadImage("summary_moves_effect_type", "ui");
this.loadImage("summary_moves_overlay_row", "ui");
this.loadImage("summary_moves_overlay_pp", "ui");
this.loadAtlas("summary_moves_cursor", "ui");
Expand Down
4 changes: 4 additions & 0 deletions src/locales/de/modifier-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export const modifierType: ModifierTypeTranslationEntries = {
name: "TM{{moveId}} - {{moveName}}",
description: "Bringt einem Pokémon {{moveName}} bei",
},
"TmModifierTypeWithInfo": {
name: "TM{{moveId}} - {{moveName}}",
description: "Bringt einem Pokémon {{moveName}} bei\n(Halte C oder Shift für mehr Infos)",
},
"EvolutionItemModifierType": {
description: "Erlaubt es bestimmten Pokémon sich zu entwickeln",
},
Expand Down
4 changes: 4 additions & 0 deletions src/locales/en/modifier-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export const modifierType: ModifierTypeTranslationEntries = {
name: "TM{{moveId}} - {{moveName}}",
description: "Teach {{moveName}} to a Pokémon",
},
"TmModifierTypeWithInfo": {
name: "TM{{moveId}} - {{moveName}}",
description: "Teach {{moveName}} to a Pokémon\n(Hold C or Shift for more info)",
},
"EvolutionItemModifierType": {
description: "Causes certain Pokémon to evolve",
},
Expand Down
4 changes: 4 additions & 0 deletions src/locales/es/modifier-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export const modifierType: ModifierTypeTranslationEntries = {
name: "MT{{moveId}} - {{moveName}}",
description: "Enseña {{moveName}} a un Pokémon",
},
"TmModifierTypeWithInfo": {
name: "MT{{moveId}} - {{moveName}}",
description: "Enseña {{moveName}} a un Pokémon\n(Hold C or Shift for more info)",
},
"EvolutionItemModifierType": {
description: "Hace que ciertos Pokémon evolucionen",
},
Expand Down
4 changes: 4 additions & 0 deletions src/locales/fr/modifier-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export const modifierType: ModifierTypeTranslationEntries = {
name: "CT{{moveId}} - {{moveName}}",
description: "Apprend la capacité {{moveName}} à un Pokémon",
},
"TmModifierTypeWithInfo": {
name: "CT{{moveId}} - {{moveName}}",
description: "Apprend la capacité {{moveName}} à un Pokémon\n(Hold C or Shift for more info)",
},
"EvolutionItemModifierType": {
description: "Permet à certains Pokémon d’évoluer",
},
Expand Down
4 changes: 4 additions & 0 deletions src/locales/it/modifier-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export const modifierType: ModifierTypeTranslationEntries = {
name: "MT{{moveId}} - {{moveName}}",
description: "Insegna {{moveName}} a un Pokémon",
},
"TmModifierTypeWithInfo": {
name: "MT{{moveId}} - {{moveName}}",
description: "Insegna {{moveName}} a un Pokémon\n(Hold C or Shift for more info)",
},
"EvolutionItemModifierType": {
description: "Fa evolvere determinate specie di Pokémon",
},
Expand Down
4 changes: 4 additions & 0 deletions src/locales/ko/modifier-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export const modifierType: ModifierTypeTranslationEntries = {
name: "No.{{moveId}} {{moveName}}",
description: "포켓몬에게 {{moveName}}[[를]] 가르침",
},
"TmModifierTypeWithInfo": {
name: "No.{{moveId}} {{moveName}}",
description: "포켓몬에게 {{moveName}}를(을) 가르침\n(Hold C or Shift for more info)",
},
"EvolutionItemModifierType": {
description: "어느 특정 포켓몬을 진화",
},
Expand Down
4 changes: 4 additions & 0 deletions src/locales/pt_BR/modifier-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export const modifierType: ModifierTypeTranslationEntries = {
name: "TM{{moveId}} - {{moveName}}",
description: "Ensina {{moveName}} a um Pokémon",
},
"TmModifierTypeWithInfo": {
name: "TM{{moveId}} - {{moveName}}",
description: "Ensina {{moveName}} a um Pokémon\n(Hold C or Shift for more info)",
},
"EvolutionItemModifierType": {
description: "Faz certos Pokémon evoluírem",
},
Expand Down
4 changes: 4 additions & 0 deletions src/locales/zh_CN/modifier-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export const modifierType: ModifierTypeTranslationEntries = {
name: "招式学习器 {{moveId}} - {{moveName}}",
description: "教会一只宝可梦{{moveName}}",
},
"TmModifierTypeWithInfo": {
name: "招式学习器 {{moveId}} - {{moveName}}",
description: "教会一只宝可梦{{moveName}}\n(Hold C or Shift for more info)",
},
"EvolutionItemModifierType": {
description: "使某些宝可梦进化",
},
Expand Down
4 changes: 4 additions & 0 deletions src/locales/zh_TW/modifier-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export const modifierType: ModifierTypeTranslationEntries = {
name: "招式學習器 {{moveId}} - {{moveName}}",
description: "教會一隻寶可夢{{moveName}}",
},
TmModifierTypeWithInfo: {
name: "TM{{moveId}} - {{moveName}}",
description: "教會一隻寶可夢{{moveName}}\n(Hold C or Shift for more info)",
},
EvolutionItemModifierType: { description: "使某些寶可夢進化" },
FormChangeItemModifierType: { description: "使某些寶可夢更改形態" },
FusePokemonModifierType: {
Expand Down
11 changes: 10 additions & 1 deletion src/modifier/modifier-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ModifierTier } from "./modifier-tier";
import { Nature, getNatureName, getNatureStatMultiplier } from "#app/data/nature";
import i18next from "#app/plugins/i18n";
import { getModifierTierTextTint } from "#app/ui/text";
import * as Overrides from "../overrides";

const outputModifierData = false;
const useMaxWeightForOutput = false;
Expand Down Expand Up @@ -721,7 +722,7 @@ export class TmModifierType extends PokemonModifierType {
}

getDescription(scene: BattleScene): string {
return i18next.t("modifierType:ModifierType.TmModifierType.description", { moveName: allMoves[this.moveId].name });
return i18next.t(scene.enableMoveInfo ? "modifierType:ModifierType.TmModifierTypeWithInfo.description" : "modifierType:ModifierType.TmModifierType.description", { moveName: allMoves[this.moveId].name });
}
}

Expand Down Expand Up @@ -1673,6 +1674,14 @@ export function getPlayerModifierTypeOptions(count: integer, party: PlayerPokemo
}
options.push(candidate);
});
// OVERRIDE IF NECESSARY
if (Overrides.ITEM_REWARD_OVERRIDE?.length) {
options.forEach((mod, i) => {
// @ts-ignore: keeps throwing don't use string as index error in typedoc run
const override = modifierTypes[Overrides.ITEM_REWARD_OVERRIDE[i]]?.();
mod.type = (override instanceof ModifierTypeGenerator ? override.generateType(party) : override) || mod.type;
});
}
return options;
}

Expand Down
8 changes: 8 additions & 0 deletions src/overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,11 @@ export const OPP_MODIFIER_OVERRIDE: Array<ModifierOverride> = [];

export const STARTING_HELD_ITEMS_OVERRIDE: Array<ModifierOverride> = [];
export const OPP_HELD_ITEMS_OVERRIDE: Array<ModifierOverride> = [];

/**
* An array of items by keys as defined in the "modifierTypes" object in the "modifier/modifier-type.ts" file.
* Items listed will replace the normal rolls.
* If less items are listed than rolled, only some items will be replaced
* If more items are listed than rolled, only the first X items will be shown, where X is the number of items rolled.
*/
export const ITEM_REWARD_OVERRIDE: Array<String> = [];
11 changes: 11 additions & 0 deletions src/system/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const SettingKeys = {
UI_Theme: "UI_THEME",
Window_Type: "WINDOW_TYPE",
Tutorials: "TUTORIALS",
Move_Info: "MOVE_INFO",
Enable_Retries: "ENABLE_RETRIES",
Skip_Seen_Dialogues: "SKIP_SEEN_DIALOGUES",
Candy_Upgrade_Notification: "CANDY_UPGRADE_NOTIFICATION",
Expand Down Expand Up @@ -132,6 +133,13 @@ export const Setting: Array<Setting> = [
default: 1,
type: SettingType.GENERAL
},
{
key: SettingKeys.Move_Info,
label: "Move Info",
options: OFF_ON,
default: 1,
type: SettingType.ACCESSIBILITY
},
{
key: SettingKeys.Enable_Retries,
label: "Enable Retries",
Expand Down Expand Up @@ -312,6 +320,9 @@ export function setSetting(scene: BattleScene, setting: string, value: integer):
case SettingKeys.Tutorials:
scene.enableTutorials = Setting[index].options[value] === "On";
break;
case SettingKeys.Move_Info:
scene.enableMoveInfo = Setting[index].options[value] === "On";
break;
case SettingKeys.Enable_Retries:
scene.enableRetries = Setting[index].options[value] === "On";
break;
Expand Down
5 changes: 5 additions & 0 deletions src/ui-inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ export class UiInputs {
}

buttonStats(pressed: boolean = true): void {
// allow access to Button.STATS as a toggle for other elements
for (const t of this.scene.getInfoToggles(true)) {
t.toggleInfo(pressed);
}
// handle normal pokemon battle ui
for (const p of this.scene.getField().filter(p => p?.isActive(true))) {
p.toggleStats(pressed);
}
Expand Down
Loading

0 comments on commit 037cda5

Please sign in to comment.