|
| 1 | +import React, { useContext } from 'react' |
| 2 | +import { useTranslation } from 'react-i18next' |
| 3 | +import { SelectField, ToggleSwitch } from 'frontend/components/UI' |
| 4 | +import useSetting from 'frontend/hooks/useSetting' |
| 5 | +import ContextProvider from 'frontend/state/ContextProvider' |
| 6 | +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' |
| 7 | +import { faCircleInfo } from '@fortawesome/free-solid-svg-icons' |
| 8 | +import SettingsContext from '../SettingsContext' |
| 9 | + |
| 10 | +const EnableFSR = () => { |
| 11 | + const { t } = useTranslation() |
| 12 | + const { platform } = useContext(ContextProvider) |
| 13 | + const { isLinuxNative } = useContext(SettingsContext) |
| 14 | + const isLinux = platform === 'linux' |
| 15 | + const [enableFSR, setEnableFSR] = useSetting('enableFSR', false) |
| 16 | + const [maxSharpness, setFsrSharpness] = useSetting('maxSharpness', 5) |
| 17 | + |
| 18 | + if (!isLinux || isLinuxNative) { |
| 19 | + return <></> |
| 20 | + } |
| 21 | + |
| 22 | + return ( |
| 23 | + <> |
| 24 | + <div className="toggleRow"> |
| 25 | + <ToggleSwitch |
| 26 | + htmlId="enableFSR" |
| 27 | + value={enableFSR || false} |
| 28 | + handleChange={() => setEnableFSR(!enableFSR)} |
| 29 | + title={t( |
| 30 | + 'setting.enableFSRHack', |
| 31 | + 'Enable FSR Hack (Wine version needs to support it)' |
| 32 | + )} |
| 33 | + /> |
| 34 | + |
| 35 | + <FontAwesomeIcon |
| 36 | + className="helpIcon" |
| 37 | + icon={faCircleInfo} |
| 38 | + title={t( |
| 39 | + 'help.amdfsr', |
| 40 | + "AMD's FSR helps boost framerate by upscaling lower resolutions in Fullscreen Mode. Image quality increases from 5 to 1 at the cost of a slight performance hit. Enabling may improve performance." |
| 41 | + )} |
| 42 | + /> |
| 43 | + </div> |
| 44 | + |
| 45 | + {enableFSR && ( |
| 46 | + <SelectField |
| 47 | + htmlId="setFsrSharpness" |
| 48 | + onChange={(event) => setFsrSharpness(Number(event.target.value))} |
| 49 | + value={maxSharpness.toString()} |
| 50 | + label={t('setting.FsrSharpnessStrenght', 'FSR Sharpness Strength')} |
| 51 | + extraClass="smaller" |
| 52 | + > |
| 53 | + {Array.from(Array(5).keys()).map((n) => ( |
| 54 | + <option key={n + 1}>{n + 1}</option> |
| 55 | + ))} |
| 56 | + </SelectField> |
| 57 | + )} |
| 58 | + </> |
| 59 | + ) |
| 60 | +} |
| 61 | + |
| 62 | +export default EnableFSR |
0 commit comments