mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
feat: wine prefix for achievements
This commit is contained in:
parent
36e6a8cef7
commit
22fc95ff53
@ -5,6 +5,7 @@ import { mergeAchievements } from "./merge-achievements";
|
|||||||
import fs, { readdirSync } from "node:fs";
|
import fs, { readdirSync } from "node:fs";
|
||||||
import {
|
import {
|
||||||
findAchievementFileInExecutableDirectory,
|
findAchievementFileInExecutableDirectory,
|
||||||
|
findAchievementFiles,
|
||||||
findAllAchievementFiles,
|
findAllAchievementFiles,
|
||||||
getAlternativeObjectIds,
|
getAlternativeObjectIds,
|
||||||
} from "./find-achivement-files";
|
} from "./find-achivement-files";
|
||||||
@ -53,12 +54,19 @@ const watchAchievementsWithWine = async () => {
|
|||||||
|
|
||||||
if (games.length === 0) return;
|
if (games.length === 0) return;
|
||||||
|
|
||||||
// const user = app.getPath("home").split("/").pop()
|
for (const game of games) {
|
||||||
|
const gameAchievementFiles = findAchievementFiles(game);
|
||||||
|
const achievementFileInsideDirectory =
|
||||||
|
findAchievementFileInExecutableDirectory(game);
|
||||||
|
|
||||||
// for (const game of games) {
|
gameAchievementFiles.push(...achievementFileInsideDirectory);
|
||||||
// }
|
|
||||||
|
|
||||||
// TODO: watch achievements with wine
|
if (!gameAchievementFiles.length) continue;
|
||||||
|
|
||||||
|
for (const file of gameAchievementFiles) {
|
||||||
|
compareFile(game, file);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const watchAchievements = async () => {
|
export const watchAchievements = async () => {
|
||||||
|
@ -6,12 +6,59 @@ import { Cracker } from "@shared";
|
|||||||
import { Game } from "@main/entity";
|
import { Game } from "@main/entity";
|
||||||
import { achievementsLogger } from "../logger";
|
import { achievementsLogger } from "../logger";
|
||||||
|
|
||||||
|
const getAppDataPath = () => {
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
return app.getPath("appData");
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = app.getPath("home").split("/").pop();
|
||||||
|
|
||||||
|
return path.join("drive_c", "users", user || "", "AppData", "Roaming");
|
||||||
|
};
|
||||||
|
|
||||||
|
const getDocumentsPath = () => {
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
return app.getPath("appData");
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = app.getPath("home").split("/").pop();
|
||||||
|
|
||||||
|
return path.join("drive_c", "users", user || "", "Documents");
|
||||||
|
};
|
||||||
|
|
||||||
|
const getPublicDocumentsPath = () => {
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
return app.getPath("appData");
|
||||||
|
}
|
||||||
|
// /media/jackenx/JED2/.newprefix/dosdevices/c:/users/Public/Documents/Steam/CODEX/489830
|
||||||
|
|
||||||
|
return path.join("drive_c", "users", "Public", "Documents");
|
||||||
|
};
|
||||||
|
|
||||||
|
const getLocalAppDataPath = () => {
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
return path.join(appData, "..", "Local");
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = app.getPath("home").split("/").pop();
|
||||||
|
|
||||||
|
return path.join("drive_c", "users", user || "", "AppData", "Local");
|
||||||
|
};
|
||||||
|
|
||||||
|
const getProgramDataPath = () => {
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
return path.join("C:", "ProgramData");
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.join("drive_c", "ProgramData");
|
||||||
|
};
|
||||||
|
|
||||||
//TODO: change to a automatized method
|
//TODO: change to a automatized method
|
||||||
const publicDocuments = path.join("C:", "Users", "Public", "Documents");
|
const publicDocuments = getPublicDocumentsPath();
|
||||||
const programData = path.join("C:", "ProgramData");
|
const programData = getProgramDataPath();
|
||||||
const appData = app.getPath("appData");
|
const appData = getAppDataPath();
|
||||||
const documents = app.getPath("documents");
|
const documents = getDocumentsPath();
|
||||||
const localAppData = path.join(appData, "..", "Local");
|
const localAppData = getLocalAppDataPath();
|
||||||
|
|
||||||
const crackers = [
|
const crackers = [
|
||||||
Cracker.codex,
|
Cracker.codex,
|
||||||
@ -190,7 +237,12 @@ export const findAchievementFiles = (game: Game) => {
|
|||||||
for (const cracker of crackers) {
|
for (const cracker of crackers) {
|
||||||
for (const { folderPath, fileLocation } of getPathFromCracker(cracker)) {
|
for (const { folderPath, fileLocation } of getPathFromCracker(cracker)) {
|
||||||
for (const objectId of getAlternativeObjectIds(game.objectID)) {
|
for (const objectId of getAlternativeObjectIds(game.objectID)) {
|
||||||
const filePath = path.join(folderPath, objectId, ...fileLocation);
|
const filePath = path.join(
|
||||||
|
game.winePrefixPath ?? "",
|
||||||
|
folderPath,
|
||||||
|
objectId,
|
||||||
|
...fileLocation
|
||||||
|
);
|
||||||
|
|
||||||
if (fs.existsSync(filePath)) {
|
if (fs.existsSync(filePath)) {
|
||||||
achievementFiles.push({
|
achievementFiles.push({
|
||||||
@ -216,6 +268,7 @@ export const findAchievementFileInExecutableDirectory = (
|
|||||||
{
|
{
|
||||||
type: Cracker.userstats,
|
type: Cracker.userstats,
|
||||||
filePath: path.join(
|
filePath: path.join(
|
||||||
|
game.winePrefixPath ?? "",
|
||||||
game.executablePath,
|
game.executablePath,
|
||||||
"..",
|
"..",
|
||||||
"SteamData",
|
"SteamData",
|
||||||
@ -225,6 +278,7 @@ export const findAchievementFileInExecutableDirectory = (
|
|||||||
{
|
{
|
||||||
type: Cracker._3dm,
|
type: Cracker._3dm,
|
||||||
filePath: path.join(
|
filePath: path.join(
|
||||||
|
game.winePrefixPath ?? "",
|
||||||
game.executablePath,
|
game.executablePath,
|
||||||
"..",
|
"..",
|
||||||
"3DMGAME",
|
"3DMGAME",
|
||||||
|
Loading…
Reference in New Issue
Block a user