Skip to content

Commit 585295e

Browse files
committed
feat: add Steam installation dialog and integrate with game launch process
1 parent aba09d0 commit 585295e

File tree

5 files changed

+47
-6
lines changed

5 files changed

+47
-6
lines changed

public/locales/en/translation.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,12 @@
11311131
"processing": "Processing files, please wait"
11321132
},
11331133
"steam": {
1134+
"install": {
1135+
"later": "Install Later",
1136+
"launch": "Launch Steam",
1137+
"message": "Please install this game from Steam and refresh the library afterwards to play on HyperPlay.",
1138+
"title": "Install from Steam"
1139+
},
11341140
"integration": {
11351141
"requirements": {
11361142
"part1": "To ensure this integration works properly and HyperPlay can access your games, you must have",
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { DialogType, ButtonOptions } from 'common/types'
2+
import { DialogModalOptions } from 'frontend/types'
3+
import { TFunction } from 'i18next'
4+
5+
export function showSteamInstallDialog(
6+
showDialogModal: (options: DialogModalOptions) => void,
7+
t: TFunction,
8+
appName: string
9+
) {
10+
showDialogModal({
11+
type: 'MESSAGE',
12+
title: t('steam.install.title', 'Install from Steam'),
13+
message: t(
14+
'steam.install.message',
15+
'Please install this game from Steam and refresh the library afterwards to play on HyperPlay.'
16+
),
17+
buttons: [
18+
{
19+
text: t('steam.install.launch', 'Launch Steam'),
20+
onClick: () => window.api.openExternalUrl(`steam://install/${appName}`)
21+
},
22+
{
23+
text: t('steam.install.later', 'Install Later'),
24+
onClick: () => {}
25+
}
26+
]
27+
} as {
28+
type: DialogType
29+
title: string
30+
message: string
31+
buttons: ButtonOptions[]
32+
})
33+
}

src/frontend/screens/Game/GamePage/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
import { NavLink, useLocation, useParams } from 'react-router-dom'
2121
import { useTranslation } from 'react-i18next'
2222
import ContextProvider from 'frontend/state/ContextProvider'
23+
2324
import { UpdateComponent, SelectField } from 'frontend/components/UI'
2425
import walletStore from 'frontend/state/WalletState'
2526
import onboardingStore from 'frontend/store/OnboardingStore'
@@ -69,6 +70,7 @@ import libraryState from 'frontend/state/libraryState'
6970
import DMQueueState from 'frontend/state/DMQueueState'
7071
import { useEstimatedUncompressedSize } from 'frontend/hooks/useEstimatedUncompressedSize'
7172
import authState from 'frontend/state/authState'
73+
import { showSteamInstallDialog } from 'frontend/components/UI/DialogHandler/components/MessageBoxModal/showSteamInstallDialog'
7274

7375
type locationState = {
7476
fromDM?: boolean
@@ -966,8 +968,7 @@ export default observer(function GamePage(): React.JSX.Element | null {
966968

967969
async function mainAction(is_installed: boolean) {
968970
if (isSteam) {
969-
window.api.openExternalUrl(`steam://install/${appName}`)
970-
return
971+
return showSteamInstallDialog(showDialogModal, t, appName)
971972
}
972973

973974
// resume download

src/frontend/screens/Library/components/GameCard/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import libraryState from 'frontend/state/libraryState'
2828
import DMQueueState from 'frontend/state/DMQueueState'
2929
import authState from 'frontend/state/authState'
3030
import { getImageFormattingForArtSquare } from 'frontend/screens/Game/GamePicture'
31+
import { showSteamInstallDialog } from 'frontend/components/UI/DialogHandler/components/MessageBoxModal/showSteamInstallDialog'
3132

3233
interface Card {
3334
buttonClick: () => void
@@ -435,8 +436,7 @@ const GameCard = ({
435436

436437
async function mainAction(runner: Runner) {
437438
if (runner === 'steam') {
438-
window.api.openExternalUrl(`steam://install/${appName}`)
439-
return
439+
return showSteamInstallDialog(showDialogModal, t, appName)
440440
}
441441

442442
if (isInstalling || isExtracting || isPaused) {

src/frontend/screens/Library/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import React, {
99
import { UpdateComponent } from 'frontend/components/UI'
1010
import { useTranslation } from 'react-i18next'
1111
import ContextProvider from 'frontend/state/ContextProvider'
12+
import { showSteamInstallDialog } from 'frontend/components/UI/DialogHandler/components/MessageBoxModal/showSteamInstallDialog'
1213
import GamesList from './components/GamesList'
1314
import { FilterItem, GameInfo, Runner } from 'common/types'
1415
import ErrorComponent from 'frontend/components/UI/ErrorComponent'
@@ -37,7 +38,7 @@ type ModalState = {
3738
}
3839

3940
export default observer(function Library(): React.JSX.Element {
40-
const { layout, epic, gog, platform, connectivity } =
41+
const { layout, epic, gog, platform, connectivity, showDialogModal } =
4142
useContext(ContextProvider)
4243
const { t } = useTranslation()
4344

@@ -112,7 +113,7 @@ export default observer(function Library(): React.JSX.Element {
112113
gameInfo: GameInfo | null
113114
) {
114115
if (runner === 'steam') {
115-
return window.api.openExternalUrl(`steam://install/${appName}`)
116+
return showSteamInstallDialog(showDialogModal, t, appName)
116117
}
117118
setShowModal({ game: appName, show: true, runner, gameInfo })
118119
}

0 commit comments

Comments
 (0)