Skip to content

[UX] Allow setting offline mode even if game does not have the metadata #3385

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 2 commits into from
Jan 6, 2024
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
3 changes: 3 additions & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,9 @@
"sync": "Cloud Saves Sync",
"systemInformation": "System Information"
},
"offline": {
"warning": "This game does not explicitly allow offline mode, turn this on at your own risk. The game may not work."
},
"open-config-file": "Open Config File",
"reset-heroic": "Reset Heroic",
"saves": {
Expand Down
7 changes: 3 additions & 4 deletions src/backend/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ async function prepareLaunch(

// Check if the game needs an internet connection
if (!gameInfo.canRunOffline && offlineMode) {
return {
success: false,
failureReason: 'Offline mode not supported'
}
logWarning(
'Offline Mode is on but the game does not allow offline mode explicitly.'
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we don't stop the launching of the game, but we still log this information cause it's important

}

// Update Discord RPC if enabled
Expand Down
27 changes: 20 additions & 7 deletions src/frontend/screens/Settings/components/OfflineMode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { ToggleSwitch } from 'frontend/components/UI'
import { getGameInfo } from 'frontend/helpers'
import useSetting from 'frontend/hooks/useSetting'
import SettingsContext from '../SettingsContext'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'

const OfflineMode = () => {
const { t } = useTranslation()
Expand All @@ -26,17 +28,28 @@ const OfflineMode = () => {

const [offlineMode, setOfflineMode] = useSetting('offlineMode', false)

if (isDefault || !canRunOffline) {
if (isDefault || runner !== 'legendary') {
return <></>
}

return (
<ToggleSwitch
htmlId="offlinemode"
value={offlineMode}
handleChange={() => setOfflineMode(!offlineMode)}
title={t('setting.offlinemode')}
/>
<>
<ToggleSwitch
htmlId="offlinemode"
value={offlineMode}
handleChange={() => setOfflineMode(!offlineMode)}
title={t('setting.offlinemode')}
/>
{!canRunOffline && offlineMode && (
<div className="infoBox saves-warning">
<FontAwesomeIcon icon={faExclamationTriangle} color={'yellow'} />
{t(
'settings.offline.warning',
'This game does not explicitly allow offline mode, turn this on at your own risk. The game may not work.'
)}
</div>
)}
</>
)
}

Expand Down