Skip to content

Commit

Permalink
[General/Protocol] Fix protocol not launching gog games (#1969)
Browse files Browse the repository at this point in the history
* fix: launching gog games through protocol

* add support for sideload, make code cleaner

* apply review suggestions, use generic getInfo function
  • Loading branch information
imLinguin committed Nov 1, 2022
1 parent 54ac7cc commit 10b3c6b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/backend/protocol.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { BrowserWindow, dialog } from 'electron'
import { logError, logInfo, LogPrefix } from './logger/logger'
import i18next from 'i18next'
import { getGame } from './utils'
import { getInfo } from './utils'
import { Runner } from 'common/types'

export async function handleProtocol(window: BrowserWindow, args: string[]) {
// Figure out which argv element is our protocol
Expand Down Expand Up @@ -31,9 +32,12 @@ export async function handleProtocol(window: BrowserWindow, args: string[]) {
}

if (command === 'launch') {
const game =
getGame(arg, 'legendary').getGameInfo() ||
getGame(arg, 'gog').getGameInfo()
const runners: Runner[] = ['legendary', 'gog', 'sideload']

const game = runners
.map((runner) => getInfo(arg, runner))
.filter(({ app_name }) => app_name)
.shift()

if (!game) {
return logError(`Could not receive game data for ${arg}!`, {
Expand Down

0 comments on commit 10b3c6b

Please sign in to comment.