@@ -262,7 +262,8 @@ function SearchGui.build_results(data, statistics, frame, check_result_found, in
262262 column_count = 10 ,
263263 style = " slot_table" ,
264264 children = SearchGui .build_surface_results (surface_name , surface_data .logistics )
265- }, {
265+ },
266+ {
266267 type = " table" ,
267268 column_count = 10 ,
268269 style = " slot_table" ,
@@ -339,20 +340,29 @@ function SearchGui.build_invalid_state(frame)
339340 })
340341end
341342
342- --- @param frame LuaGuiElement
343- function SearchGui .add_loading_results (frame )
344- gui .add (frame ,
345- {
346- type = " label" ,
347- caption = {" search-gui.searching" },
348- tooltip = {" search-gui.searching-tooltip" , {" " , " [font=default-semibold]" , {" mod-setting-name.fs-non-blocking-search" }, " [/font]" }}
349- }
350- )
343+ --- @param refs SearchGuiRefs
344+ --- @param progress ? double
345+ function SearchGui .show_search_progress (refs , progress )
346+ refs .searching_label .visible = true
347+ refs .search_progressbar .visible = progress ~= nil
348+
349+ if progress ~= nil then
350+ refs .search_progressbar .value = progress
351+ refs .search_progressbar .tooltip = {' ' , math.floor (progress * 100 ), ' %' }
352+ end
351353end
352354
353- function SearchGui .build_loading_results (frame )
354- frame .clear ()
355- SearchGui .add_loading_results (frame )
355+ --- @param refs SearchGuiRefs
356+ function SearchGui .hide_search_progress (refs )
357+ refs .searching_label .visible = false
358+ refs .search_progressbar .visible = false
359+ end
360+
361+ --- @param refs SearchGuiRefs
362+ --- @param progress ? double
363+ function SearchGui .build_loading_results (refs , progress )
364+ refs .result_flow .clear ()
365+ SearchGui .show_search_progress (refs , progress )
356366end
357367
358368--- @param player LuaPlayer
@@ -584,12 +594,37 @@ function SearchGui.build(player)
584594 children = {
585595 {
586596 type = " flow" ,
587- ref = {" result_flow" },
588597 direction = " vertical" ,
589598 children = {
590599 {
591- type = " label" ,
592- caption = {" search-gui.explanation" },
600+ type = " flow" ,
601+ direction = " vertical" ,
602+ children = {
603+ {
604+ type = " label" ,
605+ ref = { " searching_label" },
606+ visible = false ,
607+ caption = {" search-gui.searching" },
608+ tooltip = {" search-gui.searching-tooltip" , {" " , " [font=default-semibold]" , {" mod-setting-name.fs-non-blocking-search" }, " [/font]" }}
609+ },
610+ {
611+ type = " progressbar" ,
612+ ref = { " search_progressbar" },
613+ visible = false ,
614+ value = 0
615+ }
616+ }
617+ },
618+ {
619+ type = " flow" ,
620+ ref = {" result_flow" },
621+ direction = " vertical" ,
622+ children = {
623+ {
624+ type = " label" ,
625+ caption = {" search-gui.explanation" },
626+ }
627+ }
593628 }
594629 }
595630 }
@@ -755,7 +790,11 @@ function SearchGui.start_search(player, player_data, _, _, immediate)
755790 search_started = Search .find_machines (item , force , state , player , immediate )
756791 refs .subheader_title .caption = get_signal_name (item ) or " "
757792 if search_started then
758- SearchGui .build_loading_results (refs .result_flow )
793+ if storage .current_searches [player .index ].blocking then
794+ SearchGui .build_loading_results (refs , nil )
795+ else
796+ SearchGui .build_loading_results (refs , 0 )
797+ end
759798 else
760799 SearchGui .build_results ({}, {}, refs .result_flow )
761800 end
0 commit comments