Logic Simulator example UI (LogicUI), Delete-key test
This commit is contained in:
1 parent
53d4cfba75
commit
d471cb855c
5 files changed
+253
-172
No files matched your search
@@ -0,0 +1,35 @@
|
||||
local RS = game:GetService("ReplicatedStorage")
|
||||
local G = require(RS:WaitForChild("ImGui"))
|
||||
local ImNodes = require(RS:WaitForChild("ImNodes"))(G)
|
||||
local LogicSim = require(RS:WaitForChild("LogicSim"))(G, ImNodes)
|
||||
local UI = require(RS:WaitForChild("LogicUI"))(G, ImNodes, LogicSim)
|
||||
local ImGui = G.ImGui
|
||||
local Impl = G.ImGui_ImplRoblox
|
||||
|
||||
ImGui.CreateContext()
|
||||
Impl.Init()
|
||||
Impl.SetRenderRate(0)
|
||||
ImNodes.CreateContext()
|
||||
local io = ImGui.GetIO()
|
||||
|
||||
local function frame(before)
|
||||
Impl.NewFrame()
|
||||
io.DeltaTime = 1 / 60
|
||||
if before then before() end
|
||||
ImGui.NewFrame()
|
||||
UI.Draw()
|
||||
ImGui.Render()
|
||||
end
|
||||
|
||||
frame()
|
||||
frame()
|
||||
local g = UI.Graph
|
||||
local victim = g.order[1]
|
||||
local count = #g.order
|
||||
assert(g.nodes[victim] and count == 10, "full adder loaded")
|
||||
ImNodes.SelectNode(victim)
|
||||
frame(function() io:AddKeyEvent(G.ImGuiKey.Delete, true) end)
|
||||
frame(function() io:AddKeyEvent(G.ImGuiKey.Delete, false) end)
|
||||
assert(g.nodes[victim] == nil and #g.order == count - 1, "Delete removed selected node")
|
||||
assert(ImNodes.NumSelectedNodes() == 0)
|
||||
print("OK")
|
||||
Reference in new issue
Block a user