|
717 | 717 | local search_matched_indices = {} |
718 | 718 | local search_current_match_idx = 0 |
719 | 719 | local order_names_checksum = nil |
720 | | -local search_overlay_instance = nil |
721 | 720 |
|
722 | 721 | local function perform_search(text) |
723 | 722 | local matches = {} |
@@ -758,6 +757,7 @@ OrdersSearchOverlay.ATTRS{ |
758 | 757 | default_enabled=true, |
759 | 758 | viewscreens='dwarfmode/Info/WORK_ORDERS/Default', |
760 | 759 | frame={w=26, h=4}, |
| 760 | + overlay_onupdate_max_freq_seconds=1, |
761 | 761 | } |
762 | 762 |
|
763 | 763 | function OrdersSearchOverlay:init() |
@@ -827,7 +827,16 @@ function OrdersSearchOverlay:init() |
827 | 827 | } |
828 | 828 |
|
829 | 829 | self.minimized = false |
830 | | - search_overlay_instance = self |
| 830 | +end |
| 831 | + |
| 832 | +function OrdersSearchOverlay:overlay_onupdate() |
| 833 | + if self.minimized then return end |
| 834 | + |
| 835 | + local new_checksum = calculate_order_names_checksum() |
| 836 | + if new_checksum ~= order_names_checksum then |
| 837 | + order_names_checksum = new_checksum |
| 838 | + self:update_filter() |
| 839 | + end |
831 | 840 | end |
832 | 841 |
|
833 | 842 | function OrdersSearchOverlay:update_filter() |
@@ -958,8 +967,6 @@ local LIST_START_Y_ONE_TABS_ROW = 8 |
958 | 967 | local LIST_START_Y_TWO_TABS_ROWS = 10 |
959 | 968 | local BOTTOM_MARGIN = 9 |
960 | 969 | local ARROW_X = 10 |
961 | | -local CHECK_FRAME_INTERVAL = 50 |
962 | | -local check_frame_counter = 0 |
963 | 970 |
|
964 | 971 | local function getListStartY() |
965 | 972 | local rect = gui.get_interface_rect() |
@@ -1031,25 +1038,6 @@ function OrderHighlightOverlay:render(dc) |
1031 | 1038 |
|
1032 | 1039 | if mi.job_details.open or #search_matched_indices == 0 then return end |
1033 | 1040 |
|
1034 | | - -- Periodic check for order name changes |
1035 | | - check_frame_counter = check_frame_counter + 1 |
1036 | | - if check_frame_counter >= CHECK_FRAME_INTERVAL then |
1037 | | - check_frame_counter = 0 |
1038 | | - |
1039 | | - local new_checksum = calculate_order_names_checksum() |
1040 | | - if new_checksum ~= order_names_checksum then |
1041 | | - order_names_checksum = new_checksum |
1042 | | - |
1043 | | - -- Auto re-run search if active |
1044 | | - if search_overlay_instance and not search_overlay_instance.minimized then |
1045 | | - search_overlay_instance:update_filter() |
1046 | | - end |
1047 | | - end |
1048 | | - end |
1049 | | - |
1050 | | - -- Draw highlight arrows for all matches in viewport |
1051 | | - if #search_matched_indices == 0 then return end |
1052 | | - |
1053 | 1041 | local selected_pen = dfhack.pen.parse{ |
1054 | 1042 | fg=COLOR_BLACK, |
1055 | 1043 | bg=COLOR_WHITE, |
|
0 commit comments