Skip to content

Dreamfinity/DSGL

Repository files navigation

Dreamfinity Simple GUI Library (DSGL)

DSGL is a retained-mode UI DSL written in Kotlin. It renders a DOM-like tree into platform-specific render commands, with Minecraft 1.7.10 support provided by the mc-forge-1-7-10 module.

Modules:

  • core: Platform-agnostic UI tree, layout, events, and render commands.
  • mc-forge-1-7-10: Minecraft 1.7.10 host and renderer that turns render commands into MC calls.

Quick Start

See the repo docs or online docs

What is this

DSGL lets you describe UI with a Kotlin DSL. It builds a retained DOM tree, measures and lays out nodes, then emits render commands. A host adapter (like Minecraft 1.7.10) executes those commands and routes input events back to the tree.

Main Concepts

  • DsglWindow: The entry point for building UI. Override render() to return a DomTree.
  • DOM nodes: Elements like ContainerNode, TextNode, ButtonNode, etc.
  • Layout: ContainerNode supports Column, Row, and Stack.
  • Event bus: EventBus routes input events to node handlers.
  • State: DsglWindow.state(...) returns state that triggers rebuilds on change.
  • Host adapter: DsglScreenHost owns lifecycle, Mc1710UiAdapter paints commands.

Public API Entry Points

  • DsglWindow and DsglWindowHost
  • DSL builders in Dsl.kt (ui, UiScope, ComponentProps, etc.)
  • Event types and EventBus
  • RenderCommand and UiMeasureContext
  • MC host: DsglScreenHost, Mc1710UiAdapter

Build/Run

Build the project:

.\gradlew build

Run your mod as usual with ForgeGradle. For UI usage, open a screen derived from DsglScreenHost on the client side.

Common pitfalls and constraints

  • Rebuilds: UI is rebuilt on demand. Use state(...) or invalidate() to trigger rebuilds.
  • Focus: Key events are routed to the focused node; set stable key values to retain focus.
  • Threading: Build and mutate UI state on the host UI thread.
  • Sizing: Nodes measure from content unless width/height are provided.
  • Images: In MC 1.7.10, ImageNode supports resource IDs, file:// paths, and http(s) URLs.

More Docs

About

Declarative, DSL-aware, version (and even game and platform)-agnostic UI library, heavily inspired by React

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages