Skip to content

Commit 7731826

Browse files
committed
Add support for wiki links in known fixes
1 parent 3f7033e commit 7731826

File tree

10 files changed

+73
-11
lines changed

10 files changed

+73
-11
lines changed

public/locales/en/gamepage.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,5 +284,6 @@
284284
"header": "This game is managed by a third-party application",
285285
"notice1": "This game is managed by a third-party application: \"{{application_name}}\"",
286286
"notice2": "After clicking Install, Heroic will run the application in order to complete the installation process"
287-
}
287+
},
288+
"wikiLink": "Important information about this game, read this:&nbsp;<1>Open page</1>"
288289
}

src/backend/api/misc.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ export const callTool = async (toolArgs: Tools) =>
115115
ipcRenderer.invoke('callTool', toolArgs)
116116
export const getAnticheatInfo = async (namespace: string) =>
117117
ipcRenderer.invoke('getAnticheatInfo', namespace)
118+
export const getKnownFixes = async (appName: string, runner: Runner) =>
119+
ipcRenderer.invoke('getKnownFixes', appName, runner)
118120

119121
export const clipboardReadText = async () =>
120122
ipcRenderer.invoke('clipboardReadText')

src/backend/downloadmanager/utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { DMStatus, InstallParams, Runner } from 'common/types'
99
import i18next from 'i18next'
1010
import { notify, showDialogBoxModalAuto } from '../dialog/dialog'
1111
import { isOnline } from '../online_monitor'
12-
import { fixesPath, isWindows } from 'backend/constants'
12+
import { fixesPath } from 'backend/constants'
1313
import path from 'path'
1414
import { existsSync, mkdirSync } from 'graceful-fs'
1515
import { storeMap } from 'common/utils'
@@ -74,9 +74,7 @@ async function installQueueElement(params: InstallParams): Promise<{
7474
}
7575

7676
try {
77-
if (!isWindows) {
78-
downloadFixesFor(appName, runner)
79-
}
77+
downloadFixesFor(appName, runner)
8078

8179
const { status, error } = await gameManagerMap[runner].install(appName, {
8280
path: path.replaceAll("'", ''),

src/backend/launcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ async function prepareWineLaunch(
684684
return { success: true, envVars: envVars }
685685
}
686686

687-
function readKnownFixes(appName: string, runner: Runner) {
687+
export function readKnownFixes(appName: string, runner: Runner) {
688688
const fixPath = join(fixesPath, `${appName}-${storeMap[runner]}.json`)
689689

690690
if (!existsSync(fixPath)) return null

src/backend/main.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ import {
103103
} from './logger/logger'
104104
import { gameInfoStore } from 'backend/storeManagers/legendary/electronStores'
105105
import { getFonts } from 'font-list'
106-
import { launchEventCallback, runWineCommand } from './launcher'
106+
import { launchEventCallback, readKnownFixes, runWineCommand } from './launcher'
107107
import shlex from 'shlex'
108108
import { initQueue } from './downloadmanager/downloadqueue'
109109
import {
@@ -1498,6 +1498,10 @@ ipcMain.on('changeGameVersionPinnedStatus', (e, appName, runner, status) => {
14981498
libraryManagerMap[runner].changeVersionPinnedStatus(appName, status)
14991499
})
15001500

1501+
ipcMain.handle('getKnownFixes', (e, appName, runner) =>
1502+
readKnownFixes(appName, runner)
1503+
)
1504+
15011505
/*
15021506
Other Keys that should go into translation files:
15031507
t('box.error.generic.title')

src/common/typedefs/ipcBridge.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import {
3434
InstallInfo,
3535
WikiInfo,
3636
UploadedLogData,
37-
RunnerCommandStub
37+
RunnerCommandStub,
38+
KnowFixesInfo
3839
} from 'common/types'
3940
import { GameOverride, SelectiveDownload } from 'common/types/legendary'
4041
import { GOGCloudSavesLocation } from 'common/types/gog'
@@ -251,6 +252,7 @@ interface AsyncIPCFunctions {
251252
removeFromSteam: (appName: string, runner: Runner) => Promise<void>
252253
isAddedToSteam: (appName: string, runner: Runner) => Promise<boolean>
253254
getAnticheatInfo: (appNamespace: string) => AntiCheatInfo | null
255+
getKnownFixes: (appName: string, runner: Runner) => KnowFixesInfo | null
254256
getEosOverlayStatus: () => {
255257
isInstalled: boolean
256258
version?: string

src/common/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ export interface KnowFixesInfo {
768768
winetricks?: string[]
769769
runInPrefix?: string[]
770770
envVariables?: Record<string, string>
771+
wikiLink?: string
771772
}
772773

773774
export interface UploadedLogData {

src/frontend/hooks/hasKnownFixes.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { useEffect, useState } from 'react'
2+
import { KnowFixesInfo, Runner } from 'common/types'
3+
4+
export const hasKnownFixes = (appName: string, runner: Runner) => {
5+
const [knownFixes, setKnownFixes] = useState<KnowFixesInfo | null>(null)
6+
7+
useEffect(() => {
8+
window.api
9+
.getKnownFixes(appName, runner)
10+
.then((info: KnowFixesInfo | null) => {
11+
console.log({ info })
12+
setKnownFixes(info)
13+
})
14+
}, [appName])
15+
16+
return knownFixes
17+
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,3 +916,20 @@
916916
left: 0;
917917
right: unset;
918918
}
919+
920+
.gameConfigContainer {
921+
.wikiLink {
922+
background: var(--status-warning);
923+
color: black;
924+
padding: 0.5rem 1rem;
925+
display: flex;
926+
align-items: center;
927+
& svg {
928+
margin-inline-end: 0.5rem;
929+
}
930+
& a {
931+
color: black;
932+
text-decoration: underline;
933+
}
934+
}
935+
}

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import {
2020
sendKill,
2121
updateGame
2222
} from 'frontend/helpers'
23-
import { NavLink, useLocation, useParams } from 'react-router-dom'
24-
import { useTranslation } from 'react-i18next'
23+
import { Link, NavLink, useLocation, useParams } from 'react-router-dom'
24+
import { Trans, useTranslation } from 'react-i18next'
2525
import ContextProvider from 'frontend/state/ContextProvider'
2626
import { CachedImage, UpdateComponent, TabPanel } from 'frontend/components/UI'
2727
import UninstallModal from 'frontend/components/UI/UninstallModal'
@@ -71,13 +71,14 @@ import { hasAnticheatInfo } from 'frontend/hooks/hasAnticheatInfo'
7171
import { hasHelp } from 'frontend/hooks/hasHelp'
7272
import Genres from './components/Genres'
7373
import ReleaseDate from './components/ReleaseDate'
74+
import { hasKnownFixes } from 'frontend/hooks/hasKnownFixes'
7475

7576
export default React.memo(function GamePage(): JSX.Element | null {
7677
const { appName, runner } = useParams() as { appName: string; runner: Runner }
7778
const location = useLocation() as {
7879
state: { fromDM: boolean; gameInfo: GameInfo }
7980
}
80-
const { t } = useTranslation('gamepage')
81+
const { t, i18n } = useTranslation('gamepage')
8182
const { t: t2 } = useTranslation()
8283

8384
const { gameInfo: locationGameInfo } = location.state
@@ -133,6 +134,8 @@ export default React.memo(function GamePage(): JSX.Element | null {
133134

134135
const anticheatInfo = hasAnticheatInfo(gameInfo)
135136

137+
const knownFixes = hasKnownFixes(appName, runner)
138+
136139
const isWin = platform === 'win32'
137140
const isLinux = platform === 'linux'
138141
const isMac = platform === 'darwin'
@@ -347,6 +350,21 @@ export default React.memo(function GamePage(): JSX.Element | null {
347350

348351
const hasRequirements = extraInfo ? extraInfo.reqs.length > 0 : false
349352

353+
let wikiLink = <></>
354+
if (knownFixes && knownFixes.wikiLink) {
355+
wikiLink = (
356+
<p className="wikiLink">
357+
<Info />
358+
<span>
359+
<Trans key="wikiLink" i18n={i18n}>
360+
Important information about this game, read this:&nbsp;
361+
<Link to={knownFixes.wikiLink}>Open page</Link>
362+
</Trans>
363+
</span>
364+
</p>
365+
)
366+
}
367+
350368
return (
351369
<div className="gameConfigContainer">
352370
{!!(art_background ?? art_cover) &&
@@ -439,6 +457,7 @@ export default React.memo(function GamePage(): JSX.Element | null {
439457
/>
440458

441459
<Anticheat anticheatInfo={anticheatInfo} />
460+
{wikiLink}
442461
<MainButton
443462
gameInfo={gameInfo}
444463
handlePlay={handlePlay}
@@ -499,6 +518,7 @@ export default React.memo(function GamePage(): JSX.Element | null {
499518
gameInfo={gameInfo}
500519
setLaunchArguments={setLaunchArguments}
501520
/>
521+
{wikiLink}
502522
<div className="buttons">
503523
<MainButton
504524
gameInfo={gameInfo}

0 commit comments

Comments
 (0)