Skip to content

A games launcher for GOG, Amazon and Epic Games for Linux, Windows and macOS.

2.6 KB
Raw Blame
import './index.scss'
import { Wrench } from 'lucide-react'
import { useTranslation } from 'react-i18next'

import type { EnviromentVariable } from 'common/types'
import { Icon, TextInputField } from 'frontend/components/UI'
import Button from 'frontend/components/UI/Button'
import EnvVariablesTable from 'frontend/screens/Settings/components/EnvVariablesTable'

type Props = {
  canRunWinetricks: boolean
  onOpenWinetricks: () => void
  environmentOptions: EnviromentVariable[]
  onEnvironmentOptionsChange: (environmentOptions: EnviromentVariable[]) => void
  umuGameId: string
  onUmuGameIdChange: (umuGameId: string) => void
  showUmuOptions: boolean
}

export default function SideloadAdvanced({
  canRunWinetricks,
  onOpenWinetricks,
  environmentOptions,
  onEnvironmentOptionsChange,
  umuGameId,
  onUmuGameIdChange,
  showUmuOptions
}: Props) {
  const { t } = useTranslation('gamepage')

  return (
    <details className="sideloadAdvanced">
      <summary className="sideloadAdvanced__summary">
        {t('sideload.advanced.title', 'Advanced')}
      </summary>
      <p className="sideloadAdvanced__hint">
        {t(
          'sideload.advanced.hint',
          'Optional. Configure Wine dependencies, the UMU GAMEID and environment variables before installing.'
        )}
      </p>

      <div className="sideloadAdvanced__winetricks">
        <span className="sideloadAdvanced__winetricksText">
          {t(
            'sideload.advanced.winetricks-description',
            'Install Wine dependencies in the selected prefix. They are used by the installer and by the app after it is added.'
          )}
        </span>
        <Button
          variant="secondary"
          icon={<Icon glyph={Wrench} size="sm" />}
          onClick={onOpenWinetricks}
          disabled={!canRunWinetricks}
        >
          {t('sideload.advanced.winetricks', 'Run winetricks')}
        </Button>
      </div>

      {showUmuOptions && (
        <TextInputField
          htmlId="sideload-umu-game-id"
          label={t('sideload.advanced.umu-id', 'UMU GAMEID')}
          placeholder={t(
            'sideload.advanced.umu-placeholder',
            'Leave blank to use the default'
          )}
          value={umuGameId}
          onChange={onUmuGameIdChange}
          info={t(
            'sideload.advanced.umu-info',
            'UMU uses GAMEID to apply Proton fixes and store metadata. Set it when the game or launcher is missing from the UMU database.'
          )}
        />
      )}

      <EnvVariablesTable
        environmentOptions={environmentOptions}
        onEnvironmentOptionsChange={onEnvironmentOptionsChange}
      />
    </details>
  )
}