Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement menu options for opening the install file path and Wine prefix in the default file manager #4285

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
2 changes: 2 additions & 0 deletions public/locales/en/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
},
"button": {
"add_to_favourites": "Add To Favourites",
"browse_files": "Browse Files",
"browse_wine_prefix": "Browse Wine Prefix",
"cancel": "Pause/Cancel",
"changelog": "Show Changelog",
"continue": "Continue Download",
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/screens/Game/GamePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export default React.memo(function GamePage(): JSX.Element | null {
}

const isMacNative = ['osx', 'Mac'].includes(installPlatform ?? '')
const isLinuxNative = installPlatform === 'linux'
const isLinuxNative = ['linux', 'Linux'].includes(installPlatform ?? '')

// create setting context functions
const contextValues: GameContextType = {
Expand Down
39 changes: 37 additions & 2 deletions src/frontend/screens/Game/GameSubMenu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './index.css'

import React, { useContext, useEffect, useState } from 'react'
import React, { useCallback, useContext, useEffect, useState } from 'react'

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

Expand Down Expand Up @@ -50,7 +50,7 @@ export default function GamesSubmenu({
showDialogModal,
setIsSettingsModalOpen
} = useContext(ContextProvider)
const { is } = useContext(GameContext)
const { is, gameSettings } = useContext(GameContext)
const isWin = platform === 'win32'
const isLinux = platform === 'linux'

Expand Down Expand Up @@ -233,6 +233,25 @@ export default function GamesSubmenu({
isInstalled &&
!isThirdPartyManaged

const hasWine =
!is.win && !is.native && gameSettings?.wineVersion.type !== 'crossover'

const onBrowseFiles = useCallback(() => {
const path = gameInfo.install.install_path || gameInfo.folder_name
luluco250 marked this conversation as resolved.
Show resolved Hide resolved

if (path) {
window.api.openFolder(path)
}
}, [gameInfo])

const onBrowsePrefix = useCallback(() => {
const path = gameSettings?.winePrefix

if (path) {
window.api.openFolder(path)
}
}, [gameSettings])

return (
<>
<div className="gameTools subMenuContainer">
Expand Down Expand Up @@ -377,6 +396,22 @@ export default function GamesSubmenu({
{t('game.modify', 'Modify Installation')}
</button>
)}
{isInstalled && (
<button
onClick={async () => onBrowseFiles()}
className="link button is-text is-link"
>
{t('button.browse_files', 'Browse Files')}
</button>
)}
{hasWine && (
<button
onClick={async () => onBrowsePrefix()}
className="link button is-text is-link"
>
{t('button.browse_wine_prefix', 'Browse Wine Prefix')}
</button>
)}
</div>
</div>
{showModal && (
Expand Down
Loading