From f4d2916f0dd562ec059cab61023346d969c41097 Mon Sep 17 00:00:00 2001 From: N0VAN0M4LY <224130499+N0VAN0M4LY@users.noreply.github.com> Date: Sun, 29 Nov 2026 16:32:13 +0800 Subject: [PATCH] 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. --- apps/launcher/src/main/ipc/handlers.ts | 17 ++++ apps/launcher/src/renderer/src/App.tsx | 15 +++- .../src/renderer/src/i18n/locales/en.json | 42 +++++++++- .../src/renderer/src/i18n/locales/zh-CN.json | 42 +++++++++- .../renderer/src/pages/about/AboutPage.tsx | 74 ++++++++++++++++- .../src/pages/settings/GeneralSettings.tsx | 6 ++ .../src/renderer/src/shell/Footer.tsx | 14 +++- .../src/renderer/src/shell/usePatchPack.ts | 82 +++++++++++++++++++ .../src/renderer/src/styles/shell.css | 19 ++++- apps/launcher/src/shared/ipc/channels.ts | 2 + apps/launcher/src/shared/ipc/contract.ts | 23 ++++++ .../launcher/src/shared/schemas/patch-pack.ts | 77 +++++++++-------- apps/launcher/src/shared/schemas/settings.ts | 3 + 13 files changed, 372 insertions(+), 44 deletions(-) create mode 100644 apps/launcher/src/renderer/src/shell/usePatchPack.ts diff --git a/apps/launcher/src/main/ipc/handlers.ts b/apps/launcher/src/main/ipc/handlers.ts index 5439b5f..cefdff1 100644 --- a/apps/launcher/src/main/ipc/handlers.ts +++ b/apps/launcher/src/main/ipc/handlers.ts @@ -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); diff --git a/apps/launcher/src/renderer/src/App.tsx b/apps/launcher/src/renderer/src/App.tsx index 1cbdecb..212a6b5 100644 --- a/apps/launcher/src/renderer/src/App.tsx +++ b/apps/launcher/src/renderer/src/App.tsx @@ -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({ phase: 'ready' }); const [route, setRoute] = useState(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: , bar: home }; + return { side: homeSide, main: , 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 &&

{message}

} -