diff --git a/src/main/services/achievements/find-achivement-files.ts b/src/main/services/achievements/find-achivement-files.ts index 9a0b2ad3..9057d062 100644 --- a/src/main/services/achievements/find-achivement-files.ts +++ b/src/main/services/achievements/find-achivement-files.ts @@ -4,12 +4,14 @@ import { app } from "electron"; import type { AchievementFile } from "@types"; import { Cracker } from "@shared"; import { Game } from "@main/entity"; +import { achievementsLogger } from "../logger"; //TODO: change to a automatized method -const publicDir = path.join("C:", "Users", "Public", "Documents"); +const publicDocuments = path.join("C:", "Users", "Public", "Documents"); const programData = path.join("C:", "ProgramData"); const appData = app.getPath("appData"); const documents = app.getPath("documents"); +const localAppData = path.join(appData, "..", "Local"); const crackers = [ Cracker.codex, @@ -25,11 +27,24 @@ const crackers = [ ]; const getPathFromCracker = async (cracker: Cracker) => { - if (cracker === Cracker.smartSteamEmu) { + if (cracker === Cracker.codex) { return [ { - folderPath: path.join(appData, "SmartSteamEmu"), - fileLocation: ["User", "Achievements"], + folderPath: path.join(publicDocuments, "Steam", "CODEX"), + fileLocation: ["achievements.ini"], + }, + { + folderPath: path.join(appData, "Steam", "CODEX"), + fileLocation: ["achievements.ini"], + }, + ]; + } + + if (cracker === Cracker.rune) { + return [ + { + folderPath: path.join(publicDocuments, "Steam", "RUNE"), + fileLocation: ["achievements.ini"], }, ]; } @@ -37,7 +52,7 @@ const getPathFromCracker = async (cracker: Cracker) => { if (cracker === Cracker.onlineFix) { return [ { - folderPath: path.join(publicDir, Cracker.onlineFix), + folderPath: path.join(publicDocuments, Cracker.onlineFix), fileLocation: ["Stats", "Achievements.ini"], }, ]; @@ -56,6 +71,10 @@ const getPathFromCracker = async (cracker: Cracker) => { ]; } + if (cracker === Cracker.userstats) { + return []; + } + if (cracker === Cracker.rld) { return [ { @@ -69,11 +88,15 @@ const getPathFromCracker = async (cracker: Cracker) => { ]; } - if (cracker === Cracker.creamAPI) { + if (cracker === Cracker.empress) { return [ { - folderPath: path.join(appData, "CreamAPI"), - fileLocation: ["achievements.ini"], + folderPath: path.join(appData, "EMPRESS", "remote"), + fileLocation: ["achievements.json"], + }, + { + folderPath: path.join(publicDocuments, "EMPRESS", "remote"), + fileLocation: ["achievements.json"], }, ]; } @@ -88,28 +111,33 @@ const getPathFromCracker = async (cracker: Cracker) => { folderPath: path.join(documents, "Player"), fileLocation: ["SteamEmu", "UserStats", "achiev.ini"], }, + { + folderPath: path.join(localAppData, "SKIDROW"), + fileLocation: ["SteamEmu", "UserStats", "achiev.ini"], + }, ]; } - if (cracker === Cracker.codex) { + if (cracker === Cracker.creamAPI) { return [ { - folderPath: path.join(publicDir, "Steam", "CODEX"), - fileLocation: ["achievements.ini"], - }, - { - folderPath: path.join(appData, "Steam", "CODEX"), - fileLocation: ["achievements.ini"], + folderPath: path.join(appData, "CreamAPI"), + fileLocation: ["stats", "CreamAPI.Achievements.cfg"], }, ]; } - return [ - { - folderPath: path.join(publicDir, "Steam", cracker), - fileLocation: ["achievements.ini"], - }, - ]; + if (cracker === Cracker.smartSteamEmu) { + return [ + { + folderPath: path.join(appData, "SmartSteamEmu"), + fileLocation: ["User", "Achievements"], + }, + ]; + } + + achievementsLogger.error(`Cracker ${cracker} not implemented`); + throw new Error(`Cracker ${cracker} not implemented`); }; export const findAchievementFiles = async (game: Game) => { diff --git a/src/main/services/achievements/parse-achievement-file.ts b/src/main/services/achievements/parse-achievement-file.ts index a2fe8f1b..e239c05e 100644 --- a/src/main/services/achievements/parse-achievement-file.ts +++ b/src/main/services/achievements/parse-achievement-file.ts @@ -2,6 +2,7 @@ import { Cracker } from "@shared"; import { UnlockedAchievement } from "@types"; import { existsSync, createReadStream, readFileSync } from "node:fs"; import readline from "node:readline"; +import { achievementsLogger } from "../logger"; export const parseAchievementFile = async ( filePath: string, @@ -9,27 +10,21 @@ export const parseAchievementFile = async ( ): Promise => { if (!existsSync(filePath)) return []; - if (type === Cracker.empress) { - return []; - } - - if (type === Cracker.skidrow) { + if (type == Cracker.codex) { const parsed = await iniParse(filePath); - return processSkidrow(parsed); + return processDefault(parsed); } - if (type === Cracker.smartSteamEmu) { - return []; - } - - if (type === Cracker.creamAPI) { - return []; + if (type == Cracker.rune) { + const parsed = await iniParse(filePath); + return processDefault(parsed); } if (type === Cracker.onlineFix) { const parsed = await iniParse(filePath); return processOnlineFix(parsed); } + if (type === Cracker.goldberg) { const parsed = await jsonParse(filePath); return processGoldberg(parsed); @@ -45,8 +40,13 @@ export const parseAchievementFile = async ( return processRld(parsed); } - const parsed = await iniParse(filePath); - return processDefault(parsed); + if (type === Cracker.skidrow) { + const parsed = await iniParse(filePath); + return processSkidrow(parsed); + } + + achievementsLogger.log(`${type} achievements found on ${filePath}`); + return []; }; const iniParse = async (filePath: string) => { diff --git a/src/main/services/logger.ts b/src/main/services/logger.ts index 1eb7060b..26a8331c 100644 --- a/src/main/services/logger.ts +++ b/src/main/services/logger.ts @@ -29,3 +29,4 @@ log.initialize(); export const pythonInstanceLogger = log.scope("python-instance"); export const logger = log.scope("main"); +export const achievementsLogger = log.scope("achievements");