Fix store.jsonc vehiclePacks nesting and gjn field name, matchingApiFunc callback argument order, and DaGui CSS @import/lowercase rules; add stock archive inspection steps, BR-to-mrank table, cloned vehicle walkthrough, tuning field reference, and official-map-selector full-stack trace while bringing en/01..07.md to full 1:1 parity with zh-CN/.
11 KiB
04 · Client GUI Patches & Declarative EXE Patches
Experimental Notice: GUI script patches (
gui-patches) and declarativeexepatches (exe-patches) depend directly on target client code layout and may require maintenance when the game or core offline patches update.
1. Plain-Language Intro: War Thunder's DaGui UI Triad (.tpl + .css + .nut)
War Thunder's hangar and lobby screens are powered by Dagor's native DaGui framework (packaged inside gui.vromfs.bin). Every screen or modal window combines three plain-text file types:
| Extension | Role | Plain-Language Explanation |
|---|---|---|
.tpl |
Handyman Layout Template | Similar to HTML + Mustache (e.g. gui/missions/wtomapselectormodal.tpl); declares UI containers, buttons, element ids, and data-binding tags (<<wndTitle>>, {{#cards}}...{{/cards}}). |
.css |
DaGui Stylesheet | Controls widths, heights, margins, colors, fonts, and custom attribute state selectors (such as [wtoSelected=yes]). |
.nut |
Quirrel UI Script | War Thunder's statically-scoped scripting language (derived from Squirrel); subclasses BaseGuiHandlerWT to render .tpl views, handle button clicks, and call local server RPCs. |
Best-Practice UI Pattern: "Standalone Files for Logic + Minimal Patch for Entry Hook"
Just like the bundled templates/official-map-selector mod, the cleanest way to add new UI is:
- Place your new standalone
.nut,.tpl, and.cssfiles underclient/packs/gui.vromfs.bin/: standalone files have zero collision risk with other mods and survive game updates cleanly; - Use minimal
client/gui-patches/edits on stock files: wire a button into an existing screen and register your stylesheet ingui/css.css!
Critical Rule: Standalone
.cssFiles Are NOT Auto-Loaded by DaGui! Droppinggui/missions/wtomapselector.cssintoclient/packs/gui.vromfs.bin/alone has no effect! DaGui loads stylesheets solely through the root manifestgui/css.css, so you must also patchgui/css.cssviaclient/gui-patches/to append@import "missions\wtomapselector.css"(note: paths insidegui/css.cssare relative togui/, use backslashes\, and have no trailing semicolon—see the real example in Section 2.2 below).
2. client/gui-patches/ Format & Matching Rules
client/gui-patches/ is not limited to .nut files—it works identically on .nut scripts, .tpl templates, and .css stylesheets inside gui.vromfs.bin! Each patch lives in a folder containing patch.jsonc (nested subdirectories are supported):
client/gui-patches/
└─ mode-select-map-selector-button/
├─ css/
│ ├─ patch.jsonc
│ ├─ find-css.css
│ └─ replace-css.css
├─ tpl/
│ ├─ patch.jsonc
│ ├─ find-nav-right.tpl
│ └─ replace-nav-right.tpl
└─ script/
├─ patch.jsonc
├─ find-imports.nut
├─ replace-imports.nut
├─ find-buttons.nut
└─ replace-buttons.nut
2.1 .nut Script Patch Example
// Adds a custom entry button to the mode selection panel.
{
"id": "my-mod/add-button",
"title": "Add custom button to mode selector",
"features": [],
"variants": [
{
"written_for": "2.61.0.58",
"file": "scripts/gamemodes/gamemodeselect.nut",
"edits": [
{
"find": "find-imports.nut",
"replace": "replace-imports.nut"
},
{
"find": "find-buttons.nut",
"replace": "replace-buttons.nut"
}
]
}
]
}
2.2 Real Example: Registering a Standalone .css in gui/css.css
// client/gui-patches/my-style/patch.jsonc
{
"id": "my-mod/register-css",
"title": "Include custom stylesheet in gui/css.css",
"features": [],
"variants": [
{
"written_for": "2.61.0.58",
"file": "gui/css.css",
"edits": [
{
"find": "find-css.css",
"replace": "replace-css.css"
}
]
}
]
}
find-css.css:
@import "missions\mapPreferences.css"
replace-css.css:
@import "missions\mapPreferences.css"
@import "missions\wtomapselector.css"
2.3 Four Critical Path & Variant Rules (Must-Read)
variant.fileMust Be All Lowercase & Exact Case-Sensitive! Every file path inside stockgui.vromfs.binis all lowercase (e.g.scripts/gamemodes/gamemodeselect.nut,gui/gamemodeselect/gamemodeselect.tpl,gui/css.css). Even though Quirrelfrom "%scripts/gameModes/..."imports are case-insensitive at runtime, thegui-patchesbuilder looks upvariant.filein the archive map via exact case-sensitive string match—writing camelCase likescripts/gameModes/gameModeSelect.nutfails immediately withthe data pack has no script ...! Keep added files underclient/packs/gui.vromfs.bin/all lowercase as well.- Every
findSnippet Must Match Exactly Once: Eachedit'sfindtext must occur uniquely once in the target file (\r\nvs\nline endings are normalized automatically). If it occurs 0 times or ≥2 times, the entire patch is skipped safely and logged tolauncher.logwithout half-applying edits. - How
variantsandwritten_forActually Work:written_foris purely an informational version label for logs and diagnostics. At build time, the builder tests all entries invariantsagainst the client archive and requires an exact single match (1matching variant applies;0matches skips safely as a build mismatch;≥2simultaneous matches rejects the patch as an ambiguous variant definition). {{LOCAL_ENDPOINT}}Placeholder: Any occurrence of{{LOCAL_ENDPOINT}}inreplacetext is automatically expanded to the client's bound local server127.0.0.1:<port>(for examplehttp://{{LOCAL_ENDPOINT}}/mods/demo.my-mod/panelfor embedded browser pages). Core offline GUI patches always run first; modgui-patchesrun afterward in load order.
3. Mandatory Check: Building sq.exe & Full Quirrel Bytecode Verification
War Thunder pre-compiles Quirrel UI scripts during login. Any of the following mistakes in a .nut file will cause the client to hang indefinitely on the "Loading" screen:
- Lexical scope name collisions: declaring a
let/localvariable that shadows a symbol imported viafrom "..." import *at the top of the file; - Forward references to undeclared functions or accidental use of Quirrel reserved words (such as
base); - JS-style backtick strings (
`...`): unsupported by War Thunder's Quirrel VM—always use Quirrel's native string interpolation$"hello {name}"instead!
Note: sq.exe --syntax-check runs AST parsing only and misses lexical collisions and undeclared identifiers—you must invoke compilestring(...) so the full bytecode generator runs!
3.1 How External Modders Build a Matching sq.exe
Clone Gaijin's open-source GaijinEntertainment/quirrel repository, check out commit 19f17df9b6ee43c91ef5c635fd45970ec76c5dbe (matching 2.61 clients), and build sq with CMake + Visual Studio (C++17):
git clone https://github.com/GaijinEntertainment/quirrel.git quirrel-src
git -C quirrel-src checkout 19f17df9b6ee43c91ef5c635fd45970ec76c5dbe
cmake -S quirrel-src -B quirrel-build
cmake --build quirrel-build --config Release --target sq
# Output binary: quirrel-build\bin\Release\sq.exe
3.2 Run compilestring on a Complete .nut File (Not a Partial Snippet)
Note
: Pass a complete
.nutfile tocompilestringrather than an isolatedreplace.nutfragment.replace.nutis only an in-place snippet and will fail out of context. Always runcompilestringagainst a complete.nutfile—either your standalone.nutscript, or the full stock.nutfile after applying yourfind/replaceedits:
- If you cloned the WTOffline repo:
tools/src/wtotools/gui_check.pyautomatically resolvesgui.vromfs.binmodule exports, applies yourgui-patches, and runscompilestringwith stub bindings across every touched file; - Standalone full-file check example (pass a bindings table as the 3rd argument to
compilestringif your file uses top-levelfrom "..." import ...bindings):
& "quirrel-build\bin\Release\sq.exe" -e "let io = require('io'); let f = io.file('your_complete_script.nut', 'rb'); let src = f.readblob(f.len()).as_string(); f.close(); compilestring(src, 'your_complete_script.nut'); print('OK\n')"
4. Declarative EXE Patches (client/exe-patches/)
Advanced mods can reuse WTOffline's @wto/exepatch engine to apply signature-located binary patches to win64/aces.exe. Use declarative patch files instead of packaging or distributing modified aces.exe binaries.
client/exe-patches/
└─ my-tweak/
└─ patch.jsonc
Example patch.jsonc:
// Brief description of what this binary patch changes.
// Why the local server cannot do this alone.
// What happens if this patch is skipped.
{
"id": "my-tweak",
"title": "Example declarative exe patch",
"features": [],
"requires": [],
"variants": [
{
"written_for": "2.61.0.58",
"locate": {
"kind": "signature",
"pattern": "48 8B ?? ?? ?? ?? ?? 84 C0 74 ??",
"captures": []
},
"edit": {
"offset": 9,
"asm": "nop; nop",
"bytes": "90 90",
"expect_original": "74 ??",
"fixups": []
}
}
]
}
Supported Locators (locate.kind)
signature: byte pattern scan supporting??wildcards andcapturesfor displacements / relative branch targets;string_ref: locates code referencing a fixed ASCII string literal, with optional local instruction verification;within: searches inside the PE.pdatafunction boundaries of a required patch or anchor site.
Core Isolation Protection & Conflict Handling
- Core offline & isolation patches are always planned first and their byte ranges are locked (covering Gaijin network block, anti-cheat bypass in offline copy, save/registry isolation, launcher suppression, and local TLS/matching keys);
- Any mod
exepatch overlapping even 1 byte of a core patch is hard-rejected withoverlaps protected core patchinlauncher.log; - If two mods'
exepatches write to overlapping byte ranges, the later mod's patch is rejected with the conflicting mod ID; - If a signature or
expect_originalcheck fails on a newer game version, that mod patch is skipped cleanly and logged tolauncher.logwithout breaking the offline copy build.