Skip to content

Commit 2a0f8c5

Browse files
committed
tech: add steam runner wip
1 parent d3f887e commit 2a0f8c5

File tree

8 files changed

+496
-4
lines changed

8 files changed

+496
-4
lines changed

src/backend/storeManagers/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import * as HyperPlayGameManager from 'backend/storeManagers/hyperplay/games'
22
import * as SideloadGameManager from 'backend/storeManagers/sideload/games'
33
import * as GOGGameManager from 'backend/storeManagers/gog/games'
44
import * as LegendaryGameManager from 'backend/storeManagers/legendary/games'
5+
import * as SteamGameManager from 'backend/storeManagers/steam/games'
56

67
import * as HyperPlayLibraryManager from 'backend/storeManagers/hyperplay/library'
78
import * as SideloadLibraryManager from 'backend/storeManagers/sideload/library'
89
import * as GOGLibraryManager from 'backend/storeManagers/gog/library'
910
import * as LegendaryLibraryManager from 'backend/storeManagers/legendary/library'
11+
import * as SteamLibraryManager from 'backend/storeManagers/steam/library'
1012
import { GameManager, LibraryManager } from 'common/types/game_manager'
1113

1214
import { logInfo, RunnerToLogPrefixMap } from 'backend/logger/logger'
@@ -27,14 +29,16 @@ export const gameManagerMap: Record<Runner, GameManager> = {
2729
hyperplay: HyperPlayGameManager,
2830
sideload: SideloadGameManager,
2931
gog: GOGGameManager,
30-
legendary: LegendaryGameManager
32+
legendary: LegendaryGameManager,
33+
steam: SteamGameManager
3134
}
3235

3336
export const libraryManagerMap: Record<Runner, LibraryManager> = {
3437
hyperplay: HyperPlayLibraryManager,
3538
legendary: LegendaryLibraryManager,
3639
gog: GOGLibraryManager,
37-
sideload: SideloadLibraryManager
40+
sideload: SideloadLibraryManager,
41+
steam: SteamLibraryManager
3842
}
3943

4044
function getDMElement(gameInfo: GameInfo, appName: string) {
@@ -157,6 +161,7 @@ export async function sendGameUpdatesNotifications() {
157161
export async function initStoreManagers() {
158162
await LegendaryLibraryManager.initLegendaryLibraryManager()
159163
await GOGLibraryManager.refresh()
164+
await SteamLibraryManager.refresh()
160165
loadEpicHyperPlayGameInfoMap()
161166
}
162167

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import CacheStore from 'backend/cache'
2+
import { TypeCheckedStoreBackend } from 'backend/electron_store'
3+
import { GameInfo } from 'common/types'
4+
5+
export const steamEnabledUsers = new TypeCheckedStoreBackend(
6+
'steamEnabledUsersConfig',
7+
{ cwd: 'steam_store' }
8+
)
9+
10+
export const libraryCache = new CacheStore<GameInfo[], 'games'>(
11+
'steam_library',
12+
null
13+
)
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
2+
import { getGameInfo as getSteamLibraryGameInfo } from './library'
3+
import { logError, LogPrefix } from 'backend/logger/logger'
4+
import {
5+
GameInfo,
6+
GameSettings,
7+
ExtraInfo,
8+
InstallPlatform,
9+
ExecResult,
10+
InstallArgs,
11+
UpdateArgs
12+
} from 'common/types'
13+
import { existsSync } from 'graceful-fs'
14+
import { GOGCloudSavesLocation } from 'common/types/gog'
15+
import { InstallResult, RemoveArgs } from 'common/types/game_manager'
16+
17+
export function getGameInfo(appName: string): GameInfo {
18+
const info = getSteamLibraryGameInfo(appName)
19+
if (!info) {
20+
logError(
21+
[
22+
'Could not get game info for',
23+
`${appName},`,
24+
'returning empty object. Something is probably gonna go wrong soon'
25+
],
26+
LogPrefix.Gog
27+
)
28+
return {
29+
app_name: '',
30+
runner: 'steam',
31+
art_cover: '',
32+
art_square: '',
33+
install: {},
34+
is_installed: false,
35+
title: '',
36+
canRunOffline: false
37+
}
38+
}
39+
return info
40+
}
41+
42+
export async function isGameAvailable(appName: string): Promise<boolean> {
43+
const info = getGameInfo(appName)
44+
if (info && info.is_installed) {
45+
if (info.install.install_path && existsSync(info.install.install_path!)) {
46+
return true
47+
} else {
48+
return false
49+
}
50+
}
51+
return false
52+
}
53+
54+
export async function getSettings(appName: string): Promise<GameSettings> {
55+
// not used
56+
return {} as GameSettings
57+
}
58+
59+
export async function getExtraInfo(appName: string): Promise<ExtraInfo> {
60+
// not used
61+
return {} as ExtraInfo
62+
}
63+
64+
export async function importGame(
65+
appName: string,
66+
path: string,
67+
platform: InstallPlatform
68+
): Promise<ExecResult> {
69+
// not used
70+
return { stderr: '', stdout: '' }
71+
}
72+
73+
export function onInstallOrUpdateOutput(
74+
appName: string,
75+
action: 'installing' | 'updating',
76+
data: string,
77+
totalDownloadSize: number
78+
): void {
79+
// not used
80+
}
81+
82+
export async function install(
83+
appName: string,
84+
args: InstallArgs
85+
): Promise<InstallResult> {
86+
// not used
87+
return { status: 'error', error: 'Not implemented' }
88+
}
89+
90+
export function isNative(appName: string): boolean {
91+
// not used
92+
return false
93+
}
94+
95+
export async function addShortcuts(
96+
appName: string,
97+
fromMenu?: boolean
98+
): Promise<void> {
99+
// not used
100+
}
101+
102+
export async function removeShortcuts(appName: string): Promise<void> {
103+
// not used
104+
}
105+
106+
export async function launch(
107+
appName: string,
108+
launchArguments?: string
109+
): Promise<boolean> {
110+
// not used
111+
return false
112+
}
113+
114+
export async function moveInstall(
115+
appName: string,
116+
newInstallPath: string
117+
): Promise<InstallResult> {
118+
// not used
119+
return { status: 'error', error: 'Not implemented' }
120+
}
121+
122+
export async function repair(appName: string): Promise<ExecResult> {
123+
// not used
124+
return { stderr: '', stdout: '' }
125+
}
126+
127+
export async function syncSaves(
128+
appName: string,
129+
arg: string,
130+
path: string,
131+
gogSaves?: GOGCloudSavesLocation[]
132+
): Promise<string> {
133+
// not used
134+
return ''
135+
}
136+
137+
export async function uninstall(args: RemoveArgs): Promise<ExecResult> {
138+
// not used
139+
return { stderr: '', stdout: '' }
140+
}
141+
142+
export async function update(
143+
appName: string,
144+
args?: UpdateArgs
145+
): Promise<InstallResult> {
146+
// not used
147+
return { status: 'error', error: 'Not implemented' }
148+
}
149+
150+
export async function forceUninstall(appName: string): Promise<void> {
151+
// not used
152+
}
153+
154+
export async function stop(appName: string): Promise<void> {
155+
// not used
156+
}
157+
158+
export async function pause(appName: string): Promise<void> {
159+
// not used
160+
}

0 commit comments

Comments
 (0)