From 20dab9c4c1d4991ea3c5cb8be5a5dc883288377e Mon Sep 17 00:00:00 2001 From: mag1yar Date: Wed, 15 May 2024 01:51:25 +0500 Subject: [PATCH 1/4] Adding recently played games to tray context menu --- src/main/services/window-manager.ts | 99 +++++++++++++++++++++-------- 1 file changed, 73 insertions(+), 26 deletions(-) diff --git a/src/main/services/window-manager.ts b/src/main/services/window-manager.ts index cf846daf..1ac38c07 100644 --- a/src/main/services/window-manager.ts +++ b/src/main/services/window-manager.ts @@ -1,10 +1,19 @@ -import { BrowserWindow, Menu, Tray, app } from "electron"; +import { + BrowserWindow, + Menu, + MenuItem, + MenuItemConstructorOptions, + Tray, + app, + shell, +} from "electron"; import { is } from "@electron-toolkit/utils"; import { t } from "i18next"; import path from "node:path"; import icon from "@resources/icon.png?asset"; import trayIcon from "@resources/tray-icon.png?asset"; -import { userPreferencesRepository } from "@main/repository"; +import { gameRepository, userPreferencesRepository } from "@main/repository"; +import { IsNull, Not } from "typeorm"; export class WindowManager { public static mainWindow: Electron.BrowserWindow | null = null; @@ -77,33 +86,66 @@ export class WindowManager { public static createSystemTray(language: string) { const tray = new Tray(trayIcon); - const contextMenu = Menu.buildFromTemplate([ - { - label: t("open", { - ns: "system_tray", - lng: language, - }), - type: "normal", - click: () => { - if (this.mainWindow) { - this.mainWindow.show(); - } else { - this.createMainWindow(); - } + const updateSystemTray = async () => { + const games = await gameRepository.find({ + where: { + isDeleted: false, + executablePath: Not(IsNull()), }, - }, - { - label: t("quit", { - ns: "system_tray", - lng: language, - }), - type: "normal", - click: () => app.quit(), - }, - ]); + take: 5, + order: { + lastTimePlayed: "DESC", + }, + }); + + const recentlyPlayedGames: Array = + games.map(({ title, id, executablePath }) => ({ + label: title, + type: "normal", + click: async () => { + if (!executablePath) return; + await gameRepository.update({ id }, { executablePath }); + + shell.openPath(executablePath); + }, + })); + + const contextMenu = Menu.buildFromTemplate([ + { + label: t("open", { + ns: "system_tray", + lng: language, + }), + type: "normal", + click: () => { + if (this.mainWindow) { + this.mainWindow.show(); + } else { + this.createMainWindow(); + } + }, + }, + { + type: "separator", + }, + ...recentlyPlayedGames, + { + type: "separator", + }, + { + label: t("quit", { + ns: "system_tray", + lng: language, + }), + type: "normal", + click: () => app.quit(), + }, + ]); + + return contextMenu; + }; tray.setToolTip("Hydra"); - tray.setContextMenu(contextMenu); if (process.platform === "win32" || process.platform === "linux") { tray.addListener("click", () => { @@ -117,6 +159,11 @@ export class WindowManager { this.createMainWindow(); }); + + tray.addListener("right-click", async () => { + const contextMenu = await updateSystemTray(); + tray.popUpContextMenu(contextMenu); + }); } } } From 2034e0a157fe546271d8e66555d24455435c6bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Raty=C5=84ski?= Date: Thu, 16 May 2024 10:37:49 +0200 Subject: [PATCH 2/4] Update translation.json --- src/locales/pl/translation.json | 44 +++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/src/locales/pl/translation.json b/src/locales/pl/translation.json index 5214019e..d629d1f3 100644 --- a/src/locales/pl/translation.json +++ b/src/locales/pl/translation.json @@ -17,7 +17,11 @@ "downloading": "{{title}} ({{percentage}} - Pobieranie…)", "filter": "Filtruj biblioteke", "follow_us": "Śledź nas", - "home": "Główna" + "home": "Główna", + "discord": "Dołącz nasz Discord", + "telegram": "Dołącz nasz Telegram", + "x": "Śledź na X", + "github": "Przyczyń się na GitHub" }, "header": { "search": "Szukaj", @@ -66,6 +70,8 @@ "copied_link_to_clipboard": "Skopiowano łącze", "hours": "godzin", "minutes": "minut", + "amount_hours": "{{amount}} godzin", + "amount_minutes": "{{amount}} minut", "accuracy": "{{accuracy}}% dokładność", "add_to_library": "Dodaj do biblioteki", "remove_from_library": "Usuń z biblioteki", @@ -80,9 +86,23 @@ "playing_now": "Granie teraz", "change": "Zmień", "repacks_modal_description": "Wybierz repack, który chcesz pobrać", - "downloads_path": "Ścieżka pobierania", "select_folder_hint": "Aby zmienić domyślny folder, przejdź do", - "download_now": "Pobierz teraz" + "download_now": "Pobierz teraz", + "installation_instructions": "Instrukcja instalacji", + "installation_instructions_description": "Do zainstalowania tej gry wymagane są dodatkowe kroki", + "online_fix_instruction": "Gry OnlineFix wymagają hasła do wyodrębnienia. W razie potrzeby użyj następującego hasła:", + "dodi_installation_instruction": "Po otwarciu instalatora DODI naciśnij klawisz <0 /> w górę, aby rozpocząć proces instalacji:", + "dont_show_it_again": "Nie pokazuj tego ponownie", + "copy_to_clipboard": "Skopiuj", + "copied_to_clipboard": "Skopiowano", + "got_it": "Rozumiem", + "no_shop_details": "Nie udało się pobrać danych sklepu.", + "download_options": "Opcje pobierania", + "download_path": "Ścieżka pobierania", + "previous_screenshot": "Poprzedni zrzut ekranu", + "next_screenshot": "Następny zrzut ekranu", + "screenshot": "Zrzut ekranu {{number}}", + "open_screenshot": "Otwórz zrzut ekranu {{number}}" }, "activation": { "title": "Aktywuj Hydra", @@ -113,7 +133,9 @@ "remove_from_list": "Usuń", "delete_modal_title": "Czy na pewno?", "delete_modal_description": "Spowoduje to usunięcie wszystkich plików instalacyjnych z komputera", - "install": "Instaluj" + "install": "Instaluj", + "real_debrid": "Real Debrid", + "torrent": "Torrent" }, "settings": { "downloads_path": "Ścieżka pobierania", @@ -122,7 +144,16 @@ "enable_download_notifications": "Gdy pobieranie zostanie zakończone", "enable_repack_list_notifications": "Gdy dodawany jest nowy repack", "telemetry": "Telemetria", - "telemetry_description": "Włącz anonimowe statystyki użycia" + "telemetry_description": "Włącz anonimowe statystyki użycia", + "real_debrid_api_token_label": "Real Debrid API token", + "quit_app_instead_hiding": "Zamknij Hydr zamiast minimalizować do zasobnika", + "launch_with_system": "Uruchom Hydra przy starcie systemu", + "general": "Ogólne", + "behavior": "Zachowania", + "enable_real_debrid": "Włącz Real Debrid", + "real_debrid": "Real Debrid", + "real_debrid_api_token_hint": "Możesz uzyskać swój klucz API <0>tutaj.", + "save_changes": "Zapisz zmiany" }, "notifications": { "download_complete": "Pobieranie zakończone", @@ -142,5 +173,8 @@ "title": "Programy nie są zainstalowane", "description": "Pliki wykonywalne Wine lub Lutris nie zostały znalezione na twoim systemie", "instructions": "Sprawdź prawidłowy sposób instalacji dowolnego z nich w swojej dystrybucji Linuksa, aby gra działała normalnie" + }, + "modal": { + "close": "Zamknij" } } From 28bd70e74591723a3f5808426116568bfca2d913 Mon Sep 17 00:00:00 2001 From: mag1yar Date: Thu, 16 May 2024 19:26:45 +0500 Subject: [PATCH 3/4] Removed update when clicking on a game and fixed sorting --- src/main/services/window-manager.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/services/window-manager.ts b/src/main/services/window-manager.ts index 1ac38c07..973a0c64 100644 --- a/src/main/services/window-manager.ts +++ b/src/main/services/window-manager.ts @@ -91,20 +91,20 @@ export class WindowManager { where: { isDeleted: false, executablePath: Not(IsNull()), + lastTimePlayed: Not(IsNull()), }, take: 5, order: { - lastTimePlayed: "DESC", + updatedAt: "DESC", }, }); const recentlyPlayedGames: Array = - games.map(({ title, id, executablePath }) => ({ + games.map(({ title, executablePath }) => ({ label: title, type: "normal", click: async () => { if (!executablePath) return; - await gameRepository.update({ id }, { executablePath }); shell.openPath(executablePath); }, From 75a9d56624b211bdc88630bb4ad890e5e6caf64f Mon Sep 17 00:00:00 2001 From: itsOdell Date: Thu, 16 May 2024 11:17:01 -0400 Subject: [PATCH 4/4] feat: force developer to use yarn This solves alot of issues in PR's that have package-lock.json becuase they did npm install, this update forces an error and exits out when developer runs npm install --- .npmrc | 1 + package.json | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..d1cdf2f0 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +engine-strict = true \ No newline at end of file diff --git a/package.json b/package.json index 7878b902..e1da546a 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,10 @@ "url": "https://github.com/hydralauncher/hydra.git" }, "type": "module", + "engines": { + "npm": "please-use-yarn", + "yarn": ">= 1.19.1" + }, "scripts": { "format": "prettier --write .", "format-check": "prettier --check .",