From b74d067e5f3c9a84472fad513cc9184ff4f96fd0 Mon Sep 17 00:00:00 2001 From: Trap Date: Wed, 11 Dec 2024 23:44:10 +0100 Subject: [PATCH] chore: full cleanup of the pttr legacy tooltips --- configs/PathToTarkovReloaded/Tooltips.json | 178 --------------------- scripts/extract-legacy-tooltips.js | 122 -------------- src/config.ts | 9 -- src/mod.ts | 24 +-- src/pttr-tooltips.ts | 82 ---------- 5 files changed, 3 insertions(+), 412 deletions(-) delete mode 100644 configs/PathToTarkovReloaded/Tooltips.json delete mode 100644 scripts/extract-legacy-tooltips.js delete mode 100644 src/pttr-tooltips.ts diff --git a/configs/PathToTarkovReloaded/Tooltips.json b/configs/PathToTarkovReloaded/Tooltips.json deleted file mode 100644 index 1f16d6b7..00000000 --- a/configs/PathToTarkovReloaded/Tooltips.json +++ /dev/null @@ -1,178 +0,0 @@ -{ - "comment": "In the locales arrays below, even indexes (including 0) must be locale keywords, and odd indexes are the overwrite locale values.", - "comment": "If you are using the mode that includes the extra trader and specific trader/ stash locations, this should be set to true", - "comment": "If you are using the standard config, this should be set to false", - - "moddedTraderCompat": false, - "additionalLocalesToggle": true, - - "moddedTraderExtracts": [ - "Saferoom Exfil", - "Saferoom (Goblin King)", - "EXFIL_ZB013", - "ZB-1013 Storage Bunker (Broker)" - ], - - "localesToChangeAdditional": [ - "RUAF Roadblock", - "North UN Woods(PeaceKeeper)", - - "un-sec", - "RUAF Roadblock(PeaceKeeper)", - - "Road to Customs", - "Road to Customs to Customs, SniperRoadblock(Skier)", - - "Sniper Roadblock", - "Sniper Roadblock to Shoreline, Road to Customs(Skier)", - - "Smuggler's Boat", - "Shoreline,Woods,Lighthouse(Machine,Artem,Jaeger)", - - "PP Exfil", - "Car (Home,Prapor,Therapist,Rag,Jae,Harry)", - - "South V-Ex", - "Car (Jaeger)", - - "Dorms V-Ex", - "Car (Jaeger)", - - " V-Ex_light", - "Car (Jaeger)", - - "Pier Boat", - "Boat (Machine,Artem)", - - "The Boat", - "Boat (Machine,Artem)", - - "WoodsFactoryGate", - "Gate 0 (Prapor)", - - "Hole Exfil", - "Crossroads (The Machine)", - - "ZB-1012", - "ZB-1012 to Factory, Med tent gate(Mechanic)", - - "ZB-1011", - "Zb-1011 to Factory, Cellars(Mechanic)", - - "ZB-1013", - "ZB-1013 to Factory, Gate 3(Mechanic)", - - "ZB-1014", - "ZB-1014 to Factory, Gate 3(Mechanic)", - - "Outskirts", - "Outskirts to Reserve and Shoreline (Priscillu)", - - "Checkpoint Fence", - "Checkpoint Fence to Woods and Shoreline (Priscillu)", - - "Nakatani_stairs_free_exit", - "Nakatani Basement (Hideout)" - ], - - "localesToChange": [ - "Gate 0", - "Gate 0 (to Customs, Old Gas Gate)", - "Gate 3", - "Gate 3 (to Customs, Factory Far Corner)", - "Gate m", - "Medical Tent (to Woods, Factory Gate)", - - "Outskirts Water", - "Northern Bridge (to Streets, Car)", - "UN Roadblock", - "UN Roadblock (to Customs, RUAF)", - "Factory gate", - "Factory Gate (to Factory, Med Tent)", - - "Old Azs Gate", - "Old Gas Gate (to Factory, Gate 0)", - "Factory Far Corner", - "Factory Far Corner (to Factory, Gate 3)", - "Railroad To Tarkov", - "RR to Tarkov (to Interchange, Railway)", - "Crossroads", - "Crossroads (to Shoreline, Road to Customs)", - "Railroad To Port", - "RR to Port (to Shoreline, Railbridge)", - "Railroad To Military Base", - "RR to Mil Base (to Reserve, Train Station *1way)", - - "NW Exfil", - "Railway (to Customs, RR to Tarkov)", - "SE Exfil", - "Emercom (to Streets, Underpass)", - - "E1", - "Underpass (to Interchange, Emercom)", - "E2", - "Sewer River (to Lab, Sewage Conduit)", - "E4", - "Evac to Mil Base (to Reserve, Checkpoint Fence)", - "E7_car", - "Primorsky Ave Taxi (to Woods, Bridge Car)", - "scav_e1", - "Basement Descent (to Lab, Main Elevator)", - "scav_e2", - "Entrance to Catacombs (to Lab, Parking Gate)", - "scav_e3", - "Vents (to Lab, Vents)", - "scav_e4", - "Manhole (to Reserve, Manhole)", - - "Alpinist", - "Cliff Descent (to Shoreline, N. Cliffs *1way)", - "EXFIL_vent", - "Manhole (to Streets, Manhole)", - "Exit4", - "Checkpoint Fence (to Streets, Evac to Mil Base)", - "EXFIL_Bunker", - "Bunker Hermetic Door (to Shoreline, Checkpoint *1way)", - "EXFIL_BUNKER_D2", - "D-2 (to Woods, Snip er Rock Bunker *1way)", - - "Tunnel", - "Tunnel (to Lighthouse, Side Tunnel)", - "Lighthouse_pass", - "Path to Lighthouse (... you get it)", - "South Fence Passage", - "North Fence Passage (to Reserve, Hole in Wall *1way)", - "Road_at_railbridge", - "Railbridge (to Customs, RR to Port)", - - "Nothern_Checkpoint", - "Northern CP (to Woods, Outskirts)", - " V-ex_light", - "Car Ride Home", - "Shorl_free", - "Path to Shoreline (I swear if you ask)", - "Coastal_South_road", - "Southern Road (to Shoreline, Tunnel)", - "Alpinist_light", - "Mountain Pass (to Shoreline, Path to Shoreline)", - "Tunnel_Shared", - "Side Tunnel (to Shoreline, Tunnel)", - "Scav_Hideout_at_the_grotto", - "Hideout at the Grotto (to Shoreline, Pier Boat)", - - "lab_Elevator_Cargo", - "Cargo Elevator (to Streets, Basement)", - "lab_Elevator_Main", - "Main Elevator (to Streets, Basement)", - "lab_Elevator_med", - "Medical Block Elevator (to Streets, Basement)", - "lab_Hangar_Gate", - "Hangar Gate (to Streets, Catacombs)", - "lab_Parking_Gate", - "Parking Gate (to Streets, Catacombs)", - "lab_Under_Storage_Collector", - "Sewage Conduit (to Streets, Sewer River)", - "lab_Vent", - "Vents (to Streets, Vents)" - ] -} diff --git a/scripts/extract-legacy-tooltips.js b/scripts/extract-legacy-tooltips.js deleted file mode 100644 index d250b807..00000000 --- a/scripts/extract-legacy-tooltips.js +++ /dev/null @@ -1,122 +0,0 @@ -const loadTooltips = tooltipsPath => { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const Tooltips = require(`../configs/${tooltipsPath}/Tooltips.json`); - - const localesToChange = Tooltips.localesToChange ?? []; - const additionalLocales = - (Tooltips.additionalLocalesToggle ? Tooltips.localesToChangeAdditional : []) ?? []; - const moddedLocales = (Tooltips.moddedTraderCompat ? Tooltips.moddedTraderExtracts : []) ?? []; - const allLocales = [...localesToChange, ...additionalLocales, ...moddedLocales]; - - return { allLocales, language: Tooltips.language || 'en' }; -}; - -const localeMappings = { - english: 'en', - en: 'en', - chinese: 'ch', - ch: 'ch', - czech: 'cz', - cz: 'cz', - french: 'fr', - fr: 'fr', - german: 'ge', - ge: 'ge', - hungarian: 'hu', - hu: 'hu', - italian: 'it', - it: 'it', - japanese: 'jp', - jp: 'jp', - korean: 'kr', - kr: 'kr', - polish: 'pl', - pl: 'pl', - portuguese: 'po', - po: 'po', - slovakian: 'sk', - sk: 'sk', - spanish: 'es', - es: 'es', - turkish: 'tu', - tu: 'tu', - russian: 'ru', - ru: 'ru', - romanian: 'ro', - ro: 'ro', -}; - -const getLang = rawLang => { - return localeMappings[rawLang] ?? rawLang ?? 'en'; -}; - -const createExfilConfig = (rawLang, localeValue) => { - const lang = getLang(rawLang); - - return { - displayName: { - // ch: localeValue, - // cz: localeValue, - // en: localeValue, - // 'es-mx': localeValue, - // es: localeValue, - // fr: localeValue, - // ge: localeValue, - // hu: localeValue, - // it: localeValue, - // jp: localeValue, - // kr: localeValue, - // pl: localeValue, - // po: localeValue, - // ro: localeValue, - // ru: localeValue, - // sk: localeValue, - // tu: localeValue, - [lang]: localeValue, - }, - }; -}; - -const isOdd = n => Boolean(n % 2); -const isEven = n => !isOdd(n); - -const extractExfiltrationsConfigFromLocales = (locales, lang) => { - const exfiltrationsConfig = {}; - locales.forEach((localeKey, i) => { - if (isEven(i)) { - const localeValue = locales[i + 1]; - if (exfiltrationsConfig[localeKey]) { - throw new Error(`duplicate found for localeKey ${localeKey}`); - } - exfiltrationsConfig[localeKey] = createExfilConfig(lang, localeValue); - } - }); - return exfiltrationsConfig; -}; - -const mergeConfigs = (configA, configB) => { - const result = {}; - - Object.keys(configA).forEach(exfilName => { - const exfilConfigA = configA[exfilName]; - const exfilConfigB = configB[exfilName]; - result[exfilName] = { - displayName: { - ...exfilConfigA.displayName, - ...exfilConfigB.displayName, - }, - }; - }); - - return result; -}; -void mergeConfigs; - -const Tooltips_EN = loadTooltips('PathToTarkovReloaded'); - -const configEN = extractExfiltrationsConfigFromLocales( - Tooltips_EN.allLocales, - Tooltips_EN.language, -); - -console.log(JSON.stringify(configEN, undefined, 2)); diff --git a/src/config.ts b/src/config.ts index 9a048d1c..9a9e03d8 100644 --- a/src/config.ts +++ b/src/config.ts @@ -192,15 +192,6 @@ export type Config = Omit { - try { - return require(path.join(CONFIGS_DIR, userConfig.selectedConfig, 'Tooltips.json')); - } catch (_err) { - return undefined; - } -}; - class PathToTarkov implements IPreSptLoadMod, IPostSptLoadMod { private packageJson: PackageJson; private config: Config; private spawnConfig: SpawnConfig; - private tooltipsConfig: PathToTarkovReloadedTooltipsConfig | undefined; public logger: ILogger; public debug: (data: string) => void; public container: DependencyContainer; @@ -67,8 +56,6 @@ class PathToTarkov implements IPreSptLoadMod, IPostSptLoadMod { this.config, ); - this.tooltipsConfig = getTooltipsConfig(userConfig); - this.logger = container.resolve('WinstonLogger'); this.debug = this.config.debug ? (data: string) => this.logger.debug(`Path To Tarkov: ${data}`, true) @@ -164,11 +151,6 @@ class PathToTarkov implements IPreSptLoadMod, IPostSptLoadMod { this.pathToTarkovController.tradersAvailabilityService.init(quests); - if (this.tooltipsConfig) { - pathToTarkovReloadedTooltipsConfigCompat(db, this.tooltipsConfig); - this.debug('injected legacy PTTR Tooltips.json file'); - } - const [api, executeOnStartAPICallbacks] = createPathToTarkovAPI( this.pathToTarkovController, this.logger, diff --git a/src/pttr-tooltips.ts b/src/pttr-tooltips.ts deleted file mode 100644 index 7fbeced8..00000000 --- a/src/pttr-tooltips.ts +++ /dev/null @@ -1,82 +0,0 @@ -import type { DatabaseServer } from '@spt/servers/DatabaseServer'; -import type { PathToTarkovReloadedTooltipsConfig } from './config'; - -export const pathToTarkovReloadedTooltipsConfigCompat = ( - db: DatabaseServer, - tooltipsConfig: PathToTarkovReloadedTooltipsConfig, -): void => { - const database = db.getTables(); - const locales = database.locales?.global; - - if (!locales) { - throw new Error('Cannot load locales from db'); - } - - const tooltipLocale = tooltipsConfig.language?.toLowerCase() ?? 'en'; - const localesToChange = tooltipsConfig.localesToChange ?? []; - const localesToChangeAdditional = tooltipsConfig.localesToChangeAdditional ?? []; - const additionalLocalesToggle = tooltipsConfig.additionalLocalesToggle; - const moddedTraderExtracts = tooltipsConfig.moddedTraderExtracts ?? []; - const moddedTraderCompat = tooltipsConfig.moddedTraderCompat; - - // updated to cover all language locales - const updateLocale = (localeObj: Record): void => { - for (let i = 0; i < localesToChange.length; i += 2) { - localeObj[localesToChange[i]] = localesToChange[i + 1]; - } - if (additionalLocalesToggle) { - for (let i = 0; i < localesToChangeAdditional.length; i += 2) { - localeObj[localesToChangeAdditional[i]] = localesToChangeAdditional[i + 1]; - } - } - if (moddedTraderCompat) { - for (let i = 0; i < moddedTraderExtracts.length; i += 2) { - localeObj[moddedTraderExtracts[i]] = moddedTraderExtracts[i + 1]; - } - } - }; - - const localeMappings = { - english: locales.en, - en: locales.en, - chinese: locales.ch, - ch: locales.ch, - czech: locales.cz, - cz: locales.cz, - french: locales.fr, - fr: locales.fr, - german: locales.ge, - ge: locales.ge, - hungarian: locales.hu, - hu: locales.hu, - italian: locales.it, - it: locales.it, - japanese: locales.jp, - jp: locales.jp, - korean: locales.kr, - kr: locales.kr, - polish: locales.pl, - pl: locales.pl, - portuguese: locales.po, - po: locales.po, - slovakian: locales.sk, - sk: locales.sk, - spanish: locales.es, - es: locales.es, - turkish: locales.tu, - tu: locales.tu, - russian: locales.ru, - ru: locales.ru, - romanian: locales.ro, - ro: locales.ro, - }; - - // Get the locale object based on tooltipLocale - const selectedLocale = localeMappings[tooltipLocale as keyof typeof localeMappings]; - - if (!selectedLocale) { - throw new Error(`incorrect language '${tooltipLocale}' found in Tooltips.json`); - } - - updateLocale(selectedLocale); -};