Skip to content

Commit fe80662

Browse files
committed
devel/dflayout: use getUIElementStateChecker
1 parent 012593f commit fe80662

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

devel/dflayout.lua

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ end
384384
---@param el DFLayout.DynamicUIElement
385385
---@param item_count_fn fun(): integer
386386
---@return Demo
387-
local function info_items_demo(text, focus_string, el, item_count_fn)
387+
local function info_items_demo(text, focus_string, el)
388388
local demo = {
389389
text = text,
390390
available = dfhack.world.isFortressMode,
@@ -402,11 +402,9 @@ local function info_items_demo(text, focus_string, el, item_count_fn)
402402

403403
demo.views = { panel }
404404

405-
local item_count
405+
local state_changed = layout.getUIElementStateChecker(el)
406406
function demo.on_render()
407-
local new_count = item_count_fn()
408-
if new_count ~= item_count then
409-
item_count = new_count
407+
if state_changed() then
410408
panel:updateLayout()
411409
end
412410
end
@@ -417,16 +415,12 @@ end
417415
local orders_demo = info_items_demo(
418416
'info Orders tab',
419417
'dwarfmode/Info/WORK_ORDERS/Default',
420-
layout.experimental_elements.orders,
421-
function() return #df.global.world.manager_orders.all end)
418+
layout.experimental_elements.orders)
422419

423420
local zones_demo = info_items_demo(
424421
'info Places/Zones tab',
425422
'dwarfmode/Info/BUILDINGS/ZONES',
426-
layout.experimental_elements.zones,
427-
function()
428-
return #df.global.game.main_interface.info.buildings.list[df.buildings_mode_type.ZONES]
429-
end)
423+
layout.experimental_elements.zones)
430424

431425
--- Demo Control Window and Screen ---
432426

0 commit comments

Comments
 (0)