Merge branch 'main' into feature/rpc

This commit is contained in:
Zamitto 2024-12-18 12:29:07 -03:00 committed by GitHub
commit ad59fcd3e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
33 changed files with 717 additions and 552 deletions

View File

@ -2,7 +2,7 @@
<div align="center">
[<img src="./resources/icon.png" width="144"/>](https://hydralauncher.site)
[<img src="./resources/icon.png" width="144"/>](https://help.hydralauncher.gg)
<h1 align="center">Hydra Launcher</h1>

View File

@ -2,7 +2,7 @@
<div align="center">
[<img src="./resources/icon.png" width="144"/>](https://hydralauncher.site)
[<img src="../resources/icon.png" width="144"/>](https://help.hydralauncher.gg)
<h1 align="center">Hydra Launcher</h1>

View File

@ -2,7 +2,7 @@
<div align="center">
[<img src="./resources/icon.png" width="144"/>](https://hydralauncher.site)
[<img src="./resources/icon.png" width="144"/>](https://help.hydralauncher.gg)
<h1 align="center">Hydra Launcher</h1>

View File

@ -2,7 +2,7 @@
<div align="center">
[<img src="./resources/icon.png" width="144"/>](https://hydralauncher.site)
[<img src="../resources/icon.png" width="144"/>](https://help.hydralauncher.gg)
<h1 align="center">Hydra Launcher</h1>

View File

@ -2,7 +2,7 @@
<div align="center">
[<img src="./resources/icon.png" width="144"/>](https://hydralauncher.site)
[<img src="../resources/icon.png" width="144"/>](https://help.hydralauncher.gg)
<h1 align="center">Hydra Launcher</h1>

View File

@ -2,7 +2,7 @@
<div align="center">
[<img src="./resources/icon.png" width="144"/>](https://hydralauncher.site)
[<img src="./resources/icon.png" width="144"/>](https://help.hydralauncher.gg)
<h1 align="center">Hydra Launcher</h1>

View File

@ -1,6 +1,6 @@
<div align="center">
[<img src="../resources/icon.png" width="144"/>](https://hydralauncher.site)
[<img src="../resources/icon.png" width="144"/>](https://help.hydralauncher.gg)
<h1 align="center">Hydra Launcher</h1>

View File

@ -2,7 +2,7 @@
<div align="center">
[<img src="./resources/icon.png" width="144"/>](https://hydralauncher.site)
[<img src="./resources/icon.png" width="144"/>](https://help.hydralauncher.gg)
<h1 align="center">Hydra Launcher</h1>

View File

@ -2,7 +2,7 @@
<div align="center">
[<img src="./resources/icon.png" width="144"/>](https://hydralauncher.site)
[<img src="./resources/icon.png" width="144"/>](https://help.hydralauncher.gg)
<h1 align="center">Hydra Launcher</h1>

View File

@ -2,7 +2,7 @@
<div align="center">
[<img src="./resources/icon.png" width="144"/>](https://hydralauncher.site)
[<img src="./resources/icon.png" width="144"/>](https://help.hydralauncher.gg)
<h1 align="center">Hydra Launcher</h1>

View File

@ -2,7 +2,7 @@
<div align="center">
[<img src="./resources/icon.png" width="144"/>](https://hydralauncher.site)
[<img src="./resources/icon.png" width="144"/>](https://help.hydralauncher.gg)
<h1 align="center">Hydra Launcher</h1>

View File

@ -2,7 +2,7 @@
<div align="center">
[<img src="./resources/icon.png" width="144"/>](https://hydralauncher.site)
[<img src="../resources/icon.png" width="144"/>](https://help.hydralauncher.gg)
<h1 align="center">Hydra Launcher</h1>

View File

@ -2,7 +2,7 @@
<div align="center">
[<img src="./resources/icon.png" width="144"/>](https://hydralauncher.site)
[<img src="../resources/icon.png" width="144"/>](https://help.hydralauncher.gg)
<h1 align="center">Hydra Launcher</h1>

View File

@ -2,7 +2,7 @@
<div align="center">
[<img src="./resources/icon.png" width="144"/>](https://hydralauncher.site)
[<img src="./resources/icon.png" width="144"/>](https://help.hydralauncher.gg)
<h1 align="center">Hydra Launcher</h1>

View File

@ -34,24 +34,24 @@
"dependencies": {
"@electron-toolkit/preload": "^3.0.0",
"@electron-toolkit/utils": "^3.0.0",
"@fontsource/noto-sans": "^5.0.22",
"@hookform/resolvers": "^3.9.0",
"@fontsource/noto-sans": "^5.1.0",
"@hookform/resolvers": "^3.9.1",
"@primer/octicons-react": "^19.9.0",
"@reduxjs/toolkit": "^2.2.3",
"@vanilla-extract/css": "^1.14.2",
"@vanilla-extract/dynamic": "^2.1.1",
"@vanilla-extract/dynamic": "^2.1.2",
"@vanilla-extract/recipes": "^0.5.2",
"auto-launch": "^5.0.6",
"axios": "^1.7.7",
"better-sqlite3": "^11.3.0",
"axios": "^1.7.9",
"better-sqlite3": "^11.7.0",
"check-disk-space": "^3.4.0",
"classnames": "^2.5.1",
"color": "^4.2.3",
"color.js": "^1.2.0",
"create-desktop-shortcuts": "^1.11.0",
"date-fns": "^3.6.0",
"dexie": "^4.0.9",
"electron-log": "^5.2.0",
"dexie": "^4.0.10",
"electron-log": "^5.2.4",
"electron-updater": "^6.3.9",
"file-type": "^19.6.0",
"flexsearch": "^0.7.43",
@ -72,14 +72,14 @@
"sudo-prompt": "^9.2.1",
"tar": "^7.4.3",
"typeorm": "^0.3.20",
"user-agents": "^1.1.193",
"yaml": "^2.4.1",
"yup": "^1.4.0",
"zod": "^3.23.8"
"user-agents": "^1.1.387",
"yaml": "^2.6.1",
"yup": "^1.5.0",
"zod": "^3.24.1"
},
"devDependencies": {
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@commitlint/cli": "^19.6.0",
"@commitlint/config-conventional": "^19.6.0",
"@electron-toolkit/eslint-config-prettier": "^2.0.0",
"@electron-toolkit/eslint-config-ts": "^2.0.0",
"@electron-toolkit/tsconfig": "^1.0.1",
@ -87,8 +87,8 @@
"@types/auto-launch": "^5.0.5",
"@types/color": "^3.0.6",
"@types/folder-hash": "^4.0.4",
"@types/jsdom": "^21.1.6",
"@types/jsonwebtoken": "^9.0.6",
"@types/jsdom": "^21.1.7",
"@types/jsonwebtoken": "^9.0.7",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.12.7",
"@types/parse-torrent": "^5.8.7",
@ -98,15 +98,15 @@
"@types/user-agents": "^1.0.4",
"@vanilla-extract/vite-plugin": "^4.0.7",
"@vitejs/plugin-react": "^4.2.1",
"electron": "^30.3.0",
"electron": "^31.7.6",
"electron-builder": "^25.1.8",
"electron-vite": "^2.0.0",
"eslint": "^8.56.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^9.0.11",
"prettier": "^3.2.4",
"husky": "^9.1.7",
"prettier": "^3.4.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sass-embedded": "^1.80.6",

View File

@ -258,7 +258,8 @@
"user_unblocked": "User has been unblocked",
"enable_achievement_notifications": "When an achievement is unlocked",
"launch_minimized": "Launch Hydra minimized",
"disable_nsfw_alert": "Disable NSFW alert"
"disable_nsfw_alert": "Disable NSFW alert",
"show_hidden_achievement_description": "Show hidden achievements description before unlocking them"
},
"notifications": {
"download_complete": "Download complete",

View File

@ -254,7 +254,8 @@
"user_unblocked": "Usuário desbloqueado",
"enable_achievement_notifications": "Quando uma conquista é desbloqueada",
"launch_minimized": "Iniciar o Hydra minimizado",
"disable_nsfw_alert": "Desativar alerta de conteúdo inapropriado"
"disable_nsfw_alert": "Desativar alerta de conteúdo inapropriado",
"show_hidden_achievement_description": "Mostrar descrição de conquistas ocultas antes de debloqueá-las"
},
"notifications": {
"download_complete": "Download concluído",

View File

@ -4,12 +4,13 @@
"successfully_signed_in": "Успешный вход"
},
"home": {
"featured": "Рекомендованное",
"featured": "Рекомендации",
"surprise_me": "Удиви меня",
"no_results": "Ничего не найдено",
"hot": "Сейчас в топе",
"start_typing": "Начинаю вводить текст для поиска...",
"weekly": "📅 Лучшие игры недели"
"weekly": "📅 Лучшие игры недели",
"achievements": "🏆 Игры, в которых нужно победить"
},
"sidebar": {
"catalogue": "Каталог",
@ -19,7 +20,7 @@
"downloading_metadata": "{{title}} (Загрузка метаданных…)",
"paused": "{{title}} (Приостановлено)",
"downloading": "{{title}} ({{percentage}} - Загрузка…)",
"filter": "Фильтр библиотеки",
"filter": "Поиск",
"home": "Главная",
"queued": "{{title}} (В очереди)",
"game_has_no_executable": "Файл запуска игры не выбран",
@ -49,10 +50,10 @@
"previous_page": "Предыдущая страница"
},
"game_details": {
"open_download_options": "Открыть варианты загрузки",
"download_options_zero": "Нет вариантов загрузки",
"download_options_one": "{{count}} вариант загрузки",
"download_options_other": "{{count}} вариантов загрузки",
"open_download_options": "Открыть источники",
"download_options_zero": "Нет источников",
"download_options_one": "{{count}} источник",
"download_options_other": "{{count}} источников",
"updated_at": "Обновлено {{updated_at}}",
"install": "Установить",
"resume": "Возобновить",
@ -63,7 +64,7 @@
"eta": "Окончание {{eta}}",
"calculating_eta": "Подсчёт оставшегося времени…",
"downloading_metadata": "Загрузка метаданных…",
"filter": "Фильтр репаков",
"filter": "Поиск репаков",
"requirements": "Системные требования",
"minimum": "Минимальные",
"recommended": "Рекомендуемые",
@ -77,7 +78,7 @@
"accuracy": "точность {{accuracy}}%",
"add_to_library": "Добавить в библиотеку",
"remove_from_library": "Удалить из библиотеки",
"no_downloads": "Нет доступных загрузок",
"no_downloads": "Нет доступных источников",
"play_time": "Сыграно {{amount}}",
"last_time_played": "Последний запуск {{period}}",
"not_played_yet": "Вы ещё не играли в {{title}}",
@ -91,7 +92,7 @@
"select_folder_hint": "Чтобы изменить папку загрузок по умолчанию, откройте <0>Настройки</0>",
"download_now": "Загрузить сейчас",
"no_shop_details": "Не удалось получить описание",
"download_options": "Вариантов загрузки",
"download_options": "Источники",
"download_path": "Путь для загрузок",
"previous_screenshot": "Предыдущий скриншот",
"next_screenshot": "Следующий скриншот",
@ -119,16 +120,53 @@
"last_downloaded_option": "Последний вариант загрузки",
"create_shortcut_success": "Ярлык создан",
"create_shortcut_error": "Не удалось создать ярлык",
"allow_nsfw_content": "Продолжать",
"allow_nsfw_content": "Продолжить",
"download": "Скачать",
"download_count": "Загрузки",
"download_error": "Этот вариант загрузки недоступен",
"executable_path_in_use": "Исполняемый файл уже используется \"{{game}}\"",
"nsfw_content_description": "{{title}} содержит контент, который может не подходить для всех возрастов. \nВы уверены, что хотите продолжить?",
"nsfw_content_title": "Эта игра содержит неприемлемый контент",
"refuse_nsfw_content": "Назад",
"stats": "Статистика",
"player_count": "Активные игроки",
"refuse_nsfw_content": "Возвращаться",
"stats": "Статистика"
"warning": "Внимание:",
"hydra_needs_to_remain_open": "Для этой загрузки Hydra должна оставаться открытой до завершения. Если Hydra закроется до завершения, вы потеряете прогресс.",
"achievements": "Достижения",
"achievements_count": "Достижения {{unlockedCount}}/{{achievementsCount}}",
"cloud_save": "Облачное сохранение",
"cloud_save_description": "Сохраняйте ваш прогресс в облаке и продолжайте играть на любом устройстве",
"backups": "Резервные копии",
"install_backup": "Установить",
"delete_backup": "Удалить",
"create_backup": "Создать новую резервную копию",
"last_backup_date": "Последняя резервная копия от {{date}}",
"no_backup_preview": "Сохранения для этого заголовка не найдены",
"restoring_backup": "Восстановление резервной копии ({{progress}} завершено)…",
"uploading_backup": "Загрузка резервной копии…",
"no_backups": "Вы еще не создали резервных копий для этой игры",
"backup_uploaded": "Резервная копия загружена",
"backup_deleted": "Резервная копия удалена",
"backup_restored": "Резервная копия восстановлена",
"see_all_achievements": "Просмотреть все достижения",
"sign_in_to_see_achievements": "Войдите, чтобы увидеть достижения",
"mapping_method_automatic": "Автоматическая",
"mapping_method_manual": "Ручная",
"mapping_method_label": "Метод сопоставления",
"files_automatically_mapped": "Файлы автоматически сопоставлены",
"no_backups_created": "Для этой игры не создано резервных копий",
"manage_files": "Управление файлами",
"loading_save_preview": "Поиск сохранений…",
"wine_prefix": "Префикс Wine",
"wine_prefix_description": "Префикс Wine, используемый для запуска этой игры",
"no_download_option_info": "Информация недоступна",
"backup_deletion_failed": "Не удалось удалить резервную копию",
"max_number_of_artifacts_reached": "Достигнуто максимальное количество резервных копий для этой игры",
"achievements_not_sync": "Ваши достижения не синхронизированы",
"manage_files_description": "Управляйте файлами, которые будут сохраняться и восстанавливаться",
"select_folder": "Выбрать папку",
"backup_from": "Резервная копия от {{date}}",
"custom_backup_location_set": "Установлено настраиваемое местоположение резервной копии"
},
"activation": {
"title": "Активировать Hydra",
@ -147,7 +185,7 @@
"completed": "Завершено",
"removed": "Не скачано",
"cancel": "Отмена",
"filter": "Фильтр загруженных игр",
"filter": "Поиск загруженных игр",
"remove": "Удалить",
"downloading_metadata": "Загрузка метаданных…",
"deleting": "Удаление установщика…",
@ -168,10 +206,13 @@
"change": "Изменить",
"notifications": "Уведомления",
"enable_download_notifications": "По завершении загрузки",
"enable_achievement_notifications": "Когда достижение разблокировано",
"enable_repack_list_notifications": "При добавлении нового репака",
"real_debrid_api_token_label": "Real-Debrid API-токен",
"quit_app_instead_hiding": "Закрывать приложение вместо сворачивания в трей",
"launch_with_system": "Запускать Hydra вместе с системой",
"launch_minimized": "Запустить Hydra в свернутом виде",
"disable_nsfw_alert": "Отключить предупреждение о непристойном контенте",
"general": "Основные",
"behavior": "Поведение",
"download_sources": "Источники загрузки",
@ -196,7 +237,7 @@
"add_download_source_description": "Вставьте ссылку на .json-файл",
"download_source_up_to_date": "Обновлён",
"download_source_errored": "Ошибка",
"sync_download_sources": "Синхронизировать источники",
"sync_download_sources": "Обновить источники",
"removed_download_source": "Источник загрузок удален",
"added_download_source": "Источник загрузок добавлен",
"download_sources_synced": "Все источники загрузок синхронизированы",
@ -206,13 +247,13 @@
"found_download_option_other": "Найдено {{countFormatted}} вариантов загрузки",
"import": "Импортировать",
"blocked_users": "Заблокированные пользователи",
"friends_only": "Только друзья",
"friends_only": "Только для друзей",
"must_be_valid_url": "Источник должен быть действительным URL-адресом.",
"privacy": "Конфиденциальность",
"private": "Частный",
"profile_visibility": "Видимость профиля",
"profile_visibility_description": "Выберите, кто может видеть ваш профиль и библиотеку",
"public": "Общественный",
"public": "Публичный",
"required_field": "Это поле обязательно к заполнению",
"source_already_exists": "Этот источник уже добавлен",
"user_unblocked": "Пользователь разблокирован"
@ -223,15 +264,17 @@
"repack_list_updated": "Список репаков обновлен",
"repack_count_one": "{{count}} репак добавлен",
"repack_count_other": "{{count}} репаков добавлено",
"new_update_available": "Доступна версия {{version}}",
"restart_to_install_update": "Перезапустите Hydra для установки обновления"
"new_update_available": "Доступна новая версия {{version}}",
"restart_to_install_update": "Перезапустите Hydra для установки обновления",
"notification_achievement_unlocked_title": "Достижение разблокировано для {{game}}",
"notification_achievement_unlocked_body": "были разблокированы {{achievement}} и другие {{count}}"
},
"system_tray": {
"open": "Открыть Hydra",
"quit": "Выйти"
},
"game_card": {
"no_downloads": "Нет доступных загрузок"
"no_downloads": "Нет доступных источников"
},
"binary_not_found_modal": {
"title": "Программы не установлены",
@ -310,5 +353,25 @@
"report_reason_violence": "Насилие",
"required_field": "Это поле обязательно к заполнению",
"undo_friendship_modal_text": "Это отменит вашу дружбу с {{displayName}}."
},
"achievement": {
"achievement_unlocked": "Достижение разблокировано",
"user_achievements": "Достижения {{displayName}}",
"your_achievements": "Ваши достижения",
"unlocked_at": "Разблокировано:",
"subscription_needed": "Для просмотра этого содержимого необходима подписка на Hydra Cloud",
"new_achievements_unlocked": "Разблокировано {{achievementCount}} новых достижений из {{gameCount}} игр",
"achievement_progress": "{{unlockedCount}}/{{totalCount}} достижений",
"achievements_unlocked_for_game": "Разблокировано {{achievementCount}} новых достижений для {{gameTitle}}"
},
"tour": {
"subscription_tour_title": "Подписка Hydra Cloud",
"subscribe_now": "Подпишитесь прямо сейчас",
"cloud_saving": "Сохранение в облаке",
"cloud_achievements": "Сохраняйте свои достижения в облаке",
"animated_profile_picture": "Анимированные фотографии профиля",
"premium_support": "Премиальная поддержка",
"show_and_compare_achievements": "Показывайте и сравнивайте свои достижения с достижениями других пользователей",
"animated_profile_banner": "Анимированный баннер профиля"
}
}

View File

@ -41,6 +41,9 @@ export class UserPreferences {
@Column("boolean", { default: false })
disableNsfwAlert: boolean;
@Column("boolean", { default: false })
showHiddenAchievementsDescription: boolean;
@CreateDateColumn()
createdAt: Date;

View File

@ -1,6 +1,6 @@
import { registerEvent } from "../register-event";
import type { StartGameDownloadPayload } from "@types";
import { DownloadManager, HydraApi, logger } from "@main/services";
import { DownloadManager, HydraApi } from "@main/services";
import { Not } from "typeorm";
import { steamGamesWorker } from "@main/workers";
@ -76,24 +76,23 @@ const startGameDownload = async (
},
});
createGame(updatedGame!).catch(() => {});
HydraApi.post(
"/games/download",
{
objectId: updatedGame!.objectID,
shop: updatedGame!.shop,
},
{ needsAuth: false }
).catch((err) => {
logger.error("Failed to create game download", err);
});
await DownloadManager.cancelDownload(updatedGame!.id);
await DownloadManager.startDownload(updatedGame!);
await downloadQueueRepository.delete({ game: { id: updatedGame!.id } });
await downloadQueueRepository.insert({ game: { id: updatedGame!.id } });
await Promise.all([
createGame(updatedGame!).catch(() => {}),
HydraApi.post(
"/games/download",
{
objectId: updatedGame!.objectID,
shop: updatedGame!.shop,
},
{ needsAuth: false }
).catch(() => {}),
]);
});
};

View File

@ -1,6 +1,9 @@
import type { GameShop, UnlockedAchievement, UserAchievement } from "@types";
import { registerEvent } from "../register-event";
import { gameAchievementRepository } from "@main/repository";
import {
gameAchievementRepository,
userPreferencesRepository,
} from "@main/repository";
import { getGameAchievementData } from "@main/services/achievements/get-game-achievement-data";
export const getUnlockedAchievements = async (
@ -12,10 +15,17 @@ export const getUnlockedAchievements = async (
where: { objectId, shop },
});
const userPreferences = await userPreferencesRepository.findOne({
where: { id: 1 },
});
const showHiddenAchievementsDescription =
userPreferences?.showHiddenAchievementsDescription || false;
const achievementsData = await getGameAchievementData(
objectId,
shop,
useCachedData
useCachedData ? cachedAchievements : null
);
const unlockedAchievements = JSON.parse(
@ -50,6 +60,10 @@ export const getUnlockedAchievements = async (
unlocked: false,
unlockTime: null,
icongray: icongray,
description:
!achievementData.hidden || showHiddenAchievementsDescription
? achievementData.description
: undefined,
} as UserAchievement;
})
.sort((a, b) => {

View File

@ -13,6 +13,8 @@ import { AddBackgroundImageUrl } from "./migrations/20241016100249_add_backgroun
import { AddWinePrefixToGame } from "./migrations/20241019081648_add_wine_prefix_to_game";
import { AddStartMinimizedColumn } from "./migrations/20241030171454_add_start_minimized_column";
import { AddDisableNsfwAlertColumn } from "./migrations/20241106053733_add_disable_nsfw_alert_column";
import { AddHiddenAchievementDescriptionColumn } from "./migrations/20241216140633_add_hidden_achievement_description_column ";
export type HydraMigration = Knex.Migration & { name: string };
class MigrationSource implements Knex.MigrationSource<HydraMigration> {
@ -30,6 +32,7 @@ class MigrationSource implements Knex.MigrationSource<HydraMigration> {
AddWinePrefixToGame,
AddStartMinimizedColumn,
AddDisableNsfwAlertColumn,
AddHiddenAchievementDescriptionColumn,
]);
}
getMigrationName(migration: HydraMigration): string {

View File

@ -0,0 +1,20 @@
import type { HydraMigration } from "@main/knex-client";
import type { Knex } from "knex";
export const AddHiddenAchievementDescriptionColumn: HydraMigration = {
name: "AddHiddenAchievementDescriptionColumn",
up: (knex: Knex) => {
return knex.schema.alterTable("user_preferences", (table) => {
return table
.boolean("showHiddenAchievementsDescription")
.notNullable()
.defaultTo(0);
});
},
down: async (knex: Knex) => {
return knex.schema.alterTable("user_preferences", (table) => {
return table.dropColumn("showHiddenAchievementsDescription");
});
},
};

View File

@ -1,40 +0,0 @@
import path from "node:path";
import fs from "node:fs";
import { getSteamGameClientIcon, logger } from "@main/services";
import { chunk } from "lodash-es";
import { seedsPath } from "@main/constants";
import type { SteamGame } from "@types";
const steamGamesPath = path.join(seedsPath, "steam-games.json");
const steamGames = JSON.parse(
fs.readFileSync(steamGamesPath, "utf-8")
) as SteamGame[];
const chunks = chunk(steamGames, 1500);
for (const chunk of chunks) {
await Promise.all(
chunk.map(async (steamGame) => {
if (steamGame.clientIcon) return;
const index = steamGames.findIndex((game) => game.id === steamGame.id);
try {
const clientIcon = await getSteamGameClientIcon(String(steamGame.id));
steamGames[index].clientIcon = clientIcon;
logger.log("info", `Set ${steamGame.name} client icon`);
} catch (err) {
steamGames[index].clientIcon = null;
logger.log("info", `Could not set icon for ${steamGame.name}`);
}
})
);
fs.writeFileSync(steamGamesPath, JSON.stringify(steamGames));
logger.log("info", "Updated steam games");
}

View File

@ -236,24 +236,28 @@ export class AchievementWatcherManager {
};
public static preSearchAchievements = async () => {
const newAchievementsCount =
process.platform === "win32"
? await this.preSearchAchievementsWindows()
: await this.preSearchAchievementsWithWine();
try {
const newAchievementsCount =
process.platform === "win32"
? await this.preSearchAchievementsWindows()
: await this.preSearchAchievementsWithWine();
const totalNewGamesWithAchievements = newAchievementsCount.filter(
(achievements) => achievements
).length;
const totalNewAchievements = newAchievementsCount.reduce(
(acc, val) => acc + val,
0
);
if (totalNewAchievements > 0) {
publishCombinedNewAchievementNotification(
totalNewAchievements,
totalNewGamesWithAchievements
const totalNewGamesWithAchievements = newAchievementsCount.filter(
(achievements) => achievements
).length;
const totalNewAchievements = newAchievementsCount.reduce(
(acc, val) => acc + val,
0
);
if (totalNewAchievements > 0) {
publishCombinedNewAchievementNotification(
totalNewAchievements,
totalNewGamesWithAchievements
);
}
} catch (err) {
achievementsLogger.error("Error on preSearchAchievements", err);
}
this.hasFinishedMergingWithRemote = true;

View File

@ -6,20 +6,15 @@ import { HydraApi } from "../hydra-api";
import type { AchievementData, GameShop } from "@types";
import { UserNotLoggedInError } from "@shared";
import { logger } from "../logger";
import { GameAchievement } from "@main/entity";
export const getGameAchievementData = async (
objectId: string,
shop: GameShop,
useCachedData: boolean
cachedAchievements: GameAchievement | null
) => {
if (useCachedData) {
const cachedAchievements = await gameAchievementRepository.findOne({
where: { objectId, shop },
});
if (cachedAchievements && cachedAchievements.achievements) {
return JSON.parse(cachedAchievements.achievements) as AchievementData[];
}
if (cachedAchievements && cachedAchievements.achievements) {
return JSON.parse(cachedAchievements.achievements) as AchievementData[];
}
const userPreferences = await userPreferencesRepository.findOne({

View File

@ -9,144 +9,134 @@ export const parseAchievementFile = (
): UnlockedAchievement[] => {
if (!existsSync(filePath)) return [];
if (type == Cracker.codex) {
const parsed = iniParse(filePath);
return processDefault(parsed);
try {
if (type == Cracker.codex) {
const parsed = iniParse(filePath);
return processDefault(parsed);
}
if (type == Cracker.rune) {
const parsed = iniParse(filePath);
return processDefault(parsed);
}
if (type === Cracker.onlineFix) {
const parsed = iniParse(filePath);
return processOnlineFix(parsed);
}
if (type === Cracker.goldberg) {
const parsed = jsonParse(filePath);
return processGoldberg(parsed);
}
if (type == Cracker.userstats) {
const parsed = iniParse(filePath);
return processUserStats(parsed);
}
if (type == Cracker.rld) {
const parsed = iniParse(filePath);
return processRld(parsed);
}
if (type === Cracker.skidrow) {
const parsed = iniParse(filePath);
return processSkidrow(parsed);
}
if (type === Cracker._3dm) {
const parsed = iniParse(filePath);
return process3DM(parsed);
}
if (type === Cracker.flt) {
const achievements = readdirSync(filePath);
return achievements.map((achievement) => {
return {
name: achievement,
unlockTime: Date.now(),
};
});
}
if (type === Cracker.creamAPI) {
const parsed = iniParse(filePath);
return processCreamAPI(parsed);
}
if (type === Cracker.empress) {
const parsed = jsonParse(filePath);
return processGoldberg(parsed);
}
if (type === Cracker.razor1911) {
return processRazor1911(filePath);
}
achievementsLogger.log(
`Unprocessed ${type} achievements found on ${filePath}`
);
return [];
} catch (err) {
achievementsLogger.error(`Error parsing ${type} - ${filePath}`, err);
return [];
}
if (type == Cracker.rune) {
const parsed = iniParse(filePath);
return processDefault(parsed);
}
if (type === Cracker.onlineFix) {
const parsed = iniParse(filePath);
return processOnlineFix(parsed);
}
if (type === Cracker.goldberg) {
const parsed = jsonParse(filePath);
return processGoldberg(parsed);
}
if (type == Cracker.userstats) {
const parsed = iniParse(filePath);
return processUserStats(parsed);
}
if (type == Cracker.rld) {
const parsed = iniParse(filePath);
return processRld(parsed);
}
if (type === Cracker.skidrow) {
const parsed = iniParse(filePath);
return processSkidrow(parsed);
}
if (type === Cracker._3dm) {
const parsed = iniParse(filePath);
return process3DM(parsed);
}
if (type === Cracker.flt) {
const achievements = readdirSync(filePath);
return achievements.map((achievement) => {
return {
name: achievement,
unlockTime: Date.now(),
};
});
}
if (type === Cracker.creamAPI) {
const parsed = iniParse(filePath);
return processCreamAPI(parsed);
}
if (type === Cracker.empress) {
const parsed = jsonParse(filePath);
return processGoldberg(parsed);
}
if (type === Cracker.razor1911) {
return processRazor1911(filePath);
}
achievementsLogger.log(
`Unprocessed ${type} achievements found on ${filePath}`
);
return [];
};
const iniParse = (filePath: string) => {
try {
const fileContent = readFileSync(filePath, "utf-8");
const fileContent = readFileSync(filePath, "utf-8");
const lines =
fileContent.charCodeAt(0) === 0xfeff
? fileContent.slice(1).split(/[\r\n]+/)
: fileContent.split(/[\r\n]+/);
const lines =
fileContent.charCodeAt(0) === 0xfeff
? fileContent.slice(1).split(/[\r\n]+/)
: fileContent.split(/[\r\n]+/);
let objectName = "";
const object: Record<string, Record<string, string | number>> = {};
let objectName = "";
const object: Record<string, Record<string, string | number>> = {};
for (const line of lines) {
if (line.startsWith("###") || !line.length) continue;
for (const line of lines) {
if (line.startsWith("###") || !line.length) continue;
if (line.startsWith("[") && line.endsWith("]")) {
objectName = line.slice(1, -1);
object[objectName] = {};
} else {
const [name, ...value] = line.split("=");
object[objectName][name.trim()] = value.join("=").trim();
}
if (line.startsWith("[") && line.endsWith("]")) {
objectName = line.slice(1, -1);
object[objectName] = {};
} else {
const [name, ...value] = line.split("=");
object[objectName][name.trim()] = value.join("=").trim();
}
return object;
} catch (err) {
achievementsLogger.error(`Error parsing ${filePath}`, err);
return {};
}
return object;
};
const jsonParse = (filePath: string) => {
try {
return JSON.parse(readFileSync(filePath, "utf-8"));
} catch (err) {
achievementsLogger.error(`Error parsing ${filePath}`, err);
return {};
}
return JSON.parse(readFileSync(filePath, "utf-8"));
};
const processRazor1911 = (filePath: string): UnlockedAchievement[] => {
try {
const fileContent = readFileSync(filePath, "utf-8");
const fileContent = readFileSync(filePath, "utf-8");
const lines =
fileContent.charCodeAt(0) === 0xfeff
? fileContent.slice(1).split(/[\r\n]+/)
: fileContent.split(/[\r\n]+/);
const lines =
fileContent.charCodeAt(0) === 0xfeff
? fileContent.slice(1).split(/[\r\n]+/)
: fileContent.split(/[\r\n]+/);
const achievements: UnlockedAchievement[] = [];
for (const line of lines) {
if (!line.length) continue;
const achievements: UnlockedAchievement[] = [];
for (const line of lines) {
if (!line.length) continue;
const [name, unlocked, unlockTime] = line.split(" ");
if (unlocked === "1") {
achievements.push({
name,
unlockTime: Number(unlockTime) * 1000,
});
}
const [name, unlocked, unlockTime] = line.split(" ");
if (unlocked === "1") {
achievements.push({
name,
unlockTime: Number(unlockTime) * 1000,
});
}
return achievements;
} catch (err) {
achievementsLogger.error(`Error processing ${filePath}`, err);
return [];
}
return achievements;
};
const processOnlineFix = (unlockedAchievements: any): UnlockedAchievement[] => {

View File

@ -1,7 +1,6 @@
export * from "./logger";
export * from "./steam";
export * from "./steam-250";
export * from "./steam-grid";
export * from "./window-manager";
export * from "./download";
export * from "./process-watcher";

View File

@ -1,69 +0,0 @@
import type { GameShop } from "@types";
import axios from "axios";
export interface SteamGridResponse {
success: boolean;
data: {
id: number;
};
}
export interface SteamGridGameResponse {
data: {
platforms: {
steam: {
metadata: {
clienticon: string;
};
};
};
};
}
export const getSteamGridData = async (
objectId: string,
path: string,
shop: GameShop,
params: Record<string, string> = {}
): Promise<SteamGridResponse> => {
const searchParams = new URLSearchParams(params);
if (!import.meta.env.MAIN_VITE_STEAMGRIDDB_API_KEY) {
throw new Error("MAIN_VITE_STEAMGRIDDB_API_KEY is not set");
}
const response = await axios.get(
`https://www.steamgriddb.com/api/v2/${path}/${shop}/${objectId}?${searchParams.toString()}`,
{
headers: {
Authorization: `Bearer ${import.meta.env.MAIN_VITE_STEAMGRIDDB_API_KEY}`,
},
}
);
return response.data;
};
export const getSteamGridGameById = async (
id: number
): Promise<SteamGridGameResponse> => {
const response = await axios.get(
`https://www.steamgriddb.com/api/public/game/${id}`,
{
headers: {
Referer: "https://www.steamgriddb.com/",
},
}
);
return response.data;
};
export const getSteamGameClientIcon = async (objectId: string) => {
const {
data: { id: steamGridGameId },
} = await getSteamGridData(objectId, "games", "steam");
const steamGridGame = await getSteamGridGameById(steamGridGameId);
return steamGridGame.data.platforms.steam.metadata.clienticon;
};

View File

@ -11,10 +11,10 @@ import type {
GameRunning,
FriendRequestAction,
UpdateProfileRequest,
GameAchievement,
} from "@types";
import type { CatalogueCategory } from "@shared";
import type { AxiosProgressEvent } from "axios";
import { GameAchievement } from "@main/entity";
contextBridge.exposeInMainWorld("electron", {
/* Torrenting */

View File

@ -19,6 +19,7 @@ export function SettingsBehavior() {
runAtStartup: false,
startMinimized: false,
disableNsfwAlert: false,
showHiddenAchievementsDescription: false,
});
const { t } = useTranslation("settings");
@ -30,6 +31,8 @@ export function SettingsBehavior() {
runAtStartup: userPreferences.runAtStartup,
startMinimized: userPreferences.startMinimized,
disableNsfwAlert: userPreferences.disableNsfwAlert,
showHiddenAchievementsDescription:
userPreferences.showHiddenAchievementsDescription,
});
}
}, [userPreferences]);
@ -96,6 +99,17 @@ export function SettingsBehavior() {
handleChange({ disableNsfwAlert: !form.disableNsfwAlert })
}
/>
<CheckboxField
label={t("show_hidden_achievement_description")}
checked={form.showHiddenAchievementsDescription}
onChange={() =>
handleChange({
showHiddenAchievementsDescription:
!form.showHiddenAchievementsDescription,
})
}
/>
</>
);
}

View File

@ -162,6 +162,7 @@ export interface UserPreferences {
runAtStartup: boolean;
startMinimized: boolean;
disableNsfwAlert: boolean;
showHiddenAchievementsDescription: boolean;
}
export interface Steam250Game {

621
yarn.lock

File diff suppressed because it is too large Load Diff