An integrated VS Code extension and schema indexer providing IntelliSense (autocompletion, hover documentation, and diagnostics) for Mount & Blade II: Bannerlord GauntletUI prefab XML files.
This repository is split into three main components:
- Schema Indexer (C# Console App): Reflects over Bannerlord
.NETassemblies usingSystem.Reflection.MetadataLoadContextand parses game UI resources to generate a unifiedgauntlet-schema.jsondatabase. - TpacTool Submodule (C# Library): Linked as a Git submodule pointing to a custom fork. It decompresses BC7/DXT5 sheets and performs on-the-fly cropping.
- VS Code Extension (TypeScript): The LSP client and server that consumes the generated schema to provide rich editor features without hijacking non-GauntletUI XML files.
graph TD
GameBin[Bannerlord bin folder] -->|C# MetadataLoadContext| Indexer[Schema Indexer]
GameRes[Bannerlord GUI resources] -->|XML parsing| Indexer
Indexer -->|Emits| Schema[gauntlet-schema.json]
Schema -->|Bundled or workspace fallback| LSP[LSP Server]
Workspace[Workspace XML Prefabs] -->|Indexed on load/change| LSP
LSP -->|IntelliSense / Hover / Diagnostics| VSCode[VS Code client]
LSP -->|Spawn extract-sheet| Tpac[TpacTool Submodule]
Tpac -->|Decompress & Crop on-the-fly| Cache[.gauntletui-cache/]
Cache -->|Resolved via baseUri| VSCode
- Live Sprite Hover Previews: Hovering over any
Spriteattribute resolves the sprite's category and sheet (traversinggauntlet_ui.tpac,core_game.tpac, etc. lazily). It decompresses the BC7/DXT5 texture and crops the sprite on-the-fly in C#, displaying a live preview image in the hover tooltip. - Document Color Decorators & Picker: Shows inline color squares next to hex colors in the editor. Intercepts VS Code's built-in color picker to format selected colors directly into GauntletUI-compliant hex formats (
#RRGGBBAAand#RRGGBB). - Attached Layout & Brush Properties: Full autocomplete, type information, and enum completions for dot-nested attached properties (e.g.
StackLayout.LayoutMethod,Brush.FontSize). - Local Constant (
!) & Parameter (*) Autocomplete: Typing!or*dynamically scans the active XML document for defined<Constant>and<Parameter>elements, providing instant name autocomplete. - VisualState Target Property Autocomplete: When animating widget properties inside
<VisualState>, the LSP automatically resolves the target widget, suggesting its animatable properties and their enum values. - Tag Completion: Lists all native Widget tags (e.g.
ListPanel,TextWidget) plus custom workspace prefab filenames as custom tags. - Attribute & Value Completion: Offers widget attributes with specific value hints (enums, boolean, brushes, sprites).
- Context-aware Filtering: Filters tags contextually (e.g. only suggests
<Constant>inside<Constants>). - Smart Language Activation: Only activates on GauntletUI prefabs (inspecting root
<Prefab>and<Window>tags) to prevent hijacking unrelated XML files (likepom.xmlor Android layouts).
The schema indexer resides in /schema-indexer. It reflects over the game's assemblies to extract widgets, properties, and ViewModels, and parses XML files to extract brushes and sprites.
- No game binaries are committed: Assemblies reside in a local, untracked
refs/directory or are fetched from the local game path. - No assembly execution: Uses
MetadataLoadContextso it doesn't try to load native engines or execute game code.
Run the indexer from the command line:
dotnet run --project schema-indexer/schema-indexer.csproj -- --game-bin-path "C:\Path\To\Bannerlord\bin\Win64_Shipping_Client" --resource-path "C:\Path\To\Bannerlord\Modules" --output "gauntlet-schema.json"The extension lives in /vscode-extension. It implements the Language Server Protocol (LSP) to provide completion, hover, and diagnostics.
- Clone the repository and initialize submodules:
git clone --recursive <repo-url> cd GauntletUI-LSP
- Install dependencies:
cd vscode-extension npm install - Build the extension:
npm run build
- To package into an installable
.vsix:npm run package
Configure the following settings in your VS Code settings.json:
gauntletui.gamePath: Path to the game directory (containsbinandModules).gauntletui.schemaPath: Custom location forgauntlet-schema.json. Defaults to workspace root.gauntletui.fileGlob: Glob pattern for prefab activation (defaults to**/GUI/**/*.xml).gauntletui.viewModelMapping: Map prefab names to ViewModels for accurate binding autocompletion.gauntletui.diagnosticsEnabled: Toggle diagnostics warnings (defaults totrue).
MIT