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.
See the repo docs or online docs
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.
- DsglWindow: The entry point for building UI. Override
render()to return aDomTree. - DOM nodes: Elements like
ContainerNode,TextNode,ButtonNode, etc. - Layout:
ContainerNodesupportsColumn,Row, andStack. - Event bus:
EventBusroutes input events to node handlers. - State:
DsglWindow.state(...)returns state that triggers rebuilds on change. - Host adapter:
DsglScreenHostowns lifecycle,Mc1710UiAdapterpaints commands.
DsglWindowandDsglWindowHost- DSL builders in
Dsl.kt(ui,UiScope,ComponentProps, etc.) - Event types and
EventBus RenderCommandandUiMeasureContext- MC host:
DsglScreenHost,Mc1710UiAdapter
Build the project:
.\gradlew buildRun your mod as usual with ForgeGradle. For UI usage, open a screen derived from
DsglScreenHost on the client side.
- Rebuilds: UI is rebuilt on demand. Use
state(...)orinvalidate()to trigger rebuilds. - Focus: Key events are routed to the focused node; set stable
keyvalues to retain focus. - Threading: Build and mutate UI state on the host UI thread.
- Sizing: Nodes measure from content unless
width/heightare provided. - Images: In MC 1.7.10,
ImageNodesupports resource IDs,file://paths, and http(s) URLs.