mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-21 10:03:56 +00:00
feat: add achievements tracking to game library
- 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.
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
downloadsSublevel,
|
||||
gamesShopAssetsSublevel,
|
||||
gamesSublevel,
|
||||
gameAchievementsSublevel,
|
||||
} from "@main/level";
|
||||
|
||||
const getLibrary = async (): Promise<LibraryGame[]> => {
|
||||
@@ -18,10 +19,26 @@ const getLibrary = async (): Promise<LibraryGame[]> => {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user