Skip to content

Commit

Permalink
Add UI for adding components
Browse files Browse the repository at this point in the history
  • Loading branch information
dextercd committed Oct 3, 2022
1 parent 9c7ba08 commit 22561a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions component-explorer/entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions components.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 22561a4

Please sign in to comment.