From 060ffc67160fff76ccccef64f330aed50005b12f Mon Sep 17 00:00:00 2001 From: Benjamin Odom Date: Thu, 30 May 2024 12:51:58 -0500 Subject: [PATCH] Fix i18next and mobile errors (#1601) --- src/inputs-controller.ts | 4 ++-- src/plugins/i18n.ts | 21 +++++++++++++-------- src/touch-controls.ts | 4 ++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/inputs-controller.ts b/src/inputs-controller.ts index 83d26a83cff..cb7b828f57c 100644 --- a/src/inputs-controller.ts +++ b/src/inputs-controller.ts @@ -1,6 +1,6 @@ import Phaser from "phaser"; import * as Utils from "./utils"; -import {initTouchControls} from "./touch-controls"; +import {ButtonKey, initTouchControls} from "./touch-controls"; import pad_generic from "./configs/pad_generic"; import pad_unlicensedSNES from "./configs/pad_unlicensedSNES"; import pad_xbox360 from "./configs/pad_xbox360"; @@ -357,7 +357,7 @@ export class InputsController { [Button.SPEED_UP]: [keyCodes.PLUS], [Button.SLOW_DOWN]: [keyCodes.MINUS] }; - const mobileKeyConfig = {}; + const mobileKeyConfig = new Map(); for (const b of Utils.getEnumValues(Button)) { const keys: Phaser.Input.Keyboard.Key[] = []; if (keyConfig.hasOwnProperty(b)) { diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 1733b61bb82..06c660434d5 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -80,25 +80,29 @@ export interface Localizable { const alternativeFonts = { "ko": [ - new FontFace("emerald", "url(./fonts/PokePT_Wansung.ttf)") + new FontFace("emerald", "url(./fonts/PokePT_Wansung.ttf)"), ], }; function loadFont(language: string) { - const altFontLanguages = Object.keys(alternativeFonts); if (!alternativeFonts[language]) { language = language.split(/[-_/]/)[0]; } if (alternativeFonts[language]) { - alternativeFonts[language].forEach(f => { - document.fonts.add(f); + alternativeFonts[language].forEach((fontFace: FontFace) => { + document.fonts.add(fontFace); }); + + const altFontLanguages = Object.keys(alternativeFonts); altFontLanguages.splice(altFontLanguages.indexOf(language), 0); } - altFontLanguages.forEach(f=> { - if (f && f.status === "loaded") { - document.fonts.delete(f); - } + + (Object.values(alternativeFonts)).forEach(fontFaces => { + fontFaces.forEach(fontFace => { + if (fontFace && fontFace.status === "loaded") { + document.fonts.delete(fontFace); + } + }); }); } @@ -179,6 +183,7 @@ export function initI18n(): void { // Module declared to make referencing keys in the localization files type-safe. declare module "i18next" { interface CustomTypeOptions { + defaultNS: "menu"; // Even if we don't use it, i18next requires a valid default namespace resources: { menu: SimpleTranslationEntries; menuUiHandler: SimpleTranslationEntries; diff --git a/src/touch-controls.ts b/src/touch-controls.ts index 759d988b61f..d828e709f31 100644 --- a/src/touch-controls.ts +++ b/src/touch-controls.ts @@ -1,9 +1,9 @@ -interface ButtonKey { +export interface ButtonKey { onDown: (opt: object) => void; onUp: (opt: object) => void; } -type ButtonMap = Map; +export type ButtonMap = Map; export const keys = new Map(); export const keysDown = new Map();