Skip to content

Commit

Permalink
[Tech] Update Legendary. Replace XDG_CONFIG_HOME variable. Disallow u…
Browse files Browse the repository at this point in the history
…ninstalling epic game if installing one (Heroic-Games-Launcher#3168)

* Update legendary to stop using XDG_CONFIG_HOME

* Disallow uninstalling epic game while an epic install is in progress

---------

Co-authored-by: Etaash Mathamsetty <etaash.mathamsetty@gmail.com>
  • Loading branch information
arielj and Etaash-mathamsetty authored Oct 29, 2023
1 parent 015d5fc commit 896a396
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 22 deletions.
Binary file modified public/bin/darwin/legendary
Binary file not shown.
Binary file modified public/bin/linux/legendary
Binary file not shown.
Binary file modified public/bin/win32/legendary.exe
100644 → 100755
Binary file not shown.
2 changes: 2 additions & 0 deletions public/locales/en/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"title": "Change Games Install Path"
},
"choose": "Choose",
"close": "Close",
"importpath": "Choose Game Folder to import",
"move": {
"message": "This can take a long time, are you sure?",
Expand All @@ -32,6 +33,7 @@
"title": "Stop Installation"
},
"uninstall": {
"cannotUninstallEpic": "Epic games cannot be uninstalled while another Epic game is being installed.",
"checkbox": "Remove prefix: {{prefix}}{{newLine}}Note: This can't be undone and will also remove not backed up save files.",
"dlc": "Do you want to Uninstall this DLC?",
"message": "Do you want to uninstall this game?",
Expand Down
18 changes: 0 additions & 18 deletions src/backend/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,24 +397,6 @@ function setupWineEnvVars(
if (gameSettings.enableDXVKFpsLimit) {
ret.DXVK_FRAME_RATE = gameSettings.DXVKFpsCap
}
if (
gameSettings.showMangohud &&
!gameSettings.enviromentOptions.find(
({ key }) => key === 'MANGOHUD_CONFIGFILE'
)
) {
if (!process.env.XDG_CONFIG_HOME) {
ret.MANGOHUD_CONFIGFILE = join(
flatPakHome,
'.config/MangoHud/MangoHud.conf'
)
} else {
ret.MANGOHUD_CONFIGFILE = join(
process.env.XDG_CONFIG_HOME,
'MangoHud/MangoHud.conf'
)
}
}
if (gameSettings.enableFSR) {
ret.WINE_FULLSCREEN_FSR = '1'
ret.WINE_FULLSCREEN_FSR_STRENGTH =
Expand Down
4 changes: 2 additions & 2 deletions src/backend/storeManagers/legendary/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,15 +647,15 @@ export async function runRunnerCommand(
): Promise<ExecResult> {
const { dir, bin } = getLegendaryBin()

// Set XDG_CONFIG_HOME to a custom, Heroic-specific location so user-made
// Set LEGENDARY_CONFIG_PATH to a custom, Heroic-specific location so user-made
// changes to Legendary's main config file don't affect us
if (!options) {
options = {}
}
if (!options.env) {
options.env = {}
}
options.env.XDG_CONFIG_HOME = dirname(legendaryConfigPath)
options.env.LEGENDARY_CONFIG_PATH = legendaryConfigPath

const commandParts = commandToArgsArray(command)

Expand Down
31 changes: 30 additions & 1 deletion src/frontend/components/UI/UninstallModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import './index.scss'
import React, { useEffect, useState } from 'react'
import React, { useContext, useEffect, useState } from 'react'
import {
Dialog,
DialogContent,
Expand All @@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next'
import { Runner } from 'common/types'
import ToggleSwitch from '../ToggleSwitch'
import { useNavigate, useLocation } from 'react-router-dom'
import ContextProvider from 'frontend/state/ContextProvider'

interface UninstallModalProps {
appName: string
Expand All @@ -33,6 +34,7 @@ const UninstallModal: React.FC<UninstallModalProps> = function ({
const [showUninstallModal, setShowUninstallModal] = useState(false)
const navigate = useNavigate()
const location = useLocation()
const { installingEpicGame } = useContext(ContextProvider)

const checkIfIsNative = async () => {
// This assumes native games are installed should be changed in the future
Expand Down Expand Up @@ -94,6 +96,33 @@ const UninstallModal: React.FC<UninstallModalProps> = function ({

const showWineCheckbox = !isNative && !isDlc

// disallow uninstalling epic games if an epic game is being installed
if (installingEpicGame && runner === 'legendary') {
return (
<>
{showUninstallModal && (
<Dialog onClose={onClose} showCloseButton className="uninstall-modal">
<DialogHeader onClose={onClose}>
{t('gamepage:box.uninstall.title')}
</DialogHeader>
<DialogContent>
{t(
'gamepage:box.uninstall.cannotUninstallEpic',
'Epic games cannot be uninstalled while another Epic game is being installed.'
)}
</DialogContent>
<DialogFooter>
<button onClick={onClose} className={`button outline`}>
{t('box.close', 'Close')}
</button>
</DialogFooter>
</Dialog>
)}
</>
)
}

// normal dialog to uninstall a game
return (
<>
{showUninstallModal && (
Expand Down
1 change: 1 addition & 0 deletions src/frontend/state/ContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const initialContext: ContextType = {
login: async () => Promise.resolve(''),
logout: async () => Promise.resolve()
},
installingEpicGame: false,
sideloadedLibrary: [],
error: false,
gameUpdates: [],
Expand Down
8 changes: 7 additions & 1 deletion src/frontend/state/GlobalState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -806,10 +806,15 @@ class GlobalState extends PureComponent<Props> {
hiddenGames,
settingsModalOpen,
hideChangelogsOnStartup,
lastChangelogShown
lastChangelogShown,
libraryStatus
} = this.state
const isRTL = RTL_LANGUAGES.includes(language)

const installingEpicGame = libraryStatus.some(
(game) => game.status === 'installing' && game.runner === 'legendary'
)

return (
<ContextProvider.Provider
value={{
Expand All @@ -834,6 +839,7 @@ class GlobalState extends PureComponent<Props> {
login: this.amazonLogin,
logout: this.amazonLogout
},
installingEpicGame,
setLanguage: this.setLanguage,
isRTL,
refresh: this.refresh,
Expand Down
1 change: 1 addition & 0 deletions src/frontend/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export interface ContextType {
login: (data: NileRegisterData) => Promise<string>
logout: () => Promise<void>
}
installingEpicGame: boolean
allTilesInColor: boolean
setAllTilesInColor: (value: boolean) => void
setSideBarCollapsed: (value: boolean) => void
Expand Down

0 comments on commit 896a396

Please sign in to comment.