Skip to content

Commit

Permalink
Merge branch 'main' into feat/ipdt_patching
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioislima authored Nov 7, 2024
2 parents 5ab6b30 + ac374ca commit 8399197
Show file tree
Hide file tree
Showing 25 changed files with 472 additions and 465 deletions.
10 changes: 2 additions & 8 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
},
"choose": "Choose",
"choose-egs-prefix": "Choose Prefix where EGS is installed",
"choose-gogdl-binary": "Select GOGDL Binary (needs restart)",
"choose-legendary-binary": "Select Legendary binary",
"customWine": "Select the Wine or Proton binary",
"default-install-path": "Choose Default Install Path",
"default-steam-path": "Steam path.",
Expand Down Expand Up @@ -330,6 +328,7 @@
"hyperplay": {
"accesscodes": {
"error": {
"licenseUndefined": "Could not validate access code. Please check your internet access or firewall settings.",
"validation": "Access code is invalid"
},
"requirescode": "This game update requires an access code.",
Expand Down Expand Up @@ -710,8 +709,6 @@
}
},
"other": {
"gogdl-version": "GOGDL Version: ",
"legendary-version": "Legendary Version: ",
"weblate": "Help Translate HyperPlay."
},
"Other": "Other",
Expand All @@ -721,15 +718,14 @@
"links": {
"bridge": "Bridge",
"buy": "Buy",
"marketplace": "Marketplace",
"portfolio": "Portfolio",
"sell": "Sell",
"swap": "Swap"
},
"WALLET_DISCONNECTED": "You do not have a wallet connected to HyperPlay."
},
"placeholder": {
"alt-gogdl-bin": "Using built-in GOGDL binary...",
"alt-legendary-bin": "Using built-in Legendary binary...",
"custom_themes_path": "Select the path to look for custom CSS files",
"dxvkfpsvalue": "Positive integer value (e.g. 30, 60, ...)",
"egs-prefix": "Prefix where EGS is installed",
Expand Down Expand Up @@ -823,8 +819,6 @@
"addgamestoapplications": "Add games to Applications automatically",
"addgamestostartmenu": "Add games to start menu automatically",
"addgamestosteam": "Add games to Steam automatically",
"alt-gogdl-bin": "Choose an Alternative GOGDL Binary to use",
"alt-legendary-bin": "Choose an Alternative Legendary Binary",
"autodxvk": "Auto Install/Update DXVK on Prefix",
"autodxvknvapi": "Auto Install/Update DXVK-NVAPI on Prefix",
"autoLaunchHyperPlay": "Auto Launch HyperPlay",
Expand Down
9 changes: 8 additions & 1 deletion src/backend/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import getPartitionCookies from './utils/get_partition_cookies'
import { DEV_PORTAL_URL } from '../common/constants'
import { LogPrefix } from './logger/logger'
import { AuthSession } from '../common/types/auth'
import { captureException } from '@sentry/electron'

export async function getAuthSession() {
const cookieString = await getPartitionCookies({
Expand All @@ -17,8 +18,14 @@ export async function getAuthSession() {
})

if (!response.ok) {
const responseError = await response.text()
captureException(responseError, {
tags: {
event: 'getAuthSession Error'
}
})
throw new Error(
`${LogPrefix.Backend} Failed to get auth session: ${response.statusText}`
`${LogPrefix.Backend} Failed to get auth session. Status text: ${response.statusText}. Error message: ${responseError}`
)
}

Expand Down
8 changes: 0 additions & 8 deletions src/backend/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,20 +419,12 @@ function splitPathAndName(fullPath: string): { dir: string; bin: string } {
}

function getLegendaryBin(): { dir: string; bin: string } {
const settings = GlobalConfig.get().getSettings()
if (settings?.altLegendaryBin) {
return splitPathAndName(settings.altLegendaryBin)
}
return splitPathAndName(
fixAsarPath(join(publicDir, 'bin', process.platform, 'legendary'))
)
}

function getGOGdlBin(): { dir: string; bin: string } {
const settings = GlobalConfig.get().getSettings()
if (settings?.altGogdlBin) {
return splitPathAndName(settings.altGogdlBin)
}
return splitPathAndName(
fixAsarPath(join(publicDir, 'bin', process.platform, 'gogdl'))
)
Expand Down
106 changes: 68 additions & 38 deletions src/backend/utils/systeminfo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { isSteamDeck } from './steamDeck'

import { getGogdlVersion, getLegendaryVersion } from '../helperBinaries'
import { getAppVersion } from 'backend/utils'
import { logError, logInfo, LogPrefix } from 'backend/logger/logger'

type GPUInfo = {
// The PCI device ID of the graphics card (hexadecimal)
Expand Down Expand Up @@ -65,47 +66,76 @@ let cachedSystemInfo: SystemInformation | null = null
* @param cache Whether cached information should be returned if possible
*/
async function getSystemInfo(cache = true): Promise<SystemInformation> {
if (cache && cachedSystemInfo) return cachedSystemInfo
try {
if (cache && cachedSystemInfo) return cachedSystemInfo
logInfo('Gathering system specs...', LogPrefix.Backend)
const cpus = os.cpus()
const memory = await getMemoryInfo()
const gpus = await getGpuInfo()
const detailedOsInfo = await getOsInfo()
const isDeck = isSteamDeck(cpus, gpus)
const [legendaryVersion, gogdlVersion] = await Promise.all([
getLegendaryVersion(),
getGogdlVersion()
])

const cpus = os.cpus()
const memory = await getMemoryInfo()
const gpus = await getGpuInfo()
const detailedOsInfo = await getOsInfo()
const isDeck = isSteamDeck(cpus, gpus)
const [legendaryVersion, gogdlVersion] = await Promise.all([
getLegendaryVersion(),
getGogdlVersion()
])

const sysinfo: SystemInformation = {
CPU: {
model: cpus[0]!.model,
// FIXME: Technically the user could be on a server with more than one
// physical CPU installed, but I'd say that's rather unlikely
cores: cpus.length
},
memory: {
total: memory.total,
used: memory.used,
totalFormatted: filesize(memory.total, { base: 2 }) as string,
usedFormatted: filesize(memory.used, { base: 2 }) as string
},
GPUs: gpus,
OS: {
platform: process.platform,
version: process.getSystemVersion(),
...detailedOsInfo
},
isSteamDeck: isDeck,
isFlatpak: !!process.env.FLATPAK_ID,
softwareInUse: {
appVersion: getAppVersion(),
legendaryVersion: legendaryVersion,
gogdlVersion: gogdlVersion
const sysinfo: SystemInformation = {
CPU: {
model: cpus[0]!.model,
// FIXME: Technically the user could be on a server with more than one
// physical CPU installed, but I'd say that's rather unlikely
cores: cpus.length
},
memory: {
total: memory.total,
used: memory.used,
totalFormatted: filesize(memory.total, { base: 2 }) as string,
usedFormatted: filesize(memory.used, { base: 2 }) as string
},
GPUs: gpus,
OS: {
platform: process.platform,
version: process.getSystemVersion(),
...detailedOsInfo
},
isSteamDeck: isDeck,
isFlatpak: !!process.env.FLATPAK_ID,
softwareInUse: {
appVersion: getAppVersion(),
legendaryVersion: legendaryVersion,
gogdlVersion: gogdlVersion
}
}
cachedSystemInfo = sysinfo
return sysinfo
} catch (error) {
logError(['Failed to gather system specs', error], LogPrefix.Backend)
return {
CPU: {
model: 'Unknown',
cores: 0
},
memory: {
total: 0,
used: 0,
totalFormatted: 'Unknown',
usedFormatted: 'Unknown'
},
GPUs: [],
OS: {
platform: 'Unknown',
name: 'Unknown',
version: 'Unknown'
},
isSteamDeck: false,
isFlatpak: false,
softwareInUse: {
appVersion: 'Unknown',
legendaryVersion: 'Unknown',
gogdlVersion: 'Unknown'
}
}
}
cachedSystemInfo = sysinfo
return sysinfo
}

async function formatSystemInfo(info: SystemInformation): Promise<string> {
Expand Down
2 changes: 0 additions & 2 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ export interface AppSettings extends GameSettings {
addDesktopShortcuts: boolean
addStartMenuShortcuts: boolean
addSteamShortcuts: boolean
altGogdlBin: string
altLegendaryBin: string
autoUpdateGames: boolean
checkForUpdatesOnStartup: boolean
autoLaunchHyperPlay: boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react'
import { ContractMetadata } from '@valist/sdk/dist/typesApi'
import { SubLink } from '@hyperplay/ui'
import { Link, useLocation } from 'react-router-dom'
import styles from '../../index.module.scss'

export function MarketplaceSublinks(contractMetadata?: ContractMetadata[]) {
const location = useLocation()
const { pathname, search } = location
const searchParams = new URLSearchParams(search)
const urlQueryParam = searchParams.get('url')

const marketplaceSublinks = contractMetadata
?.filter((val) => !!val.marketplace_urls)
.flatMap((val) =>
(val.marketplace_urls ?? [])
.filter((val) => !!val)
.map((mktUrl) => {
return (
<SubLink
key={val.name}
component={Link}
to={`/marketplace?url=${encodeURIComponent(mktUrl)}`}
selected={pathname === '/marketplace' && urlQueryParam === mktUrl}
className={styles.sublink}
>
{val.name}
</SubLink>
)
})
)
return marketplaceSublinks
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React, { useState } from 'react'
import { Images, NavItem } from '@hyperplay/ui'
import { useLocation } from 'react-router-dom'
import { useQuery } from '@tanstack/react-query'
import { BrowserGameProps } from 'frontend/OverlayManager/types'
import styles from '../index.module.scss'
import classNames from 'classnames'
import { useTranslation } from 'react-i18next'
import { MarketplaceSublinks } from './MarketplaceSublinks'

export interface MarketplaceNavItemProps extends BrowserGameProps {
collapsed: boolean
}

export function MarketplaceNavItem({
appName,
runner,
collapsed,
...props
}: MarketplaceNavItemProps) {
const location = useLocation()
const { pathname } = location
const [mktCollapsed, setMktCollapsed] = useState(false)
const { t } = useTranslation()

const { data: gameInfo } = useQuery({
queryKey: ['getGameInfo', appName],
queryFn: async () => {
return window.api.getGameInfo(appName, runner)
}
})

const gameInfoExists = !!gameInfo
const gameInfoHasSomeMarketplaceUrls = !!gameInfo?.networks?.some(
(val) => !!val.marketplace_urls?.length
)
const marketplaceEnabled = gameInfoExists && gameInfoHasSomeMarketplaceUrls
const marketplaceClass: Record<string, boolean> = {}
marketplaceClass[styles.disabled] = !marketplaceEnabled

if (!marketplaceEnabled) {
return null
}

return (
<NavItem
title={t('overlay.links.marketplace', 'Marketplace')}
icon={<Images.Home fill="white" />}
key={'/marketplace'}
collapsed={collapsed}
selected={pathname === '/marketplace'}
classNames={{ link: classNames(marketplaceClass) }}
subLinks={
marketplaceEnabled ? MarketplaceSublinks(gameInfo?.networks) : undefined
}
subLinksCollapsed={mktCollapsed}
setSubLinksCollapsed={() => setMktCollapsed(!mktCollapsed)}
onClick={() => setMktCollapsed(!mktCollapsed)}
{...props}
/>
)
}
Loading

0 comments on commit 8399197

Please sign in to comment.