Skip to content

Commit

Permalink
[Fix] 2.5.0 Beta 1 Fixes (#1979)
Browse files Browse the repository at this point in the history
* fix: library item always selected

* chore: refresh library only if library is empty

* Fix Heroic does not respect launch arguments on custom added windows games (v2.5.0beta1) #1977

* fix: uninstalled recent games shown as installed

* fix: spacing on settings

* fix: broken gamepad

* fix: wine settings on windows

* fix: game settings route

* fix: enable language setting on default settings

* fix: pr comments
  • Loading branch information
flavioislima committed Nov 3, 2022
1 parent cbd237a commit 1a23c3c
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 59 deletions.
2 changes: 1 addition & 1 deletion src/backend/api/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const refreshLibrary = async (
) => ipcRenderer.invoke('refreshLibrary', fullRefresh, library)

export const gamepadAction = async (
args: [action: string, metadata: { elementTag: string; x: number; y: number }]
args: [action: string, metadata: unknown]
) => ipcRenderer.invoke('gamepadAction', args)

export const logError = (error: string) => ipcRenderer.send('logError', error)
Expand Down
7 changes: 4 additions & 3 deletions src/backend/sideload/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ export async function launchApp(appName: string): Promise<boolean> {
folder_name
} = gameInfo

const gameSettings = await getAppSettings(appName)
const { launcherArgs } = gameSettings

if (executable) {
const gameSettings = await getAppSettings(appName)
const {
success: launchPrepSuccess,
failureReason: launchPrepFailReason,
Expand Down Expand Up @@ -143,7 +145,6 @@ export async function launchApp(appName: string): Promise<boolean> {

// Native
if (isNativeApp(appName)) {
const { launcherArgs } = gameSettings
logInfo(
`launching native sideloaded: ${executable} ${launcherArgs ?? ''}`,
{ prefix: LogPrefix.Backend }
Expand Down Expand Up @@ -187,7 +188,7 @@ export async function launchApp(appName: string): Promise<boolean> {
})

await runWineCommand({
commandParts: [executable],
commandParts: [executable, launcherArgs ?? ''],
gameSettings,
wait: false,
startFolder: folder_name,
Expand Down
7 changes: 4 additions & 3 deletions src/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext } from 'react'

import './App.css'
import { HashRouter, Route, Routes } from 'react-router-dom'
import { HashRouter, Navigate, Route, Routes } from 'react-router-dom'
import Login from './screens/Login'
import WebView from './screens/WebView'
import { GamePage } from './screens/Game'
Expand All @@ -27,12 +27,13 @@ function App() {
<main className="content">
<DialogHandler />
<Routes>
<Route path="/" element={<Library />} />
<Route path="/" element={<Navigate replace to="/library" />} />
<Route path="/library" element={<Library />} />
<Route path="login" element={<Login />} />
<Route path="epicstore" element={<WebView />} />
<Route path="gogstore" element={<WebView />} />
<Route path="wiki" element={<WebView />} />
<Route path="gamepage">
<Route path="/gamepage">
<Route path=":runner">
<Route path=":appName" element={<GamePage />} />
</Route>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@ export default function SidebarLinks() {
setGameInfo(info)
if (info?.is_installed) {
setIsDefaultSetting(false)
const isNative = await window.api.isNative({ appName, runner })
// setIsNativeApp(isNative)
const wineOrOther = isNative
? `/settings/${runner}/${appName}/other`
: `/settings/${runner}/${appName}/games_settings`
setSettingsPath(wineOrOther)
setSettingsPath(`/settings/${runner}/${appName}/games_settings`)
}
}
}
Expand All @@ -93,6 +88,18 @@ export default function SidebarLinks() {
}
}, [location])

async function handleRefresh() {
localStorage.setItem('scrollPosition', '0')

const shouldRefresh =
(epic.username && !epic.library.length) ||
(gog.username && !gog.library.length)
if (shouldRefresh) {
return refreshLibrary({ runInBackground: true, fullRefresh: true })
}
return
}

return (
<div className="SidebarLinks Sidebar__section">
{!loggedIn && (
Expand All @@ -117,11 +124,8 @@ export default function SidebarLinks() {
className={({ isActive }) =>
classNames('Sidebar__item', { active: isActive })
}
to={'/'}
onClick={() => {
localStorage.setItem('scrollPosition', '0')
refreshLibrary({ runInBackground: false, fullRefresh: true })
}}
to={'/library'}
onClick={async () => handleRefresh()}
>
<>
<div className="Sidebar__itemIcon">
Expand Down
3 changes: 1 addition & 2 deletions src/frontend/helpers/gamepad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ export const initGamepad = () => {
} else {
// we have to tell Electron to simulate key presses
// so the spatial navigation works
const metadataReturn = metadata()
if (metadataReturn) window.api.gamepadAction([action, metadataReturn])
window.api.gamepadAction([action, metadata()])
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/screens/Game/GamePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,7 @@ export default function GamePage(): JSX.Element | null {
const isMacNative = isMac.includes(installPlatform ?? '')
const isLinuxNative = installPlatform === 'linux'
const isNative = isWin || isMacNative || isLinuxNative
const pathname = isNative
? `/settings/${runner}/${appName}/other`
: `/settings/${runner}/${appName}/games_settings`
const pathname = `/settings/${runner}/${appName}/games_settings`

const showCloudSaveInfo = cloud_save_enabled && !isLinuxNative
/*
Expand Down
10 changes: 2 additions & 8 deletions src/frontend/screens/Library/components/GameCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,12 @@ const GameCard = ({
libraryStatus,
layout,
handleGameStatus,
platform,
hiddenGames,
favouriteGames,
allTilesInColor,
showDialogModal
} = useContext(ContextProvider)

const isWin = platform === 'win32'

const grid = forceCard || layout === 'grid'

const { status, folder } =
Expand Down Expand Up @@ -244,10 +241,7 @@ const GameCard = ({
const isMac = ['osx', 'Mac']
const isMacNative = isMac.includes(installedPlatform ?? '')
const isLinuxNative = installedPlatform === 'linux'
const isNative = isWin || isMacNative || isLinuxNative
const pathname = isNative
? `/settings/${runner}/${appName}/other`
: `/settings/${runner}/${appName}/games_settings`
const pathname = `/settings/${runner}/${appName}/games_settings`

const onUninstallClick = function () {
setShowUninstallModal(true)
Expand Down Expand Up @@ -327,7 +321,7 @@ const GameCard = ({
<div className={wrapperClasses}>
{haveStatus && <span className="progress">{getStatus()}</span>}
<Link
to={`gamepage/${runner}/${appName}`}
to={`/gamepage/${runner}/${appName}`}
style={
{ '--installing-effect': installingGrayscale } as CSSProperties
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function RecentlyPlayed({ handleModal, onlyInstalled }: Props) {
return () => {
recentGamesChangedRemoveListener()
}
}, [])
}, [epic.library, gog.library, sideloadedLibrary])

if (!recentGames.length) {
return null
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/screens/Settings/components/BattlEyeRuntime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const BattlEyeRuntime = () => {
}

return (
<>
<div className="toggleRow">
<ToggleSwitch
htmlId="battlEyeRuntime"
value={battlEyeRuntime}
Expand All @@ -47,7 +47,7 @@ const BattlEyeRuntime = () => {
)}
</span>
)}
</>
</div>
)
}

Expand Down
4 changes: 2 additions & 2 deletions src/frontend/screens/Settings/components/EacRuntime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const EacRuntime = () => {
setEacRuntime(!eacRuntime)
}
return (
<>
<div className="toggleRow">
<ToggleSwitch
htmlId="eacRuntime"
value={eacRuntime}
Expand All @@ -64,7 +64,7 @@ const EacRuntime = () => {
{t('settings.eacRuntime.installing', 'Installing EAC Runtime...')}
</span>
)}
</>
</div>
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import React, { ChangeEvent, useContext } from 'react'
import React, { ChangeEvent } from 'react'
import { useTranslation } from 'react-i18next'
import { InfoBox, TextInputField } from 'frontend/components/UI'
import useSetting from 'frontend/hooks/useSetting'
import SettingsContext from '../SettingsContext'

const PreferedLanguage = () => {
const { t } = useTranslation()
const { isDefault } = useContext(SettingsContext)
const [languageCode, setLanguageCode] = useSetting('language', '')

const handleLanguageCode = (event: ChangeEvent<HTMLInputElement>) =>
setLanguageCode(event.currentTarget.value)

if (isDefault) {
return <></>
}

const languageInfo = (
<InfoBox text="infobox.help">
{t(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@

section:not(:nth-of-type(0)) {
padding-top: var(--space-xl);
min-width: 500px;
}
}
39 changes: 23 additions & 16 deletions src/frontend/screens/Settings/sections/GamesSettings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default function GamesSettings() {
const { platform } = useContext(ContextProvider)
const { isDefault } = useContext(SettingsContext)
const isLinux = platform === 'linux'
const isWin = platform === 'win32'

return (
<>
Expand All @@ -52,31 +53,37 @@ export default function GamesSettings() {
</p>
)}

<section>
<h3 className="settingSubheader">{isLinux ? 'Wine' : 'Crossover'}</h3>
{!isWin && (
<>
<section>
<h3 className="settingSubheader">
{isLinux ? 'Wine' : 'Crossover'}
</h3>

<WinePrefix />
<WinePrefix />

<WineVersionSelector />
<WineVersionSelector />

<CrossoverBottle />
<CrossoverBottle />

<Tools />
</section>
<Tools />
</section>

<section>
<h3 className="settingSubheader">
{t('settings.navbar.wineExt', 'Wine Extensions')}
</h3>
<section>
<h3 className="settingSubheader">
{t('settings.navbar.wineExt', 'Wine Extensions')}
</h3>

<AutoDXVK />
<AutoDXVK />

<AutoVKD3D />
<AutoVKD3D />

<EacRuntime />
<EacRuntime />

<BattlEyeRuntime />
</section>
<BattlEyeRuntime />
</section>
</>
)}

<section>
<h3 className="settingSubheader">{t('settings.navbar.other')}</h3>
Expand Down

0 comments on commit 1a23c3c

Please sign in to comment.