Skip to content

Commit

Permalink
[FIX] Improve default Compatibility Layer setup (#1045)
Browse files Browse the repository at this point in the history
* [FIX] Improve default Compatibility Layer setup

* tech: refactor compatbility layer initialization and move things around

* chore: comments and logs

* tech: enforce to use downloaded CLs instead of system ones

* fix: imports

* chore: revert yarn.lock

---------

Co-authored-by: Flavio F Lima <[email protected]>
  • Loading branch information
flavioislima and flavioislima committed Sep 16, 2024
1 parent 76ff74d commit 13e289d
Show file tree
Hide file tree
Showing 6 changed files with 380 additions and 315 deletions.
19 changes: 3 additions & 16 deletions src/backend/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ import { logError, logInfo, LogPrefix } from './logger/logger'
import {
getCrossover,
getDefaultWine,
getSystemGamingPortingToolkitWine,
getGamingPortingToolkitWine,
getLinuxWineSet,
getWhisky,
getWineOnMac,
getWineskinWine
getWineOnMac
} from './utils/compatibility_layers'

import { backendEvents } from './backend_events'
Expand Down Expand Up @@ -140,20 +137,10 @@ abstract class GlobalConfig {
}

const getGPTKWine = await getGamingPortingToolkitWine()
const getSystemGPTK = await getSystemGamingPortingToolkitWine()
const crossover = await getCrossover()
const wineOnMac = await getWineOnMac()
const wineskinWine = await getWineskinWine()
const whiskyWine = await getWhisky()

return new Set([
...getGPTKWine,
...getSystemGPTK,
...crossover,
...wineOnMac,
...wineskinWine,
...whiskyWine
])

return new Set([...getGPTKWine, ...crossover, ...wineOnMac])
}

/**
Expand Down
33 changes: 11 additions & 22 deletions src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,12 @@ import {
getStoreName,
isEpicServiceOffline,
handleExit,
checkRosettaInstall,
openUrlOrFile,
resetApp,
setGPTKDefaultOnMacOS,
showAboutWindow,
showItemInFolder,
wait,
getShellPath,
checkWineBeforeLaunch,
downloadDefaultWine,
writeConfig
} from './utils'
import {
Expand All @@ -81,7 +77,6 @@ import {
isCLIFullscreen,
isCLINoGui,
isFlatpak,
isMac,
isSteamDeckGameMode,
onboardLocalStore,
publicDir,
Expand Down Expand Up @@ -150,6 +145,13 @@ import * as Sentry from '@sentry/electron'
import { DEV_PORTAL_URL, devSentryDsn, prodSentryDsn } from 'common/constants'
import { getHpOverlay, initOverlay } from './overlay'

import { initExtension } from './extension/importer'
import { hpApi } from './utils/hyperplay_api'
import {
initializeCompatibilityLayer,
checkWineBeforeLaunch
} from './utils/compatibility_layers'

/*
* INSERT OTHER IPC HANDLERS HERE
*/
Expand Down Expand Up @@ -633,21 +635,10 @@ if (!gotTheLock) {
}, 10000)
}

// Will download Wine if none was found
const availableWine = (await GlobalConfig.get().getAlternativeWine()) || []
const toolkitDownloaded = availableWine.some(
(wine) => wine.type === 'toolkit'
)
const shouldDownloadWine =
!availableWine.length || (isMac && !toolkitDownloaded)

Promise.all([
DXVK.getLatest(),
Winetricks.download(),
shouldDownloadWine ? downloadDefaultWine() : null,
isMac && checkRosettaInstall(),
isMac && !shouldDownloadWine && setGPTKDefaultOnMacOS()
])
// Setup the compatibility layer if not on Windows
if (!isWindows) {
initializeCompatibilityLayer()
}

// set initial zoom level after a moment, if set in sync the value stays as 1
setTimeout(() => {
Expand Down Expand Up @@ -2071,5 +2062,3 @@ ipcMain.handle('getHyperPlayListings', async () => {
*/

import './storeManagers/legendary/eos_overlay/ipc_handler'
import { initExtension } from './extension/importer'
import { hpApi } from './utils/hyperplay_api'
3 changes: 2 additions & 1 deletion src/backend/storeManagers/gog/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { copySync } from 'fs-extra'
import path from 'node:path'
import { GameInfo, InstalledInfo } from 'common/types'
import { checkWineBeforeLaunch, getShellPath, spawnAsync } from '../../utils'
import { getShellPath, spawnAsync } from '../../utils'
import { GameConfig } from '../../game_config'
import { logError, logInfo, LogPrefix, logWarning } from '../../logger/logger'
import { isWindows } from '../../constants'
Expand All @@ -18,6 +18,7 @@ import { isOnline } from '../../online_monitor'
import { getWinePath, runWineCommand, verifyWinePrefix } from '../../launcher'
import { logFileLocation } from 'backend/storeManagers/storeManagerCommon/games'
import { getGameInfo as getGogLibraryGameInfo } from 'backend/storeManagers/gog/library'
import { checkWineBeforeLaunch } from 'backend/utils/compatibility_layers'
const nonNativePathSeparator = path.sep === '/' ? '\\' : '/'

/**
Expand Down
Loading

0 comments on commit 13e289d

Please sign in to comment.