docs(mods): add standalone mod-dev-docs handbook and launcher quick-open button
This commit is contained in:
1 parent
5983e3f3e2
commit
aa952e7cca
26 files changed
+1619
-145
No files matched your search
@@ -118,6 +118,20 @@ export async function openModsFolder(): Promise<void> {
|
||||
if (failure) console.warn('[mods] opening the mods folder failed:', modsDir, failure);
|
||||
}
|
||||
|
||||
export async function openModDocs(language?: string): Promise<void> {
|
||||
const docsRoot = resourcePaths().modDocs;
|
||||
const preferred = language && language.toLowerCase().startsWith('zh') ? 'zh-CN.html' : 'en.html';
|
||||
const fallback = preferred === 'zh-CN.html' ? 'en.html' : 'zh-CN.html';
|
||||
const target = (await pathExists(join(docsRoot, preferred)))
|
||||
? join(docsRoot, preferred)
|
||||
: join(docsRoot, fallback);
|
||||
if (!(await pathExists(target))) {
|
||||
throw new AppError('folder_unreadable', { path: docsRoot });
|
||||
}
|
||||
const failure = await shell.openPath(target);
|
||||
if (failure) console.warn('[mods] opening the mod docs failed:', target, failure);
|
||||
}
|
||||
|
||||
export async function getModsState(copyId: string): Promise<ModsStateView> {
|
||||
const copy = await requireCopy(copyId);
|
||||
return buildModsStateView(copy);
|
||||
|
||||
@@ -19,6 +19,8 @@ export interface ResourcePaths {
|
||||
readonly appIcon: string;
|
||||
/** Bundled example mod templates seeded into an empty mods folder on first use. */
|
||||
readonly modTemplates: string;
|
||||
/** Offline HTML mod development handbook (zh-CN.html and en.html). */
|
||||
readonly modDocs: string;
|
||||
}
|
||||
|
||||
export function resourcePaths(): ResourcePaths {
|
||||
@@ -35,6 +37,7 @@ export function bundledResourcePaths(): ResourcePaths {
|
||||
networkHookLibrary: join(process.resourcesPath, 'native', 'wto_ws.dll'),
|
||||
appIcon: join(process.resourcesPath, 'icon.ico'),
|
||||
modTemplates: join(process.resourcesPath, 'mod-templates'),
|
||||
modDocs: join(process.resourcesPath, 'mod-dev-docs'),
|
||||
};
|
||||
}
|
||||
// The app path is apps/launcher; the repository is two levels up.
|
||||
@@ -44,6 +47,7 @@ export function bundledResourcePaths(): ResourcePaths {
|
||||
networkHookLibrary: join(repository, 'build', 'native', 'wto_ws.dll'),
|
||||
appIcon: join(repository, 'apps', 'launcher', 'resources', 'icon.ico'),
|
||||
modTemplates: join(repository, 'dev-docs', 'templates', 'mods'),
|
||||
modDocs: join(repository, 'build', 'mod-dev-docs'),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user