Skip to content

[GOG]: add support for linux native dlcs in modify install dialog #3895

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

Merged
merged 1 commit into from
Aug 9, 2024
Merged
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
31 changes: 27 additions & 4 deletions src/backend/storeManagers/gog/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,12 @@ export async function install(
}

const sizeOnDisk = await getPathDiskSize(join(path, gameInfo.folder_name))
const install_path = join(path, gameInfo.folder_name)

const installedData: InstalledInfo = {
platform: installPlatform,
executable: '',
install_path: join(path, gameInfo.folder_name),
install_path,
install_size: getFileSize(sizeOnDisk),
is_dlc: false,
version: additionalInfo ? additionalInfo.version : installInfo.game.version,
Expand Down Expand Up @@ -434,6 +435,17 @@ export async function install(
LogPrefix.Gog
)
}
} else if (isLinuxNative) {
const installer = join(install_path, 'support/postinst.sh')
if (existsSync(installer)) {
logInfo(`Running ${installer}`, LogPrefix.Gog)
await spawnAsync(installer, []).catch((err) =>
logError(
`Failed to run linux installer: ${installer} - ${err}`,
LogPrefix.Gog
)
)
}
}
addShortcuts(appName)
return { status: 'done' }
Expand Down Expand Up @@ -1117,9 +1129,6 @@ export async function update(
gameObject.version = installInfo.game.version
gameObject.branch = updateOverwrites?.branch
gameObject.language = overwrittenLanguage
if (updateOverwrites?.dlcs) {
gameObject.installedDLCs = updateOverwrites?.dlcs
}
gameObject.versionEtag = etag
} else {
const installerInfo = await getLinuxInstallerInfo(appName)
Expand All @@ -1128,6 +1137,9 @@ export async function update(
}
gameObject.version = installerInfo.version
}
if (updateOverwrites?.dlcs) {
gameObject.installedDLCs = updateOverwrites?.dlcs
}
const sizeOnDisk = await getPathDiskSize(join(gameObject.install_path))
gameObject.install_size = getFileSize(sizeOnDisk)
installedGamesStore.set('installed', installedArray)
Expand All @@ -1140,6 +1152,17 @@ export async function update(
(isWindows || existsSync(gameSettings.winePrefix))
) {
await setup(appName, gameObject, false)
} else if (gameObject.platform === 'linux') {
const installer = join(gameObject.install_path, 'support/postinst.sh')
if (existsSync(installer)) {
logInfo(`Running ${installer}`, LogPrefix.Gog)
await spawnAsync(installer, []).catch((err) =>
logError(
`Failed to run linux installer: ${installer} - ${err}`,
LogPrefix.Gog
)
)
}
}
sendGameStatusUpdate({
appName: appName,
Expand Down
3 changes: 1 addition & 2 deletions src/frontend/screens/Game/GamePage/components/DotsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const DotsMenu = ({ gameInfo, handleUpdate }: Props) => {
const [showChangelog, setShowChangelog] = useState(false)
const [showModifyInstallModal, setShowModifyInstallModal] = useState(false)

const { is_installed, title, install } = gameInfo
const { is_installed, title } = gameInfo

const hasRequirements = (gameExtraInfo?.reqs || []).length > 0

Expand All @@ -50,7 +50,6 @@ const DotsMenu = ({ gameInfo, handleUpdate }: Props) => {
}
changelog={gameExtraInfo?.changelog}
runner={gameInfo.runner}
installPlatform={install.platform}
handleUpdate={handleUpdate}
handleChangeLog={() => setShowChangelog(true)}
disableUpdate={is.installing || is.updating}
Expand Down
5 changes: 1 addition & 4 deletions src/frontend/screens/Game/GameSubMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ interface Props {
title: string
storeUrl: string
changelog?: string
installPlatform?: string
runner: Runner
handleUpdate: () => void
handleChangeLog: () => void
Expand All @@ -37,7 +36,6 @@ export default function GamesSubmenu({
storeUrl,
changelog,
runner,
installPlatform,
handleUpdate,
handleChangeLog,
disableUpdate,
Expand Down Expand Up @@ -235,8 +233,7 @@ export default function GamesSubmenu({
onShowModifyInstall &&
['legendary', 'gog'].includes(runner) &&
isInstalled &&
!isThirdPartyManaged &&
installPlatform !== 'linux'
!isThirdPartyManaged

return (
<>
Expand Down
57 changes: 32 additions & 25 deletions src/frontend/screens/Game/ModifyInstallModal/GOG/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function GOGModifyInstallModal({
}: GOGModifyInstallModal) {
const { t, i18n } = useTranslation('gamepage')
const { t: tr } = useTranslation()
const isLinux = gameInfo.install.platform === 'linux'
const [gameInstallInfo, setGameInstallInfo] = useState<GogInstallInfo>()

const [installLanguages, setInstallLanguages] = useState<string[]>([])
Expand Down Expand Up @@ -65,7 +66,7 @@ export default function GOGModifyInstallModal({
const [currentTab, setCurrentTab] = useState('updates')

const handleConfirm = () => {
const gameBuild = selectedBuild || builds[0].build_id
const gameBuild = selectedBuild || builds[0]?.build_id
const versionPinned = !!selectedBuild
const buildModified = gameBuild !== gameInfo.install.buildId
const languageModified = installLanguage !== gameInfo.install.language
Expand Down Expand Up @@ -100,7 +101,9 @@ export default function GOGModifyInstallModal({
}

const gameModified =
buildModified || branchModified || languageModified || dlcModified
(!isLinux && (buildModified || branchModified)) ||
languageModified ||
dlcModified

if (gameModified) {
// Create update
Expand Down Expand Up @@ -247,35 +250,39 @@ export default function GOGModifyInstallModal({
)}
</Tabs>
<TabPanel value={currentTab} index={'updates'}>
<div className="ModifyInstall__branch">
<BranchSelector
appName={gameInfo.app_name}
branches={branches}
branch={branch}
setBranch={setBranch}
savedBranchPassword={savedBranchPassword}
onPasswordChange={(newPasswd) => setSavedBranchPassword(newPasswd)}
/>
</div>

{installLanguages.length > 1 && (
<div className="ModifyInstall__languages">
<GameLanguageSelector
installLanguages={installLanguages}
setInstallLanguage={setInstallLanguage}
installPlatform={gameInfo.install.platform ?? 'windows'}
installLanguage={installLanguage}
{!!branches.length && (
<div className="ModifyInstall__branch">
<BranchSelector
appName={gameInfo.app_name}
branches={branches}
branch={branch}
setBranch={setBranch}
savedBranchPassword={savedBranchPassword}
onPasswordChange={(newPasswd) =>
setSavedBranchPassword(newPasswd)
}
/>
</div>
)}

<div className="ModifyInstall__version">
<BuildSelector
gameBuilds={builds}
selectedBuild={selectedBuild}
setSelectedBuild={setSelectedBuild}
<div className="ModifyInstall__languages">
<GameLanguageSelector
installLanguages={installLanguages}
setInstallLanguage={setInstallLanguage}
installPlatform={gameInfo.install.platform ?? 'windows'}
installLanguage={installLanguage}
/>
</div>

{!!builds.length && (
<div className="ModifyInstall__version">
<BuildSelector
gameBuilds={builds}
selectedBuild={selectedBuild}
setSelectedBuild={setSelectedBuild}
/>
</div>
)}
</TabPanel>
<TabPanel value={currentTab} index={'dlc'}>
<div className="ModifyInstall__gogDlcs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default function GameLanguageSelector({
label={`${t('game.language', 'Language')}:`}
htmlId="languagePick"
value={installLanguage}
disabled={installLanguages?.length === 1}
onChange={(e) => setInstallLanguage(e.target.value)}
>
{installLanguages &&
Expand Down
Loading