Skip to main content

Overview

The IUiBuilder interface represents the Dalamud UI that is drawn on top of the game. It can be used to draw custom windows and overlays using ImGui. Namespace: Dalamud.Interface Assembly: Dalamud.dll

Events

Draw
event Action?
The event that gets called when Dalamud is ready to draw your windows or overlays. When it is called, you can use static ImGui calls.
uiBuilder.Draw += OnDraw;

private void OnDraw()
{
    ImGui.Begin("My Window");
    ImGui.Text("Hello, world!");
    ImGui.End();
}
ResizeBuffers
event Action?
The event that is called when the game’s DirectX device is requesting you to resize your buffers.
OpenConfigUi
event Action?
Event that is fired when the plugin should open its configuration interface.This event is triggered when users click on the plugin’s settings button in the plugin installer.
OpenMainUi
event Action?
Event that is fired when the plugin should open its main interface.This event is triggered when users click on the plugin in the plugin installer.
ShowUi
event Action?
An action that is called when plugin UI or interface modifications are supposed to be shown. These may be fired consecutively.
HideUi
event Action?
An action that is called when plugin UI or interface modifications are supposed to be hidden. These may be fired consecutively.
DefaultGlobalScaleChanged
event Action?
Event fired when the default global scale changes.
DefaultFontChanged
event Action?
Event fired when the default font changes.
DefaultStyleChanged
event Action?
Event fired when the default style changes.

Properties

Font Handles

DefaultFontHandle
IFontHandle
Gets the handle to the default Dalamud font - supporting all game languages and icons.
// To create a matching font handle:
var fontHandle = fontAtlas.NewDelegateFontHandle(
    e => e.OnPreBuild(
        tk => tk.AddDalamudDefaultFont(UiBuilder.DefaultFontSizePx)));
IconFontHandle
IFontHandle
Gets the default Dalamud icon font based on FontAwesome 5 Free solid.
// To create a matching font handle:
var fontHandle = fontAtlas.NewDelegateFontHandle(
    e => e.OnPreBuild(
        tk => tk.AddFontAwesomeIconFont(new() { SizePx = UiBuilder.DefaultFontSizePx })));
MonoFontHandle
IFontHandle
Gets the default Dalamud monospaced font based on Inconsolata Regular.
// To create a matching font handle:
var fontHandle = fontAtlas.NewDelegateFontHandle(
    e => e.OnPreBuild(
        tk => tk.AddDalamudAssetFont(
            DalamudAsset.InconsolataRegular,
            new() { SizePx = UiBuilder.DefaultFontSizePx })));
IconFontFixedWidthHandle
IFontHandle
Gets the default Dalamud icon font based on FontAwesome 5 free solid with a fixed width and vertically centered glyphs.

Font Properties

DefaultFontSpec
IFontSpec
Gets the default font specifications.
FontDefaultSizePt
float
Gets the default Dalamud font size in points.
FontDefaultSizePx
float
Gets the default Dalamud font size in pixels.
FontDefault
ImFontPtr
Gets the default Dalamud font - supporting all game languages and icons.
Accessing this property outside of the Draw event is dangerous and not supported.
FontIcon
ImFontPtr
Gets the default Dalamud icon font based on FontAwesome 5 Free solid.
Accessing this property outside of the Draw event is dangerous and not supported.
FontMono
ImFontPtr
Gets the default Dalamud monospaced font based on Inconsolata Regular.
Accessing this property outside of the Draw event is dangerous and not supported.

Device and Window

DeviceHandle
nint
Gets the game’s active Direct3D device.Returns a pointer to the instance of IUnknown that the game is using and should be containing an ID3D11Device, or 0 if it is not available yet.Use QueryInterface with IID of IID_ID3D11Device if you want to ensure that the interface type contained within is indeed an instance of ID3D11Device.
WindowHandlePtr
nint
Gets the game’s main window handle.Returns the HWND of the main game window, or 0 if it is not available yet.

UI Visibility Settings

DisableAutomaticUiHide
bool
Gets or sets a value indicating whether this plugin should hide its UI automatically when the game’s UI is hidden.Default: false
DisableUserUiHide
bool
Gets or sets a value indicating whether this plugin should hide its UI automatically when the user toggles the UI.Default: false
DisableCutsceneUiHide
bool
Gets or sets a value indicating whether this plugin should hide its UI automatically during cutscenes.Default: false
DisableGposeUiHide
bool
Gets or sets a value indicating whether this plugin should hide its UI automatically while gpose is active.Default: false
OverrideGameCursor
bool
Gets or sets a value indicating whether the game’s cursor should be overridden with the ImGui cursor.Default: false

State Properties

FrameCount
ulong
Gets the count of Draw calls made since plugin creation.
CutsceneActive
bool
Gets a value indicating whether a cutscene is playing.
ShouldModifyUi
bool
Gets a value indicating whether this plugin should modify the game’s interface at this time.
UiPrepared
bool
Gets a value indicating whether UI functions can be used.
FontAtlas
IFontAtlas
Gets the plugin-private font atlas.
ShouldUseReducedMotion
bool
Gets a value indicating whether to use “reduced motion”. This usually means that you should use less intrusive animations, or disable them entirely.
PluginUISoundEffectsEnabled
bool
Gets a value indicating whether the user has enabled the “Enable sound effects for plugin windows” setting.This setting is effected by the in-game “System Sounds” option and volume.

Methods

LoadUld
UldWrapper
Loads an ULD file that can load textures containing multiple icons in a single texture.Parameters:
  • uldPath (string) - The path of the requested ULD file.
Returns: A wrapper around said ULD file.
var uldWrapper = uiBuilder.LoadUld("ui/uld/someicon.uld");
WaitForUi
Task
Waits for UI to become available for use.Returns: A task that completes when the game’s Present has been called at least once.
await uiBuilder.WaitForUi();
RunWhenUiPrepared<T>
Task<T>
Waits for UI to become available for use, then runs a function.Parameters:
  • func (Func<T> or Func<Task<T>>) - Function to call.
  • runInFrameworkThread (bool) - Specifies whether to call the function from the framework thread. Default: false
Returns: A task that completes when the game’s Present has been called at least once.
var result = await uiBuilder.RunWhenUiPrepared(() => DoSomething());
CreateFontAtlas
IFontAtlas
Creates an isolated IFontAtlas.Parameters:
  • autoRebuildMode (FontAtlasAutoRebuildMode) - Specify when and how to rebuild this atlas.
  • isGlobalScaled (bool) - Whether the fonts in the atlas is global scaled. Default: true
  • debugName (string?) - Name for debugging purposes. Default: null
Returns: A new instance of IFontAtlas.Use this to create extra font atlases, if you want to create and dispose fonts without having to rebuild all other fonts together.If autoRebuildMode is not FontAtlasAutoRebuildMode.OnNewFrame, the font rebuilding functions must be called manually.
var fontAtlas = uiBuilder.CreateFontAtlas(
    FontAtlasAutoRebuildMode.Async,
    isGlobalScaled: true,
    debugName: "MyCustomAtlas");

Usage Example

public class MyPlugin : IDalamudPlugin
{
    private readonly IUiBuilder uiBuilder;
    private bool isVisible = false;

    public MyPlugin(IDalamudPluginInterface pluginInterface)
    {
        this.uiBuilder = pluginInterface.UiBuilder;
        
        // Subscribe to draw event
        this.uiBuilder.Draw += OnDraw;
        
        // Subscribe to config UI event
        this.uiBuilder.OpenConfigUi += OnOpenConfigUi;
        
        // Configure UI behavior
        this.uiBuilder.DisableCutsceneUiHide = true;
    }

    private void OnDraw()
    {
        if (!isVisible) return;

        ImGui.Begin("My Plugin Window", ref isVisible);
        ImGui.Text("Hello from my plugin!");
        
        // Use custom font
        using (uiBuilder.MonoFontHandle.Push())
        {
            ImGui.Text("This is in monospace font");
        }
        
        ImGui.End();
    }

    private void OnOpenConfigUi()
    {
        isVisible = true;
    }

    public void Dispose()
    {
        this.uiBuilder.Draw -= OnDraw;
        this.uiBuilder.OpenConfigUi -= OnOpenConfigUi;
    }
}

See Also

Build docs developers (and LLMs) love