pull/726/merge
Lugiad 2024-05-15 18:24:39 +02:00 committed by GitHub
commit 42e5883f76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 6827 additions and 349 deletions

Binary file not shown.

Binary file not shown.

View File

@ -13,4 +13,4 @@ export const pokemonStat: SimpleTranslationEntries = {
"SPDEFshortened": "DéfSp",
"SPD": "Vitesse",
"SPDshortened": "Vit"
} as const;
} as const;

View File

@ -0,0 +1,5 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const abilityTriggers: SimpleTranslationEntries = {
'blockRecoilDamage' : `{{pokemonName}}'s {{abilityName}}\nprotected it from recoil!`,
} as const;

1244
src/locales/jp/ability.ts Normal file

File diff suppressed because it is too large Load Diff

53
src/locales/jp/battle.ts Normal file
View File

@ -0,0 +1,53 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const battle: SimpleTranslationEntries = {
"bossAppeared": "{{bossName}}が あらわれた!",
"trainerAppeared": "{{trainerName}}が\nしょうぶを しかけてきた",
"singleWildAppeared": "あっ! やせいの\n{{pokemonName}}が とびだしてきた!",
"multiWildAppeared": "あっ! やせいの {{pokemonName1}}と\n{{pokemonName2}}が とびだしてきた!",
"playerComeBack": "Come back, {{pokemonName}}!",
"trainerComeBack": "{{trainerName}}は\n{{pokemonName}}を ひっこめた!",
"playerGo": "ゆけっ! {{pokemonName}}",
"trainerGo": "{{trainerName}}は\n{{pokemonName}}を くりだした!",
"switchQuestion": "{{pokemonName}}を\nいれかえますか",
"trainerDefeated": "{{trainerName}}\nとの しょうぶに かった",
"pokemonCaught": "{{pokemonName}}を\nつかまえたぞ",
"pokemon": "ポケモン",
"sendOutPokemon": "がんばれ! {{pokemonName}}",
"hitResultCriticalHit": "きゅうしょに あたった!",
"hitResultSuperEffective": "こうかは ばつぐんだ!",
"hitResultNotVeryEffective": "こうかは いまひとつの ようだ……",
"hitResultNoEffect": "It doesn't affect {{pokemonName}}!",
"hitResultOneHitKO": "いちげき ひっさつ!",
"attackFailed": "しかし うまく きまらなかった!!",
"attackHitsCount": "{{count}}かい あたった!",
"expGain": "{{pokemonName}}は\n{{exp}}けいけんちを もらった!",
"levelUp": "{{pokemonName}}は\nレベル{{level}} に あがった!",
"learnMove": "{{pokemonName}}は あたらしく\n{{moveName}}を おぼえた!",
"learnMovePrompt": "{{pokemonName}}は あたらしく\n{{moveName}}を おぼえたい……",
"learnMoveLimitReached": "しかし {{pokemonName}}は わざを 4つ\nおぼえるので せいいっぱいだ",
"learnMoveReplaceQuestion": "{{moveName}}の かわりに\nほかの わざを わすれさせますか",
"learnMoveStopTeaching": "それでは…… {{moveName}}を\nおぼえるのを あきらめますか",
"learnMoveNotLearned": "{{pokemonName}}は {{moveName}}を\nおぼえずに おわった",
"learnMoveForgetQuestion": "どの わざを\nわすれさせたい",
"learnMoveForgetSuccess": "{{pokemonName}}は {{moveName}}の\nつかいかたを きれいに わすれた",
"levelCapUp": "The level cap\nhas increased to {{levelCap}}!",
"moveNotImplemented": "{{moveName}} is not yet implemented and cannot be selected.",
"moveNoPP": "しかし わざの\nのこりポイントが なかった",
"moveDisabled": "{{moveName}} is disabled!",
"noPokeballForce": "An unseen force\nprevents using Poké Balls.",
"noPokeballTrainer": "You can't catch\nanother trainer's Pokémon!",
"noPokeballMulti": "You can only throw a Poké Ball\nwhen there is one Pokémon remaining!",
"noPokeballStrong": "The target Pokémon is too strong to be caught!\nYou need to weaken it first!",
"noEscapeForce": "An unseen force\nprevents escape.",
"noEscapeTrainer": "ダメだ! しょうぶのさいちゅうに\nあいてに せなかを みせられない",
"noEscapePokemon": "{{pokemonName}}'s {{moveName}}\nprevents {{escapeVerb}}!",
"runAwaySuccess": " うまく にげきれた!",
"runAwayCannotEscape": "にげることが できない!",
"escapeVerbSwitch": "switching",
"escapeVerbFlee": "fleeing",
"notDisabled": "{{pokemonName}}'s {{moveName}} is disabled\nno more!",
"skipItemQuestion": "Are you sure you want to skip taking an item?",
"eggHatching": "Oh?",
"ivScannerUseQuestion": "Use IV Scanner on {{pokemonName}}?"
} as const;

View File

@ -0,0 +1,9 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const commandUiHandler: SimpleTranslationEntries = {
"fight": "たたかう",
"ball": "ボール",
"pokemon": "ポケモン",
"run": "にげる",
"actionMessage": "{{pokemonName}}は どうする?",
} as const;

34
src/locales/jp/config.ts Normal file
View File

@ -0,0 +1,34 @@
import { ability } from "./ability";
import { abilityTriggers } from "./ability-trigger";
import { battle } from "./battle";
import { commandUiHandler } from "./command-ui-handler";
import { fightUiHandler } from "./fight-ui-handler";
import { growth } from "./growth";
import { menu } from "./menu";
import { menuUiHandler } from "./menu-ui-handler";
import { move } from "./move";
import { nature } from "./nature";
import { pokeball } from "./pokeball";
import { pokemon } from "./pokemon";
import { pokemonStat } from "./pokemon-stat";
import { starterSelectUiHandler } from "./starter-select-ui-handler";
import { tutorial } from "./tutorial";
export const jpConfig = {
ability: ability,
abilityTriggers: abilityTriggers,
battle: battle,
commandUiHandler: commandUiHandler,
fightUiHandler: fightUiHandler,
menuUiHandler: menuUiHandler,
menu: menu,
move: move,
pokeball: pokeball,
pokemonStat: pokemonStat,
pokemon: pokemon,
starterSelectUiHandler: starterSelectUiHandler,
tutorial: tutorial,
nature: nature,
growth: growth
}

View File

@ -0,0 +1,7 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const fightUiHandler: SimpleTranslationEntries = {
"pp": "PP",
"power": "いりょく",
"accuracy": "めいちゅう",
} as const;

10
src/locales/jp/growth.ts Normal file
View File

@ -0,0 +1,10 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const growth: SimpleTranslationEntries = {
"Erratic": "60まんタイプ",
"Fast": "80まんタイプ",
"Medium_Fast": "100まんタイプ",
"Medium_Slow": "105まんタイプ",
"Slow": "125まんタイプ",
"Fluctuating": "164まんタイプ"
} as const;

View File

@ -0,0 +1,23 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const menuUiHandler: SimpleTranslationEntries = {
"GAME_SETTINGS": "せってい",
"ACHIEVEMENTS": "じっせき",
"STATS": "とうけい",
"VOUCHERS": "クーポン",
"EGG_LIST": "タマゴリスト",
"EGG_GACHA": "タマゴガチャ",
"MANAGE_DATA": "データかんり",
"COMMUNITY": "コミュニティ",
"SAVE_AND_QUIT": "Save and Quit",
"LOG_OUT": "ログアウト",
"slot": "スロット {{slotNumber}}",
"importSession": "セッションのインポート",
"importSlotSelect": "Select a slot to import to.",
"exportSession": "セッションのエクスポート",
"exportSlotSelect": "Select a slot to export from.",
"importData": "データのインポート",
"exportData": "データのエクスポート",
"cancel": "キャンセル",
"losingProgressionWarning": "You will lose any progress since the beginning of the battle. Proceed?"
} as const;

46
src/locales/jp/menu.ts Normal file
View File

@ -0,0 +1,46 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
/**
* The menu namespace holds most miscellaneous text that isn't directly part of the game's
* contents or directly related to Pokemon data. This includes menu navigation, settings,
* account interactions, descriptive text, etc.
*/
export const menu: SimpleTranslationEntries = {
"cancel": "キャンセル",
"continue": "つづきから",
"dailyRun": "Daily Run (Beta)",
"loadGame": "ロードセーブ",
"newGame": "はじめから",
"selectGameMode": "Select a game mode.",
"logInOrCreateAccount": "Log in or create an account to start. No email required!",
"username": "ユーザーめい",
"password": "パスワード",
"login": "ログイン",
"register": "かいいん とうろく",
"emptyUsername": "Username must not be empty",
"invalidLoginUsername": "The provided username is invalid",
"invalidRegisterUsername": "Username must only contain letters, numbers, or underscores",
"invalidLoginPassword": "The provided password is invalid",
"invalidRegisterPassword": "Password must be 6 characters or longer",
"usernameAlreadyUsed": "The provided username is already in use",
"accountNonExistent": "The provided user does not exist",
"unmatchingPassword": "The provided password does not match",
"passwordNotMatchingConfirmPassword": "Password must match confirm password",
"confirmPassword": "Confirm Password",
"registrationAgeWarning": "By registering, you confirm you are of 13 years of age or older.",
"backToLogin": "ログインへ",
"failedToLoadSaveData": "Failed to load save data. Please reload the page.\nIf this continues, please contact the administrator.",
"sessionSuccess": "Session loaded successfully.",
"failedToLoadSession": "Your session data could not be loaded.\nIt may be corrupted.",
"boyOrGirl": "おとこのこ?\nそれとも おんなのこ?",
"boy": "おとこ",
"girl": "おんな",
"dailyRankings": "ほんじつのランキング",
"weeklyRankings": "しゅうのランキング",
"noRankings": "ランキングなし",
"loading": "よみこみちゅう…",
"playersOnline": "オンラインのプレイヤー",
"empty":"なし",
"yes":"はい",
"no":"いいえ",
} as const;

3812
src/locales/jp/move.ts Normal file

File diff suppressed because it is too large Load Diff

29
src/locales/jp/nature.ts Normal file
View File

@ -0,0 +1,29 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const nature: SimpleTranslationEntries = {
"Hardy": "がんばりや",
"Lonely": "さみしがり",
"Brave": "ゆうかん",
"Adamant": "いじっぱり",
"Naughty": "やんちゃ",
"Bold": "ずぶとい",
"Docile": "すなお",
"Relaxed": "のんき",
"Impish": "わんぱく",
"Lax": "のうてんき",
"Timid": "おくびょう",
"Hasty": "せっかち",
"Serious": "まじめ",
"Jolly": "ようき",
"Naive": "むじゃき",
"Modest": "ひかえめ",
"Mild": "おっとり",
"Quiet": "れいせい",
"Bashful": "てれや",
"Rash": "うっかりや",
"Calm": "おだやか",
"Gentle": "おとなしい",
"Sassy": "なまいき",
"Careful": "しんちょう",
"Quirky": "きまぐれ"
} as const;

View File

@ -0,0 +1,10 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const pokeball: SimpleTranslationEntries = {
"pokeBall": "モンスターボール",
"greatBall": "スーパーボール",
"ultraBall": "ハイパーボール",
"rogueBall": "ローグボール",
"masterBall": "マスターボール",
"luxuryBall": "ゴージャスボール",
} as const;

View File

@ -0,0 +1,16 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const pokemonStat: SimpleTranslationEntries = {
"HP": "HP",
"HPshortened": "HP",
"ATK": "こうげき",
"ATKshortened": "こうげき",
"DEF": "ぼうぎょ",
"DEFshortened": "ぼうぎょ",
"SPATK": "とくこう",
"SPATKshortened": "とくこう",
"SPDEF": "とくぼう",
"SPDEFshortened": "とくぼう",
"SPD": "すばやさ",
"SPDshortened": "すばやさ"
} as const;

1086
src/locales/jp/pokemon.ts Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,44 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
/**
* The menu namespace holds most miscellaneous text that isn't directly part of the game's
* contents or directly related to Pokemon data. This includes menu navigation, settings,
* account interactions, descriptive text, etc.
*/
export const starterSelectUiHandler: SimpleTranslationEntries = {
"confirmStartTeam":'Begin with these Pokémon?',
"gen1": "I",
"gen2": "II",
"gen3": "III",
"gen4": "IV",
"gen5": "V",
"gen6": "VI",
"gen7": "VII",
"gen8": "VIII",
"gen9": "IX",
"growthRate": "けいけんちタイプ:",
"ability": "とくせい:",
"passive": "パッシブ:",
"nature": "せいかく:",
"eggMoves": 'タマゴわざ',
"start": "はじめる",
"addToParty": "えらぶ",
"toggleIVs": "こたいちを ひょうじ",
"manageMoves": "わざを ならびかえ",
"useCandies": "アメを つかう",
"selectMoveSwapOut": "Select a move to swap out.",
"selectMoveSwapWith": "Select a move to swap with",
"unlockPassive": "パッシブを かいほうする",
"reduceCost": "ポケモンの コストを さくげんする",
"cycleShiny": "R: Cycle Shiny",
"cycleForm": 'F: Cycle Form',
"cycleGender": 'G: Cycle Gender',
"cycleAbility": 'E: Cycle Ability',
"cycleNature": 'N: Cycle Nature',
"cycleVariant": 'V: Cycle Variant',
"enablePassive": "Enable Passive",
"disablePassive": "Disable Passive",
"locked": "Locked",
"disabled": "Disabled",
"uncaught": "Uncaught"
}

View File

@ -0,0 +1,42 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const tutorial: SimpleTranslationEntries = {
"intro": `Welcome to PokéRogue! This is a battle-focused Pokémon fangame with roguelite elements.
$This game is not monetized and we claim no ownership of Pokémon nor of the copyrighted assets used.
$The game is a work in progress, but fully playable.\nFor bug reports, please use the Discord community.
$If the game runs slowly, please ensure 'Hardware Acceleration' is turned on in your browser settings.`,
"accessMenu": `To access the menu, press M or Escape while awaiting input.\nThe menu contains settings and various features.`,
"menu": `From this menu you can access the settings.
$From the settings you can change game speed, window style, and other options.
$There are also various other features here, so be sure to check them all!`,
"starterSelect": `From this screen, you can select your starters.\nThese are your initial party members.
$Each starter has a value. Your party can have up to\n6 members as long as the total does not exceed 10.
$You can also select gender, ability, and form depending on\nthe variants you've caught or hatched.
$The IVs for a species are also the best of every one you've\ncaught or hatched, so try to get lots of the same species!`,
"pokerus": `A daily random 3 selectable starters have a purple border.
$If you see a starter you own with one of these,\ntry adding it to your party. Be sure to check its summary!`,
"statChange": `Stat changes persist across battles as long as your Pokémon aren't recalled.
$Your Pokémon are recalled before a trainer battle and before entering a new biome.
$You can also view the stat changes for the Pokémon on the field by holding C or Shift.`,
"selectItem": `After every battle, you are given a choice of 3 random items.\nYou may only pick one.
$These range from consumables, to Pokémon held items, to passive permanent items.
$Most non-consumable item effects will stack in various ways.
$Some items will only show up if they can be used, such as evolution items.
$You can also transfer held items between Pokémon using the transfer option.
$The transfer option will appear in the bottom right once you have obtained a held item.
$You may purchase consumable items with money, and a larger variety will be available the further you get.
$Be sure to buy these before you pick your random item, as it will progress to the next battle once you do.`,
"eggGacha": `From this screen, you can redeem your vouchers for\nPokémon eggs.
$Eggs have to be hatched and get closer to hatching after\nevery battle. Rarer eggs take longer to hatch.
$Hatched Pokémon also won't be added to your party, they will\nbe added to your starters.
$Pokémon hatched from eggs generally have better IVs than\nwild Pokémon.
$Some Pokémon can only even be obtained from eggs.
$There are 3 different machines to pull from with different\nbonuses, so pick the one that suits you best!`,
} as const;

View File

@ -1,117 +1,121 @@
import i18next from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import { deConfig } from '#app/locales/de/config.js';
import { enConfig } from '#app/locales/en/config.js';
import { esConfig } from '#app/locales/es/config.js';
import { frConfig } from '#app/locales/fr/config.js';
import { itConfig } from '#app/locales/it/config.js';
import { ptBrConfig } from '#app/locales/pt_BR/config.js';
import { zhCnConfig } from '#app/locales/zh_CN/config.js';
export interface SimpleTranslationEntries {
[key: string]: string
}
export interface MoveTranslationEntry {
name: string,
effect: string
}
export interface MoveTranslationEntries {
[key: string]: MoveTranslationEntry
}
export interface AbilityTranslationEntry {
name: string,
description: string
}
export interface AbilityTranslationEntries {
[key: string]: AbilityTranslationEntry
}
export interface Localizable {
localize(): void;
}
export function initI18n(): void {
let lang = '';
if (localStorage.getItem('prLang'))
lang = localStorage.getItem('prLang');
/**
* i18next is a localization library for maintaining and using translation resources.
*
* Q: How do I add a new language?
* A: To add a new language, create a new folder in the locales directory with the language code.
* Each language folder should contain a file for each namespace (ex. menu.ts) with the translations.
* Don't forget to declare new language in `supportedLngs` i18next initializer
*
* Q: How do I add a new namespace?
* A: To add a new namespace, create a new file in each language folder with the translations.
* Then update the `resources` field in the init() call and the CustomTypeOptions interface.
*
* Q: How do I make a language selectable in the settings?
* A: In src/system/settings.ts, add a new case to the Setting.Language switch statement.
*/
i18next.use(LanguageDetector).init({
lng: lang,
fallbackLng: 'en',
supportedLngs: ['en', 'es', 'fr', 'it', 'de', 'zh_CN','pt_BR'],
debug: true,
interpolation: {
escapeValue: false,
},
resources: {
en: {
...enConfig
},
es: {
...esConfig
},
fr: {
...frConfig
},
it: {
...itConfig
},
de: {
...deConfig
},
pt_BR: {
...ptBrConfig
},
zh_CN: {
...zhCnConfig
}
},
});
}
// Module declared to make referencing keys in the localization files type-safe.
declare module 'i18next' {
interface CustomTypeOptions {
resources: {
menu: SimpleTranslationEntries;
menuUiHandler: SimpleTranslationEntries;
move: MoveTranslationEntries;
battle: SimpleTranslationEntries;
abilityTriggers: SimpleTranslationEntries;
ability: AbilityTranslationEntries;
pokeball: SimpleTranslationEntries;
pokemon: SimpleTranslationEntries;
pokemonStat: SimpleTranslationEntries;
commandUiHandler: SimpleTranslationEntries;
fightUiHandler: SimpleTranslationEntries;
tutorial: SimpleTranslationEntries;
starterSelectUiHandler: SimpleTranslationEntries;
nature: SimpleTranslationEntries;
growth: SimpleTranslationEntries;
};
}
}
export default i18next;
import i18next from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import { deConfig } from '#app/locales/de/config.js';
import { enConfig } from '#app/locales/en/config.js';
import { esConfig } from '#app/locales/es/config.js';
import { frConfig } from '#app/locales/fr/config.js';
import { itConfig } from '#app/locales/it/config.js';
import { ptBrConfig } from '#app/locales/pt_BR/config.js';
import { zhCnConfig } from '#app/locales/zh_CN/config.js';
import { jpConfig } from '#app/locales/jp/config.js';
export interface SimpleTranslationEntries {
[key: string]: string
}
export interface MoveTranslationEntry {
name: string,
effect: string
}
export interface MoveTranslationEntries {
[key: string]: MoveTranslationEntry
}
export interface AbilityTranslationEntry {
name: string,
description: string
}
export interface AbilityTranslationEntries {
[key: string]: AbilityTranslationEntry
}
export interface Localizable {
localize(): void;
}
export function initI18n(): void {
let lang = '';
if (localStorage.getItem('prLang'))
lang = localStorage.getItem('prLang');
/**
* i18next is a localization library for maintaining and using translation resources.
*
* Q: How do I add a new language?
* A: To add a new language, create a new folder in the locales directory with the language code.
* Each language folder should contain a file for each namespace (ex. menu.ts) with the translations.
* Don't forget to declare new language in `supportedLngs` i18next initializer
*
* Q: How do I add a new namespace?
* A: To add a new namespace, create a new file in each language folder with the translations.
* Then update the `resources` field in the init() call and the CustomTypeOptions interface.
*
* Q: How do I make a language selectable in the settings?
* A: In src/system/settings.ts, add a new case to the Setting.Language switch statement.
*/
i18next.use(LanguageDetector).init({
lng: lang,
fallbackLng: 'en',
supportedLngs: ['en', 'es', 'fr', 'it', 'de', 'zh_CN','pt_BR','jp'],
debug: true,
interpolation: {
escapeValue: false,
},
resources: {
en: {
...enConfig
},
es: {
...esConfig
},
fr: {
...frConfig
},
it: {
...itConfig
},
de: {
...deConfig
},
pt_BR: {
...ptBrConfig
},
zh_CN: {
...zhCnConfig
},
jp: {
...jpConfig
}
},
});
}
// Module declared to make referencing keys in the localization files type-safe.
declare module 'i18next' {
interface CustomTypeOptions {
resources: {
menu: SimpleTranslationEntries;
menuUiHandler: SimpleTranslationEntries;
move: MoveTranslationEntries;
battle: SimpleTranslationEntries;
abilityTriggers: SimpleTranslationEntries;
ability: AbilityTranslationEntries;
pokeball: SimpleTranslationEntries;
pokemon: SimpleTranslationEntries;
pokemonStat: SimpleTranslationEntries;
commandUiHandler: SimpleTranslationEntries;
fightUiHandler: SimpleTranslationEntries;
tutorial: SimpleTranslationEntries;
starterSelectUiHandler: SimpleTranslationEntries;
nature: SimpleTranslationEntries;
growth: SimpleTranslationEntries;
};
}
}
export default i18next;

View File

@ -1,231 +1,235 @@
import SettingsUiHandler from "#app/ui/settings-ui-handler";
import { Mode } from "#app/ui/ui";
import i18next from "i18next";
import BattleScene from "../battle-scene";
import { hasTouchscreen } from "../touch-controls";
import { updateWindowType } from "../ui/ui-theme";
import { PlayerGender } from "./game-data";
export enum Setting {
Game_Speed = "GAME_SPEED",
Master_Volume = "MASTER_VOLUME",
BGM_Volume = "BGM_VOLUME",
SE_Volume = "SE_VOLUME",
Language = "LANGUAGE",
Damage_Numbers = "DAMAGE_NUMBERS",
UI_Theme = "UI_THEME",
Window_Type = "WINDOW_TYPE",
Tutorials = "TUTORIALS",
Enable_Retries = "ENABLE_RETRIES",
Sprite_Set = "SPRITE_SET",
Move_Animations = "MOVE_ANIMATIONS",
Show_Stats_on_Level_Up = "SHOW_LEVEL_UP_STATS",
EXP_Gains_Speed = "EXP_GAINS_SPEED",
EXP_Party_Display = "EXP_PARTY_DISPLAY",
HP_Bar_Speed = "HP_BAR_SPEED",
Fusion_Palette_Swaps = "FUSION_PALETTE_SWAPS",
Player_Gender = "PLAYER_GENDER",
Gamepad_Support = "GAMEPAD_SUPPORT",
Swap_A_and_B = "SWAP_A_B", // Swaps which gamepad button handles ACTION and CANCEL
Touch_Controls = "TOUCH_CONTROLS",
Vibration = "VIBRATION"
}
export interface SettingOptions {
[key: string]: string[]
}
export interface SettingDefaults {
[key: string]: integer
}
export const settingOptions: SettingOptions = {
[Setting.Game_Speed]: ['1x', '1.25x', '1.5x', '2x', '2.5x', '3x', '4x', '5x'],
[Setting.Master_Volume]: new Array(11).fill(null).map((_, i) => i ? (i * 10).toString() : 'Mute'),
[Setting.BGM_Volume]: new Array(11).fill(null).map((_, i) => i ? (i * 10).toString() : 'Mute'),
[Setting.SE_Volume]: new Array(11).fill(null).map((_, i) => i ? (i * 10).toString() : 'Mute'),
[Setting.Language]: ['English', 'Change'],
[Setting.Damage_Numbers]: ['Off', 'Simple', 'Fancy'],
[Setting.UI_Theme]: ['Default', 'Legacy'],
[Setting.Window_Type]: new Array(5).fill(null).map((_, i) => (i + 1).toString()),
[Setting.Tutorials]: ['Off', 'On'],
[Setting.Enable_Retries]: ['Off', 'On'],
[Setting.Sprite_Set]: ['Consistent', 'Mixed Animated'],
[Setting.Move_Animations]: ['Off', 'On'],
[Setting.Show_Stats_on_Level_Up]: ['Off', 'On'],
[Setting.EXP_Gains_Speed]: ['Normal', 'Fast', 'Faster', 'Skip'],
[Setting.EXP_Party_Display]: ['Normal', 'Level Up Notification', 'Skip'],
[Setting.HP_Bar_Speed]: ['Normal', 'Fast', 'Faster', 'Instant'],
[Setting.Fusion_Palette_Swaps]: ['Off', 'On'],
[Setting.Player_Gender]: ['Boy', 'Girl'],
[Setting.Gamepad_Support]: ['Auto', 'Disabled'],
[Setting.Swap_A_and_B]: ['Enabled', 'Disabled'],
[Setting.Touch_Controls]: ['Auto', 'Disabled'],
[Setting.Vibration]: ['Auto', 'Disabled']
};
export const settingDefaults: SettingDefaults = {
[Setting.Game_Speed]: 3,
[Setting.Master_Volume]: 5,
[Setting.BGM_Volume]: 10,
[Setting.SE_Volume]: 10,
[Setting.Language]: 0,
[Setting.Damage_Numbers]: 0,
[Setting.UI_Theme]: 0,
[Setting.Window_Type]: 0,
[Setting.Tutorials]: 1,
[Setting.Enable_Retries]: 0,
[Setting.Sprite_Set]: 0,
[Setting.Move_Animations]: 1,
[Setting.Show_Stats_on_Level_Up]: 1,
[Setting.EXP_Gains_Speed]: 0,
[Setting.EXP_Party_Display]: 0,
[Setting.HP_Bar_Speed]: 0,
[Setting.Fusion_Palette_Swaps]: 1,
[Setting.Player_Gender]: 0,
[Setting.Gamepad_Support]: 0,
[Setting.Swap_A_and_B]: 1, // Set to 'Disabled' by default
[Setting.Touch_Controls]: 0,
[Setting.Vibration]: 0
};
export const reloadSettings: Setting[] = [Setting.UI_Theme, Setting.Language, Setting.Sprite_Set];
export function setSetting(scene: BattleScene, setting: Setting, value: integer): boolean {
switch (setting) {
case Setting.Game_Speed:
scene.gameSpeed = parseFloat(settingOptions[setting][value].replace('x', ''));
break;
case Setting.Master_Volume:
scene.masterVolume = value ? parseInt(settingOptions[setting][value]) * 0.01 : 0;
scene.updateSoundVolume();
break;
case Setting.BGM_Volume:
scene.bgmVolume = value ? parseInt(settingOptions[setting][value]) * 0.01 : 0;
scene.updateSoundVolume();
break;
case Setting.SE_Volume:
scene.seVolume = value ? parseInt(settingOptions[setting][value]) * 0.01 : 0;
scene.updateSoundVolume();
break;
case Setting.Damage_Numbers:
scene.damageNumbersMode = value;
break;
case Setting.UI_Theme:
scene.uiTheme = value;
break;
case Setting.Window_Type:
updateWindowType(scene, parseInt(settingOptions[setting][value]));
break;
case Setting.Tutorials:
scene.enableTutorials = settingOptions[setting][value] === 'On';
break;
case Setting.Enable_Retries:
scene.enableRetries = settingOptions[setting][value] === 'On';
break;
case Setting.Sprite_Set:
scene.experimentalSprites = !!value;
if (value)
scene.initExpSprites();
break;
case Setting.Move_Animations:
scene.moveAnimations = settingOptions[setting][value] === 'On';
break;
case Setting.Show_Stats_on_Level_Up:
scene.showLevelUpStats = settingOptions[setting][value] === 'On';
break;
case Setting.EXP_Gains_Speed:
scene.expGainsSpeed = value;
break;
case Setting.EXP_Party_Display:
scene.expParty = value;
break;
case Setting.HP_Bar_Speed:
scene.hpBarSpeed = value;
break;
case Setting.Fusion_Palette_Swaps:
scene.fusionPaletteSwaps = !!value;
break;
case Setting.Player_Gender:
if (scene.gameData) {
const female = settingOptions[setting][value] === 'Girl';
scene.gameData.gender = female ? PlayerGender.FEMALE : PlayerGender.MALE;
scene.trainer.setTexture(scene.trainer.texture.key.replace(female ? 'm' : 'f', female ? 'f' : 'm'));
} else
return false;
break;
case Setting.Gamepad_Support:
// if we change the value of the gamepad support, we call a method in the inputController to
// activate or deactivate the controller listener
scene.inputController.setGamepadSupport(settingOptions[setting][value] !== 'Disabled');
break;
case Setting.Swap_A_and_B:
scene.abSwapped = settingOptions[setting][value] !== 'Disabled';
break;
case Setting.Touch_Controls:
scene.enableTouchControls = settingOptions[setting][value] !== 'Disabled' && hasTouchscreen();
const touchControls = document.getElementById('touchControls');
if (touchControls)
touchControls.classList.toggle('visible', scene.enableTouchControls);
break;
case Setting.Vibration:
scene.enableVibration = settingOptions[setting][value] !== 'Disabled' && hasTouchscreen();
break;
case Setting.Language:
if (value) {
if (scene.ui) {
const cancelHandler = () => {
scene.ui.revertMode();
(scene.ui.getHandler() as SettingsUiHandler).setOptionCursor(Object.values(Setting).indexOf(Setting.Language), 0, true);
};
const changeLocaleHandler = (locale: string) => {
i18next.changeLanguage(locale);
localStorage.setItem('prLang', locale);
cancelHandler();
scene.reset(true, false, true);
};
scene.ui.setOverlayMode(Mode.OPTION_SELECT, {
options: [
{
label: 'English',
handler: () => changeLocaleHandler('en')
},
{
label: 'Español',
handler: () => changeLocaleHandler('es')
},
{
label: 'Italiano',
handler: () => changeLocaleHandler('it')
},
{
label: 'Français',
handler: () => changeLocaleHandler('fr')
},
{
label: 'Deutsch',
handler: () => changeLocaleHandler('de')
},
{
label: 'Português (BR)',
handler: () => changeLocaleHandler('pt_BR')
},
{
label: '简体中文',
handler: () => changeLocaleHandler('zh_CN')
},
{
label: 'Cancel',
handler: () => cancelHandler()
}
],
maxOptions: 7
});
return false;
}
}
break;
}
return true;
}
import i18next from "i18next";
import BattleScene from "../battle-scene";
import { hasTouchscreen } from "../touch-controls";
import { updateWindowType } from "../ui/ui-theme";
import { PlayerGender } from "./game-data";
import { Mode } from "#app/ui/ui";
import SettingsUiHandler from "#app/ui/settings-ui-handler";
export enum Setting {
Game_Speed = "GAME_SPEED",
Master_Volume = "MASTER_VOLUME",
BGM_Volume = "BGM_VOLUME",
SE_Volume = "SE_VOLUME",
Language = "LANGUAGE",
Damage_Numbers = "DAMAGE_NUMBERS",
UI_Theme = "UI_THEME",
Window_Type = "WINDOW_TYPE",
Tutorials = "TUTORIALS",
Enable_Retries = "ENABLE_RETRIES",
Sprite_Set = "SPRITE_SET",
Move_Animations = "MOVE_ANIMATIONS",
Show_Stats_on_Level_Up = "SHOW_LEVEL_UP_STATS",
EXP_Gains_Speed = "EXP_GAINS_SPEED",
EXP_Party_Display = "EXP_PARTY_DISPLAY",
HP_Bar_Speed = "HP_BAR_SPEED",
Fusion_Palette_Swaps = "FUSION_PALETTE_SWAPS",
Player_Gender = "PLAYER_GENDER",
Gamepad_Support = "GAMEPAD_SUPPORT",
Swap_A_and_B = "SWAP_A_B", // Swaps which gamepad button handles ACTION and CANCEL
Touch_Controls = "TOUCH_CONTROLS",
Vibration = "VIBRATION"
}
export interface SettingOptions {
[key: string]: string[]
}
export interface SettingDefaults {
[key: string]: integer
}
export const settingOptions: SettingOptions = {
[Setting.Game_Speed]: [ '1x', '1.25x', '1.5x', '2x', '2.5x', '3x', '4x', '5x' ],
[Setting.Master_Volume]: new Array(11).fill(null).map((_, i) => i ? (i * 10).toString() : 'Mute'),
[Setting.BGM_Volume]: new Array(11).fill(null).map((_, i) => i ? (i * 10).toString() : 'Mute'),
[Setting.SE_Volume]: new Array(11).fill(null).map((_, i) => i ? (i * 10).toString() : 'Mute'),
[Setting.Language]: [ 'English', 'Change' ],
[Setting.Damage_Numbers]: [ 'Off', 'Simple', 'Fancy' ],
[Setting.UI_Theme]: [ 'Default', 'Legacy' ],
[Setting.Window_Type]: new Array(5).fill(null).map((_, i) => (i + 1).toString()),
[Setting.Tutorials]: [ 'Off', 'On' ],
[Setting.Enable_Retries]: [ 'Off', 'On' ],
[Setting.Sprite_Set]: [ 'Consistent', 'Mixed Animated' ],
[Setting.Move_Animations]: [ 'Off', 'On' ],
[Setting.Show_Stats_on_Level_Up]: [ 'Off', 'On' ],
[Setting.EXP_Gains_Speed]: [ 'Normal', 'Fast', 'Faster', 'Skip' ],
[Setting.EXP_Party_Display]: [ 'Normal', 'Level Up Notification', 'Skip' ],
[Setting.HP_Bar_Speed]: [ 'Normal', 'Fast', 'Faster', 'Instant' ],
[Setting.Fusion_Palette_Swaps]: [ 'Off', 'On' ],
[Setting.Player_Gender]: [ 'Boy', 'Girl' ],
[Setting.Gamepad_Support]: [ 'Auto', 'Disabled' ],
[Setting.Swap_A_and_B]: [ 'Enabled', 'Disabled' ],
[Setting.Touch_Controls]: [ 'Auto', 'Disabled' ],
[Setting.Vibration]: [ 'Auto', 'Disabled' ]
};
export const settingDefaults: SettingDefaults = {
[Setting.Game_Speed]: 3,
[Setting.Master_Volume]: 5,
[Setting.BGM_Volume]: 10,
[Setting.SE_Volume]: 10,
[Setting.Language]: 0,
[Setting.Damage_Numbers]: 0,
[Setting.UI_Theme]: 0,
[Setting.Window_Type]: 0,
[Setting.Tutorials]: 1,
[Setting.Enable_Retries]: 0,
[Setting.Sprite_Set]: 0,
[Setting.Move_Animations]: 1,
[Setting.Show_Stats_on_Level_Up]: 1,
[Setting.EXP_Gains_Speed]: 0,
[Setting.EXP_Party_Display]: 0,
[Setting.HP_Bar_Speed]: 0,
[Setting.Fusion_Palette_Swaps]: 1,
[Setting.Player_Gender]: 0,
[Setting.Gamepad_Support]: 0,
[Setting.Swap_A_and_B]: 1, // Set to 'Disabled' by default
[Setting.Touch_Controls]: 0,
[Setting.Vibration]: 0
};
export const reloadSettings: Setting[] = [ Setting.UI_Theme, Setting.Language, Setting.Sprite_Set ];
export function setSetting(scene: BattleScene, setting: Setting, value: integer): boolean {
switch (setting) {
case Setting.Game_Speed:
scene.gameSpeed = parseFloat(settingOptions[setting][value].replace('x', ''));
break;
case Setting.Master_Volume:
scene.masterVolume = value ? parseInt(settingOptions[setting][value]) * 0.01 : 0;
scene.updateSoundVolume();
break;
case Setting.BGM_Volume:
scene.bgmVolume = value ? parseInt(settingOptions[setting][value]) * 0.01 : 0;
scene.updateSoundVolume();
break;
case Setting.SE_Volume:
scene.seVolume = value ? parseInt(settingOptions[setting][value]) * 0.01 : 0;
scene.updateSoundVolume();
break;
case Setting.Damage_Numbers:
scene.damageNumbersMode = value;
break;
case Setting.UI_Theme:
scene.uiTheme = value;
break;
case Setting.Window_Type:
updateWindowType(scene, parseInt(settingOptions[setting][value]));
break;
case Setting.Tutorials:
scene.enableTutorials = settingOptions[setting][value] === 'On';
break;
case Setting.Enable_Retries:
scene.enableRetries = settingOptions[setting][value] === 'On';
break;
case Setting.Sprite_Set:
scene.experimentalSprites = !!value;
if (value)
scene.initExpSprites();
break;
case Setting.Move_Animations:
scene.moveAnimations = settingOptions[setting][value] === 'On';
break;
case Setting.Show_Stats_on_Level_Up:
scene.showLevelUpStats = settingOptions[setting][value] === 'On';
break;
case Setting.EXP_Gains_Speed:
scene.expGainsSpeed = value;
break;
case Setting.EXP_Party_Display:
scene.expParty = value;
break;
case Setting.HP_Bar_Speed:
scene.hpBarSpeed = value;
break;
case Setting.Fusion_Palette_Swaps:
scene.fusionPaletteSwaps = !!value;
break;
case Setting.Player_Gender:
if (scene.gameData) {
const female = settingOptions[setting][value] === 'Girl';
scene.gameData.gender = female ? PlayerGender.FEMALE : PlayerGender.MALE;
scene.trainer.setTexture(scene.trainer.texture.key.replace(female ? 'm' : 'f', female ? 'f' : 'm'));
} else
return false;
break;
case Setting.Gamepad_Support:
// if we change the value of the gamepad support, we call a method in the inputController to
// activate or deactivate the controller listener
scene.inputController.setGamepadSupport(settingOptions[setting][value] !== 'Disabled');
break;
case Setting.Swap_A_and_B:
scene.abSwapped = settingOptions[setting][value] !== 'Disabled';
break;
case Setting.Touch_Controls:
scene.enableTouchControls = settingOptions[setting][value] !== 'Disabled' && hasTouchscreen();
const touchControls = document.getElementById('touchControls');
if (touchControls)
touchControls.classList.toggle('visible', scene.enableTouchControls);
break;
case Setting.Vibration:
scene.enableVibration = settingOptions[setting][value] !== 'Disabled' && hasTouchscreen();
break;
case Setting.Language:
if (value) {
if (scene.ui) {
const cancelHandler = () => {
scene.ui.revertMode();
(scene.ui.getHandler() as SettingsUiHandler).setOptionCursor(Object.values(Setting).indexOf(Setting.Language), 0, true);
};
const changeLocaleHandler = (locale: string) => {
i18next.changeLanguage(locale);
localStorage.setItem('prLang', locale);
cancelHandler();
scene.reset(true, false, true);
};
scene.ui.setOverlayMode(Mode.OPTION_SELECT, {
options: [
{
label: 'English',
handler: () => changeLocaleHandler('en')
},
{
label: 'Español',
handler: () => changeLocaleHandler('es')
},
{
label: 'Italiano',
handler: () => changeLocaleHandler('it')
},
{
label: 'Français',
handler: () => changeLocaleHandler('fr')
},
{
label: 'Deutsch',
handler: () => changeLocaleHandler('de')
},
{
label: 'Português (BR)',
handler: () => changeLocaleHandler('pt_BR')
},
{
label: '简体中文',
handler: () => changeLocaleHandler('zh_CN')
},
{
label: 'にほんご',
handler: () => changeLocaleHandler('jp')
},
{
label: 'Cancel',
handler: () => cancelHandler()
}
],
maxOptions: 7
});
return false;
}
}
break;
}
return true;
}