DiceModders-UiKit icon

UiKit

A shared UI toolkit for Dice Kingdoms mods.

Last updated 8 hours ago
Total downloads 2
Total rating 1 
Categories AI Generated Libraries
Dependency string DiceModders-UiKit-1.0.0
Dependants 1 other package depends on this package

This mod requires the following mods to function

BepInEx-BepInExPack_IL2CPP-6.0.788 icon
BepInEx-BepInExPack_IL2CPP

BepInEx pack for IL2CPP x64 Unity games. Preconfigured and ready to use.

Preferred version: 6.0.788

README

DiceModders UiKit

A shared UI toolkit for Dice Kingdoms mods. UiKit owns the global UI runtime, game skins, native hooks and lifecycle, so a mod can build windows, widgets and native-looking additions without creating its own canvases or Harmony patches.

Status: active development. The managed API is usable and nullable-annotated; native integrations are add-only and target the current Dice Kingdoms build. There are no automated in-game tests; the built-in demo is the smoke test.

Why UiKit

A game UI is more than a window. It needs canvases, sorting orders, fonts, sprites, input handling, native skins, settings integration and cleanup across scene changes. If every mod implements that itself, mods duplicate work and fight over the same game objects.

UiKit provides one shared runtime and one ownership model:

  • one set of layer canvases for the whole process;
  • one theme/asset/template cache;
  • one event-driven native lifecycle;
  • one safe boundary for callbacks and game callbacks;
  • stable scopes and native handles that survive scene changes.

A mod creates a UiScope, builds content through scope.Custom, and registers native additions through scope.Native. Disposing the scope removes everything it owns.

Features

Area What you get
Managed UI Windows, rows, columns, grids, scrolling, text, images, buttons, toggles, sliders and dropdowns
Native integrations Top-bar buttons, Settings tabs and blocks, scoreboard columns and Rules civilizations
Native look Game button/slider/dropdown/settings skins when available, with managed fallbacks for managed widgets
Lifecycle Stable handles, scene-safe reattachment, WhenReady, scope disposal and idempotent cleanup
Input Pointer events, drag support, fullscreen windows and wheel scrolling
Safety Null/no-throw public contract, guarded callbacks and main-thread-only game access
Theming Shared game font, materials, colors and sprites through UiTheme

Requirements

  • Dice Kingdoms (IL2CPP build) with BepInEx 6 for IL2CPP.
  • .NET 6 for the mod project.
  • A reference to DiceModders.UiKit.dll.

Example

using System;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using DiceModders.UiKit;
using DiceModders.UiKit.Custom;

[BepInPlugin("author.my-mod", "My Mod", "1.0.0")]
[BepInDependency("DiceModders.UiKit")]
public sealed class MyPlugin : BasePlugin {
    private UiScope? _ui;

    public override void Load() {
        _ui = UiKit.CreateScope("author.my-mod");

        _ui?.WhenReady(ui => {
            ui.Native.TopBar.AddIconButton("hammer", "Open My Mod", () => OpenWindow(ui));
        });
    }

    private static void OpenWindow(UiScope ui) {
        var window = ui.Custom.Window(w => {
            w.Title("My Mod")
             .Size(460f, 320f)
             .Center()
             .Draggable()
             .Closable();

            w.Body.Paragraph(
                "Everything created through this scope is removed when the mod unloads.");

            w.Body.Row(row => {
                row.Button("OK", () => w.Close())?.FillWidth();
                row.Button("Cancel", w.Close)?.FillWidth();
            });
        });

        window?.BringToFront();
    }

    public override bool Unload() {
        _ui?.Dispose();
        _ui = null;
        return true;
    }
}