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

Introduce Enable Gamescope toggle #4224

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Collaborator

@arielj arielj Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with this change we'll be disabling gamescope for all users that currently have it configured with the other checkboxes until they go and manually enable it

Maybe we need some code setting the initial enableGamescope setting to be the value of gameSettings.gamescope?.enableLimiter || gameSettings.gamescope?.enableUpscaling. Or maybe we can type it as boolean | null and default it to null with null meaning it was never set, use the previous logic?

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
Loading