Skip to content

Commit

Permalink
Improve performance of mod settings table
Browse files Browse the repository at this point in the history
  • Loading branch information
dextercd committed Oct 28, 2023
1 parent ea4365b commit b869599
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion component-explorer/mod_settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,13 @@ function mod_settings.show()
local modal_current_next_value = nil
local modal_setting_exists = false

local filtered_items = {}

for setting_idx=0,ModSettingGetCount()-1 do
local id, value, next_value = ModSettingGetAtIndex(setting_idx)

if string_util.ifind(id, search, 1, true) then
mod_table_item(setting_idx, id, value, next_value)
table.insert(filtered_items, {setting_idx, id, value, next_value})
end

if modal and modal.setting_id == id then
Expand All @@ -163,6 +165,15 @@ function mod_settings.show()
end
end

local clipper = imgui.ListClipper.new()
clipper:Begin(#filtered_items)
while clipper:Step() do
for i=clipper.DisplayStart,clipper.DisplayEnd - 1 do
local setting_idx, id, value, next_value = unpack(filtered_items[i + 1])
mod_table_item(setting_idx, id, value, next_value)
end
end

imgui.EndTable()

if modal then
Expand Down

0 comments on commit b869599

Please sign in to comment.