local imgui = require("imgui") local array = { {name="Test", type="Action"}, {name="Test2", type="Action"}, {name="Cont", type="Container", holding={4,5,6,7,8}}, {name="Held", type="Action"}, {name="Held", type="Action"}, {name="Held", type="Action"}, {name="Held", type="Action"}, {name="Held", type="Action"}, {name="Held", type="Action"} } function not_in(v,t) for k,e in ipairs(t) do if v == e then return false end end return true end function draw_array() imgui.Begin("Array") imgui.BeginChild("", 0,0, true) local nodes_drawn_in_containers = {} for i,node in ipairs(array) do if node.type == "Action" and not_in(i, nodes_drawn_in_containers) then imgui.BeginChildFrame(i, 0,48, true) imgui.Text(node.name) imgui.EndChildFrame() elseif node.type == "Container" then imgui.BeginChild("Container "..i, 0,64, true) imgui.Columns(#node.holding, nil, false) for k,v in ipairs(node.holding) do nodes_drawn_in_containers[#nodes_drawn_in_containers + 1] = v local node = array[v] imgui.BeginChildFrame(v,0,48, true) imgui.Text(node.name..v) imgui.Separator() imgui.EndChildFrame() imgui.NextColumn() end imgui.EndChild() end end imgui.EndChild() imgui.End() end local iui_state = { array={cbk = draw_array, show=true} } function love.load() end function love.update(dt) imgui.NewFrame() end function love.draw() if imgui.BeginMainMenuBar() then if imgui.BeginMenu("Test") then for k,v in pairs(iui_state) do if imgui.MenuItem(k, nil, v.show) then iui_state[k].show = not iui_state[k].show end end imgui.EndMenu() end end imgui.EndMainMenuBar() for k,v in pairs(iui_state) do if v.show then v.cbk() end end imgui.Render() end function love.quit() imgui.ShutDown() end -- -- User inputs -- function love.textinput(t) imgui.TextInput(t) if not imgui.GetWantCaptureKeyboard() then -- Pass event to the game end end function love.keypressed(key) imgui.KeyPressed(key) if not imgui.GetWantCaptureKeyboard() then -- Pass event to the game end end function love.keyreleased(key) imgui.KeyReleased(key) if not imgui.GetWantCaptureKeyboard() then -- Pass event to the game end end function love.mousemoved(x, y) imgui.MouseMoved(x, y) if not imgui.GetWantCaptureMouse() then -- Pass event to the game end end function love.mousepressed(x, y, button) imgui.MousePressed(button) if not imgui.GetWantCaptureMouse() then -- Pass event to the game end end function love.mousereleased(x, y, button) imgui.MouseReleased(button) if not imgui.GetWantCaptureMouse() then -- Pass event to the game end end function love.wheelmoved(x, y) imgui.WheelMoved(y) if not imgui.GetWantCaptureMouse() then -- Pass event to the game end end