Skip to content

NanaKhide/Astral

Repository files navigation

Astral

Astral is an XML abstraction layer for Dalamud's ImGui bindings.

Early Development

This library is currently under initial development. APIs, XML attributes, and internal logic will change significantly as features are finalized.

Expect breaking changes until the first stable release.

Installation

Currently, Astral is not available on NuGet. Include it as a Submodule in your project until the lib has had the first major release.

Features

  • Opt-Out Hot Reloading
  • Register your own C# classes as custom XML tags.
  • Data and Action Binding
  • Presets and Custom Elements

Demo

Astral comes with a tiny UI demo plugin, you may try it with this repo link; https://raw.githubusercontent.com/NanaKhide/Astral/refs/heads/master/repo.json

Usage

Initialize Astral with your Plugin Interface; this is required for accessing Dalamud's services.

public Plugin(IDalamudPluginInterface pluginInterface)
{
    Astral.Initialize(pluginInterface);
    // Optional: Register your custom elements
    Astral.Register<MyCustomWidget>("MyWidget");
}

Define a context class, keep a reference to your window, and add it to the WindowSystem. This context class will be used to bind values and actions.

public class MyWindowContext
{
    // Properties are bound to the UI
    public int Counter { get; set; } = 0;
    
    // Methods can be bound to events like OnClick
    public void OnIncrement() => Counter++;
}

// In your Plugin class:
private readonly AstralWindow _myWindow;

public Plugin(...)
{
    // Load the XML
    var path = Path.Combine(PluginInterface.AssemblyLocation.DirectoryName!, "MyWindow.xml");
    var context = new MyWindowContext();

    // Create the window (false disables hot-reloading)
    // This is optional but i left it in this example for clarity.
    _myWindow = new AstralWindow("MyUniqueId", path, context, enableHotReload: true);
    
    // Add to Dalamud's WindowSystem
    WindowSystem.AddWindow(_myWindow);
}

Use Bound values through the {PropertyName} syntax.

<Window Title="My Astral Window" Flags="AlwaysAutoResize">
    <Text Value="{Counter}" />
    <Button Label="Increase" OnClick="OnIncrement" />
</Window>

About

Astral is an XML abstraction layer for Dalamud's ImGui bindings.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages