mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 13:56:16 +00:00
feat: Hide to tray on game startup and ability to disable trailers auto-play
This commit is contained in:
@@ -541,7 +541,9 @@
|
||||
"hidden": "Hidden",
|
||||
"test_notification": "Test notification",
|
||||
"notification_preview": "Achievement Notification Preview",
|
||||
"enable_friend_start_game_notifications": "When a friend starts playing a game"
|
||||
"enable_friend_start_game_notifications": "When a friend starts playing a game",
|
||||
"autoplay_trailers_on_game_page": "Automatically start playing trailers on game page",
|
||||
"hide_to_tray_on_game_start": "Hide Hydra to tray on game startup"
|
||||
},
|
||||
"notifications": {
|
||||
"download_complete": "Download complete",
|
||||
|
||||
@@ -4,7 +4,8 @@ import type { Game, GameRunning } from "@types";
|
||||
import { PythonRPC } from "./python-rpc";
|
||||
import axios from "axios";
|
||||
import { ProcessPayload } from "./download/types";
|
||||
import { gamesSublevel, levelKeys } from "@main/level";
|
||||
import { db, gamesSublevel, levelKeys } from "@main/level";
|
||||
import type { UserPreferences } from "@types";
|
||||
import { CloudSync } from "./cloud-sync";
|
||||
import { logger } from "./logger";
|
||||
import path from "path";
|
||||
@@ -209,6 +210,18 @@ function onOpenGame(game: Game) {
|
||||
lastSyncTick: now,
|
||||
});
|
||||
|
||||
// Hide Hydra to tray on game startup if enabled
|
||||
db
|
||||
.get<string, UserPreferences | null>(levelKeys.userPreferences, {
|
||||
valueEncoding: "json",
|
||||
})
|
||||
.then((userPreferences) => {
|
||||
if (userPreferences?.hideToTrayOnGameStart) {
|
||||
WindowManager.mainWindow?.hide();
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
|
||||
if (game.remoteId) {
|
||||
updateGamePlaytime(
|
||||
game,
|
||||
|
||||
@@ -7,11 +7,16 @@ import {
|
||||
} from "@primer/octicons-react";
|
||||
import useEmblaCarousel from "embla-carousel-react";
|
||||
import { gameDetailsContext } from "@renderer/context";
|
||||
import { useAppSelector } from "@renderer/hooks";
|
||||
import "./gallery-slider.scss";
|
||||
|
||||
export function GallerySlider() {
|
||||
const { shopDetails } = useContext(gameDetailsContext);
|
||||
const { t } = useTranslation("game_details");
|
||||
const userPreferences = useAppSelector(
|
||||
(state) => state.userPreferences.value
|
||||
);
|
||||
const autoplayEnabled = userPreferences?.autoplayGameTrailers !== false;
|
||||
|
||||
const hasScreenshots = shopDetails && shopDetails.screenshots?.length;
|
||||
|
||||
@@ -164,7 +169,7 @@ export function GallerySlider() {
|
||||
poster={item.poster}
|
||||
loop
|
||||
muted
|
||||
autoPlay
|
||||
autoPlay={autoplayEnabled}
|
||||
tabIndex={-1}
|
||||
>
|
||||
<source src={item.videoSrc} />
|
||||
|
||||
@@ -27,6 +27,8 @@ export function SettingsBehavior() {
|
||||
showDownloadSpeedInMegabytes: false,
|
||||
extractFilesByDefault: true,
|
||||
enableSteamAchievements: false,
|
||||
autoplayGameTrailers: true,
|
||||
hideToTrayOnGameStart: false,
|
||||
});
|
||||
|
||||
const { t } = useTranslation("settings");
|
||||
@@ -49,6 +51,10 @@ export function SettingsBehavior() {
|
||||
extractFilesByDefault: userPreferences.extractFilesByDefault ?? true,
|
||||
enableSteamAchievements:
|
||||
userPreferences.enableSteamAchievements ?? false,
|
||||
autoplayGameTrailers:
|
||||
userPreferences.autoplayGameTrailers ?? true,
|
||||
hideToTrayOnGameStart:
|
||||
userPreferences.hideToTrayOnGameStart ?? false,
|
||||
});
|
||||
}
|
||||
}, [userPreferences]);
|
||||
@@ -76,6 +82,16 @@ export function SettingsBehavior() {
|
||||
}
|
||||
/>
|
||||
|
||||
<CheckboxField
|
||||
label={t("hide_to_tray_on_game_start")}
|
||||
checked={form.hideToTrayOnGameStart}
|
||||
onChange={() =>
|
||||
handleChange({
|
||||
hideToTrayOnGameStart: !form.hideToTrayOnGameStart,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
{showRunAtStartup && (
|
||||
<CheckboxField
|
||||
label={t("launch_with_system")}
|
||||
@@ -120,6 +136,14 @@ export function SettingsBehavior() {
|
||||
/>
|
||||
)}
|
||||
|
||||
<CheckboxField
|
||||
label={t("autoplay_trailers_on_game_page")}
|
||||
checked={form.autoplayGameTrailers}
|
||||
onChange={() =>
|
||||
handleChange({ autoplayGameTrailers: !form.autoplayGameTrailers })
|
||||
}
|
||||
/>
|
||||
|
||||
<CheckboxField
|
||||
label={t("disable_nsfw_alert")}
|
||||
checked={form.disableNsfwAlert}
|
||||
|
||||
@@ -118,6 +118,8 @@ export interface UserPreferences {
|
||||
showDownloadSpeedInMegabytes?: boolean;
|
||||
extractFilesByDefault?: boolean;
|
||||
enableSteamAchievements?: boolean;
|
||||
autoplayGameTrailers?: boolean;
|
||||
hideToTrayOnGameStart?: boolean;
|
||||
}
|
||||
|
||||
export interface ScreenState {
|
||||
|
||||
Reference in New Issue
Block a user