Skip to content

Commit 38e08f5

Browse files
committed
feat: add Enable Steam Integration setting and update config handling
1 parent 8d2eb9b commit 38e08f5

File tree

7 files changed

+74
-13
lines changed

7 files changed

+74
-13
lines changed

src/backend/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ class GlobalConfigV0 extends GlobalConfig {
323323
ldUser: {
324324
kind: 'user',
325325
key: uuid()
326-
}
326+
},
327+
enableSteamIntegration: false
327328
} as AppSettings
328329
}
329330

src/backend/main.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -891,16 +891,18 @@ ipcMain.on('clearCache', (event, showDialog, fromVersionChange = false) => {
891891
clearCache(undefined, fromVersionChange)
892892
sendFrontendMessage('refreshLibrary')
893893

894-
showDialogBoxModalAuto({
895-
event,
896-
title: i18next.t('box.cache-cleared.title', 'Cache Cleared'),
897-
message: i18next.t(
898-
'box.cache-cleared.message',
899-
'HyperPlay Cache Was Cleared!'
900-
),
901-
type: 'MESSAGE',
902-
buttons: [{ text: i18next.t('box.ok', 'Ok') }]
903-
})
894+
if (showDialog) {
895+
showDialogBoxModalAuto({
896+
event,
897+
title: i18next.t('box.cache-cleared.title', 'Cache Cleared'),
898+
message: i18next.t(
899+
'box.cache-cleared.message',
900+
'HyperPlay Cache Was Cleared!'
901+
),
902+
type: 'MESSAGE',
903+
buttons: [{ text: i18next.t('box.ok', 'Ok') }]
904+
})
905+
}
904906
})
905907

906908
ipcMain.on('resetApp', async () => {

src/backend/storeManagers/steam/library.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,20 @@ import { loadUsers } from './user'
2020
import { GameInfo, InstallPlatform } from 'common/types'
2121
import { getGamesdbData } from '../gog/library'
2222
import { apiInfoCache } from '../gog/electronStores'
23+
import { GlobalConfig } from 'backend/config'
2324

2425
const library = new Map<string, GameInfo>()
2526
const installed = new Map<string, SteamInstallInfo>()
2627

2728
export async function getOwnedGames(
2829
userId: string
2930
): Promise<OwnedGame[] | undefined> {
31+
if (!GlobalConfig.get().getSettings().enableSteamIntegration) {
32+
logDebug('Steam integration is disabled in settings', {
33+
prefix: LogPrefix.Steam
34+
})
35+
return []
36+
}
3037
if (isMac) {
3138
logWarning('getOwnedGames is not supported on macOS', {
3239
prefix: LogPrefix.Steam
@@ -54,6 +61,12 @@ const ignoredAppIds = [
5461
]
5562

5663
export async function getInstalledGames() {
64+
if (!GlobalConfig.get().getSettings().enableSteamIntegration) {
65+
logDebug('Steam integration is disabled in settings', {
66+
prefix: LogPrefix.Steam
67+
})
68+
return
69+
}
5770
const steamLibraries = await getSteamLibraries()
5871
const steamAppsDirs = steamLibraries.map((lib) => path.join(lib, 'steamapps'))
5972

@@ -94,6 +107,12 @@ export async function getInstalledGames() {
94107
}
95108

96109
export async function refresh(): Promise<null> {
110+
if (!GlobalConfig.get().getSettings().enableSteamIntegration) {
111+
logDebug('Steam integration is disabled in settings', {
112+
prefix: LogPrefix.Steam
113+
})
114+
return null
115+
}
97116
const steamUsers = await loadUsers()
98117

99118
const enabledSteamUsers = steamUsers.reduce((acc, val) => {

src/common/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export interface AppSettings extends GameSettings {
114114
userInfo: UserInfo
115115
steamId: string
116116
ldUser: LDUser
117+
enableSteamIntegration: boolean
117118
}
118119

119120
export type LibraryTopSectionOptions =
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react'
2+
import { useTranslation } from 'react-i18next'
3+
import ToggleSwitch from 'frontend/components/UI/ToggleSwitch'
4+
import useSetting from 'frontend/hooks/useSetting'
5+
import libraryState from 'frontend/state/libraryState'
6+
7+
export default function EnableSteamIntegration() {
8+
const { t } = useTranslation()
9+
const [enabled, setEnabled] = useSetting('enableSteamIntegration', false)
10+
11+
const handleChange = () => {
12+
const newValue = !enabled
13+
setEnabled(newValue)
14+
if (newValue) {
15+
window.api.refreshLibrary('steam')
16+
} else {
17+
if (libraryState.category === 'steam') {
18+
libraryState.category = 'all'
19+
}
20+
window.api.clearCache(false)
21+
}
22+
}
23+
24+
return (
25+
<ToggleSwitch
26+
htmlId="enable_steam_integration"
27+
value={enabled}
28+
handleChange={handleChange}
29+
title={t(
30+
'setting.enable-steam-integration',
31+
'Enable Steam Integration (experimental)'
32+
)}
33+
/>
34+
)
35+
}

src/frontend/screens/Settings/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ export { default as WinePrefixesBasePath } from './WinePrefixesBasePath'
4141
export { default as WineVersionSelector } from './WineVersionSelector'
4242
export { default as WrappersTable } from './WrappersTable'
4343
export { default as HyperPlayAnalytics } from './HyperPlayAnalytics'
44+
export { default as EnableSteamIntegration } from './EnableSteamIntegration'

src/frontend/screens/Settings/sections/GeneralSettings/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import {
1414
Shortcuts,
1515
TraySettings,
1616
UseDarkTrayIcon,
17-
WinePrefixesBasePath
17+
WinePrefixesBasePath,
18+
EnableSteamIntegration
1819
} from '../../components'
1920
import AutoLaunchHyperPlay from '../../components/AutoLaunchHyperPlay'
2021
import styles from './index.module.scss'
@@ -32,6 +33,7 @@ export default function GeneralSettings() {
3233
<LanguageSelector />
3334
<DefaultInstallPath />
3435
<WinePrefixesBasePath />
36+
<EnableSteamIntegration />
3537
<DefaultSteamPath />
3638
<EgsSettings />
3739
<AutoLaunchHyperPlay />
@@ -40,7 +42,7 @@ export default function GeneralSettings() {
4042
<MinimizeOnGameLaunch />
4143
<UseDarkTrayIcon />
4244
<Shortcuts />
43-
{/*
45+
{/*
4446
disabled until we fix the controller navigation in hyperplay
4547
<DisableController /> */}
4648
<LibraryTopSection />

0 commit comments

Comments
 (0)