mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-13 11:42:10 +00:00
feat: add 3dm file inside game directory
This commit is contained in:
parent
94e242168c
commit
5e313a0374
5 changed files with 65 additions and 17 deletions
|
@ -62,9 +62,7 @@ export const checkAchievementFileChange = async (games: Game[]) => {
|
|||
const achievementFileInsideDirectory =
|
||||
findAchievementFileInExecutableDirectory(game);
|
||||
|
||||
if (achievementFileInsideDirectory) {
|
||||
gameAchievementFiles.push(achievementFileInsideDirectory);
|
||||
}
|
||||
gameAchievementFiles.push(...achievementFileInsideDirectory);
|
||||
|
||||
if (!gameAchievementFiles.length) continue;
|
||||
|
||||
|
|
|
@ -136,6 +136,10 @@ const getPathFromCracker = async (cracker: Cracker) => {
|
|||
];
|
||||
}
|
||||
|
||||
if (cracker === Cracker._3dm) {
|
||||
return [];
|
||||
}
|
||||
|
||||
achievementsLogger.error(`Cracker ${cracker} not implemented`);
|
||||
throw new Error(`Cracker ${cracker} not implemented`);
|
||||
};
|
||||
|
@ -163,22 +167,33 @@ export const findAchievementFiles = async (game: Game) => {
|
|||
|
||||
export const findAchievementFileInExecutableDirectory = (
|
||||
game: Game
|
||||
): AchievementFile | null => {
|
||||
): AchievementFile[] => {
|
||||
if (!game.executablePath) {
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
|
||||
const steamDataPath = path.join(
|
||||
return [
|
||||
{
|
||||
type: Cracker.userstats,
|
||||
filePath: path.join(
|
||||
game.executablePath,
|
||||
"..",
|
||||
"SteamData",
|
||||
"user_stats.ini"
|
||||
);
|
||||
|
||||
return {
|
||||
type: Cracker.userstats,
|
||||
filePath: steamDataPath,
|
||||
};
|
||||
),
|
||||
},
|
||||
{
|
||||
type: Cracker._3dm,
|
||||
filePath: path.join(
|
||||
game.executablePath,
|
||||
"..",
|
||||
"3DMGAME",
|
||||
"Player",
|
||||
"stats",
|
||||
"achievements.ini"
|
||||
),
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
export const findAllAchievementFiles = async () => {
|
||||
|
|
|
@ -45,6 +45,11 @@ export const parseAchievementFile = async (
|
|||
return processSkidrow(parsed);
|
||||
}
|
||||
|
||||
if (type === Cracker._3dm) {
|
||||
const parsed = await iniParse(filePath);
|
||||
return process3DM(parsed);
|
||||
}
|
||||
|
||||
achievementsLogger.log(`${type} achievements found on ${filePath}`);
|
||||
return [];
|
||||
};
|
||||
|
@ -139,6 +144,28 @@ const processGoldberg = (unlockedAchievements: any): UnlockedAchievement[] => {
|
|||
return newUnlockedAchievements;
|
||||
};
|
||||
|
||||
const process3DM = (unlockedAchievements: any): UnlockedAchievement[] => {
|
||||
const newUnlockedAchievements: UnlockedAchievement[] = [];
|
||||
|
||||
const achievements = unlockedAchievements["State"];
|
||||
const times = unlockedAchievements["Time"];
|
||||
|
||||
for (const achievement of Object.keys(achievements)) {
|
||||
if (achievements[achievement] == "0101") {
|
||||
const time = times[achievement];
|
||||
|
||||
newUnlockedAchievements.push({
|
||||
name: achievement,
|
||||
unlockTime: new DataView(
|
||||
new Uint8Array(Buffer.from(time.toString(), "hex")).buffer
|
||||
).getUint32(0, true),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return newUnlockedAchievements;
|
||||
};
|
||||
|
||||
const processDefault = (unlockedAchievements: any): UnlockedAchievement[] => {
|
||||
const newUnlockedAchievements: UnlockedAchievement[] = [];
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import { parseAchievementFile } from "./parse-achievement-file";
|
|||
import { mergeAchievements } from "./merge-achievements";
|
||||
import type { UnlockedAchievement } from "@types";
|
||||
import { getGameAchievementData } from "./get-game-achievement-data";
|
||||
import { achievementsLogger } from "../logger";
|
||||
|
||||
export const updateAllLocalUnlockedAchievements = async () => {
|
||||
const gameAchievementFilesMap = await findAllAchievementFiles();
|
||||
|
@ -47,10 +48,16 @@ export const updateAllLocalUnlockedAchievements = async () => {
|
|||
achievementFile.filePath,
|
||||
achievementFile.type
|
||||
);
|
||||
console.log("Parsed for", game.title, parsedAchievements);
|
||||
|
||||
if (parsedAchievements.length) {
|
||||
unlockedAchievements.push(...parsedAchievements);
|
||||
}
|
||||
|
||||
achievementsLogger.log(
|
||||
"Achievement file for",
|
||||
game.title,
|
||||
achievementFile.filePath
|
||||
);
|
||||
}
|
||||
|
||||
mergeAchievements(objectId, "steam", unlockedAchievements, false);
|
||||
|
|
|
@ -35,4 +35,5 @@ export enum Cracker {
|
|||
skidrow = "SKIDROW",
|
||||
creamAPI = "CreamAPI",
|
||||
smartSteamEmu = "SmartSteamEmu",
|
||||
_3dm = "3dm",
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue