Skip to content

Commit 0189b13

Browse files
authored
Implement menu options for opening the install file path and Wine prefix in the default file manager (#4285)
* Added context menu options for browsing install files and Wine prefix. * Added English translation * Added options for browsing files and prefix to game details page * Revert lock file * Reuse existing checks, remove context menu options, fix Linux check. * Fix lint error * Consistent formatting * Add check for Crossover * Remove console debug log
1 parent c217f9a commit 0189b13

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

public/locales/en/gamepage.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
},
5252
"button": {
5353
"add_to_favourites": "Add To Favourites",
54+
"browse_files": "Browse Files",
55+
"browse_wine_prefix": "Browse Wine Prefix",
5456
"cancel": "Pause/Cancel",
5557
"changelog": "Show Changelog",
5658
"continue": "Continue Download",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export default React.memo(function GamePage(): JSX.Element | null {
303303
}
304304

305305
const isMacNative = ['osx', 'Mac'].includes(installPlatform ?? '')
306-
const isLinuxNative = installPlatform === 'linux'
306+
const isLinuxNative = ['linux', 'Linux'].includes(installPlatform ?? '')
307307

308308
// create setting context functions
309309
const contextValues: GameContextType = {

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

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import './index.css'
22

3-
import React, { useContext, useEffect, useState } from 'react'
3+
import React, { useCallback, useContext, useEffect, useState } from 'react'
44

55
import { GameInfo, GameStatus, Runner } from 'common/types'
66

@@ -50,7 +50,7 @@ export default function GamesSubmenu({
5050
showDialogModal,
5151
setIsSettingsModalOpen
5252
} = useContext(ContextProvider)
53-
const { is } = useContext(GameContext)
53+
const { is, gameSettings } = useContext(GameContext)
5454
const isWin = platform === 'win32'
5555
const isLinux = platform === 'linux'
5656

@@ -233,6 +233,25 @@ export default function GamesSubmenu({
233233
isInstalled &&
234234
!isThirdPartyManaged
235235

236+
const hasWine =
237+
!is.win && !is.native && gameSettings?.wineVersion.type !== 'crossover'
238+
239+
const onBrowseFiles = useCallback(() => {
240+
const path = gameInfo.install.install_path || gameInfo.folder_name
241+
242+
if (path) {
243+
window.api.openFolder(path)
244+
}
245+
}, [gameInfo])
246+
247+
const onBrowsePrefix = useCallback(() => {
248+
const path = gameSettings?.winePrefix
249+
250+
if (path) {
251+
window.api.openFolder(path)
252+
}
253+
}, [gameSettings])
254+
236255
return (
237256
<>
238257
<div className="gameTools subMenuContainer">
@@ -377,6 +396,22 @@ export default function GamesSubmenu({
377396
{t('game.modify', 'Modify Installation')}
378397
</button>
379398
)}
399+
{isInstalled && (
400+
<button
401+
onClick={async () => onBrowseFiles()}
402+
className="link button is-text is-link"
403+
>
404+
{t('button.browse_files', 'Browse Files')}
405+
</button>
406+
)}
407+
{hasWine && (
408+
<button
409+
onClick={async () => onBrowsePrefix()}
410+
className="link button is-text is-link"
411+
>
412+
{t('button.browse_wine_prefix', 'Browse Wine Prefix')}
413+
</button>
414+
)}
380415
</div>
381416
</div>
382417
{showModal && (

0 commit comments

Comments
 (0)