diff --git a/apps/launcher/src/renderer/src/App.tsx b/apps/launcher/src/renderer/src/App.tsx index 46349d6..8a8947f 100644 --- a/apps/launcher/src/renderer/src/App.tsx +++ b/apps/launcher/src/renderer/src/App.tsx @@ -33,6 +33,7 @@ import { Background } from './shell/Background.tsx'; import { BottomBar } from './shell/BottomBar.tsx'; import type { BarModel } from './shell/bar-model.ts'; import { Footer } from './shell/Footer.tsx'; +import { isMapNavPromptSuppressed, MapNavPromptModal } from './shell/MapNavPromptModal.tsx'; import { COPY_SECTIONS, MODS_SECTIONS, navigate, SAVE_SECTIONS, SETTINGS_SECTIONS, START_ROUTE, TUNING_SECTIONS, type Destination, type Route } from './shell/navigation.ts'; import { SubNav } from './shell/SubNav.tsx'; import { TitleBar } from './shell/TitleBar.tsx'; @@ -68,6 +69,7 @@ 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 [mapNavPromptOpen, setMapNavPromptOpen] = useState(false); // The setting as the window opened: turning it on later does not check right away. const patchPack = usePatchPack(initialSettings.checkPatchPacksOnStart, report); const mapNavPack = useMapNavPack(initialSettings.checkPatchPacksOnStart, report); @@ -129,8 +131,16 @@ export function App({ info, initialSettings, initialCopies }: AppProps) { }; const perCopyStatus = ['version-changed', 'failed', 'port-busy', 'server-exited', 'game-exited'].includes(launch.phase); const launchStatus: LaunchState = perCopyStatus && launch.copyId && launch.copyId !== record?.id ? { phase: 'ready' } : launch; + const startLaunch = (): void => { ipcInvoke('launch:start').catch(report); }; + const handleStart = (): void => { + if (mapNavPack.active === null && !isMapNavPromptSuppressed()) { + setMapNavPromptOpen(true); + return; + } + startLaunch(); + }; const home = homeBar(record, launchStatus, t, wizard.start, { - start: () => { ipcInvoke('launch:start').catch(report); }, + start: handleStart, stop: () => { ipcInvoke('launch:stop').catch(report); }, checkVersion: () => go({ page: 'copies', section: 'features' }), relocate: () => { if (record) relocateCopy(record.id); }, @@ -158,13 +168,8 @@ export function App({ info, initialSettings, initialCopies }: AppProps) { side: homeSide, main: ( ), bar: home, @@ -213,13 +218,7 @@ export function App({ info, initialSettings, initialCopies }: AppProps) { return { side, main: ( - + ), bar: home, }; @@ -264,23 +263,9 @@ export function App({ info, initialSettings, initialCopies }: AppProps) {
{view.main} {error && ( -
setErrorPaused(true)} - onMouseLeave={() => setErrorPaused(false)} - > +
setErrorPaused(true)} onMouseLeave={() => setErrorPaused(false)}> {error.message} - +
)}
@@ -290,9 +275,20 @@ export function App({ info, initialSettings, initialCopies }: AppProps) { gameVersion={record?.gameVersion ?? null} copyName={record?.name ?? null} packUpdate={patchPack.check?.status === 'available' ? (patchPack.check.latest?.version ?? null) : null} + mapNavUpdate={mapNavPack.check?.status === 'available' && mapNavPack.check.latest + ? { version: mapNavPack.check.latest.version, installed: mapNavPack.active !== null } + : null} appUpdate={appUpdate.check?.status === 'available' ? appUpdate.check.release.version : null} onOpenUpdates={() => go({ page: 'about' })} /> + {mapNavPromptOpen && ( + { setMapNavPromptOpen(false); go({ page: 'about' }); }} + onLaunchAnyway={() => { setMapNavPromptOpen(false); startLaunch(); }} + onClose={() => setMapNavPromptOpen(false)} + /> + )} ); diff --git a/apps/launcher/src/renderer/src/i18n/locales/en.json b/apps/launcher/src/renderer/src/i18n/locales/en.json index 94a656c..c5f94c6 100644 --- a/apps/launcher/src/renderer/src/i18n/locales/en.json +++ b/apps/launcher/src/renderer/src/i18n/locales/en.json @@ -27,6 +27,8 @@ "game": "{{name}} · Game {{version}}", "notInstalled": "Not installed", "packUpdate": "Adaptation pack {{version}} available · Update ›", + "mapNavAvailable": "Map pack {{version}} available · Download ›", + "mapNavUpdate": "Map pack {{version}} available · Update ›", "appUpdate": "Launcher {{version}} available · Update ›" }, "home": { @@ -87,6 +89,14 @@ "stopping": "Stopping", "stopServer": "Close local server", "cancel": "Cancel", + "mapNavPrompt": { + "title": "Ground Map Adaptation Pack not installed", + "body": "No offline ground map adaptation pack is installed yet. Custom ground AI will still run, but will fall back to stock pathfinding. Download the map pack under About → Map Adaptation Pack to enable offline navmeshes and cover routes.", + "available": "Available pack: {{version}} ({{count}} ground maps, ~{{size}})", + "dontRemind": "Don't remind me on launch again", + "launchAnyway": "Launch without map pack", + "goDownload": "Go to Map Pack" + }, "stop": "End game", "retry": "Retry", "check": "Check", diff --git a/apps/launcher/src/renderer/src/i18n/locales/zh-CN.json b/apps/launcher/src/renderer/src/i18n/locales/zh-CN.json index 18ce4df..b2a7afc 100644 --- a/apps/launcher/src/renderer/src/i18n/locales/zh-CN.json +++ b/apps/launcher/src/renderer/src/i18n/locales/zh-CN.json @@ -27,6 +27,8 @@ "game": "{{name}} · 游戏 {{version}}", "notInstalled": "未安装", "packUpdate": "适配包 {{version}} 可用 · 更新 ›", + "mapNavAvailable": "地图包 {{version}} 可下载 · 获取 ›", + "mapNavUpdate": "地图包 {{version}} 可用 · 更新 ›", "appUpdate": "本体 {{version}} 可用 · 更新 ›" }, "home": { @@ -87,6 +89,14 @@ "stopping": "正在关闭", "stopServer": "关闭本地服务器", "cancel": "取消", + "mapNavPrompt": { + "title": "尚未安装陆战地图适配包", + "body": "当前尚未安装离线陆战地图适配包,新版陆战 AI 仍可运行,但会自动回退到原版寻路。建议先到「关于 → 地图适配包」一键下载安装,以启用离线导航网格与掩体路线。", + "available": "当前可下载版本:{{version}}({{count}} 张陆战地图,约 {{size}})", + "dontRemind": "下次启动不再提示", + "launchAnyway": "暂不下载,直接启动", + "goDownload": "前往下载地图包" + }, "stop": "结束游戏", "retry": "重试", "check": "检查", diff --git a/apps/launcher/src/renderer/src/shell/Footer.tsx b/apps/launcher/src/renderer/src/shell/Footer.tsx index a570210..e822f98 100644 --- a/apps/launcher/src/renderer/src/shell/Footer.tsx +++ b/apps/launcher/src/renderer/src/shell/Footer.tsx @@ -1,5 +1,10 @@ import { useTranslation } from 'react-i18next'; +export interface FooterMapNavOffer { + readonly version: string; + readonly installed: boolean; +} + interface FooterProps { readonly launcherVersion: string; /** The installed copy's game version; null before installation, or when it is unknown. */ @@ -7,19 +12,22 @@ interface FooterProps { readonly copyName: string | null; /** A newer adaptation pack that this launcher can use, or null. */ readonly packUpdate: string | null; + readonly mapNavUpdate: FooterMapNavOffer | null; readonly appUpdate: string | null; readonly onOpenUpdates: () => void; } /** Launcher and game versions along the bottom edge; on the right, available updates. */ -export function Footer({ launcherVersion, gameVersion, copyName, packUpdate, appUpdate, onOpenUpdates }: FooterProps) { +export function Footer({ + launcherVersion, gameVersion, copyName, packUpdate, mapNavUpdate, appUpdate, onOpenUpdates, +}: FooterProps) { const { t } = useTranslation(); return (
{t('footer.launcher', { version: launcherVersion })} | {copyName ? t('footer.game', { name: copyName, version: gameVersion ?? t('source.versionUnknown') }) : t('footer.notInstalled')} - {(appUpdate || packUpdate) && ( + {(appUpdate || packUpdate || mapNavUpdate) && (
{appUpdate && ( )} + {mapNavUpdate && ( + + )}
)}
diff --git a/apps/launcher/src/renderer/src/shell/MapNavPromptModal.tsx b/apps/launcher/src/renderer/src/shell/MapNavPromptModal.tsx new file mode 100644 index 0000000..9a6332b --- /dev/null +++ b/apps/launcher/src/renderer/src/shell/MapNavPromptModal.tsx @@ -0,0 +1,95 @@ +import { useEffect, useId, useState } from 'react'; +import { createPortal } from 'react-dom'; +import { useTranslation } from 'react-i18next'; +import type { MapNavCheck } from '@shared/schemas/map-nav-pack.ts'; +import { formatBytes } from '../format.ts'; + +type MapNavOffer = NonNullable; + +const SUPPRESS_KEY = 'wto:suppress-map-nav-launch-prompt'; + +export function isMapNavPromptSuppressed(): boolean { + try { + return window.localStorage.getItem(SUPPRESS_KEY) === '1'; + } catch { + return false; + } +} + +function saveMapNavPromptSuppressed(suppressed: boolean): void { + if (!suppressed) return; + try { + window.localStorage.setItem(SUPPRESS_KEY, '1'); + } catch { + // Ignore storage quota or privacy restrictions. + } +} + +interface MapNavPromptModalProps { + readonly latest: MapNavOffer | null; + readonly onGoDownload: () => void; + readonly onLaunchAnyway: () => void; + readonly onClose: () => void; +} + +/** Pre-launch prompt shown when no ground map navigation pack is installed. */ +export function MapNavPromptModal({ latest, onGoDownload, onLaunchAnyway, onClose }: MapNavPromptModalProps) { + const { t } = useTranslation(); + const titleId = useId(); + const [dontRemind, setDontRemind] = useState(false); + + useEffect(() => { + const onKeyDown = (event: KeyboardEvent): void => { + if (event.key === 'Escape') onClose(); + }; + window.addEventListener('keydown', onKeyDown); + return () => window.removeEventListener('keydown', onKeyDown); + }, [onClose]); + + const confirmAndRun = (action: () => void): void => { + saveMapNavPromptSuppressed(dontRemind); + action(); + }; + + return createPortal( +
{ + if (event.target === event.currentTarget) onClose(); + }} + > +
+
+

{t('launch.mapNavPrompt.title')}

+ +
+
+

{t('launch.mapNavPrompt.body')}

+ {latest && ( +

+ {t('launch.mapNavPrompt.available', { + version: latest.version, + count: latest.mapCount, + size: formatBytes(latest.size), + })} +

+ )} + +
+ +
+
, + document.body, + ); +} diff --git a/apps/launcher/src/renderer/src/styles/controls.css b/apps/launcher/src/renderer/src/styles/controls.css index 1137e72..0ef9798 100644 --- a/apps/launcher/src/renderer/src/styles/controls.css +++ b/apps/launcher/src/renderer/src/styles/controls.css @@ -511,6 +511,15 @@ box-shadow: 0 18px 48px rgba(0, 0, 0, 0.65); } +.modal-dialog-compact { + width: min(520px, 100%); +} + +.modal-body-stack p { + margin: 0 0 10px; + line-height: 1.6; +} + .modal-head { display: flex; align-items: center;