Port ImPlot demo: ShowDemoWindow (menu, tabs, tool windows) and Demo_Help..Demo_RealtimePlots; stubs for the rest

This commit is contained in:
4DBug committed 2026-10-17 02:46:14 -05:00
1 parent 5ec0151f7e
commit fd3e0eb16b
4 files changed
+1217 -2

No files matched your search

+1153
View File
File diff suppressed because it is too large. Load diff
+2 -1
View File
@@ -4,7 +4,8 @@
"$className": "DataModel",
"ReplicatedStorage": {
"ImGui": { "$path": "tools/core/build/ImGuiTyped.luau", "Impl": { "$path": "tools/core/build/ImGui.luau" } },
"ImPlot": { "$path": "ImPlot.lua" }
"ImPlot": { "$path": "ImPlot.lua" },
"ImPlotDemo": { "$path": "ImPlotDemo.lua" }
},
"StarterPlayer": { "StarterPlayerScripts": { "ImPlotExample": { "$path": "examples/roblox/main.client.luau" } } }
}
+61
View File
@@ -0,0 +1,61 @@
local RS = game:GetService("ReplicatedStorage")
local G = require(RS:WaitForChild("ImGui"))
local ImPlot = require(RS:WaitForChild("ImPlot"))(G)
require(RS:WaitForChild("ImPlotDemo"))(G, ImPlot)
local ImGui = G.ImGui
ImGui.CreateContext()
G.ImGui_ImplRoblox.Init()
G.ImGui_ImplRoblox.SetRenderRate(0)
ImPlot.CreateContext()
local io = ImGui.GetIO()
-- force every DemoHeader open, and select one tab per phase
local TreeNodeEx, BeginTabItem = ImGui.TreeNodeEx, ImGui.BeginTabItem
ImGui.TreeNodeEx = function(label, ...)
ImGui.SetNextItemOpen(true)
return TreeNodeEx(label, ...)
end
local tabs = { "Plots", "Subplots", "Axes", "Tools", "Custom", "Config", "Help" }
local tab, seen = 1, {}
ImGui.BeginTabItem = function(label, p_open, flags)
if label == tabs[tab] then flags = bit32.bor(flags or 0, G.ImGuiTabItemFlags.SetSelected) end
local r = BeginTabItem(label, p_open, flags)
if r then seen[label] = true end
return r
end
local BeginPlot, plotted = ImPlot.BeginPlot, {}
ImPlot.BeginPlot = function(title, ...)
local r = BeginPlot(title, ...)
if r then plotted[title] = true end
return r
end
local frame, done = 0, false
game:GetService("RunService").Stepped:Connect(function()
if done then return end
frame += 1
tab = math.floor((frame - 1) / 14) % #tabs + 1
G.ImGui_ImplRoblox.NewFrame()
io.DeltaTime = 1 / 60
io.DisplaySize = G.ImVec2(1000, 30000)
ImGui.NewFrame()
-- tall window so every open demo is visible (clipped plots return false from BeginPlot)
if frame > 1 then ImGui.SetWindowSize("ImPlot Demo", G.ImVec2(900, 30000)) end
assert(ImPlot.ShowDemoWindow(true) == true)
ImGui.Render()
G.ImGui_ImplRoblox.RenderDrawData(ImGui.GetDrawData())
if frame == 100 then
done = true
for _, t in tabs do assert(seen[t], "tab never opened: " .. t) end
-- every ported Plots/Config demo submitted its plot
for _, p in { "Line Plots", "Stock Prices", "Shaded Plots", "Scatter Plot", "Bubble Plot", "##Scrolling", "##Rolling",
"Stairstep Plot", "Bar Plot", "Bar Group", "PolitiFact: Who Lies More?", "##ErrorBars", "Stem Plots", "##Infinite",
"##Pie1", "##Pie2", "##Heatmap1", "##Heatmap2", "##Histograms", "##Hist2D", "##Digital", "##image", "Preview" } do
assert(plotted[p], "plot never began: " .. p)
end
ImPlot.DestroyContext()
print("OK")
end
end)
+1 -1
View File
@@ -3,7 +3,7 @@
cd "$(dirname "$0")/.."
fail=0
for t in tests/t_*.luau; do
out=$(python3 tools/core/tools/test/run.py --module ImPlot=ImPlot.lua --main "$t" --quiet --roblox 2>&1)
out=$(python3 tools/core/tools/test/run.py --module ImPlot=ImPlot.lua --module ImPlotDemo=ImPlotDemo.lua --main "$t" --quiet --roblox 2>&1)
if echo "$out" | grep -q "^OK"; then echo "PASS $t"; else echo "FAIL $t"; echo "$out" | tail -20; fail=1; fi
done
exit $fail