Skip to content

Commit

Permalink
Optimise run flags UI some
Browse files Browse the repository at this point in the history
  • Loading branch information
dextercd committed Oct 24, 2024
1 parent c0c1fd4 commit d5517fd
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions component-explorer/run_flags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ function run_flags.show()

local flags = ComponentGetValue2(world_state, "flags")
local filtered_flags = {}
for _, flag in ipairs(flags) do
if string_util.ifind(flag, search, 1, false) then
table.insert(filtered_flags, flag)
if search == "" then
filtered_flags = flags
else
for _, flag in ipairs(flags) do
if string_util.ifind(flag, search, 1, false) then
table.insert(filtered_flags, flag)
end
end
end
table.sort(filtered_flags)

local table_flags = imgui.TableFlags.Resizable
if imgui.TableGetSortSpecs then
Expand All @@ -72,20 +75,23 @@ function run_flags.show()
and function(a, b) return a < b end
or function(a, b) return a > b end)
end
else
table.sort(filtered_flags)
end

for _, flag in ipairs(filtered_flags) do
imgui.PushID(flag)
imgui.TableNextColumn()
imgui.Text(flag)

imgui.TableNextColumn()
if imgui.SmallButton("Remove") then
GameRemoveFlagRun(flag)
local clipper = imgui.ListClipper.new()
clipper:Begin(#filtered_flags)
while clipper:Step() do
for i=clipper.DisplayStart,clipper.DisplayEnd-1 do
local flag = filtered_flags[i + 1]
imgui.PushID(flag)
imgui.TableNextColumn()
imgui.Text(flag)

imgui.TableNextColumn()
if imgui.SmallButton("Remove") then
GameRemoveFlagRun(flag)
end
imgui.PopID()
end
imgui.PopID()
end

imgui.EndTable()
Expand Down

0 comments on commit d5517fd

Please sign in to comment.