Skip to content
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

[General] Beta-Feature: GOG implementation #872

Merged
merged 64 commits into from
Feb 23, 2022

Conversation

imLinguin
Copy link
Member

@imLinguin imLinguin commented Jan 5, 2022

WORK IN PROGRESS!

To do List:

  • Login and refreshing user credentials
  • Update user information on launch
  • Sync Library
  • Display library
  • Download Game Files (Windows)
  • Download Game Files (Mac)
  • Download offline installers (Linux)
  • Download offline installers optionally on Windows and Mac
  • Download movies (don't know it that's necessary), Alternatively open download link in the browser
  • Check for game updates

Use the following Checklist if you have changed something on the Backend or Frontend:

  • Tested the feature and it's working on a current and clean install.
  • Tested the main App features and they are still working on a current and clean install. (Login, Install, Play, Uninstall, Move games, etc.)
  • Created / Updated Tests (If necessary)
  • Created / Updated documentation (If necessary)

@imLinguin imLinguin marked this pull request as draft January 5, 2022 17:51
electron/gog/games.ts Outdated Show resolved Hide resolved
Copy link
Member

@flavioislima flavioislima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good overall. Great job here! ⚔️
Most of the comments are about improving readability or about missing comments or future improvement.
Looking at the code like this it's hard to find some bug so I didn't focus on that.
I believe the first iteration is amazing, better than we planned at first. So After release we can focus on improving the code, refactoring, etc. :D

electron/gog/setup.ts Outdated Show resolved Hide resolved
electron/gog/library.ts Outdated Show resolved Hide resolved
electron/gog/user.ts Outdated Show resolved Hide resolved
electron/gog/user.ts Outdated Show resolved Hide resolved
electron/launcher.ts Outdated Show resolved Hide resolved
src/screens/Library/components/GameCard/index.tsx Outdated Show resolved Hide resolved
src/screens/Library/components/InstallModal/index.tsx Outdated Show resolved Hide resolved
src/screens/Settings/index.tsx Outdated Show resolved Hide resolved
src/screens/WebView/index.tsx Outdated Show resolved Hide resolved
src/state/GlobalState.tsx Outdated Show resolved Hide resolved
@flavioislima
Copy link
Member

Ah, do not forget to generate the i18n keys as well.
Running yarn i18n .

@flavioislima
Copy link
Member

I believe we also need the platform filter on Linux.

@imLinguin
Copy link
Member Author

imLinguin commented Feb 22, 2022

Summary of the PR

Features for GOG games

  • Downloading games using Galaxy API (Windows and MacOS)
  • Downloading games using offline installers (Linux)
  • Ability to pick a game language for games that support it
  • Downloading game DLCs (might not work properly with old V1 Depots)
  • Ability to run native Linux games using Steam Runtime Scout (fixes issues with Baldur's Gate libssl not found error) Requires Steam

General features

  • From now on at least one account is required (you don't have to use GOG or Epic if you don't want to 😃 )
  • Added "runner" (game store) indicator on GamePage

Screenshots

  • Library Page Library Page

  • Account Manager page obraz
    obraz
    obraz

  • Runner Indicator
    obraz
    obraz

Notes

  • If somebody ever finds game which uses V1 Depots and contains DLCs please contact me.
  • For Windows and MacOS ETA can show very large numbers, it's due to current way of dealing with decompressing files after each file is downloaded (will try to separate it between threads in the future)
  • Games that rely on Galaxy SDK for core features (like authentication to play) are not supported, example: Gwent - I suggest to get a Steam version if game is F2P and available there. (please report other games with that kind of stuff)
  • Cloud Sync for Mac and Windows GOG games is planned for the future (we don't know much about it yet, if somebody wishes to help with that reach out to us on Discord). That feature isn't currently possible for Linux native games due to lack of support on GOG side

flavioislima
flavioislima previously approved these changes Feb 22, 2022
Copy link
Member

@flavioislima flavioislima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Great!
Colossal work! ⚔️ 🛡️

@flavioislima flavioislima requested a review from arielj February 22, 2022 18:51
Copy link
Collaborator

@arielj arielj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey! I added comments mainly on code style, I don't really know how parts of this work to say if anything needs changes, hope the code style suggestions are useful

const icon = fixAsarPath(join(__dirname, '/icon.png'))
const iconDark = fixAsarPath(join(__dirname, '/icon-dark.png'))
const iconLight = fixAsarPath(join(__dirname, '/icon-light.png'))
const installed = `${legendaryConfigPath}/installed.json`
const libraryPath = `${legendaryConfigPath}/metadata/`
const loginUrl =
const fallBackImage =
'https://user-images.githubusercontent.com/26871415/103480183-1fb00680-4dd3-11eb-9171-d8c4cc601fba.jpg'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this use an image inside the project? in case github is down or something weird

public async getExtraInfo(namespace: string): Promise<ExtraInfo> {
const gameInfo = GOGLibrary.get().getGameInfo(this.appName)
let targetPlatform: 'windows' | 'osx' | 'linux' = 'windows'
switch (process.platform) {
Copy link
Collaborator

@arielj arielj Feb 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can use the isWindows isMac and isLinux from constants?

like:

let targetPlatform: 'windows' | 'osx' | 'linux' = 'windows'

if (isMac && gameInfo.is_mac_native) {
  targetPlatform = 'osx'
}
if (isLinux && gameInfo.is_linux_native) {
  targetPlatform = 'linux'
}

})
}
public async stop(): Promise<void> {
const pattern = process.platform === 'linux' ? this.appName : 'gogdl'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here about using isLinux from constants instead

const pattern = process.platform === 'linux' ? this.appName : 'gogdl'
logInfo(['killing', pattern], LogPrefix.Gog)

if (process.platform === 'win32') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and isWindows

const logPath = `"${heroicGamesConfigPath}${this.appName}.log"`
const writeLog = isWindows ? `2>&1 > ${logPath}` : `|& tee ${logPath}`
// In the future we need to add Language select option
const command = `${gogdlBin} update ${
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the code above this line in this method is the same as the lines above line 233 in the repair method, maybe it's worth to extract?

* @param etag (optional) value returned in response, works as checksum so we can check if we have up to date data
* @returns object {isUpdated, data}, where isUpdated is true when Etags match
*/
public static async get_gamesdb_data(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here for the case, getGamesdbData instead of get_gamesdb_data for consistency, and for the rest of the functions in this file

workingDir ? 'cd ' + workingDir + ' &&' : ''
} ${commandPrefix} "${executablePath}" ${exeArguments}`
// Requires testing
if (process.platform == 'win32') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use isWindows from constants

})

const gogAuthenticateUrl =
'https://auth.gog.com/token?client_id=46899977096215655&client_secret=9d85c43b1482497dbbce61f6e4aa173a433796eeae2ca8c5f6129f2dc4de46d9&grant_type=authorization_code&redirect_uri=https%3A%2F%2Fembed.gog.com%2Fon_login_success%3Forigin%3Dclient&code='
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it ok that there's client_id and secret hardcoded like this? maybe it's needed but it looks suspicious to me, just checking (maybe this is the only way)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is GOG Galaxy's client_id nothing to worry about

winePath: string,
appName: string
) {
if (platform() === 'darwin') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (isMac)

electron/main.ts Outdated
@@ -971,7 +1026,7 @@ ipcMain.handle('updateGame', async (e, game) => {
}

const epicOffline = await isEpicServiceOffline()
if (epicOffline) {
if (epicOffline && runner == 'legendary') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the check for the epic status service can be done only if runner === 'legendary'? now it seems to trigger the check for the epic service even if not needed

@imLinguin imLinguin merged commit 1522b3b into Heroic-Games-Launcher:main Feb 23, 2022
@imLinguin imLinguin deleted the gog_support branch February 23, 2022 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:ready-for-review Feature-complete, ready for the grind! :P
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants