Goal: give any code mod a native configuration UI inside the MJOLNIR Launcher's My Mods page — color pickers, dropdowns, toggles, sliders, and text fields — with zero custom React code, and read those values from UE4SS Lua or a native C DLL
Reference implementation: mods/MJOLNIRHudColor
Instead of asking players to edit Lua files or remember console commands, any code mod can declare a "settings" array in its mod.json. The launcher automatically adds a Settings button to that mod's card in My Mods, renders all controls dynamically, validates every value, and writes a flat JSON file that both Lua mods and native C DLLs can read with zero external dependencies.
MJOLNIRHudColor settings panel open inside the MJOLNIR Launcher's My Mods view, showing the Theme preset dropdown, conditional Custom HUD color picker, toggle switches, and signed badge
Architecture and storage layout
User settings are stored outside ue4ss/Mods/<ModId>/:
<game_binaries>/ue4ss/mjolnir-settings/<ModId>.json
Where <game_binaries> is Meteorite/Binaries/Win64 on Steam and Meteorite/Binaries/WinGDK on Xbox Game Pass.
Keeping user settings outside the mod's install directory enforces two invariants:
- Signed mod integrity stays intact. The launcher verifies every installed code mod's
tree_digestagainst its Ed25519-signed release manifest. Writing user config insideue4ss/Mods/<ModId>/would immediately mark the mod red (modified). Notice in the screenshot above thatMJOLNIRHudColorkeeps its bluesignedshield even after customizing its settings. - Mod updates never wipe player choices. Updating or reinstalling
<ModId>replacesue4ss/Mods/<ModId>/while leavingue4ss/mjolnir-settings/<ModId>.jsonuntouched.
On-disk JSON format
Every settings file uses a flat, primitive-only JSON object:
{
"schema_version": 1,
"values": {
"preset": "custom",
"custom_color": "#00FF88",
"recolor_menus": true,
"enable_hotkey": true
}
}
schema_versionis currently1.valuesmaps each settingkeyto a JSON primitive (string,boolean, ornumber— never nested objects or arrays).- The launcher writes atomically via a
.tmpfile and rename (apps/launcher/src-tauri/src/mod_settings.rs).
1. Building your mod's UI inside the Launcher (mod.json)
You do not need to write any React, TypeScript, or Rust code to give your mod a native settings panel in the launcher. Add a top-level "settings" array to mods/<YourMod>/mod.json and the launcher renders the full UI automatically.
All five built-in Mod Settings API control types rendered inside a launcher mod card: select dropdown, conditional color picker, boolean toggle, numeric sliders with units, and text input
What the launcher renders for you automatically
As soon as a mod's mod.json declares at least one entry in "settings":
- Settings toggle button: The launcher sets
has_settings: trueon the mod's row in My Mods and shows a Settings / Close button (Library.tsx). - Section grouping: Contiguous fields sharing a
"section"string are grouped automatically under uppercase section headers (APPEARANCE,CAMERA & MOVEMENT,LABELS). - Conditional fields (
visible_when): Fields with"visible_when": { "key": "<other_key>", "equals": <value> }appear or hide dynamically as the player interacts with the panel — ideal for revealing a custom color picker or advanced sliders only when relevant. - Per-field reset: Any field whose value differs from its
"default"shows a goldresetlink right beside its label. - Footer actions: Every panel displays the exact storage path (
ue4ss/mjolnir-settings/<ModId>.json), Reset defaults, Save settings (enabled whenever changes are pending), and a Saved confirmation.
Supported field types
type | JSON value | Launcher control | Type-specific properties & Rust validation |
|---|---|---|---|
"color" | "#RRGGBB" string | Color swatch picker + monospace hex input | Accepts #RGB or #RRGGBB (with or without #), normalized to uppercase #RRGGBB |
"select" | string | Obsidian-and-gold dropdown (Select) | options: array of { "value": string, "label": string }; saved value must match a declared option |
"boolean" | boolean | Pill toggle switch | Strict boolean |
"number" | number | Range slider (when both min & max are set) + numeric input + optional unit suffix | Optional min, max, step, unit (e.g. "u/s", "°", "%"); rejects NaN/infinity and clamps to [min, max] |
"string" | string | Text input | Optional placeholder, max_length (defaults to 256 characters) |
Common field properties
Every object in "settings" accepts these properties (mirrored in mod_settings.rs and types.ts):
| Property | Required | Description |
|---|---|---|
"key" | Yes | Setting identifier (1–64 chars: ASCII alphanumeric, _, -, .) — the exact key your Lua or C mod reads from values. Must be unique within the mod. |
"type" | Yes | One of "color", "select", "boolean", "number", "string". |
"label" | Yes | Human-readable label shown beside the control. |
"default" | Yes | Default primitive value matching "type". |
"description" | No | Helper text displayed underneath the label. |
"section" | No | Optional group heading (e.g. "Appearance", "Scope & Controls"). Contiguous fields with the same "section" render under one header. |
"visible_when" | No | { "key": "<other_key>", "equals": <primitive> } — shows the field in the launcher only when <other_key> currently equals that value. |
UI Cookbook: Recipe 1 — Preset dropdown + conditional color picker
This is the exact mods/MJOLNIRHudColor/mod.json schema that powers the first screenshot above. Notice how "custom_color" stays hidden while the player picks a built-in preset, and reveals the color swatch + hex input the instant they choose "custom":
{
"version": "0.1.0",
"summary": "Recolor Halo Campaign Evolved's Unreal Engine 5 HUD and menu theme at runtime with built-in presets or any hex color, without tag edits or recooking.",
"category": "tools",
"slug": "mjolnir-hud-color",
"settings": [
{
"key": "preset",
"type": "select",
"label": "Theme preset",
"description": "Built-in palette, or pick Custom Color to choose any hex color below.",
"section": "Appearance",
"default": "amber",
"options": [
{ "value": "amber", "label": "Amber (Halo 3 / ODST)" },
{ "value": "emerald", "label": "Emerald (Classic CE)" },
{ "value": "crimson", "label": "Crimson (Banished)" },
{ "value": "violet", "label": "Violet (Covenant)" },
{ "value": "white", "label": "Tactical Monochrome" },
{ "value": "default", "label": "Shipped Cyan (Default)" },
{ "value": "custom", "label": "Custom Color…" }
]
},
{
"key": "custom_color",
"type": "color",
"label": "Custom HUD color",
"description": "Derives a matching 6-shade HUD and menu theme from one sRGB hex color.",
"section": "Appearance",
"default": "#F5A623",
"visible_when": { "key": "preset", "equals": "custom" }
},
{
"key": "recolor_menus",
"type": "boolean",
"label": "Recolor frontend & pause menus",
"description": "Turn off to keep the main menu cyan and only recolor the in-game HUD.",
"section": "Scope & Controls",
"default": true
},
{
"key": "enable_hotkey",
"type": "boolean",
"label": "F5 preset cycle hotkey",
"description": "Press F5 in game to cycle through built-in presets.",
"section": "Scope & Controls",
"default": true
}
]
}
UI Cookbook: Recipe 2 — Sliders with units, toggles, and text inputs
This schema produces the five-control card in the second screenshot above, demonstrating "number" sliders with "unit", "string" with "placeholder" / "max_length", "boolean", "select", and "color":
{
"version": "1.0.0",
"summary": "Example code mod declaring all five Mod Settings API field types.",
"category": "tools",
"settings": [
{
"key": "profile",
"type": "select",
"label": "Display style",
"description": "Preset layout style, or choose Custom to unlock accent color customization.",
"section": "Appearance",
"default": "tactical",
"options": [
{ "value": "tactical", "label": "Tactical (Compact)" },
{ "value": "classic", "label": "Classic CE" },
{ "value": "custom", "label": "Custom…" }
]
},
{
"key": "accent_color",
"type": "color",
"label": "Accent color",
"description": "Primary highlight color in sRGB hex (#RRGGBB). Shown when Display style is Custom.",
"section": "Appearance",
"default": "#52C5D8",
"visible_when": { "key": "profile", "equals": "custom" }
},
{
"key": "show_telemetry",
"type": "boolean",
"label": "Show live telemetry overlay",
"description": "Render speed, coordinates, and camera pitch in the upper-left corner.",
"section": "Camera & Movement",
"default": true
},
{
"key": "move_speed",
"type": "number",
"label": "Base flight speed",
"description": "Movement velocity in Unreal units per second before Shift/Ctrl modifiers.",
"section": "Camera & Movement",
"default": 1800,
"min": 200,
"max": 5000,
"step": 100,
"unit": "u/s"
},
{
"key": "fov_scale",
"type": "number",
"label": "Camera FOV",
"description": "Horizontal field of view while free-cam is active.",
"section": "Camera & Movement",
"default": 90,
"min": 60,
"max": 120,
"step": 1,
"unit": "°"
},
{
"key": "watermark",
"type": "string",
"label": "Custom screenshot tag",
"description": "Optional short label stamped onto captured overlays (up to 32 characters).",
"section": "Labels",
"default": "",
"placeholder": "e.g. B30 Cinema Pass",
"max_length": 32
}
]
}
Launcher implementation files
For reference (or when contributing a new generic control type):
- Rust schema, validation, and Tauri IPC:
apps/launcher/src-tauri/src/mod_settings.rs(get_mod_settings,save_mod_settings,reset_mod_settings) - Shared TS schema types & helpers:
apps/launcher/src/components/mod-settings/types.ts - DRY control renderer:
apps/launcher/src/components/mod-settings/SettingControl.tsx - Panel container:
apps/launcher/src/components/mod-settings/ModSettingsPanel.tsx - My Mods integration:
apps/launcher/src/components/Library.tsx
Most mods never need to edit the launcher at all. If a future mod genuinely requires a reusable control type that the five built-in types cannot express (for example, a keybind capture input), extend SettingType / SettingField in mod_settings.rs and types.ts and add a single case branch in SettingControl.tsx so every mod can reuse it.
2. Reading settings in UE4SS Lua mods
The canonical zero-dependency Lua helper lives at mods/MJOLNIRCore/Scripts/ModSettings.lua.
Because UE4SS's require() searches a mod's own Scripts/ folder (and ue4ss/Mods/shared/), not sibling mod folders, each Lua mod that uses settings ships a byte-identical copy of ModSettings.lua in its own Scripts/ directory. tools/tests/test_mod_settings.lua verifies parity in CI so copies never drift.
Basic usage
local ModSettings = require("ModSettings")
local SETTING_DEFAULTS = {
preset = "amber",
custom_color = "#F5A623",
recolor_menus = true,
enable_hotkey = true,
}
local lastRaw = nil
local settings = ModSettings.merge(SETTING_DEFAULTS, nil)
local function syncSettings()
local loaded, raw = ModSettings.load("MyModName", SETTING_DEFAULTS)
if raw == lastRaw and next(settings) ~= nil then
return false -- unchanged on disk; preserve any in-game runtime override
end
lastRaw = raw
settings = loaded
return true
end
API summary (ModSettings.lua)
ModSettings.load(modId, defaults, opts)→values, rawText, resolvedPath- Resolves
<game_binaries>\ue4ss\mjolnir-settings\<modId>.jsonautomatically on both Steam (Win64) and Xbox Game Pass (WinGDK) using the caller's source path viadebug.getinfo. - Parses the JSON without external dependencies, merges only keys present in
defaultswhose runtime type matches (type(v) == type(default)), and falls back cleanly todefaultsif the file is missing, empty, or corrupt. - Returns the raw file string as
rawText(or""if no file exists) so mods can detect on-disk edits cheaply without clobbering runtime overrides.
- Resolves
ModSettings.configPath(modId, scriptPath)→ resolved path string (ornil).ModSettings.ue4ssRoot(scriptPath)→<game_binaries>\ue4ssroot string (ornil).ModSettings.parseJson(text)→ decoded Lua value (ornil, err).ModSettings.merge(defaults, parsed)→ new table with defaults merged.
Keep it event-driven (no polling loops)
Do not poll the settings file on a tick or timer loop. Re-check ModSettings.load only at natural lifecycle boundaries — startup, PlayerController:ClientRestart, menu/HUD open hooks, and an optional console reload command (e.g. mjolnir_hud_color reload). That way, players can even change a setting in the launcher while the game is running and pick it up on the next screen transition or console reload with zero per-frame overhead.
PR capability checklist: Because
ModSettings.luareads<ue4ss>\mjolnir-settings\<ModId>.jsonviaio.open, remember to check the File I/O capability box and note read-only settings loading in your code-mod pull request (contributing_code_mods.md).
3. Reading settings in native C DLL mods
Native C mods can include the header-only C99/C11 library native/include/mjolnir_mod_settings.h. It has zero external dependencies (standard C library + optional Windows.h for GetModuleFileNameA) and compiles cleanly under MSVC /W4 /WX.
Usage in a native DLL
#include <windows.h>
#include "../include/mjolnir_mod_settings.h"
static void load_my_mod_settings(void) {
char path[MAX_PATH];
if (!mjolnir_settings_path_from_address(
(const void *)&load_my_mod_settings,
"MJOLNIRHudColor",
path,
sizeof(path))) {
return;
}
MjolnirModSettings cfg;
if (mjolnir_settings_load_file(&cfg, path)) {
const char *preset = mjolnir_settings_get_string(&cfg, "preset", "amber");
int recolor_menus = mjolnir_settings_get_bool(&cfg, "recolor_menus", 1);
float r = 1.0f, g = 0.55f, b = 0.10f;
if (mjolnir_settings_get_color_linear(&cfg, "custom_color", &r, &g, &b)) {
/* r, g, b are UE5 linear-light RGB ready for FLinearColor */
}
(void)preset;
(void)recolor_menus;
}
mjolnir_settings_free(&cfg);
}
C API overview
| Function | Purpose |
|---|---|
mjolnir_settings_path_from_address(addr, mod_id, out, cap) | Resolves <ue4ss>\mjolnir-settings\<mod_id>.json from any function/static address inside your DLL (handles ue4ss/Mods/<Mod>/native/*.dll and ue4ss/Mods/<Mod>/*.dll) |
mjolnir_settings_path_from_dll_path(dll_path, mod_id, out, cap) | Pure path-string version of the resolver (testable without Windows module lookup) |
mjolnir_settings_path_from_exe(mod_id, out, cap) | Resolves via the host game executable's directory (<game_binaries>\ue4ss\mjolnir-settings\<mod_id>.json) |
mjolnir_settings_load_file(&cfg, path) / mjolnir_settings_parse(&cfg, json) | Initializes cfg and loads/parses { "schema_version": 1, "values": { ... } } |
mjolnir_settings_get_string / get_bool / get_number | Type-safe value getters with caller-supplied defaults |
mjolnir_settings_get_color_rgb(&cfg, key, &r, &g, &b) | Parses #RRGGBB / #RGB into 8-bit sRGB channels (0..255) |
mjolnir_settings_get_color_linear(&cfg, key, &r, &g, &b) | Parses #RRGGBB / #RGB and converts directly to linear-light RGB (0.0..1.0) for UE5 FLinearColor |
mjolnir_settings_free(&cfg) | Releases all memory allocated by the parsed settings table |
Unit tests live in native/include/test_mod_settings.c and run in CI via native/include/test-mod-settings.ps1.
4. Testing your mod's settings locally
- Add your
"settings"array tomods/<YourMod>/mod.json. - If your mod is Lua, copy
mods/MJOLNIRCore/Scripts/ModSettings.luaintomods/<YourMod>/Scripts/ModSettings.luaand add<YourMod>totools/tests/test_mod_settings.lua, then run:lua tools/tests/test_mod_settings.lua - If your mod has a native C DLL, test the header with:
.\native\include\test-mod-settings.ps1 - Preview your UI live in the launcher (
cd apps/launcher && pnpm tauri dev), open My Mods, click Settings on your mod's card, tweak each control, click Save settings, and verify<game_binaries>\ue4ss\mjolnir-settings\<YourMod>.jsonupdates and loads cleanly in-game. - Run the launcher Rust settings tests if you touched the schema backend:
cd apps/launcher/src-tauri cargo test --lib mod_settings