Skip to content
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: 2 additions & 1 deletion DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ No UI text below 11px. Counts and numbers use tabular figures. Folder paths in t
- Default is `surface-2`, stepping to `line` on hover.
- Glass is `glass-on` with `glass-on-line`, for secondary actions on glass.
- Destructive actions use `danger-text`, never a red fill.
- Focus is a 2px `focus` outline with 2px offset, everywhere. Disabled is 60% opacity. A busy button ("Downloading…", "Queued") is `aria-disabled` so it keeps focus.
- Focus is a 2px `focus` outline with 2px offset, everywhere. Disabled is 60% opacity. A busy button ("Downloading…", "Queued") is `aria-disabled` so it keeps focus. Play on a card or the Continue banner turns into a busy Launching… pill until the launch command returns, so a second click starts nothing.
- Favorites and Settings switches change on click and flip back if the save fails; Settings opens on the last read view and refreshes behind it.
- **Chips:** 36px, `glass` fill, `glass-line` border, `text-2`. Selected (`aria-pressed`) is `glass-on`, `glass-on-line`, `text`.
- The Settings chip carries an 8px amber dot only for a real problem: a saved login that stopped working, or a store that was set up and broke. A store never set up raises nothing.
- The store selector is one segmented control (a bits-ui `RadioGroup`) listing only the stores the library has games from. It is absent with one store. Arrows (all four), Home and End move to a segment and pick it, wrapping; one segment is the Tab stop.
Expand Down
29 changes: 25 additions & 4 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<script lang="ts">
import { onMount, tick } from 'svelte'
import { SvelteSet } from 'svelte/reactivity'
import { Tooltip } from 'bits-ui'
import * as api from './lib/api'
import {
Expand Down Expand Up @@ -157,8 +158,16 @@
if (filters.some(gone)) filters = filters.filter((f) => !gone(f))
}

/** The heart fills at once; the reload after moves the game into or out of Favorites. */
async function setFavorite(key: string, on: boolean) {
await commands.setFavorite(key, on).catch((e) => (error = api.message(e)))
const game = lib.games.find((g) => g.key === key)
if (game) game.favorite = on
try {
await commands.setFavorite(key, on)
} catch (e) {
if (game) game.favorite = !on
error = api.message(e)
}
await reload()
}

Expand Down Expand Up @@ -195,7 +204,14 @@
/** A Play from a card that stopped at a cloud save conflict; the game page asks, in its hero. */
let saveConflict = $state<{ key: string; conflict: Conflict } | null>(null)

/** Copies whose Play command hasn't returned yet: their Play shows Launching… and takes no second click. */
const launching = new SvelteSet<string>()

async function act(action: Action, key: string, options: api.ActOptions = {}) {
if (action === 'play') {
if (launching.has(key)) return
launching.add(key)
}
try {
const conflict = await api.act(action, key, options)
if (conflict) {
Expand All @@ -205,6 +221,7 @@
} catch (e) {
error = api.message(e)
}
launching.delete(key)
await reload()
}

Expand Down Expand Up @@ -251,8 +268,10 @@
}

async function openSettings(section: string | null = null) {
// Read fresh each time: the Epic state and cache size change while the panel is closed.
await loadSettings()
// Opens on the last read at once; the fresh one (the Epic state and cache size change while the panel
// is closed) lands a moment later. Only the first open, before start's read, waits.
const fresh = loadSettings()
if (!settings) await fresh
settingsSection = section
settingsOpen = settings !== null
}
Expand Down Expand Up @@ -563,6 +582,7 @@
{stat}
resetKey={`${query}|${store}|${sort}|${installedOnly}|${filters.join()}`}
{running}
{launching}
{settingUp}
{progress}
{queue}
Expand All @@ -582,6 +602,7 @@
<Continue
{featured}
running={running !== null && featured.copyKeys.includes(running)}
launching={launching.has(featured.chosen)}
{settingUp}
onplay={(key) => act('play', key)}
onopen={openGame}
Expand Down Expand Up @@ -694,7 +715,7 @@

{#if settingsOpen && settings}
<Settings
view={settings}
bind:view={() => settings!, (v) => (settings = v)}
section={settingsSection}
{attention}
{refreshedAt}
Expand Down
5 changes: 5 additions & 0 deletions src/lib/Card.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
index,
stat = null,
running,
launching = false,
settingUp = false,
progress,
queued,
Expand All @@ -27,6 +28,8 @@
/** Which hours the bottom-left badge shows; it takes Install's place on a game that isn't installed. */
stat?: 'playtime' | 'ttb' | null
running: boolean
/** Its Play is starting. */
launching?: boolean
/** Running, but its first launch on Linux still sets up. */
settingUp?: boolean
progress: Progress | undefined
Expand Down Expand Up @@ -182,6 +185,8 @@
<button class="glass small" onclick={() => oncancel(waiting.key)}>{t('common.cancel')}</button>
{/if}
</span>
{:else if launching}
<button class="pill small" aria-disabled="true">{t('busy.play')}</button>
{:else if game.installed}
<button class="pill small" onclick={() => onplay(game.chosen)}>
<svg viewBox="0 0 24 24" width="12" height="12" aria-hidden="true"><path class="solid" d="M7 4.5v15l12.5-7.5z" /></svg>
Expand Down
9 changes: 7 additions & 2 deletions src/lib/Continue.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
let {
featured,
running,
launching = false,
settingUp = false,
onplay,
onopen,
}: {
featured: Featured
running: boolean
/** Its Play is starting. */
launching?: boolean
/** Running, but its first launch on Linux still sets up. */
settingUp?: boolean
onplay: (key: string) => void
Expand All @@ -28,8 +31,10 @@
<div class="text">
<small>{t('continue.title')}</small>
<h2>{featured.title}</h2>
<button class="pill" disabled={running} onclick={() => onplay(featured.chosen)}>
{#if running}
<button class="pill" disabled={running} aria-disabled={launching} onclick={() => launching || onplay(featured.chosen)}>
{#if launching}
{t('busy.play')}
{:else if running}
{settingUp ? t('busy.settingUp') : t('play.playing')}
{:else}
<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true"><path d="M7 4.5v15l12.5-7.5z" /></svg>
Expand Down
4 changes: 4 additions & 0 deletions src/lib/Grid.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
stat = null,
resetKey,
running,
launching,
settingUp = false,
progress,
queue,
Expand All @@ -34,6 +35,8 @@
resetKey: string
/** Copy keys, as `poll` reports them. */
running: string | null
/** Copies whose Play is starting. */
launching: ReadonlySet<string>
/** The running game still sets up (`poll`'s `settingUp`). */
settingUp?: boolean
progress: Record<string, Progress>
Expand Down Expand Up @@ -172,6 +175,7 @@
{index}
{stat}
running={running !== null && game.copyKeys.includes(running)}
launching={launching.has(game.chosen)}
{settingUp}
progress={game.copyKeys.map((k) => progress[k]).find(Boolean)}
queued={queue.jobs.length ? queueState(queue, game.copyKeys) : null}
Expand Down
34 changes: 23 additions & 11 deletions src/lib/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import guildFile from '../../src-tauri/icons/source/guild.svg?no-inline'

let {
view,
view = $bindable(),
section = null,
attention,
refreshedAt,
Expand Down Expand Up @@ -261,7 +261,19 @@
await onchange()
}

const toggle = (name: string, on: boolean) => change(() => commands.updateSetting(name, String(on)))
type SwitchField = { [K in keyof SettingsView]: SettingsView[K] extends boolean ? K : never }[keyof SettingsView]

/** A switch flips at once and flips back if the save fails. None of them change the library, so nothing reloads. */
async function toggle(name: string, field: SwitchField, on: boolean) {
error = null
view[field] = on
try {
await commands.updateSetting(name, String(on))
} catch (e) {
view[field] = !on
error = api.message(e)
}
}

function saveFolder() {
if (folder.trim() === (view.epicInstallDir ?? '')) return
Expand Down Expand Up @@ -620,13 +632,13 @@
</Switch.Root>
{/snippet}

{#snippet switchRow(name: Icon, setting: string, on: boolean, label: string, hint?: string)}
{#snippet switchRow(name: Icon, setting: string, field: SwitchField, label: string, hint?: string)}
<div class="r">
{@render tile(name)}
<div class="what">
<span id="{setting}-label">{label}</span>{#if hint}<small>{hint}</small>{/if}
</div>
{@render toggleButton(on, `${setting}-label`, (v) => toggle(setting, v))}
{@render toggleButton(view[field], `${setting}-label`, (v) => toggle(setting, field, v))}
</div>
{/snippet}

Expand Down Expand Up @@ -782,7 +794,7 @@
</div>
<div class="row">
<div id="saves-label">{t('settings.syncSaves')}</div>
{@render toggleButton(view.cloudSaves, 'saves-label', (v) => toggle('cloud_saves', v))}
{@render toggleButton(view.cloudSaves, 'saves-label', (v) => toggle('cloud_saves', 'cloudSaves', v))}
</div>
<div class="row">
<div>{t('settings.importInstall')}</div>
Expand Down Expand Up @@ -883,7 +895,7 @@
</div>
<div class="row">
<div id="gog-saves-label">{t('settings.syncSaves')}</div>
{@render toggleButton(view.gogCloudSaves, 'gog-saves-label', (v) => toggle('gog_cloud_saves', v))}
{@render toggleButton(view.gogCloudSaves, 'gog-saves-label', (v) => toggle('gog_cloud_saves', 'gogCloudSaves', v))}
</div>
<div class="row">
<div>{t('settings.importInstall')}</div>
Expand Down Expand Up @@ -1116,16 +1128,16 @@
{@render switchRow(
'power',
'start_with_windows',
view.startWithWindows,
'startWithWindows',
view.linux ? t('settings.startupLinux') : t('settings.startup'),
)}
{@render switchRow('tray', 'close_to_tray', view.closeToTray, t('settings.tray'), t('settings.trayHint'))}
{@render switchRow('bell', 'notify_downloads', view.notifyDownloads, t('settings.notify'))}
{@render switchRow('tray', 'close_to_tray', 'closeToTray', t('settings.tray'), t('settings.trayHint'))}
{@render switchRow('bell', 'notify_downloads', 'notifyDownloads', t('settings.notify'))}
</div>
<h4>{t('settings.group.look')}</h4>
<div class="group">
{@render switchRow('palette', 'ambient', view.ambient, t('settings.ambient'))}
{@render switchRow('banner', 'show_banner', view.showBanner, t('settings.banner'))}
{@render switchRow('palette', 'ambient', 'ambient', t('settings.ambient'))}
{@render switchRow('banner', 'show_banner', 'showBanner', t('settings.banner'))}
<div class="r">
{@render tile('globe')}
<div class="what">{t('settings.language')}</div>
Expand Down
Loading