diff --git a/app/components/Combobox.tsx b/app/components/Combobox.tsx index 16dbd516f..dbbf7c7fb 100644 --- a/app/components/Combobox.tsx +++ b/app/components/Combobox.tsx @@ -28,6 +28,7 @@ import { subWeaponImageUrl, } from "~/utils/urls"; import { Image } from "./Image"; +import { weaponAltNames } from "~/modules/in-game-lists/weapon-alt-names"; const MAX_RESULTS_SHOWN = 6; @@ -57,7 +58,7 @@ interface ComboboxProps { } export function Combobox< - T extends Record, + T extends Record >({ options, inputName, @@ -197,11 +198,27 @@ export function WeaponCombobox({ }) { const { t, i18n } = useTranslation("weapons"); + const alt = (id: (typeof mainWeaponIds)[number]) => { + const result: string[] = []; + + if (i18n.language !== "en") { + result.push(t(`MAIN_${id}`, { lng: "en" })); + } + + const altNames = weaponAltNames.get(id); + if (typeof altNames === "string") { + result.push(altNames); + } else if (Array.isArray(altNames)) { + result.push(...altNames); + } + + return result; + }; const idToWeapon = (id: (typeof mainWeaponIds)[number]) => ({ value: String(id), label: t(`MAIN_${id}`), imgPath: mainWeaponImageUrl(id), - alt: i18n.language !== "en" ? [t(`MAIN_${id}`, { lng: "en" })] : undefined, + alt: alt(id), }); return ( @@ -329,7 +346,7 @@ export function GearCombobox({ } const mapPoolEventToOption = ( - e: SerializedMapPoolEvent, + e: SerializedMapPoolEvent ): ComboboxOption> => ({ serializedMapPool: e.serializedMapPool, label: e.name, @@ -357,13 +374,13 @@ export function MapPoolEventsCombobox({ const options = React.useMemo( () => (events ? events.map(mapPoolEventToOption) : []), - [events], + [events] ); // this is important so that we don't trigger the reset to the initialEvent every time const initialOption = React.useMemo( () => initialEvent && mapPoolEventToOption(initialEvent), - [initialEvent], + [initialEvent] ); if (isError) { @@ -384,7 +401,7 @@ export function MapPoolEventsCombobox({ id: parseInt(e.value, 10), name: e.label, serializedMapPool: e.serializedMapPool, - }, + } ); }} className={className} diff --git a/app/modules/in-game-lists/weapon-alt-names.ts b/app/modules/in-game-lists/weapon-alt-names.ts new file mode 100644 index 000000000..1b68808ef --- /dev/null +++ b/app/modules/in-game-lists/weapon-alt-names.ts @@ -0,0 +1,27 @@ +import type { MainWeaponId } from "./types"; + +export const weaponAltNames = new Map() + .set(10, "vjr") + .set(11, "cjr") + .set(21, "nsplash") + .set(41, "ttek") + .set(81, "96d") + .set(91, ["cjs", "cjet"]) + .set(1041, "swex") + .set(1120, "vincent") + .set(2070, "pencil") + .set(3000, "bucket") + .set(3001, "bucket") + .set(4001, "zimi") + .set(4030, "bp") + .set(5001, "napples") + .set(5030, "vds") + .set(5031, "cds") + .set(5040, "detras") + .set(5041, "letras") + .set(6010, "tent") + .set(6011, "tent") + .set(7010, "bow") + .set(8000, ["sword", "chainsaw"]) + .set(8010, ["sword", "vwiper"]) + .set(8011, ["sword", "diper", "dwiper"]);