fix(launcher): enable standard game launch
Remove the development gate from the launcher and keep the guarded development handoff available. Verified by type checking, Windows packaging, and opening the packaged launcher with a temporary profile.
This commit is contained in:
1 parent
746b74c564
commit
b3a30c0fd9
10 files changed
+8
-26
No files matched your search
@@ -3,7 +3,6 @@ import { join } from 'node:path';
|
||||
import { promisify } from 'node:util';
|
||||
import { GAME_FILES } from '@wto/patcher';
|
||||
import { AppError } from '@shared/errors.ts';
|
||||
import { ORDINARY_LAUNCH_ENABLED } from '@shared/schemas/launch.ts';
|
||||
|
||||
const execute = promisify(execFile);
|
||||
const OFFLINE_ARGUMENTS = ['-forcestart', '-nobeac', '-crashpad-disable-upload'];
|
||||
@@ -17,7 +16,6 @@ export async function gameProcessRunning(signal: AbortSignal): Promise<boolean>
|
||||
export async function runGameProcess(
|
||||
copyPath: string, additionalArguments: readonly string[], signal: AbortSignal, onStart: () => void,
|
||||
): Promise<void> {
|
||||
if (!ORDINARY_LAUNCH_ENABLED || process.platform !== 'win32') throw new AppError('launch_disabled');
|
||||
if (await gameProcessRunning(signal)) throw new AppError('launch_game_running');
|
||||
signal.throwIfAborted();
|
||||
const child = spawn(join(copyPath, GAME_FILES.executable), [...OFFLINE_ARGUMENTS, ...additionalArguments], {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { app, BrowserWindow, shell } from 'electron';
|
||||
import { AccountStore, LOOPBACK } from '@wto/server';
|
||||
import { executableVersion, GAME_FILES, isInSteamLibrary } from '@wto/patcher';
|
||||
import { AppError } from '@shared/errors.ts';
|
||||
import { ORDINARY_LAUNCH_ENABLED, type LaunchState } from '@shared/schemas/launch.ts';
|
||||
import type { LaunchState } from '@shared/schemas/launch.ts';
|
||||
import { getSettings } from '../config/settings-store.ts';
|
||||
import { decalCachePath } from '../install/decals.ts';
|
||||
import { copyPathContains, readInstallRecord } from '../install/install-record.ts';
|
||||
@@ -99,14 +99,12 @@ function update(job: LaunchJob, next: LaunchState): void {
|
||||
}
|
||||
|
||||
async function launch(job: LaunchJob): Promise<void> {
|
||||
if (process.platform !== 'win32') throw new AppError('launch_platform_unsupported');
|
||||
const signal = job.stop.signal;
|
||||
const [record, settings] = await Promise.all([readInstallRecord(), getSettings()]);
|
||||
if (!record) throw new AppError('launch_no_copy');
|
||||
job.copyId = record.id;
|
||||
const useLab = !app.isPackaged && settings.developerMode;
|
||||
if (!useLab && !ORDINARY_LAUNCH_ENABLED) {
|
||||
throw new AppError(app.isPackaged ? 'launch_disabled' : 'launch_lab_required');
|
||||
}
|
||||
if (isInSteamLibrary(record.copyPath)) throw new AppError('launch_copy_in_steam');
|
||||
const currentVersion = await readVersion(record.copyPath, signal);
|
||||
if (!currentVersion || currentVersion !== record.gameVersion) {
|
||||
|
||||
@@ -3,7 +3,6 @@ import { isAbsolute, join, relative } from 'node:path';
|
||||
import { GAME_FILES, isInSteamLibrary } from '@wto/patcher';
|
||||
import { AppError } from '@shared/errors.ts';
|
||||
import { parseLaunchArguments } from '@shared/launch-arguments.ts';
|
||||
import { ORDINARY_LAUNCH_ENABLED } from '@shared/schemas/launch.ts';
|
||||
import type { InstallRecord } from '@shared/schemas/install.ts';
|
||||
import type { Settings } from '@shared/schemas/settings.ts';
|
||||
import { canonicalCopyPath, copyPathContains } from '../install/install-record.ts';
|
||||
@@ -35,7 +34,6 @@ export async function runOrdinaryLaunch(
|
||||
copyPath: string, dataPath: string, port: number, settings: Settings, signal: AbortSignal,
|
||||
publish: (phase: OrdinaryPhase) => void,
|
||||
): Promise<void> {
|
||||
if (!ORDINARY_LAUNCH_ENABLED) throw new AppError('launch_disabled');
|
||||
const args = parseLaunchArguments(settings.launchArguments);
|
||||
if (!args) throw new AppError('launch_game_failed');
|
||||
publish('starting-server');
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useEffect, useState, type ReactNode } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import type { IpcOutput } from '@shared/ipc/contract.ts';
|
||||
import type { Copies } from '@shared/schemas/install.ts';
|
||||
import { ORDINARY_LAUNCH_ENABLED, type LaunchState } from '@shared/schemas/launch.ts';
|
||||
import type { LaunchState } from '@shared/schemas/launch.ts';
|
||||
import type { Settings } from '@shared/schemas/settings.ts';
|
||||
import { Sheet } from './components/Sheet.tsx';
|
||||
import { applyLanguage, resolveLanguage } from './i18n/index.ts';
|
||||
@@ -98,7 +98,6 @@ export function App({ info, initialSettings, initialCopies }: AppProps) {
|
||||
const perCopyStatus = ['version-changed', 'failed', 'port-busy', 'server-exited'].includes(launch.phase);
|
||||
const launchStatus: LaunchState = perCopyStatus && launch.copyId && launch.copyId !== record?.id ? { phase: 'ready' } : launch;
|
||||
const home = homeBar(record, launchStatus, t, wizard.start, {
|
||||
canStart: ORDINARY_LAUNCH_ENABLED || (info.development && settings.developerMode),
|
||||
start: () => { ipcInvoke('launch:start').catch(report); },
|
||||
stop: () => { ipcInvoke('launch:stop').catch(report); },
|
||||
checkVersion: () => go({ page: 'copies', section: 'features' }),
|
||||
|
||||
@@ -644,7 +644,7 @@
|
||||
"launch_no_copy": "A game copy must be installed before launching.",
|
||||
"launch_busy": "A launch is already in progress.",
|
||||
"launch_failed": "Launch failed. See the launcher log.",
|
||||
"launch_disabled": "Standard launch is pending isolation verification.",
|
||||
"launch_platform_unsupported": "Game launch requires Windows.",
|
||||
"launch_lab_required": "Enable developer mode to launch through the isolated lab.",
|
||||
"launch_lab_missing": "The isolated lab automation could not be loaded.",
|
||||
"launch_lab_version": "The lab copy and the stock backup must use the same game version.",
|
||||
|
||||
@@ -644,7 +644,7 @@
|
||||
"launch_no_copy": "启动前需要安装游戏副本。",
|
||||
"launch_busy": "启动流程正在运行。",
|
||||
"launch_failed": "启动失败。请查看启动器日志。",
|
||||
"launch_disabled": "普通启动待隔离验收。",
|
||||
"launch_platform_unsupported": "启动游戏需要 Windows。",
|
||||
"launch_lab_required": "请启用开发模式以通过隔离实验副本启动。",
|
||||
"launch_lab_missing": "无法读取隔离实验自动化配置。",
|
||||
"launch_lab_version": "实验副本和原版文件备份必须使用同一游戏版本。",
|
||||
|
||||
@@ -5,7 +5,6 @@ import type { BarModel } from '../../shell/bar-model.ts';
|
||||
import { missingFeatures } from '../copies/missing-features.ts';
|
||||
|
||||
interface LaunchActions {
|
||||
readonly canStart: boolean;
|
||||
readonly start: () => void;
|
||||
readonly stop: () => void;
|
||||
readonly checkVersion: () => void;
|
||||
@@ -19,8 +18,8 @@ export function homeBar(
|
||||
onInstall: () => void,
|
||||
actions: LaunchActions,
|
||||
): BarModel {
|
||||
const launch = { label: t('bar.launch'), onClick: actions.start, disabled: !actions.canStart };
|
||||
const retry = { label: t('launch.retry'), onClick: actions.start, disabled: !actions.canStart };
|
||||
const launch = { label: t('bar.launch'), onClick: actions.start };
|
||||
const retry = { label: t('launch.retry'), onClick: actions.start };
|
||||
const starting = { label: t('launch.starting'), disabled: true };
|
||||
const progress = { value: state.filesWritten ?? 0, max: state.filesTotal || null };
|
||||
switch (state.phase) {
|
||||
@@ -85,9 +84,6 @@ export function homeBar(
|
||||
primary: { label: t('bar.install'), onClick: onInstall },
|
||||
};
|
||||
}
|
||||
if (!actions.canStart) {
|
||||
return { tone: 'warn', title: t('errors.launch_disabled'), primary: launch };
|
||||
}
|
||||
const missing = missingFeatures(record).length;
|
||||
return {
|
||||
tone: missing ? 'warn' : 'ok',
|
||||
|
||||
@@ -2,7 +2,6 @@ import { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import type { IpcOutput } from '@shared/ipc/contract.ts';
|
||||
import { parseLaunchArguments } from '@shared/launch-arguments.ts';
|
||||
import { ORDINARY_LAUNCH_ENABLED } from '@shared/schemas/launch.ts';
|
||||
import { LAUNCH_ARGUMENTS_LIMIT, type Settings, type SettingsPatch } from '@shared/schemas/settings.ts';
|
||||
import { Row } from '../../components/Row.tsx';
|
||||
import { Sheet } from '../../components/Sheet.tsx';
|
||||
@@ -37,9 +36,6 @@ export function LaunchSettings({ settings, development, onError }: LaunchSetting
|
||||
</Sheet>
|
||||
);
|
||||
}
|
||||
if (!ORDINARY_LAUNCH_ENABLED) {
|
||||
return <Sheet title={title}><p className="lead">{t('errors.launch_disabled')}</p></Sheet>;
|
||||
}
|
||||
|
||||
return (
|
||||
<Sheet title={title}>
|
||||
|
||||
@@ -49,7 +49,7 @@ export const APP_ERROR_CODES = [
|
||||
'launch_no_copy',
|
||||
'launch_busy',
|
||||
'launch_failed',
|
||||
'launch_disabled',
|
||||
'launch_platform_unsupported',
|
||||
'launch_lab_required',
|
||||
'launch_lab_missing',
|
||||
'launch_lab_version',
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { z } from 'zod';
|
||||
import { APP_ERROR_CODES } from '../errors.ts';
|
||||
|
||||
// Enable only after isolation has been verified and the maintainer approves the change.
|
||||
export const ORDINARY_LAUNCH_ENABLED = false;
|
||||
|
||||
export const LaunchStateSchema = z.object({
|
||||
phase: z.enum([
|
||||
'ready', 'checking', 'building', 'starting-server', 'starting-game', 'running',
|
||||
|
||||
Reference in new issue
Block a user