mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-22 18:33:56 +00:00
- Updated `get-library.ts` to include unlocked and total achievement counts for each game. - Removed `library-game-card-detailed.tsx` and its associated styles as part of the refactor. - Enhanced `library-game-card-large.tsx` to display achievements with progress bars. - Modified `library-game-card.scss` and `library-game-card-large.scss` to style the achievements section. - Introduced a new `search-bar` component for filtering the game library. - Implemented fuzzy search functionality in the library view. - Updated `view-options` to improve UI consistency. - Added achievement-related properties to the `LibraryGame` type in `index.ts`. - Created a new `copilot-instructions.md` for project guidelines.
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import type { LibraryGame } from "@types";
|
|
import { registerEvent } from "../register-event";
|
|
import {
|
|
downloadsSublevel,
|
|
gamesShopAssetsSublevel,
|
|
gamesSublevel,
|
|
gameAchievementsSublevel,
|
|
} from "@main/level";
|
|
|
|
const getLibrary = async (): Promise<LibraryGame[]> => {
|
|
return gamesSublevel
|
|
.iterator()
|
|
.all()
|
|
.then((results) => {
|
|
return Promise.all(
|
|
results
|
|
.filter(([_key, game]) => game.isDeleted === false)
|
|
.map(async ([key, game]) => {
|
|
const download = await downloadsSublevel.get(key);
|
|
const gameAssets = await gamesShopAssetsSublevel.get(key);
|
|
|
|
let unlockedAchievementCount = 0;
|
|
let achievementCount = 0;
|
|
|
|
try {
|
|
const achievements = await gameAchievementsSublevel.get(key);
|
|
if (achievements) {
|
|
achievementCount = achievements.achievements.length;
|
|
unlockedAchievementCount =
|
|
achievements.unlockedAchievements.length;
|
|
}
|
|
} catch {
|
|
// No achievements data for this game
|
|
}
|
|
|
|
return {
|
|
id: key,
|
|
...game,
|
|
download: download ?? null,
|
|
unlockedAchievementCount,
|
|
achievementCount,
|
|
// Spread gameAssets last to ensure all image URLs are properly set
|
|
...gameAssets,
|
|
// Preserve custom image URLs from game if they exist
|
|
customIconUrl: game.customIconUrl,
|
|
customLogoImageUrl: game.customLogoImageUrl,
|
|
customHeroImageUrl: game.customHeroImageUrl,
|
|
} as LibraryGame;
|
|
})
|
|
);
|
|
});
|
|
};
|
|
|
|
registerEvent("getLibrary", getLibrary);
|