Skip to content

Refactor legendary setup #2629

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 5 commits into from
Aug 6, 2023
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
4 changes: 2 additions & 2 deletions src/backend/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import { spawn } from 'child_process'
import shlex from 'shlex'
import { isOnline } from './online_monitor'
import { showDialogBoxModalAuto } from './dialog/dialog'
import { setupUbisoftConnect } from './storeManagers/legendary/setup'
import { legendarySetup } from './storeManagers/legendary/setup'
import { gameManagerMap } from 'backend/storeManagers'
import * as VDF from '@node-steam/vdf'
import { readFileSync } from 'fs'
Expand Down Expand Up @@ -245,7 +245,7 @@ async function prepareWineLaunch(
await nileSetup(appName)
}
if (runner === 'legendary') {
await setupUbisoftConnect(appName)
await legendarySetup(appName)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ import {
initStoreManagers,
libraryManagerMap
} from './storeManagers'
import { setupUbisoftConnect } from 'backend/storeManagers/legendary/setup'
import { legendarySetup } from 'backend/storeManagers/legendary/setup'

import { logFileLocation as getLogFileLocation } from './storeManagers/storeManagerCommon/games'
import { addNewApp } from './storeManagers/sideload/library'
Expand Down Expand Up @@ -1600,7 +1600,7 @@ ipcMain.handle(
await nileSetup(appName)
}
if (runner === 'legendary' && updated) {
await setupUbisoftConnect(appName)
await legendarySetup(appName)
}

// FIXME: Why are we using `runinprefix` here?
Expand Down
22 changes: 9 additions & 13 deletions src/backend/storeManagers/legendary/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import axios from 'axios'
import { cachedUbisoftInstallerPath } from 'backend/constants'
import { logWarning } from 'backend/logger/logger'
import { existsSync, createWriteStream, statSync } from 'graceful-fs'
import { Winetricks } from 'backend/tools'
import { showDialogBoxModalAuto } from 'backend/dialog/dialog'
import i18next from 'i18next'
import { getWinePath } from 'backend/launcher'
Expand All @@ -13,12 +12,19 @@ import { getGameInfo, getSettings, runWineCommandOnGame } from './games'
const UBISOFT_INSTALLER_URL =
'https://ubistatic3-a.akamaihd.net/orbit/launcher_installer/UbisoftConnectInstaller.exe'

export const setupUbisoftConnect = async (appName: string) => {
export const legendarySetup = async (appName: string) => {
const gameInfo = getGameInfo(appName)
if (!gameInfo) {
return
}

// Fixes games like Fallout New Vegas and Dishonored: Death of the Outsider
await runWineCommandOnGame(appName, {
commandParts: ['reg', 'add', 'HKEY_CLASSES_ROOT\\com.epicgames.launcher'],
wait: true,
protonVerb: 'waitforexitandrun'
})

// if not a ubisoft game, do nothing
if (gameInfo.install.executable !== 'UplayLaunch.exe') {
return
Expand All @@ -35,10 +41,7 @@ export const setupUbisoftConnect = async (appName: string) => {
status: 'ubisoft'
})

const promise1 = installUbisoftConnect(appName)
const promise2 = installArialFontInPrefix(appName)
// running these 2 tasks in parallel, they are independent
await Promise.all([promise1, promise2])
await installUbisoftConnect(appName)
}

const installUbisoftConnect = async (appName: string) => {
Expand Down Expand Up @@ -68,13 +71,6 @@ const installUbisoftConnect = async (appName: string) => {
}
}

const installArialFontInPrefix = async (appName: string) => {
const settings = await getSettings(appName)
await Winetricks.runWithArgs(settings.wineVersion, settings.winePrefix, [
'arial'
])
}

const downloadIfNotCached = async (cachePath: string, url: string) => {
if (existsSync(cachePath)) {
// if the cached file exist but it was cached more than a week ago, download a new one
Expand Down