Skip to content
Open
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
2 changes: 1 addition & 1 deletion cmd/opensave-app/frontend/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
{:else}
<div class="boot-loading">
<img class="boot-logo pulse" src={logoUrl} alt="OpenSave" />
<span>Starting OpenSave…</span>
<span>{$t('app.startingOpenSave')}</span>
</div>
{/if}
</div>
Expand Down
262 changes: 261 additions & 1 deletion cmd/opensave-app/frontend/src/locales/en.json

Large diffs are not rendered by default.

249 changes: 247 additions & 2 deletions cmd/opensave-app/frontend/src/locales/zh-Hans.json

Large diffs are not rendered by default.

249 changes: 247 additions & 2 deletions cmd/opensave-app/frontend/src/locales/zh-Hant.json

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions cmd/opensave-app/frontend/src/views/GameDetail.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { t as i18n } from '../lib/i18n.js';
import { slidingIndicator } from '../lib/motion.js';
import { games } from '../lib/stores.js';
import { createRunner } from '../lib/runner.js';
Expand All @@ -22,11 +23,11 @@
const runner = createRunner();

const tabs = [
{ id: 'snapshots', label: 'Snapshots', icon: History, component: SnapshotsTab },
{ id: 'branches', label: 'Branches', icon: GitBranch, component: BranchesTab },
{ id: 'cloud', label: 'Cloud', icon: Cloud, component: CloudTab },
{ id: 'config', label: 'Configuration', icon: SlidersHorizontal, component: ConfigTab },
{ id: 'danger', label: 'Manage', icon: Wrench, component: ManageTab }
{ id: 'snapshots', label: 'game.tab.snapshots', icon: History, component: SnapshotsTab },
{ id: 'branches', label: 'game.tab.branches', icon: GitBranch, component: BranchesTab },
{ id: 'cloud', label: 'game.tab.cloud', icon: Cloud, component: CloudTab },
{ id: 'config', label: 'game.tab.config', icon: SlidersHorizontal, component: ConfigTab },
{ id: 'danger', label: 'game.tab.manage', icon: Wrench, component: ManageTab }
];
let tab = 'snapshots';

Expand All @@ -52,14 +53,14 @@
</script>

{#if !game}
<div class="empty"><h3>Game not found</h3></div>
<div class="empty"><h3>{$i18n('game.notFound')}</h3></div>
{:else}
{#key params.gameId}
<GameHeader {game} {runner} renameRequest={params.rename} />

<div class="pill-tabs tabs" use:slidingIndicator={{ inset: 10 }}>
{#each tabs as t (t.id)}
<button class:active={tab === t.id} on:click={() => (tab = t.id)}><svelte:component this={t.icon} size={15} />{t.label}</button>
<button class:active={tab === t.id} on:click={() => (tab = t.id)}><svelte:component this={t.icon} size={15} />{$i18n(t.label)}</button>
{/each}
</div>

Expand Down
24 changes: 10 additions & 14 deletions cmd/opensave-app/frontend/src/views/game/AppIdField.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// how "I added the app ID but it doesn't do anything" gets asked.
import { onDestroy } from 'svelte';
import { api } from '../../lib/api.js';
import { t } from '../../lib/i18n.js';
import MoreInfo from '../../components/ui/MoreInfo.svelte';
import CircleCheck from 'lucide-svelte/icons/circle-check';

Expand Down Expand Up @@ -55,32 +56,27 @@
</script>

<div class="field">
<label for="c-appid">Steam App ID</label>
<input id="c-appid" placeholder="e.g. 1091500" bind:value />
<label for="c-appid">{$t('game.appId.label')}</label>
<input id="c-appid" placeholder={$t('game.appId.placeholder')} bind:value />
<span class="hint">
The number in the game's Steam store URL. Used to launch it and fetch its cover art.
{$t('game.appId.hint')}
<MoreInfo>
With “Match games by Steam App ID” turned on in Settings, it also lets this game sync
with a copy tracked under a different name on another device. Filled in automatically
when it can be worked out; a save under <code>AppData</code> often has nothing to work
it out from, so you can set it here.
{$t('game.appId.moreInfo1')}<code>AppData</code>{$t('game.appId.moreInfo2')}
</MoreInfo>
</span>
{#if error}<span class="hint hint-error">{error}</span>{/if}
{#if check?.state === 'checking'}
<span class="hint appid-check">Checking with Steam…</span>
<span class="hint appid-check">{$t('game.appId.checking')}</span>
{:else if check?.state === 'found'}
<span class="hint appid-check ok"><CircleCheck size={13} class="inline-icon" />Steam: <strong>{check.name}</strong></span>
<span class="hint appid-check ok"><CircleCheck size={13} class="inline-icon" />{$t('game.appId.foundPrefix')} <strong>{check.name}</strong></span>
{:else if check?.state === 'unknown'}
<span class="hint appid-check warn">
No Steam game has this App ID. It's the number in the store page address —
<code>store.steampowered.com/app/<strong>1091500</strong>/…</code> — not the one
from another store.
{$t('game.appId.unknown1')}
<code>store.steampowered.com/app/<strong>1091500</strong>/…</code>{$t('game.appId.unknown2')}
</span>
{:else if check?.state === 'unreachable'}
<span class="hint appid-check warn">
Couldn't reach Steam to check this number. If Steam's store or CDN is blocked on
this network, cover art won't load here either — the ID itself may well be right.
{$t('game.appId.unreachable')}
</span>
{/if}
</div>
Expand Down
29 changes: 13 additions & 16 deletions cmd/opensave-app/frontend/src/views/game/BranchesTab.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// a run kept apart from the main one.
import { askConfirm } from '../../lib/stores.js';
import { api } from '../../lib/api.js';
import { plural } from '../../lib/format.js';
import NewBranchDialog from './NewBranchDialog.svelte';
import { t } from '../../lib/i18n.js';
import Plus from 'lucide-svelte/icons/plus';

export let game;
Expand All @@ -25,31 +25,30 @@
}
const createBranch = (copyCurrentSave) => {
dialogOpen = false;
return run(copyCurrentSave ? 'Branch created from your current save' : 'Empty branch created', async () => {
return run(copyCurrentSave ? $t('game.branches.createdFromCurrent') : $t('game.branches.createdEmpty'), async () => {
await api.post(`/api/games/${game.id}/branch`, { name: newBranch, copyCurrentSave });
newBranch = '';
});
};
const switchBranch = (name) =>
run(`Switched to "${name}"`, () => api.post(`/api/games/${game.id}/branch/switch`, { name }));
run($t('game.branches.switchedTo', { name }), () => api.post(`/api/games/${game.id}/branch/switch`, { name }));
async function deleteBranch(name) {
if (!(await askConfirm(`Delete branch "${name}" and all its snapshots? Your current save and other branches aren't affected.`, { title: 'Delete branch?', confirmText: 'Delete', danger: true }))) return;
run(`Deleted branch "${name}"`, () => api.del(`/api/games/${game.id}/branch/${encodeURIComponent(name)}`));
if (!(await askConfirm($t('game.branches.deleteConfirm', { name }), { title: $t('game.branches.deleteTitle'), confirmText: $t('common.delete'), danger: true }))) return;
run($t('game.branches.deleted', { name }), () => api.del(`/api/games/${game.id}/branch/${encodeURIComponent(name)}`));
}
</script>

<div class="card branch-new">
<div class="new-row">
<input
placeholder="New branch name (e.g. ng-plus)"
placeholder={$t('game.branches.namePlaceholder')}
bind:value={newBranch}
on:keydown={(e) => e.key === 'Enter' && openDialog()}
/>
<button class="btn primary" disabled={!newBranch || $busy} on:click={openDialog}><Plus size={15} />Create branch</button>
<button class="btn primary" disabled={!newBranch || $busy} on:click={openDialog}><Plus size={15} />{$t('game.branches.create')}</button>
</div>
<span class="hint">
A branch is a separate line of saves — a second playthrough, or a run you want to keep
apart from your main one. You'll be asked what it starts from.
{$t('game.branches.hint')}
</span>
</div>
<div class="list">
Expand All @@ -58,18 +57,18 @@
<div class="info">
<div class="top">
<span class="name">{branch.name}</span>
{#if branch.name === game.activeBranch}<span class="badge online">active</span>{/if}
{#if branch.name === game.activeBranch}<span class="badge online">{$t('game.branches.active')}</span>{/if}
</div>
<div class="meta">{plural(branch.snapshots?.length ?? 0, 'snapshot')}</div>
<div class="meta">{$t('game.branches.snapshotCount', { n: branch.snapshots?.length ?? 0 })}</div>
</div>
{#if branch.name !== game.activeBranch}
<div class="actions">
<button class="btn small primary" disabled={$busy} on:click={() => switchBranch(branch.name)}>
Switch to
{$t('game.branches.switchTo')}
</button>
{#if branch.name !== 'main'}
<button class="btn small danger" disabled={$busy} on:click={() => deleteBranch(branch.name)}>
Delete
{$t('common.delete')}
</button>
{/if}
</div>
Expand All @@ -78,9 +77,7 @@
{/each}
</div>
<p class="footnote">
Switching branches snapshots your current save first, then restores the other branch's latest
state. A branch you just created has no state of its own yet, so it starts from whatever is in
your save folder now — the two diverge from the first snapshot you take on it.
{$t('game.branches.footnote')}
</p>

{#if dialogOpen}
Expand Down
30 changes: 15 additions & 15 deletions cmd/opensave-app/frontend/src/views/game/CloudTab.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { navigate, toast, askConfirm, settings } from '../../lib/stores.js';
import { api } from '../../lib/api.js';
import { fmtSize } from '../../lib/format.js';
import { t } from '../../lib/i18n.js';
import Spinner from '../../components/ui/Spinner.svelte';
import Cloud from 'lucide-svelte/icons/cloud';
import RefreshCw from 'lucide-svelte/icons/refresh-cw';
Expand Down Expand Up @@ -31,50 +32,49 @@
load();

const restore = async (snap) => {
if (!(await askConfirm(`Download and restore cloud snapshot ${snap.snapshotId} over your current save?`, { title: 'Restore from cloud?', confirmText: 'Download & restore' }))) return;
return run('Restored from cloud', async () => {
if (!(await askConfirm($t('game.cloud.restoreConfirm', { id: snap.snapshotId }), { title: $t('game.cloud.restoreTitle'), confirmText: $t('game.cloud.downloadRestore') }))) return;
return run($t('game.cloud.restored'), async () => {
await api.post(`/api/cloud/restore/${game.id}`, { fileName: snap.name });
});
};

const upload = () =>
run('Uploaded to cloud', async () => {
run($t('game.cloud.uploaded'), async () => {
const res = await api.post(`/api/cloud/sync-local/${game.id}`);
toast(`Uploaded ${res.uploaded}, skipped ${res.skipped}`, 'success');
toast($t('game.cloud.uploadResult', { uploaded: res.uploaded, skipped: res.skipped }), 'success');
await load();
});
</script>

<div class="card">
<div class="head">
<div>
<h3 class="with-icon"><Cloud size={18} /> Cloud snapshots for {game.name}</h3>
<p class="sub">Snapshots backed up to your configured cloud provider.</p>
<h3 class="with-icon"><Cloud size={18} /> {$t('game.cloud.title', { name: game.name })}</h3>
<p class="sub">{$t('game.cloud.sub')}</p>
</div>
<div class="actions">
<button class="btn small" disabled={$busy} on:click={load}><RefreshCw size={13} />Refresh</button>
<button class="btn small primary" disabled={$busy} on:click={upload}><Upload size={13} />Upload local snapshots</button>
<button class="btn small" disabled={$busy} on:click={load}><RefreshCw size={13} />{$t('game.cloud.refresh')}</button>
<button class="btn small primary" disabled={$busy} on:click={upload}><Upload size={13} />{$t('game.cloud.uploadBtn')}</button>
</div>
</div>

{#if loading}
<div class="quiet-block"><Spinner size={13} /> Loading cloud snapshots…</div>
<div class="quiet-block"><Spinner size={13} /> {$t('game.cloud.loading')}</div>
{:else if !snaps || snaps.length === 0}
<div class="quiet-block">
<p>No cloud snapshots for this game yet.</p>
<p>{$t('game.cloud.empty')}</p>
{#if $settings?.cloudSync?.ready}
<p class="hint">New snapshots are copied up as they are taken. “Upload local snapshots” sends the ones from before.</p>
<p class="hint">{$t('game.cloud.readyHint')}</p>
{:else}
<p class="hint">
Set up a provider in <button class="linklike" on:click={() => navigate('cloud')}>Cloud Backup</button>,
then use “Upload local snapshots”.
{$t('game.cloud.setupHint1')}<button class="linklike" on:click={() => navigate('cloud')}>{$t('home.cloudBackup')}</button>{$t('game.cloud.setupHint2')}
</p>
{/if}
</div>
{:else}
<table>
<thead>
<tr><th>Branch</th><th>Date</th><th>Size</th><th></th></tr>
<tr><th>{$t('game.cloud.colBranch')}</th><th>{$t('game.cloud.colDate')}</th><th>{$t('game.cloud.colSize')}</th><th></th></tr>
</thead>
<tbody>
{#each snaps as snap (snap.name)}
Expand All @@ -83,7 +83,7 @@
<td class="mono">{new Date(snap.createdTime).toLocaleString()}</td>
<td class="mono">{fmtSize(snap.sizeBytes)}</td>
<td class="right">
<button class="btn small primary" disabled={$busy} on:click={() => restore(snap)}>Restore</button>
<button class="btn small primary" disabled={$busy} on:click={() => restore(snap)}>{$t('game.snapshots.restore')}</button>
</td>
</tr>
{/each}
Expand Down
17 changes: 9 additions & 8 deletions cmd/opensave-app/frontend/src/views/game/CompareDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import { api } from '../../lib/api.js';
import { fmtSize } from '../../lib/format.js';
import { snapshotKind, whenLabel } from '../../lib/snapshots.js';
import { t } from '../../lib/i18n.js';

export let game;
/** Every snapshot of the game, newest first. */
Expand Down Expand Up @@ -46,40 +47,40 @@
c.change === 'changed' ? `${fmtSize(c.fromSize)} → ${fmtSize(c.toSize)}` : fmtSize(c.change === 'added' ? c.toSize : c.fromSize);
</script>

<Modal title="Compare snapshots" icon={GitCompareArrows} {onClose} width={640} height="auto" maxHeight="min(80vh, 680px)">
<Modal title={$t('game.compare.title')} icon={GitCompareArrows} {onClose} width={640} height="auto" maxHeight="min(80vh, 680px)">
<svelte:fragment slot="sub">{game.name}</svelte:fragment>
<div class="body">
<div class="pick">
<label class="field">
<span>From</span>
<span>{$t('game.compare.from')}</span>
<select bind:value={from}>
{#each snapshots as s (s.id)}<option value={s.id}>{label(s)}</option>{/each}
</select>
</label>
<label class="field">
<span>To</span>
<span>{$t('game.compare.to')}</span>
<select bind:value={to}>
{#each snapshots as s (s.id)}<option value={s.id}>{label(s)}</option>{/each}
</select>
</label>
</div>

{#if error}
<p class="quiet">Couldn't compare them: {error}</p>
<p class="quiet">{$t('game.compare.failed', { error })}</p>
{:else if !result}
<p class="quiet"><Spinner size={13} /> Comparing…</p>
<p class="quiet"><Spinner size={13} /> {$t('game.compare.comparing')}</p>
{:else if result.changes.length === 0}
<p class="quiet">{from === to ? 'The same snapshot.' : `No difference: the same ${result.unchanged} file${result.unchanged === 1 ? '' : 's'} in both.`}</p>
<p class="quiet">{from === to ? $t('game.compare.same') : $t('game.compare.noDiff', { n: result.unchanged })}</p>
{:else}
<p class="count" class:stale={loading}>
{result.changes.length} file{result.changes.length === 1 ? '' : 's'} differ{result.changes.length === 1 ? 's' : ''}{#if result.unchanged}, {result.unchanged} the same{/if}
{$t('game.compare.count', { n: result.changes.length })}{#if result.unchanged}{$t('game.compare.countSame', { n: result.unchanged })}{/if}
</p>
<ul class:stale={loading}>
{#each result.changes as c (c.location + '/' + c.path)}
<li class="change {c.change}">
<svelte:component this={icons[c.change]} size={14} />
<span class="path" title={c.path}>{c.location ? `${c.location}/` : ''}{c.path}</span>
<span class="kind">{c.change}</span>
<span class="kind">{$t('game.compare.' + c.change)}</span>
<span class="sizes">{sizes(c)}</span>
</li>
{/each}
Expand Down
Loading
Loading