> For the complete documentation index, see [llms.txt](https://stoneforgeteam.gitbook.io/stoneforgeteam-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stoneforgeteam.gitbook.io/stoneforgeteam-docs/ui/esc-menu.md).

# The Esc menu

`EscMenu` changes the in-game Esc menu's buttons as [`MainMenu`](/stoneforgeteam-docs/ui/main-menu.md) does the main menu's: add your own, add, move or remove the game's, or build it again from scratch.

```csharp
EscMenu.AddButton(context, "Mod Options", window.Open);            // above the exit
EscMenu.AddAfter(context, EscButton.Resume, "Quick Save", () => SaveData.Save());
```

`EscMenu.AddButton(context, () => text, onClick)` takes its text as a function, so it follows the game's language (see [Localization](/stoneforgeteam-docs/core-concepts/localization.md)).

StoneForge adds its own **Report a bug** button: see [Bug reports](/stoneforgeteam-docs/getting-started/bug-reports.md).

## The game's buttons

`EscButton` names the game's own: `Resume`, `Settings`, `MessageLog`, `LoadGame`, `Exit`, `SaveAndExit`, `ExitGame` (to the desktop). Their text is the game's, in its language.

The menu starts each time as the game makes it there - Load Game only with saves outside permadeath, Exit in place of Save and Exit where the game can't save - and the mods' changes are applied to that.

A mod that mustn't let the player save, such as a multiplayer client:

```csharp
EscMenu.RemoveButton(context, EscButton.SaveAndExit);
EscMenu.AddButton(context, EscButton.Exit);
```

## Reference

| `EscMenu`                                                                                 |                                                                                                          |
| ----------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `AddButton(context, text, onClick)`                                                       | Your button, above the exit (Save and Exit, or Exit), or last.                                           |
| `AddBefore(context, anchor, text, onClick)`, `AddAfter(...)`                              | Just above or below a button.                                                                            |
| `AddButton(context, EscButton)`, `AddBefore(context, anchor, EscButton)`, `AddAfter(...)` | One of the game's buttons, back in, or moved if it's already there.                                      |
| `RemoveButton(context, EscButton)`, `RemoveButton(context, name)`                         | Takes a button out. A named button that isn't there yet (another mod's, added later) goes when it comes. |
| `ClearButtons(context)`                                                                   | Empties the menu.                                                                                        |
| `RestoreButtons(context)`                                                                 | The menu as it was when the game started, with what every mod did while it loaded.                       |
| `UndoChanges(context)`                                                                    | Undoes just this mod's changes since it loaded: for a change a mod makes for a while.                    |

An **anchor** or name is an `EscButton`, its name (`"SaveAndExit"`, `"Save and Exit"`), the text shown on a button, or the text of a button a mod added. Case doesn't matter. Changes show at once, whether the menu is open or not, laid out and centred as the game lays it out. A mod switched off takes what it did with it.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://stoneforgeteam.gitbook.io/stoneforgeteam-docs/ui/esc-menu.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
