Skip to content

Commit

Permalink
Introduce Enable Gamescope toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Etaash-mathamsetty committed Dec 30, 2024
1 parent a4f7937 commit 8c64e0a
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 50 deletions.
1 change: 1 addition & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@
"fsync": "Enable Fsync",
"gamemode": "Use GameMode (Feral Game Mode needs to be installed)",
"gamescope": {
"enableGamescope": "Enable Gamescope",
"enableLimiter": "Enable FPS Limiter",
"enableUpscaling": "Enables Upscaling",
"missingMsg": "We could not found gamescope on the PATH. Install it or add it to the PATH."
Expand Down
6 changes: 1 addition & 5 deletions src/backend/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,7 @@ async function prepareLaunch(
}
}

if (
(gameSettings.gamescope?.enableLimiter ||
gameSettings.gamescope?.enableUpscaling) &&
!isSteamDeckGameMode
) {
if (gameSettings.gamescope?.enableGamescope && !isSteamDeckGameMode) {
const gameScopeBin = await searchForExecutableOnPath('gamescope')
if (!gameScopeBin) {
logWarning(
Expand Down
1 change: 1 addition & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ export interface WindowProps extends Electron.Rectangle {
}

interface GameScopeSettings {
enableGamescope: boolean
enableUpscaling: boolean
enableLimiter: boolean
windowType: string
Expand Down
111 changes: 66 additions & 45 deletions src/frontend/screens/Settings/components/Gamescope.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Gamescope = () => {
const { platform } = useContext(ContextProvider)
const isLinux = platform === 'linux'
const [gamescope, setGamescope] = useSetting('gamescope', {
enableGamescope: false,
enableUpscaling: false,
enableLimiter: false,
windowType: 'fullscreen',
Expand Down Expand Up @@ -115,22 +116,38 @@ const Gamescope = () => {

return (
<div className="gamescopeSettings">
{/* Enable Upscale */}
{/* Enable Gamescope */}
<div className="toggleRow">
<ToggleSwitch
htmlId="gamescopeUpscaleToggle"
value={gamescope.enableUpscaling || false}
htmlId="gamescopeEnableToggle"
value={gamescope.enableGamescope || false}
handleChange={() =>
setGamescope({
...gamescope,
enableUpscaling: !gamescope.enableUpscaling
enableGamescope: !gamescope.enableGamescope
})
}
title={t('setting.gamescope.enableUpscaling', 'Enables Upscaling')}
title={t('setting.gamescope.enableGamescope', 'Enable Gamescope')}
/>
</div>
{/* Enable Upscale */}
{gamescope.enableGamescope && (
<div className="toggleRow">
<ToggleSwitch
htmlId="gamescopeUpscaleToggle"
value={gamescope.enableUpscaling || false}
handleChange={() =>
setGamescope({
...gamescope,
enableUpscaling: !gamescope.enableUpscaling
})
}
title={t('setting.gamescope.enableUpscaling', 'Enables Upscaling')}
/>
</div>
)}
{/* Upscale Settings */}
{gamescope.enableUpscaling && (
{gamescope.enableUpscaling && gamescope.enableGamescope && (
<>
{/* Upscale Method */}
<SelectField
Expand Down Expand Up @@ -289,21 +306,23 @@ const Gamescope = () => {
</>
)}
{/* Enable Limiter*/}
<div className="toggleRow">
<ToggleSwitch
htmlId="gamescopeLimiterToggle"
value={gamescope.enableLimiter || false}
handleChange={() =>
setGamescope({
...gamescope,
enableLimiter: !gamescope.enableLimiter
})
}
title={t('setting.gamescope.enableLimiter', 'Enable FPS Limiter')}
/>
</div>
{gamescope.enableGamescope && (
<div className="toggleRow">
<ToggleSwitch
htmlId="gamescopeLimiterToggle"
value={gamescope.enableLimiter || false}
handleChange={() =>
setGamescope({
...gamescope,
enableLimiter: !gamescope.enableLimiter
})
}
title={t('setting.gamescope.enableLimiter', 'Enable FPS Limiter')}
/>
</div>
)}
{/* FPS Limiter Settings */}
{gamescope.enableLimiter && (
{gamescope.enableLimiter && gamescope.enableGamescope && (
<div className="row">
<TextInputField
label={t('options.gamescope.fpsLimiter', 'FPS Limiter')}
Expand Down Expand Up @@ -362,31 +381,33 @@ const Gamescope = () => {
</div>
)}
{/* Additional Options */}
<TextInputField
label={t('options.gamescope.additionalOptions', 'Additional Options')}
htmlId="additionalOptions"
placeholder=""
value={additionalOptions}
afterInput={
<FontAwesomeIcon
className="helpIcon"
icon={faCircleInfo}
title={t(
'help.gamescope.additionalOptions',
'Additional commandline flags to pass into gamescope.'
)}
/>
}
onChange={(event: ChangeEvent<HTMLInputElement>) => {
setAdditionalOptions(event.currentTarget.value)
}}
onBlur={(event: ChangeEvent<HTMLInputElement>) =>
setGamescope({
...gamescope,
additionalOptions: event.currentTarget.value
})
}
/>
{gamescope.enableGamescope && (
<TextInputField
label={t('options.gamescope.additionalOptions', 'Additional Options')}
htmlId="additionalOptions"
placeholder=""
value={additionalOptions}
afterInput={
<FontAwesomeIcon
className="helpIcon"
icon={faCircleInfo}
title={t(
'help.gamescope.additionalOptions',
'Additional commandline flags to pass into gamescope.'
)}
/>
}
onChange={(event: ChangeEvent<HTMLInputElement>) => {
setAdditionalOptions(event.currentTarget.value)
}}
onBlur={(event: ChangeEvent<HTMLInputElement>) =>
setGamescope({
...gamescope,
additionalOptions: event.currentTarget.value
})
}
/>
)}
</div>
)
}
Expand Down

0 comments on commit 8c64e0a

Please sign in to comment.