Files
wiki/se-launcher/development/plugin-ui.md
2025-07-09 08:19:50 +00:00

112 lines
3.7 KiB
Markdown

---
title: Plugin UI
description: This article explains all available options to create user interfaces for your own plugins and how to use preffered Dear ImGui inside launcher environment
published: true
date: 2025-07-07T15:20:41.232Z
tags:
editor: markdown
dateCreated: 2025-07-07T15:20:39.406Z
---
# Creating UIs
The SE Launcher supports multiple approaches to creating user interfaces. Depending on your needs and the context in which the UI is displayed, you may choose from a variety of supported frameworks:
---
## Supported UI Frameworks
- **VRage Sandbox GUI (`MyGuiScreenBase`)**
The native game GUI system used by the base game for menus and dialogs.
- **EmptyKeys MVVM-XAML (`MyGuiScreenMvvmBase`)**
A more modern approach using MVVM and XAML, as used by some newer parts of the Space Engineers UI.
- **Windows Forms / WPF**
Standard UI toolkits in the .NET ecosystem. These are generally used for **external or child windows**, since they cannot be rendered on the main game window.
> These options are available and usable, but may require more complex setup and are outside the scope of this article.
---
## Recommended: ImGui
The **preferred UI system** in SE Launcher is **[Dear ImGui](https://github.com/ocornut/imgui)**, a powerful and immediate-mode GUI library.
It is used for **all SE Launcher native UI** and is tightly integrated into the plugin system, making it the best choice for creating custom plugin UIs.
This article focuses exclusively on using **ImGui**, as other frameworks are either documented elsewhere or can be studied via existing plugin implementations.
---
## Getting Started with ImGui
To create a UI with ImGui, define a class that implements the `IRenderComponent` interface.
All ImGui rendering must be done **inside the `OnFrame()` method**, which is called every frame when the renderer is active.
### Example: Simple UI Component
```csharp
using CringePlugins.Abstractions;
using ImGuiNET;
namespace TestPlugin;
public class TestRenderComponent : IRenderComponent
{
public void OnFrame()
{
if (ImGui.Begin("Test Window"))
{
ImGui.Button("Test");
ImGui.End();
}
ImGui.ShowDemoWindow();
}
}
````
In this example:
* A basic ImGui window titled **Test Window** is shown.
* A button labeled **Test** is rendered.
* `ImGui.ShowDemoWindow()` displays an interactive reference window with a showcase of all ImGui features and controls.
This is an excellent way to explore the capabilities of ImGui while developing your UI.
---
## Registering the Render Component
To make your ImGui UI render in-game, you must **register the component** using the `RenderHandler` during plugin initialization:
```csharp
public void Init(object gameInstance)
{
RenderHandler.Current.RegisterComponent(new TestRenderComponent());
}
```
Once registered, your `OnFrame()` method will be called every frame, and your ImGui-based UI will be drawn automatically.
---
## Further Learning
ImGui is a complex and versatile UI framework, and covering all of its features is beyond the scope of this article.
To learn more, you can:
* Explore the **ImGui Demo Window** via `ImGui.ShowDemoWindow()`
* Look at how the SE Launcher uses ImGui in its own UI components:
* Plugin List:
[PluginListComponent.cs](https://git.zznty.ru/PvE/se-launcher/src/branch/master/CringePlugins/Ui/PluginListComponent.cs)
* Mod List from Client Mod Loader:
[ModListComponent.cs](https://git.zznty.ru/PvE/ClientModLoader/src/branch/master/Plugin.ClientModLoader/ModListComponent.cs)
These examples demonstrate real-world usage patterns for building complex UI with ImGui in the launcher environment.