Files
WT-Offline/mod-dev-docs/README.md
T

60 lines
6.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# WTOffline 模组开发文档 / Mod Development Documentation
简体中文 · [English](#english)
> **实验期声明(API `0.1-experimental`)**
> WTOffline 当前处于极初期开发阶段。服务端脚本接口、内部数据结构、钩子契约及声明式 `exe` 补丁格式均可能随本体开发随时调整,**现阶段不承诺向后兼容**。模组作者使用服务端脚本或客户端二进制补丁时,请做好跟随本体更新维护的准备。
---
## 中文文档目录(`zh-CN/`)
| 章节 | 内容概览 |
| --- | --- |
| [01 · 快速入门与清单规范](zh-CN/01-quick-start.md) | 叠加架构、原版数据解包与查阅指南、5 分钟做出第一个模组、标准目录结构、`mod.jsonc` 全字段表、叠加能力徽标与依赖排序 |
| [02 · 客户端数据包与 BLK 增量补丁](zh-CN/02-client-packs-and-blk.md) | BLK 与 JSON 差异对照、8 个可叠加数据包、Dagor 原生 `*.blk.patch.blk` 与 `include` 编译语法、JSONC 兼容格式、13 种 BLK 类型、分房权重(BR ↔ `mrank`)速查表、`shop.blk` 与 `units.csv` 详解、从零克隆独立新坦克完整实战 |
| [03 · 添加全新 3D 模型与贴图载具](zh-CN/03-custom-3d-vehicles.md) | `.grp`/`.dxp.bin`/`.ddsx` 与跨盘 NTFS Junction 通俗说明、新车 6 步接入清单、`gift` 礼包机制与 AI 机器人池准入规则、配套外置资源边界 |
| [04 · 客户端 GUI 补丁与声明式 EXE 补丁](zh-CN/04-client-gui-and-exe.md) | DaGui 三件套(`.tpl`/`.css`/`.nut`)与 `gui/css.css` 注册规则、全小写精确路径与 `variants` 唯一命中机制、`sq.exe` 编译与完整字节码校验、声明式 `exe` 补丁与核心隔离锁 |
| [05 · 服务端零代码数值叠加(Tuning)](zh-CN/05-server-tuning.md) | 多层合并优先级(含启动器玩家覆盖说明)、12 份 `server/tuning/*.jsonc` 一览、`store.jsonc` 等核心字段速查与 `$listOps` 增量语法 |
| [06 · 服务端 JS/TS 脚本完整接口手册](zh-CN/06-server-scripting-api.md) | Node 24 可擦除 TS 语法对照与 VS Code 类型补全、`WtoServerModContext`、独立存档区、生命周期与对局钩子精确结构、`matchingApiFunc` 签名与三大路由对比、`official-map-selector` 全栈拆解 |
| [07 · 排错、日志与最佳实践](zh-CN/07-troubleshooting-and-faq.md) | 日志定位、常见报错速查表、开发调试热重载循环、`.zip` 打包发布规范、跨盘与非 NTFS 磁盘行为、开发与发布建议 |
### 自带官方模组模板(`templates/`)
以下 3 个模组会随 WTOffline 启动器自动分发到玩家首次初始化的全局 `mods/` 目录(默认关闭,勾选即用),可直接打开阅读源码或复制改造:
| 模板目录 | 定位 | 演示的核心能力 |
| --- | --- | --- |
| `templates/example-vehicle-tweak/` | 零代码数据与本地化示例 | `server/tuning/battle.jsonc` + `wpcost.blk.patch.jsonc` + `lang/units.csv.patch.csv` |
| `templates/example-server-script/` | 服务端脚本最小示例 | `server/index.ts`、`onDatasetsLoaded`、`profile.onRefresh`、独立存档区、自定义 `/mods/<id>/status` 路由 |
| `templates/official-map-selector/` | 实用全栈官方模组 | 模式选择 UI 按钮补丁 + `gui/css.css` 样式注册 + 原生 DaGui 小地图网格弹窗 + 多语言词条 + 自定义匹配 RPC + 独立存档 + `battle.onFilterMissions` 白/黑名单选图 |
---
<a id="english"></a>
## English Documentation (`en/`)
> **Experimental Notice (API `0.1-experimental`)**
> WTOffline is in early development. Server script APIs, internal data structures, hook contracts, and declarative `exe` patch formats may change without backwards compatibility across releases. Authors using server scripts or binary patches should be ready to update alongside core releases.
| Chapter | Topics |
| --- | --- |
| [01 · Quick Start & Manifest](en/01-quick-start.md) | Additive architecture, how to unpack & inspect stock game files, build your first mod in 5 minutes, folder layout, full `mod.jsonc` schema, additive capability badges & load-order rules |
| [02 · Client Packs & BLK Patching](en/02-client-packs-and-blk.md) | BLK vs JSON side-by-side intro, 8 overlayable `.vromfs.bin` packs, Dagor-style `*.blk.patch.blk` & `include` compiler, legacy JSONC format, all 13 BLK types, BR ↔ `mrank` conversion table, `shop.blk` & `units.csv` anatomy, end-to-end standalone tank clone walkthrough |
| [03 · Custom 3D Vehicle Models](en/03-custom-3d-vehicles.md) | Plain-language `.grp`/`.dxp.bin`/`.ddsx` & cross-drive NTFS Junction guide, 6-step custom 3D vehicle checklist, `gift` store packs & AI bot pool rules, companion files boundary |
| [04 · Client GUI & Declarative EXE Patches](en/04-client-gui-and-exe.md) | DaGui triad (`.tpl`/`.css`/`.nut`) & `gui/css.css` `@import` rule, lowercase case-sensitive paths & single-match `variants`, building & running `sq.exe` bytecode checks, declarative `exe` patches & core isolation lock |
| [05 · Server Code-Free Tuning Overlays](en/05-server-tuning.md) | Multi-layer precedence (including Launcher Tuning tab overrides), all 12 `server/tuning/*.jsonc` files, verified field quick-reference (`store.jsonc`, `battle.jsonc`, etc.), and `$listOps` rules |
| [06 · Server JS/TS Scripting API Reference](en/06-server-scripting-api.md) | Node 24 erasable TS Do/Don't & VS Code autocomplete setup, `WtoServerModContext`, isolated `storage`, exact battle hook payloads, `matchingApiFunc` signature & route comparison, `official-map-selector` full-stack case study |
| [07 · Troubleshooting & FAQ](en/07-troubleshooting-and-faq.md) | Reading logs, troubleshooting lookup table, development reload loop, `.zip` packaging & distribution rules, cross-drive/exFAT fallback behavior, and practical recommendations |
### Official Bundled Mod Templates (`templates/`)
The launcher automatically seeds these 3 ready-to-read official templates into the global `mods/` folder on first initialization (disabled by default—enable to try, or copy to start your own mod):
| Template Folder | Scope | Demonstrated Capabilities |
| --- | --- | --- |
| `templates/example-vehicle-tweak/` | Code-free data & localization | `server/tuning/battle.jsonc` + `wpcost.blk.patch.jsonc` + `lang/units.csv.patch.csv` |
| `templates/example-server-script/` | Minimal server TypeScript mod | `server/index.ts`, `onDatasetsLoaded`, `profile.onRefresh`, isolated per-player storage, custom `/mods/<id>/status` HTTP route |
| `templates/official-map-selector/` | Full-stack official mod | Mode-select UI button patch + `gui/css.css` stylesheet registration + standalone native DaGui map-grid modal + localized labels + custom matching RPC + isolated storage + `battle.onFilterMissions` whitelist/blacklist filtering |