|
|
@@ -3,7 +3,7 @@ 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="Cont", type="Container", holding={4,5,6,7,8}, condition="And"},
|
|
|
{name="Held", type="Action"},
|
|
|
{name="Held", type="Action"},
|
|
|
{name="Held", type="Action"},
|
|
|
@@ -12,6 +12,10 @@ local array = {
|
|
|
{name="Held", type="Action"}
|
|
|
}
|
|
|
|
|
|
+for i,node in ipairs(array) do node.id = i end
|
|
|
+
|
|
|
+local selected_node = nil
|
|
|
+
|
|
|
function not_in(v,t)
|
|
|
for k,e in ipairs(t) do
|
|
|
if v == e then return false end
|
|
|
@@ -19,30 +23,68 @@ function not_in(v,t)
|
|
|
return true
|
|
|
end
|
|
|
|
|
|
+function draw_action_node(node)
|
|
|
+ local v = 0
|
|
|
+ imgui.BeginChildFrame(node.id,0,64, true, {"NoInputs"})
|
|
|
+
|
|
|
+ local x,y = imgui.GetCursorPos()
|
|
|
+ imgui.InvisibleButton("",-1,-1)
|
|
|
+ if imgui.IsItemClicked() then
|
|
|
+ selected_node = node
|
|
|
+ end
|
|
|
+ imgui.SetCursorPos(x,y)
|
|
|
+
|
|
|
+ imgui.Text(node.name)
|
|
|
+ imgui.Separator()
|
|
|
+
|
|
|
+ imgui.EndChildFrame()
|
|
|
+end
|
|
|
+
|
|
|
function draw_array()
|
|
|
imgui.Begin("Array")
|
|
|
imgui.BeginChild("", 0,0, true)
|
|
|
+ imgui.Columns(2)
|
|
|
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()
|
|
|
+ draw_action_node(node)
|
|
|
elseif node.type == "Container" then
|
|
|
- imgui.BeginChild("Container "..i, 0,64, true)
|
|
|
+ if node.condition == "Or" then
|
|
|
+ imgui.PushStyleColor("ChildWindowBg", 0.2,0,0,1)
|
|
|
+ elseif node.condition == "And" then
|
|
|
+ imgui.PushStyleColor("ChildWindowBg", 0,0.2,0,1)
|
|
|
+ else
|
|
|
+ imgui.PushStyleColor("ChildWindowBg", 0,0,0,1)
|
|
|
+ end
|
|
|
+ imgui.BeginChild("Container "..i, 0,104, true, {"NoInputs"})
|
|
|
+ local x,y = imgui.GetCursorPos()
|
|
|
+ imgui.InvisibleButton("",-1,-1)
|
|
|
+ if imgui.IsItemClicked() then
|
|
|
+ selected_node = node
|
|
|
+ end
|
|
|
+ imgui.SetCursorPos(x,y)
|
|
|
+
|
|
|
+
|
|
|
+ imgui.Text("Condition | "..node.condition)
|
|
|
+ imgui.Separator()
|
|
|
imgui.Columns(#node.holding, nil, false)
|
|
|
+ imgui.PopStyleColor(1)
|
|
|
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()
|
|
|
+ draw_action_node(node)
|
|
|
imgui.NextColumn()
|
|
|
end
|
|
|
+ imgui.PushStyleColor("ChildWindowBg", 1,0,0,1)
|
|
|
imgui.EndChild()
|
|
|
+ imgui.PopStyleColor(1)
|
|
|
end
|
|
|
end
|
|
|
+ imgui.NextColumn()
|
|
|
+ if selected_node then
|
|
|
+ imgui.Text(selected_node.name)
|
|
|
+ end
|
|
|
+ imgui.Button("OK")
|
|
|
imgui.EndChild()
|
|
|
imgui.End()
|
|
|
end
|