diff --git a/component-explorer/entity.lua b/component-explorer/entity.lua index 7f6761a..90b7548 100644 --- a/component-explorer/entity.lua +++ b/component-explorer/entity.lua @@ -243,6 +243,19 @@ local function show_entity(entity_id, data) if imgui.CollapsingHeader("Components") then _, data.component_search = imgui.InputText("Type Search", data.component_search) + if imgui.Button("+ Add Component") then + imgui.OpenPopup("add_component_popup") + end + + if imgui.BeginPopup("add_component_popup") then + for _, component_type in ipairs(component_types) do + if imgui.MenuItem(component_type) then + EntityAddComponent(entity_id, component_type) + end + end + imgui.EndPopup() + end + local table_flags = imgui.TableFlags.Resizable if imgui.BeginTable("EntityComponents", 4, table_flags) then imgui.TableSetupColumn("ID", imgui.TableColumnFlags.WidthFixed) diff --git a/components.lua b/components.lua index 3d240c4..955ed36 100644 --- a/components.lua +++ b/components.lua @@ -2,6 +2,12 @@ dofile_once("mods/component-explorer/serialise_component.lua") dofile_once("mods/component-explorer/component_fields.lua") local xml_serialise = dofile_once("mods/component-explorer/xml_serialise.lua") +component_types = { + {% for component in component_documentation %} + "{{ component.name }}", + {% endfor %} +} + local components_watching = {} function unwatch_component(component_id)