Show adaptation pack updates in the launcher
- IPC patches:active / check / apply / useBundled and the event patch-set-changed; installing or reverting is refused while a copy is being maintained, since a build reads the patch set as it runs. - Setting checkPatchPacksOnStart (on by default): the window checks once when it opens and stays quiet when the check fails. - The footer shows an available pack at the right end and leads to the About page, which shows the patch set in use, checks on request, and downloads and activates a pack only when the player clicks for it; a pack that needs a newer offline version, or a failed check, is explained there. Supported game versions follow the active set. - Chinese and English text.
This commit is contained in:
1 parent
6068d5bc65
commit
f4d2916f0d
13 files changed
+372
-44
No files matched your search
@@ -13,6 +13,7 @@ import { cancelInstall, checkGameFolder, installGame } from '../services/install
|
||||
import { createCopyDraft, listCopies, readInstallRecord, renameCopy, setCurrentCopy } from '../services/install/install-record.ts';
|
||||
import { readInstalledLab } from '../services/launch/lab-handoff.ts';
|
||||
import { getLaunchState, openServerStatus, startLaunch, stopLaunch } from '../services/launch/launch-controller.ts';
|
||||
import { activePatchSet, applyPackUpdate, checkPackUpdate, revertToBundledPatchSet } from '../services/patch-pack/pack-update.ts';
|
||||
import { resourcePaths } from '../services/resources/resource-paths.ts';
|
||||
import { changeSaveResearch, createSave, exportSave, getSaveDetails, getSaveList, getSaveResearch, importSelectedBackups, listSaveBackups, pickOfficialBackups, pickSaveArchive, previewSelectedBackups, removeSave, restoreSaveBackup, saveWriteInProgress, selectSave, setSaveCurrencies, takeSaveBackup, transferSave } from '../services/saves/manage-saves.ts';
|
||||
import { broadcast, handle } from './register.ts';
|
||||
@@ -140,6 +141,22 @@ export function registerIpcHandlers(): void {
|
||||
handle('launch:stop', async () => { await stopLaunch(); });
|
||||
handle('launch:openServerStatus', () => openServerStatus());
|
||||
|
||||
handle('patches:active', () => activePatchSet());
|
||||
handle('patches:check', () => checkPackUpdate());
|
||||
handle('patches:apply', async () => {
|
||||
// A build reads the patch set while it runs; switch only between builds.
|
||||
if (maintenanceInProgress()) throw new AppError('maintenance_busy');
|
||||
const result = await applyPackUpdate();
|
||||
if (result.ok) broadcast('event:patch-set-changed', result.active);
|
||||
return result;
|
||||
});
|
||||
handle('patches:useBundled', async () => {
|
||||
if (maintenanceInProgress()) throw new AppError('maintenance_busy');
|
||||
const active = await revertToBundledPatchSet();
|
||||
broadcast('event:patch-set-changed', active);
|
||||
return active;
|
||||
});
|
||||
|
||||
handle('settings:get', () => getSettings());
|
||||
handle('settings:update', async (patch) => {
|
||||
const settings = await updateSettings(patch);
|
||||
|
||||
@@ -34,6 +34,7 @@ import { COPY_SECTIONS, navigate, SAVE_SECTIONS, SETTINGS_SECTIONS, START_ROUTE,
|
||||
import { SubNav } from './shell/SubNav.tsx';
|
||||
import { TitleBar } from './shell/TitleBar.tsx';
|
||||
import { useBackgrounds } from './shell/useBackgrounds.ts';
|
||||
import { usePatchPack } from './shell/usePatchPack.ts';
|
||||
import { useErrorMessage } from './useErrorMessage.ts';
|
||||
|
||||
interface AppProps {
|
||||
@@ -61,7 +62,9 @@ export function App({ info, initialSettings, initialCopies }: AppProps) {
|
||||
const record = registry.copies.find((copy) => copy.id === registry.current) ?? null;
|
||||
const [launch, setLaunch] = useState<LaunchState>({ phase: 'ready' });
|
||||
const [route, setRoute] = useState<Route>(START_ROUTE);
|
||||
const supported = info.supportedGameVersions;
|
||||
// The setting as the window opened: turning it on later does not check right away.
|
||||
const patchPack = usePatchPack(initialSettings.checkPatchPacksOnStart, report);
|
||||
const supported = patchPack.active?.gameVersions ?? info.supportedGameVersions;
|
||||
|
||||
const wizard = useInstallWizard({ onInstalled: () => setRoute(START_ROUTE) });
|
||||
|
||||
@@ -116,7 +119,7 @@ export function App({ info, initialSettings, initialCopies }: AppProps) {
|
||||
bar: home,
|
||||
};
|
||||
case 'about':
|
||||
return { side: homeSide, main: <AboutPage launcherVersion={info.version} supportedVersions={supported} />, bar: home };
|
||||
return { side: homeSide, main: <AboutPage launcherVersion={info.version} supportedVersions={supported} patchPack={patchPack} />, bar: home };
|
||||
case 'settings': {
|
||||
const sections = SETTINGS_SECTIONS.filter((section) => info.development || section !== 'dev');
|
||||
const content = {
|
||||
@@ -186,7 +189,13 @@ export function App({ info, initialSettings, initialCopies }: AppProps) {
|
||||
{message && <p className="app-error" role="alert">{message}</p>}
|
||||
</main>
|
||||
<BottomBar model={view.bar} />
|
||||
<Footer launcherVersion={info.version} gameVersion={record?.gameVersion ?? null} copyName={record?.name ?? null} />
|
||||
<Footer
|
||||
launcherVersion={info.version}
|
||||
gameVersion={record?.gameVersion ?? null}
|
||||
copyName={record?.name ?? null}
|
||||
packUpdate={patchPack.check?.status === 'available' ? (patchPack.check.latest?.version ?? null) : null}
|
||||
onOpenPackUpdate={() => go({ page: 'about' })}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -24,7 +24,8 @@
|
||||
"footer": {
|
||||
"launcher": "Launcher {{version}}",
|
||||
"game": "{{name}} · Game {{version}}",
|
||||
"notInstalled": "Not installed"
|
||||
"notInstalled": "Not installed",
|
||||
"packUpdate": "Adaptation pack {{version}} available · Update ›"
|
||||
},
|
||||
"home": {
|
||||
"kicker": "Local server · AI battles",
|
||||
@@ -407,6 +408,9 @@
|
||||
"dev": "Developer",
|
||||
"diag": "Diagnostics"
|
||||
},
|
||||
"patchPacks": "Adaptation pack updates",
|
||||
"patchPacksHint": "After a game update, the patches for the new version are released on GitHub as an adaptation pack.",
|
||||
"patchPacksToggle": "Check for a new adaptation pack at start",
|
||||
"windowClose": "When closing the window",
|
||||
"windowQuit": "Quit launcher",
|
||||
"windowTray": "Minimize to system tray",
|
||||
@@ -473,6 +477,42 @@
|
||||
"about": {
|
||||
"launcher": "Launcher {{version}}",
|
||||
"supported": "Supported game versions: {{versions}}",
|
||||
"pack": {
|
||||
"title": "Adaptation data",
|
||||
"current": "In use",
|
||||
"currentHint": "The patches used to install and update copies.",
|
||||
"bundled": "Included with the launcher",
|
||||
"bundledVersion": "Included with the launcher ({{version}})",
|
||||
"downloaded": "Adaptation pack {{version}}",
|
||||
"useBundled": "Go back to the included patches",
|
||||
"check": "Check for updates",
|
||||
"checkHint": "Looks for a new adaptation pack on GitHub. Gaijin is not contacted.",
|
||||
"checkButton": "Check",
|
||||
"checking": "Checking…",
|
||||
"applying": "Downloading and verifying the adaptation pack…",
|
||||
"upToDate": "Up to date (the newest adaptation pack is {{version}}).",
|
||||
"noneReleased": "No adaptation pack has been released yet.",
|
||||
"available": "Adaptation pack {{version}} is available. Supported game versions: {{versions}}.",
|
||||
"availableHint": "Its signature is verified before it is used. Installing and updating copies then use the new patches.",
|
||||
"apply": "Download and use {{version}}",
|
||||
"needsAppUpdate": "Adaptation pack {{version}} needs offline version {{app}} or newer. Update the offline version first.",
|
||||
"checkFailed": {
|
||||
"no_signing_key": "This launcher has no signing key built in, so it accepts no adaptation pack.",
|
||||
"network": "GitHub could not be reached. Try again later.",
|
||||
"contents": "The released adaptation pack is incomplete or malformed.",
|
||||
"signature": "The adaptation pack's signature is wrong. It was refused.",
|
||||
"size": "The adaptation pack is larger than allowed. It was refused."
|
||||
},
|
||||
"applyFailed": {
|
||||
"no_signing_key": "This launcher has no signing key built in, so it accepts no adaptation pack.",
|
||||
"network": "The download failed: GitHub could not be reached. Try again later.",
|
||||
"contents": "The adaptation pack is incomplete or malformed. It is not in use.",
|
||||
"signature": "The adaptation pack's signature is wrong. It was refused and is not in use.",
|
||||
"size": "The adaptation pack is larger than allowed. It was refused.",
|
||||
"needs_app_update": "This adaptation pack needs a newer offline version. Update the offline version first.",
|
||||
"up_to_date": "Up to date: there is no adaptation pack to download."
|
||||
}
|
||||
},
|
||||
"statement": "Project information",
|
||||
"statementBody": "WTOffline is an independent, unofficial project with no affiliation to Gaijin Entertainment. An installed copy of the official War Thunder client is required."
|
||||
},
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
"footer": {
|
||||
"launcher": "启动器 {{version}}",
|
||||
"game": "{{name}} · 游戏 {{version}}",
|
||||
"notInstalled": "未安装"
|
||||
"notInstalled": "未安装",
|
||||
"packUpdate": "适配包 {{version}} 可用 · 更新 ›"
|
||||
},
|
||||
"home": {
|
||||
"kicker": "本地服务器 · AI 对局",
|
||||
@@ -407,6 +408,9 @@
|
||||
"dev": "开发者",
|
||||
"diag": "诊断"
|
||||
},
|
||||
"patchPacks": "适配包更新",
|
||||
"patchPacksHint": "游戏更新后,新版本的补丁会以适配包的形式发布在 GitHub 上。",
|
||||
"patchPacksToggle": "启动时检查有没有新的适配包",
|
||||
"windowClose": "关闭窗口时",
|
||||
"windowQuit": "退出启动器",
|
||||
"windowTray": "最小化到系统托盘",
|
||||
@@ -473,6 +477,42 @@
|
||||
"about": {
|
||||
"launcher": "启动器 {{version}}",
|
||||
"supported": "支持的游戏版本:{{versions}}",
|
||||
"pack": {
|
||||
"title": "适配数据",
|
||||
"current": "当前使用",
|
||||
"currentHint": "安装和更新副本时使用的补丁。",
|
||||
"bundled": "启动器自带",
|
||||
"bundledVersion": "启动器自带({{version}})",
|
||||
"downloaded": "适配包 {{version}}",
|
||||
"useBundled": "改回启动器自带",
|
||||
"check": "检查更新",
|
||||
"checkHint": "在 GitHub 上查找新的适配包,不会连接 Gaijin。",
|
||||
"checkButton": "检查",
|
||||
"checking": "正在检查…",
|
||||
"applying": "正在下载并校验适配包…",
|
||||
"upToDate": "已是最新(最新的适配包是 {{version}})。",
|
||||
"noneReleased": "还没有发布适配包。",
|
||||
"available": "适配包 {{version}} 可用,支持的游戏版本:{{versions}}。",
|
||||
"availableHint": "下载后会先校验签名,通过后才启用;之后安装和更新副本都使用新的补丁。",
|
||||
"apply": "下载并启用 {{version}}",
|
||||
"needsAppUpdate": "适配包 {{version}} 需要离线版 {{app}} 或更新的版本,请先更新离线版。",
|
||||
"checkFailed": {
|
||||
"no_signing_key": "这个启动器没有内置签名公钥,不接受适配包。",
|
||||
"network": "连不上 GitHub,请稍后再试。",
|
||||
"contents": "发布的适配包信息不完整或格式不对。",
|
||||
"signature": "适配包的签名不对,已拒绝。",
|
||||
"size": "适配包超出大小上限,已拒绝。"
|
||||
},
|
||||
"applyFailed": {
|
||||
"no_signing_key": "这个启动器没有内置签名公钥,不接受适配包。",
|
||||
"network": "下载失败:连不上 GitHub,请稍后再试。",
|
||||
"contents": "适配包内容不完整或格式不对,没有启用。",
|
||||
"signature": "适配包的签名不对,已拒绝,没有启用。",
|
||||
"size": "适配包超出大小上限,已拒绝。",
|
||||
"needs_app_update": "这个适配包需要更新版本的离线版,请先更新离线版。",
|
||||
"up_to_date": "已是最新,没有需要下载的适配包。"
|
||||
}
|
||||
},
|
||||
"statement": "项目信息",
|
||||
"statementBody": "WTOffline 是独立开发的非官方项目,与 Gaijin Entertainment 无关。运行需要已安装的战争雷霆正版客户端。"
|
||||
},
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Notice } from '../../components/Notice.tsx';
|
||||
import { Row } from '../../components/Row.tsx';
|
||||
import { Sheet } from '../../components/Sheet.tsx';
|
||||
import type { PatchPackState } from '../../shell/usePatchPack.ts';
|
||||
|
||||
/** The launcher's version, the game versions it supports, and the project statement. */
|
||||
export function AboutPage({ launcherVersion, supportedVersions }: { readonly launcherVersion: string; readonly supportedVersions: readonly string[] }) {
|
||||
interface AboutPageProps {
|
||||
readonly launcherVersion: string;
|
||||
readonly supportedVersions: readonly string[];
|
||||
readonly patchPack: PatchPackState;
|
||||
}
|
||||
|
||||
/** The launcher's version, the game versions it supports, adaptation pack updates, and the project statement. */
|
||||
export function AboutPage({ launcherVersion, supportedVersions, patchPack }: AboutPageProps) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Sheet title={t('nav.about')}>
|
||||
@@ -14,8 +23,67 @@ export function AboutPage({ launcherVersion, supportedVersions }: { readonly lau
|
||||
{t('about.supported', { versions: supportedVersions.join(', ') })}
|
||||
</div>
|
||||
</div>
|
||||
<h3 className="section-title">{t('about.statement')}</h3>
|
||||
<PatchPackSection state={patchPack} />
|
||||
<h3 className="section-title section-title-spaced">{t('about.statement')}</h3>
|
||||
<p className="lead">{t('about.statementBody')}</p>
|
||||
</Sheet>
|
||||
);
|
||||
}
|
||||
|
||||
function PatchPackSection({ state }: { readonly state: PatchPackState }) {
|
||||
const { t } = useTranslation();
|
||||
const { active, check, busy } = state;
|
||||
const current = active === null
|
||||
? '…'
|
||||
: active.source === 'downloaded'
|
||||
? t('about.pack.downloaded', { version: active.version })
|
||||
: active.version
|
||||
? t('about.pack.bundledVersion', { version: active.version })
|
||||
: t('about.pack.bundled');
|
||||
return (
|
||||
<>
|
||||
<h3 className="section-title">{t('about.pack.title')}</h3>
|
||||
<Row label={t('about.pack.current')} hint={t('about.pack.currentHint')}>
|
||||
<span>{current}</span>
|
||||
{active?.source === 'downloaded' && (
|
||||
<button type="button" className="button" disabled={busy !== null} onClick={state.useBundled}>
|
||||
{t('about.pack.useBundled')}
|
||||
</button>
|
||||
)}
|
||||
</Row>
|
||||
<Row label={t('about.pack.check')} hint={t('about.pack.checkHint')}>
|
||||
<button type="button" className="button" disabled={busy !== null} onClick={state.checkNow}>
|
||||
{busy === 'checking' ? t('about.pack.checking') : t('about.pack.checkButton')}
|
||||
</button>
|
||||
</Row>
|
||||
{busy === 'applying' && <p className="small">{t('about.pack.applying')}</p>}
|
||||
{state.applyFailure && <Notice tone="error"><p>{t(`about.pack.applyFailed.${state.applyFailure}`)}</p></Notice>}
|
||||
{check && busy !== 'checking' && <CheckResult state={state} />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function CheckResult({ state }: { readonly state: PatchPackState }) {
|
||||
const { t } = useTranslation();
|
||||
const check = state.check;
|
||||
if (!check) return null;
|
||||
const latest = check.latest;
|
||||
switch (check.status) {
|
||||
case 'up_to_date':
|
||||
return <Notice tone="info"><p>{latest ? t('about.pack.upToDate', { version: latest.version }) : t('about.pack.noneReleased')}</p></Notice>;
|
||||
case 'available':
|
||||
return (
|
||||
<Notice tone="info">
|
||||
<p>{t('about.pack.available', { version: latest?.version ?? '', versions: latest?.gameVersions.join(', ') ?? '' })}</p>
|
||||
<p className="small">{t('about.pack.availableHint')}</p>
|
||||
<button type="button" className="button button-primary" disabled={state.busy !== null} onClick={state.apply}>
|
||||
{t('about.pack.apply', { version: latest?.version ?? '' })}
|
||||
</button>
|
||||
</Notice>
|
||||
);
|
||||
case 'needs_app_update':
|
||||
return <Notice tone="warning"><p>{t('about.pack.needsAppUpdate', { version: latest?.version ?? '', app: latest?.minAppVersion ?? '' })}</p></Notice>;
|
||||
case 'failed':
|
||||
return <Notice tone="error"><p>{t(`about.pack.checkFailed.${check.problem ?? 'contents'}`)}</p></Notice>;
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,12 @@ export function GeneralSettings({ settings, pictures, onError }: GeneralSettings
|
||||
{t('background.officialToggle')}
|
||||
</label>
|
||||
</Row>
|
||||
<Row label={t('settings.patchPacks')} hint={t('settings.patchPacksHint')}>
|
||||
<label className="check check-inline">
|
||||
<input type="checkbox" checked={settings.checkPatchPacksOnStart} onChange={(event) => update({ checkPatchPacksOnStart: event.target.checked })} />
|
||||
{t('settings.patchPacksToggle')}
|
||||
</label>
|
||||
</Row>
|
||||
<h3 className="section-title section-title-spaced">{t('background.title')}</h3>
|
||||
<p className="small">{t('background.hint')}</p>
|
||||
{pictures.length === 0 ? (
|
||||
|
||||
@@ -5,16 +5,24 @@ interface FooterProps {
|
||||
/** The installed copy's game version; null before installation, or when it is unknown. */
|
||||
readonly gameVersion: string | null;
|
||||
readonly copyName: string | null;
|
||||
/** A newer adaptation pack that this launcher can use, or null. */
|
||||
readonly packUpdate: string | null;
|
||||
readonly onOpenPackUpdate: () => void;
|
||||
}
|
||||
|
||||
/** Launcher and game versions along the bottom edge. */
|
||||
export function Footer({ launcherVersion, gameVersion, copyName }: FooterProps) {
|
||||
/** Launcher and game versions along the bottom edge; on the right, an available adaptation pack. */
|
||||
export function Footer({ launcherVersion, gameVersion, copyName, packUpdate, onOpenPackUpdate }: FooterProps) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<footer className="footer">
|
||||
<span>{t('footer.launcher', { version: launcherVersion })}</span>
|
||||
<span className="footer-separator">|</span>
|
||||
<span>{copyName ? t('footer.game', { name: copyName, version: gameVersion ?? t('source.versionUnknown') }) : t('footer.notInstalled')}</span>
|
||||
<span className="footer-copy">{copyName ? t('footer.game', { name: copyName, version: gameVersion ?? t('source.versionUnknown') }) : t('footer.notInstalled')}</span>
|
||||
{packUpdate && (
|
||||
<button type="button" className="footer-update" onClick={onOpenPackUpdate}>
|
||||
{t('footer.packUpdate', { version: packUpdate })}
|
||||
</button>
|
||||
)}
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import type { ActivePatchSet, PackApplyResult, PackCheck } from '@shared/schemas/patch-pack.ts';
|
||||
import { ipcInvoke, ipcOn } from '../ipc.ts';
|
||||
|
||||
export type PackFailure = Extract<PackApplyResult, { ok: false }>['problem'];
|
||||
|
||||
export interface PatchPackState {
|
||||
/** The patch set builds use; null until the launcher answered. */
|
||||
readonly active: ActivePatchSet | null;
|
||||
/** The last update check; null before the first. */
|
||||
readonly check: PackCheck | null;
|
||||
readonly busy: 'checking' | 'applying' | 'reverting' | null;
|
||||
/** Why the last install failed, until the next check or install. */
|
||||
readonly applyFailure: PackFailure | null;
|
||||
readonly checkNow: () => void;
|
||||
readonly apply: () => void;
|
||||
readonly useBundled: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adaptation pack state for the footer and the About page. Checks once when the window opens if
|
||||
* the setting allows; a failed start check stays quiet (the About page shows it).
|
||||
*/
|
||||
export function usePatchPack(checkOnStart: boolean, onError: (error: unknown) => void): PatchPackState {
|
||||
const [active, setActive] = useState<ActivePatchSet | null>(null);
|
||||
const [check, setCheck] = useState<PackCheck | null>(null);
|
||||
const [busy, setBusy] = useState<PatchPackState['busy']>(null);
|
||||
const [applyFailure, setApplyFailure] = useState<PackFailure | null>(null);
|
||||
const startChecked = useRef(false);
|
||||
|
||||
useEffect(() => ipcOn('event:patch-set-changed', setActive), []);
|
||||
useEffect(() => {
|
||||
ipcInvoke('patches:active').then(setActive).catch(onError);
|
||||
}, [onError]);
|
||||
|
||||
const checkNow = useCallback((): void => {
|
||||
setBusy('checking');
|
||||
setApplyFailure(null);
|
||||
ipcInvoke('patches:check')
|
||||
.then((result) => {
|
||||
setCheck(result);
|
||||
setActive(result.active);
|
||||
})
|
||||
.catch(onError)
|
||||
.finally(() => setBusy(null));
|
||||
}, [onError]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!checkOnStart || startChecked.current) return;
|
||||
startChecked.current = true;
|
||||
checkNow();
|
||||
}, [checkOnStart, checkNow]);
|
||||
|
||||
const apply = useCallback((): void => {
|
||||
setBusy('applying');
|
||||
setApplyFailure(null);
|
||||
ipcInvoke('patches:apply')
|
||||
.then((result) => {
|
||||
if (!result.ok) {
|
||||
setApplyFailure(result.problem);
|
||||
return;
|
||||
}
|
||||
setActive(result.active);
|
||||
setCheck((previous) => (previous ? { ...previous, status: 'up_to_date', active: result.active } : previous));
|
||||
})
|
||||
.catch(onError)
|
||||
.finally(() => setBusy(null));
|
||||
}, [onError]);
|
||||
|
||||
const useBundled = useCallback((): void => {
|
||||
setBusy('reverting');
|
||||
ipcInvoke('patches:useBundled')
|
||||
.then((result) => {
|
||||
setActive(result);
|
||||
setCheck(null);
|
||||
})
|
||||
.catch(onError)
|
||||
.finally(() => setBusy(null));
|
||||
}, [onError]);
|
||||
|
||||
return { active, check, busy, applyFailure, checkNow, apply, useBundled };
|
||||
}
|
||||
@@ -539,7 +539,7 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.footer span:last-child {
|
||||
.footer-copy {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
@@ -549,3 +549,20 @@
|
||||
.footer-separator {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* An available adaptation pack, at the right end. */
|
||||
.footer-update {
|
||||
margin-left: auto;
|
||||
flex: none;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
font: inherit;
|
||||
color: var(--amber);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.footer-update:hover,
|
||||
.footer-update:focus-visible {
|
||||
text-decoration: underline;
|
||||
}
|
||||
@@ -22,6 +22,8 @@ export const IPC_CHANNEL_PREFIXES = [
|
||||
'launch:',
|
||||
/** The launcher's own settings. */
|
||||
'settings:',
|
||||
/** Adaptation packs: the active patch set, update checks, installing a newer pack. */
|
||||
'patches:',
|
||||
/** The launcher window itself (it draws its own title bar). */
|
||||
'window:',
|
||||
] as const;
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
} from '../schemas/install.ts';
|
||||
import { LabInfoSchema, LaunchStateSchema } from '../schemas/launch.ts';
|
||||
import { MaintenanceInfoSchema, MaintenanceProgressSchema, MaintenanceRequestSchema } from '../schemas/maintenance.ts';
|
||||
import { ActivePatchSetSchema, PackApplyResultSchema, PackCheckSchema } from '../schemas/patch-pack.ts';
|
||||
import { ResearchBranchSchema, ResearchOperationSchema, SaveResearchSchema, OfficialImportOptionsSchema, OfficialPreviewSchema, SaveOfficialRequestSchema, CurrencyEditsSchema, SaveBackupNameSchema, SaveBackupSchema, SaveDetailsSchema, SaveKeysSchema, SaveListSchema, SaveRegistrationSchema, SaveTransferSchema } from '../schemas/saves.ts';
|
||||
import { TuningPatchSchema, TuningViewSchema } from '../schemas/tuning.ts';
|
||||
import { SettingsPatchSchema, SettingsSchema } from '../schemas/settings.ts';
|
||||
@@ -233,6 +234,26 @@ export const ipcContract = {
|
||||
input: SettingsPatchSchema,
|
||||
output: SettingsSchema,
|
||||
},
|
||||
'patches:active': {
|
||||
/** The patch set builds use: the bundled one or a downloaded adaptation pack. */
|
||||
input: z.void(),
|
||||
output: ActivePatchSetSchema,
|
||||
},
|
||||
'patches:check': {
|
||||
/** Asks GitHub for the newest adaptation pack. */
|
||||
input: z.void(),
|
||||
output: PackCheckSchema,
|
||||
},
|
||||
'patches:apply': {
|
||||
/** Downloads, verifies and activates the newest pack; the window asks the player first. */
|
||||
input: z.void(),
|
||||
output: PackApplyResultSchema,
|
||||
},
|
||||
'patches:useBundled': {
|
||||
/** Stops using downloaded packs. */
|
||||
input: z.void(),
|
||||
output: ActivePatchSetSchema,
|
||||
},
|
||||
'window:minimize': {
|
||||
input: z.void(),
|
||||
output: z.void(),
|
||||
@@ -249,6 +270,8 @@ export const ipcEvents = {
|
||||
'event:launch-state': LaunchStateSchema,
|
||||
'event:copies-changed': CopiesSchema,
|
||||
'event:copy-maintenance': MaintenanceProgressSchema,
|
||||
/** Another patch set became active (a pack was installed, or the bundled set restored). */
|
||||
'event:patch-set-changed': ActivePatchSetSchema,
|
||||
} as const;
|
||||
|
||||
export type IpcChannel = keyof typeof ipcContract;
|
||||
|
||||
@@ -1,56 +1,69 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
/**
|
||||
* What the launcher reports about adaptation packs (main/services/patch-pack/): which patch set
|
||||
* the builds use, and whether a newer pack is released.
|
||||
*/
|
||||
|
||||
/** The patch set that ships with the launcher, or a downloaded adaptation pack. */
|
||||
export type PatchSetSource = 'bundled' | 'downloaded';
|
||||
export const PatchSetSourceSchema = z.enum(['bundled', 'downloaded']);
|
||||
|
||||
export interface ActivePatchSet {
|
||||
readonly source: PatchSetSource;
|
||||
export const ActivePatchSetSchema = z.object({
|
||||
source: PatchSetSourceSchema,
|
||||
/** Pack version; null for a bundled set without one (a repository checkout). */
|
||||
readonly version: string | null;
|
||||
version: z.string().nullable(),
|
||||
/** Game versions with a version record in the set. */
|
||||
readonly gameVersions: readonly string[];
|
||||
}
|
||||
gameVersions: z.array(z.string()),
|
||||
});
|
||||
|
||||
export interface PackRelease {
|
||||
readonly version: string;
|
||||
readonly gameVersions: readonly string[];
|
||||
readonly minAppVersion: string;
|
||||
readonly publishedAt: string | null;
|
||||
}
|
||||
export const PackReleaseSchema = z.object({
|
||||
version: z.string(),
|
||||
gameVersions: z.array(z.string()),
|
||||
minAppVersion: z.string(),
|
||||
publishedAt: z.string().nullable(),
|
||||
});
|
||||
|
||||
export type PackCheckStatus =
|
||||
export const PackCheckStatusSchema = z.enum([
|
||||
/** No release is newer than the active set. */
|
||||
| 'up_to_date'
|
||||
'up_to_date',
|
||||
/** A newer pack this launcher can use. */
|
||||
| 'available'
|
||||
'available',
|
||||
/** A newer pack needs a newer offline version (launcher) first. */
|
||||
| 'needs_app_update'
|
||||
'needs_app_update',
|
||||
/** The check could not be made; see `problem`. */
|
||||
| 'failed';
|
||||
'failed',
|
||||
]);
|
||||
|
||||
export type PackProblem =
|
||||
export const PackProblemSchema = z.enum([
|
||||
/** This build of the launcher carries no signing key, so it accepts no pack. */
|
||||
| 'no_signing_key'
|
||||
'no_signing_key',
|
||||
/** GitHub could not be reached or answered with an error. */
|
||||
| 'network'
|
||||
'network',
|
||||
/** The release or the pack is malformed. */
|
||||
| 'contents'
|
||||
'contents',
|
||||
/** The signature does not match. */
|
||||
| 'signature'
|
||||
'signature',
|
||||
/** The pack is larger than allowed. */
|
||||
| 'size';
|
||||
'size',
|
||||
]);
|
||||
|
||||
export interface PackCheck {
|
||||
readonly status: PackCheckStatus;
|
||||
readonly active: ActivePatchSet;
|
||||
export const PackCheckSchema = z.object({
|
||||
status: PackCheckStatusSchema,
|
||||
active: ActivePatchSetSchema,
|
||||
/** The newest released pack; null when none is released or the check failed. */
|
||||
readonly latest: PackRelease | null;
|
||||
readonly problem: PackProblem | null;
|
||||
}
|
||||
latest: PackReleaseSchema.nullable(),
|
||||
problem: PackProblemSchema.nullable(),
|
||||
});
|
||||
|
||||
export type PackApplyResult =
|
||||
| { readonly ok: true; readonly active: ActivePatchSet }
|
||||
| { readonly ok: false; readonly problem: PackProblem | 'needs_app_update' | 'up_to_date' };
|
||||
export const PackApplyResultSchema = z.discriminatedUnion('ok', [
|
||||
z.object({ ok: z.literal(true), active: ActivePatchSetSchema }),
|
||||
z.object({ ok: z.literal(false), problem: z.union([PackProblemSchema, z.enum(['needs_app_update', 'up_to_date'])]) }),
|
||||
]);
|
||||
|
||||
export type PatchSetSource = z.output<typeof PatchSetSourceSchema>;
|
||||
export type ActivePatchSet = z.output<typeof ActivePatchSetSchema>;
|
||||
export type PackRelease = z.output<typeof PackReleaseSchema>;
|
||||
export type PackCheckStatus = z.output<typeof PackCheckStatusSchema>;
|
||||
export type PackProblem = z.output<typeof PackProblemSchema>;
|
||||
export type PackCheck = z.output<typeof PackCheckSchema>;
|
||||
export type PackApplyResult = z.output<typeof PackApplyResultSchema>;
|
||||
@@ -14,6 +14,8 @@ export const SettingsSchema = z.object({
|
||||
background: BackgroundChoiceSchema.default(BACKGROUND_RANDOM),
|
||||
/** Fetch wallpapers from the game website's public gallery. */
|
||||
officialWallpapers: z.boolean().default(true),
|
||||
/** Ask GitHub for a newer adaptation pack when the launcher starts. */
|
||||
checkPatchPacksOnStart: z.boolean().default(true),
|
||||
windowClose: WindowCloseSchema.default('quit'),
|
||||
afterGameStarts: AfterGameStartsSchema.default('minimize'),
|
||||
autoSaveBackups: z.boolean().default(true),
|
||||
@@ -29,6 +31,7 @@ export const SettingsPatchSchema = z.object({
|
||||
language: LanguageChoiceSchema.optional(),
|
||||
background: BackgroundChoiceSchema.optional(),
|
||||
officialWallpapers: z.boolean().optional(),
|
||||
checkPatchPacksOnStart: z.boolean().optional(),
|
||||
windowClose: WindowCloseSchema.optional(),
|
||||
afterGameStarts: AfterGameStartsSchema.optional(),
|
||||
autoSaveBackups: z.boolean().optional(),
|
||||
|
||||
Reference in new issue
Block a user