Mainframe Engine Extension
VS Code tools for Mainframe engine projects. See your game UI and scenes exactly as the engine draws them, without leaving the editor, and make Mainframe's own files easy to spot and read.
Features at a glance
| Feature |
What you get |
| Engine preview |
The real engine renders a scene (with your RmlUi HUD on top) and the frame appears next to your code. Pixel-exact: same renderer, shaders, fonts and scene logic as the game. |
| Draft preview |
An instant HTML approximation of an .rml document that updates as you type, laid out at your game's resolution. |
| Play and Debug |
▶ Play and 🐞 Debug buttons at the top of every editor build the game and start it. Debug runs it under the C# debugger: breakpoints, stepping and variables work in the game's and the engine's .cs files. Pressing again restarts the game. With a .mfscene open, a green ▶ button plays that scene. |
| Scene preview |
Open any .mfscene and render it through the engine. |
| File icons |
Distinct icons for .rml, .rcss, .mfscene, .mfres and .mfproj (vscode-icons theme). |
| Syntax highlighting |
.mfscene, .mfres and .mfproj get JSON highlighting, folding, formatting and bracket matching. |
Engine preview
The Engine view runs your game for a moment and captures one frame:
dotnet run --project <launcher.csproj> -- --scene <scene> --screenshot <frame.png> --hidden --max-frames 30 --no-log-file
- Exact. It is the engine itself: real RmlUi layout, real scene, real post-processing. What you see is what ships.
- Automatic. Re-renders whenever a file in the project changes, whether saved in VS Code (every typing pause with auto save) or edited by another tool. Build output (
bin/, obj/, .mainframe/) is ignored, so a render never triggers itself.
- Fast enough to keep open. About 3–6 seconds per frame on a typical project, including the incremental build.
- Safe. One render per project at a time, so two previews never fight over the same build. A newer change cancels the render in progress, and a render that hangs is stopped after 60 seconds.
- Clear errors. A failed build or a missing .NET SDK shows the last lines of output in the preview.
Which scene is behind my HUD?
UI documents are often attached to scenes in code, so the extension guesses and lets you choose:
- A scene whose name has the same number as the document (
hud2.rml → shot2.mfscene).
- Otherwise the project's
mainScene from project.mfproj.
- Choose Scene… (title bar) picks any
.mfscene in the project. The choice is remembered per document.
Draft preview
The Draft view converts RML/RCSS to HTML/CSS and renders it instantly, on every keystroke. Use it for fast layout work, then switch to Engine to confirm.
- Laid out at
ui.referenceResolution from project.mfproj (e.g. 1920×1080) and scaled to fit the pane.
- Loads every
.ttf/.otf font in the project under its real family name, standing in for the engine's font registration.
- Resolves relative paths and project-rooted paths like
/Assets/UI/hud.rcss.
- Handles RCSS differences:
dp units, decorator: image(...), horizontal/vertical gradient decorators, 0–255 rgba() alpha, border shorthands without a style, RmlUi tween names in animations, and RmlUi's "no default styles" behaviour.
- Not covered (use Engine for these):
<template>, @spritesheet sprites, tiled-box and other decorators, data bindings, custom engine elements, and the scene behind the UI.
How to use
| To… |
Do this |
Preview an .rml file |
Click the preview button in the editor title bar, or Cmd+K V (side) / Cmd+Shift+V (same tab). |
Open .rml files straight into the preview |
Add "*.rml": "mainframe.rmlPreview" to workbench.editorAssociations. Open Source (title bar) goes back to the text. |
| Switch Draft ↔ Engine |
Show Engine Render / Show Draft Preview in the preview's title bar. |
| Pick the scene behind the UI |
Choose Scene… in the Engine view's title bar. |
| Render again now |
Render Again in the Engine view's title bar. |
| Preview a scene |
Open the .mfscene, then the preview button or Cmd+K V. |
The side preview follows whichever .rml or .mfscene editor has focus, like the Markdown preview.
Requirements
- A Mainframe project: a folder with
project.mfproj above the file you preview.
- The .NET SDK for the Engine view (found on
PATH or in the usual install folders).
- The C# extension for Play and Debug.
- The Draft view and file features need nothing else.
Settings
| Setting |
Default |
Meaning |
mainframe.runProject |
(empty) |
.csproj that launches the game, relative to the folder with project.mfproj. Empty: the project whose code calls GameHost.Run. |
mainframe.resolution |
1920x1080 |
Draft layout size when project.mfproj has no ui.referenceResolution. |
File icons
The icons are for the vscode-icons theme, which only takes custom icons from its own folder:
- Copy the
icons/*.svg files from this repository to ~/Library/Application Support/Code/User/vsicons-custom-icons/ (macOS; on Windows %APPDATA%\Code\User\vsicons-custom-icons\, on Linux ~/.config/Code/User/vsicons-custom-icons/).
- Add to your settings:
"vsicons.associations.files": [
{ "icon": "rml", "extensions": ["rml"], "format": "svg" },
{ "icon": "rcss", "extensions": ["rcss"], "format": "svg" },
{ "icon": "mfscene", "extensions": ["mfscene"], "format": "svg" },
{ "icon": "mfres", "extensions": ["mfres"], "format": "svg" },
{ "icon": "mfproj", "extensions": ["mfproj"], "format": "svg" }
]
Development
npm test # converter, project discovery and engine runner tests (CI runs these on every push and PR)
npm run install-dev # install this working tree into your VS Code as "Mainframe Engine Extension (Dev)"
npm run package # build mainframe-engine-extension-<version>.vsix
npm run versions # published versions (one GitHub release per Marketplace version)
install-dev replaces the Marketplace build with a <next patch>-dev.<timestamp> build of the current files, committed or not. Run it after each change, then Developer: Reload Window in the project you are testing in. A VSIX install is pinned, so the Marketplace does not update over it. To go back to the public build, install it from the Extensions view.
Releasing
Publishing is manual. GitHub > Actions > Publish > Run workflow, pick patch, minor or major. The workflow runs the tests, bumps package.json, publishes to the Visual Studio Marketplace, pushes the Release vX.Y.Z commit and vX.Y.Z tag to main, and creates a GitHub release with the .vsix. It signs in with Marketplace Trusted Publishing (GitHub OIDC), so there is no token secret: the mainframe-games publisher has a Trusted Publishing policy for this repository and publish.yml.
package.json's version is always the latest published version.
License
MIT