mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
Merge branch 'feature/game-achievements' into chore/test-preview
# Conflicts: # yarn.lock
This commit is contained in:
commit
8b5ed96e9b
11 changed files with 82 additions and 51 deletions
|
|
@ -6,7 +6,7 @@ export const checkUnlockedAchievements = (
|
|||
unlockedAchievements: any
|
||||
): UnlockedAchievement[] => {
|
||||
if (type === Cracker.onlineFix) return onlineFixMerge(unlockedAchievements);
|
||||
if (type === Cracker.goldberg)
|
||||
if (type === Cracker.goldberg || type === Cracker.goldberg2)
|
||||
return goldbergUnlockedAchievements(unlockedAchievements);
|
||||
if (type == Cracker.generic) return genericMerge(unlockedAchievements);
|
||||
return defaultMerge(unlockedAchievements);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,15 @@ import { Game } from "@main/entity";
|
|||
const publicDir = path.join("C:", "Users", "Public", "Documents");
|
||||
const appData = app.getPath("appData");
|
||||
|
||||
const crackers = [
|
||||
Cracker.codex,
|
||||
Cracker.goldberg,
|
||||
Cracker.goldberg2,
|
||||
Cracker.rune,
|
||||
Cracker.onlineFix,
|
||||
Cracker.generic,
|
||||
];
|
||||
|
||||
const addGame = (
|
||||
achievementFiles: Map<string, AchievementFile[]>,
|
||||
achievementPath: string,
|
||||
|
|
@ -39,14 +48,6 @@ const getObjectIdsInFolder = (path: string) => {
|
|||
};
|
||||
|
||||
export const findSteamGameAchievementFiles = (game: Game) => {
|
||||
const crackers = [
|
||||
Cracker.codex,
|
||||
Cracker.goldberg,
|
||||
Cracker.rune,
|
||||
Cracker.onlineFix,
|
||||
Cracker.generic,
|
||||
];
|
||||
|
||||
const achievementFiles: AchievementFile[] = [];
|
||||
for (const cracker of crackers) {
|
||||
let achievementPath: string;
|
||||
|
|
@ -58,9 +59,9 @@ export const findSteamGameAchievementFiles = (game: Game) => {
|
|||
} else if (cracker === Cracker.goldberg) {
|
||||
achievementPath = path.join(appData, "Goldberg SteamEmu Saves");
|
||||
fileLocation = ["achievements.json"];
|
||||
} else if (cracker === Cracker.generic) {
|
||||
achievementPath = path.join(publicDir, Cracker.generic);
|
||||
fileLocation = ["user_stats.ini"];
|
||||
} else if (cracker === Cracker.goldberg2) {
|
||||
achievementPath = path.join(appData, "GSE Saves");
|
||||
fileLocation = ["achievements.json"];
|
||||
} else {
|
||||
achievementPath = path.join(publicDir, "Steam", cracker);
|
||||
fileLocation = ["achievements.ini"];
|
||||
|
|
@ -102,13 +103,6 @@ export const findAchievementFileInExecutableDirectory = (
|
|||
export const findAllSteamGameAchievementFiles = () => {
|
||||
const gameAchievementFiles = new Map<string, AchievementFile[]>();
|
||||
|
||||
const crackers = [
|
||||
Cracker.codex,
|
||||
Cracker.goldberg,
|
||||
Cracker.rune,
|
||||
Cracker.onlineFix,
|
||||
];
|
||||
|
||||
for (const cracker of crackers) {
|
||||
let achievementPath: string;
|
||||
let fileLocation: string[];
|
||||
|
|
@ -116,6 +110,9 @@ export const findAllSteamGameAchievementFiles = () => {
|
|||
if (cracker === Cracker.onlineFix) {
|
||||
achievementPath = path.join(publicDir, Cracker.onlineFix);
|
||||
fileLocation = ["Stats", "Achievements.ini"];
|
||||
} else if (cracker === Cracker.goldberg2) {
|
||||
achievementPath = path.join(appData, "GSE Saves");
|
||||
fileLocation = ["achievements.json"];
|
||||
} else if (cracker === Cracker.goldberg) {
|
||||
achievementPath = path.join(appData, "Goldberg SteamEmu Saves");
|
||||
fileLocation = ["achievements.json"];
|
||||
|
|
|
|||
|
|
@ -52,7 +52,9 @@ export const mergeAchievements = async (
|
|||
const newAchievements = achievements
|
||||
.filter((achievement) => {
|
||||
return !unlockedAchievements.some((localAchievement) => {
|
||||
return localAchievement.name === achievement.name.toUpperCase();
|
||||
return (
|
||||
localAchievement.name.toUpperCase() === achievement.name.toUpperCase()
|
||||
);
|
||||
});
|
||||
})
|
||||
.map((achievement) => {
|
||||
|
|
@ -64,10 +66,16 @@ export const mergeAchievements = async (
|
|||
|
||||
if (newAchievements.length && publishNotification) {
|
||||
const achievementsInfo = newAchievements
|
||||
.sort((a, b) => {
|
||||
return a.unlockTime - b.unlockTime;
|
||||
})
|
||||
.map((achievement) => {
|
||||
return JSON.parse(localGameAchievement?.achievements || "[]").find(
|
||||
(steamAchievement) => {
|
||||
return achievement.name === steamAchievement.name;
|
||||
return (
|
||||
achievement.name.toUpperCase() ===
|
||||
steamAchievement.name.toUpperCase()
|
||||
);
|
||||
}
|
||||
);
|
||||
})
|
||||
|
|
@ -85,12 +93,6 @@ export const mergeAchievements = async (
|
|||
shop,
|
||||
achievementsInfo
|
||||
);
|
||||
|
||||
WindowManager.notificationWindow?.setBounds({ y: 50 });
|
||||
|
||||
setTimeout(() => {
|
||||
WindowManager.notificationWindow?.setBounds({ y: -9999 });
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
const mergedLocalAchievements = unlockedAchievements.concat(newAchievements);
|
||||
|
|
|
|||
|
|
@ -151,19 +151,21 @@ export class WindowManager {
|
|||
maximizable: false,
|
||||
autoHideMenuBar: true,
|
||||
minimizable: false,
|
||||
focusable: true,
|
||||
focusable: false,
|
||||
skipTaskbar: true,
|
||||
frame: false,
|
||||
width: 240,
|
||||
height: 60,
|
||||
x: 25,
|
||||
y: -9999,
|
||||
y: 25,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, "../preload/index.mjs"),
|
||||
sandbox: false,
|
||||
},
|
||||
});
|
||||
|
||||
this.notificationWindow.setIgnoreMouseEvents(true);
|
||||
this.notificationWindow.webContents.openDevTools();
|
||||
this.notificationWindow.setVisibleOnAllWorkspaces(true, {
|
||||
visibleOnFullScreen: true,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue