Skip to content

Add Instant Mode checkbox to settings UI - #21

Merged
Gennadiyev merged 1 commit into
mainfrom
feat/instant-mode-checkbox
Mar 28, 2026
Merged

Add Instant Mode checkbox to settings UI#21
Gennadiyev merged 1 commit into
mainfrom
feat/instant-mode-checkbox

Conversation

@Gennadiyev

@Gennadiyev Gennadiyev commented Mar 28, 2026

Copy link
Copy Markdown
Owner

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 🐳

image

Copilot AI review requested due to automatic review settings March 28, 2026 10:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Instant and 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.

Comment thread McpMod.cs
Comment on lines 37 to +41
try
{
// Apply Harmony patches (settings UI injection, etc.)
new Harmony("com.sts2mcp").PatchAll();

Copilot AI Mar 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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
{

Copilot uses AI. Check for mistakes.
@Gennadiyev
Gennadiyev merged commit ff31767 into main Mar 28, 2026
4 checks passed
@Gennadiyev
Gennadiyev deleted the feat/instant-mode-checkbox branch March 28, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants