Save/load ini string API, ported examples, README

This commit is contained in:
4DBug committed 2026-10-17 04:45:03 -05:00
1 parent 16872277f2
commit ad9af52825
5 files changed
+356 -5

No files matched your search

+51 -1
View File
@@ -5,13 +5,63 @@ Node editor (imnodes) for imgui-luau (Roblox / LÖVE).
Luau port of [ImNodes](https://github.com/Nelarius/imnodes) for [imgui-luau](https://git.bug.tools/bug/imgui-luau) ([GitHub](https://github.com/4DBug/imgui-luau)).
Mirrors: [git.bug.tools](https://git.bug.tools/bug/imnodes-luau) / [GitHub](https://github.com/4DBug/imnodes-luau).
**Status: work in progress.**
**Status:** near-complete port of upstream imnodes (editor, nodes, pins, links, selection, minimap, style stacks, save/load to string).
Not ported: `*IniFile` save/load (no filesystem on Roblox) and the `color_node_editor` example.
## Usage
```lua
local G = require(ReplicatedStorage.ImGui)
local ImNodes = require(ReplicatedStorage.ImNodes)(G)
local ImGui = G.ImGui
ImGui.CreateContext()
ImNodes.CreateContext()
G.ImGui_ImplRoblox.Init()
local Links = {}
RunService.RenderStepped:Connect(function()
G.ImGui_ImplRoblox.NewFrame()
ImGui.NewFrame()
ImGui.Begin("node editor")
ImNodes.BeginNodeEditor()
ImNodes.BeginNode(1)
ImNodes.BeginNodeTitleBar()
ImGui.Text("node")
ImNodes.EndNodeTitleBar()
ImNodes.BeginOutputAttribute(2)
ImGui.Text("out")
ImNodes.EndOutputAttribute()
ImNodes.EndNode()
for Id, L in Links do
ImNodes.Link(Id, L[1], L[2])
end
ImNodes.EndNodeEditor()
local Created, StartAttr, EndAttr = ImNodes.IsLinkCreated()
if Created then
table.insert(Links, { StartAttr, EndAttr })
end
ImGui.End()
ImGui.Render()
G.ImGui_ImplRoblox.RenderDrawData(ImGui.GetDrawData())
end)
```
Full example (ports of upstream `hello`, `multi_editor`, `save_load`): `examples/roblox/main.client.luau`.
## API differences
- Pointer out-params become return values: `IsLinkCreated() -> created, start_attr, end_attr, from_snap`,
`IsLinkDestroyed() -> destroyed, link_id`, `IsNodeHovered() -> hovered, node_id`, `IsLinkDropped(...) -> dropped, attr_id`, etc.
Getters like `GetNodeGridSpacePos` / `EditorContextGetPanning` return copies.
- The C++ `IsLinkCreated(int*, int*, int*, int*, bool*)` overload is `IsLinkCreatedWithNodes()
-> created, start_node, start_attr, end_node, end_attr, from_snap`.
- `ImNodesIO.*.Modifier` is `nil` or a function returning bool instead of a `const bool*`:
`ImNodes.GetIO().LinkDetachWithModifierClick.Modifier = function() return ImGui.GetIO().KeyCtrl end`.
- `SaveCurrentEditorStateToIniString()` / `SaveEditorStateToIniString(editor)` return a string (no `data_size`);
`LoadCurrentEditorStateFromIniString(s)` / `LoadEditorStateFromIniString(editor, s)` take one. Persist it via DataStore etc.
- `EditorContextFree` is a no-op (GC).
## Development
```sh