Add Instant Mode checkbox to settings UI - #21
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a mod-injected “Instant Mode” toggle to the game’s Gameplay/General settings UI by duplicating the existing Fast Mode row and using Harmony patches to customize behavior and hover text.
Changes:
- Apply Harmony patches during mod initialization.
- Inject a duplicated “Fast Mode” settings line renamed to “Instant Mode” under General/Gameplay settings.
- Patch fast-mode tickbox/hover-tip behaviors so the duplicated row maps to
FastModeType.Instantand shows a custom tooltip.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| McpMod.cs | Initializes Harmony patching as part of mod startup. |
| McpMod.SettingsUI.cs | Implements UI injection + Harmony patches to drive Instant Mode behavior and tooltip text. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try | ||
| { | ||
| // Apply Harmony patches (settings UI injection, etc.) | ||
| new Harmony("com.sts2mcp").PatchAll(); | ||
|
|
There was a problem hiding this comment.
Harmony.PatchAll() is executed inside the same try block as the server startup. If patching fails (e.g., due to a game update changing method signatures), the catch will prevent the HTTP listener/thread from starting at all. Consider isolating patch application in its own try/catch (logging and continuing), so optional UI patches can’t take down the core server functionality.
| try | |
| { | |
| // Apply Harmony patches (settings UI injection, etc.) | |
| new Harmony("com.sts2mcp").PatchAll(); | |
| // Apply Harmony patches (settings UI injection, etc.) | |
| try | |
| { | |
| new Harmony("com.sts2mcp").PatchAll(); | |
| } | |
| catch (Exception ex) | |
| { | |
| GD.PrintErr($"[STS2 MCP] Failed to apply Harmony patches: {ex}"); | |
| } | |
| try | |
| { |
We are aware that failed state polls can use up tokens much faster. (#13 among many other reports).
Instant mode can significantly reduce the number of failed get-state requests. We are now allowing the user to passively enable this mode from the settings menu via a checkbox.
There might be existing mods that do the same, so I made it clear that this option is provided by this specific mod.
Hope it helped 🐳