mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
Merge branch 'feature/game-achievements' into chore/test-preview
This commit is contained in:
commit
e4ca3d38ec
@ -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,20 +71,32 @@ const getPathFromCracker = async (cracker: Cracker) => {
|
||||
];
|
||||
}
|
||||
|
||||
if (cracker === Cracker.userstats) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (cracker === Cracker.rld) {
|
||||
return [
|
||||
{
|
||||
folderPath: path.join(programData, "RLD!"),
|
||||
fileLocation: ["achievements.ini"],
|
||||
},
|
||||
{
|
||||
folderPath: path.join(programData, "Steam", "Player"),
|
||||
fileLocation: ["achievements.ini"],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
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"],
|
||||
},
|
||||
];
|
||||
}
|
||||
@ -84,28 +111,33 @@ const getPathFromCracker = async (cracker: Cracker) => {
|
||||
folderPath: path.join(documents, "Player"),
|
||||
fileLocation: ["SteamEmu", "UserStats", "achiev.ini"],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
if (cracker === Cracker.codex) {
|
||||
return [
|
||||
{
|
||||
folderPath: path.join(publicDir, "Steam", "CODEX"),
|
||||
fileLocation: ["achievements.ini"],
|
||||
},
|
||||
{
|
||||
folderPath: path.join(appData, "Steam", "CODEX"),
|
||||
fileLocation: ["achievements.ini"],
|
||||
folderPath: path.join(localAppData, "SKIDROW"),
|
||||
fileLocation: ["SteamEmu", "UserStats", "achiev.ini"],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
if (cracker === Cracker.creamAPI) {
|
||||
return [
|
||||
{
|
||||
folderPath: path.join(publicDir, "Steam", cracker),
|
||||
fileLocation: ["achievements.ini"],
|
||||
folderPath: path.join(appData, "CreamAPI"),
|
||||
fileLocation: ["stats", "CreamAPI.Achievements.cfg"],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
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) => {
|
||||
|
@ -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<UnlockedAchievement[]> => {
|
||||
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);
|
||||
}
|
||||
|
||||
if (type === Cracker.skidrow) {
|
||||
const parsed = await iniParse(filePath);
|
||||
return processDefault(parsed);
|
||||
return processSkidrow(parsed);
|
||||
}
|
||||
|
||||
achievementsLogger.log(`${type} achievements found on ${filePath}`);
|
||||
return [];
|
||||
};
|
||||
|
||||
const iniParse = async (filePath: string) => {
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user