From 50fa771ca4bad2ec4af948d9e73661d8ceedab1f Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Sun, 22 Mar 2026 01:56:07 -0400 Subject: [PATCH] Refactor touch zone functions to utilize shared UI helpers --- inventoryManager.lua | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/inventoryManager.lua b/inventoryManager.lua index 4884415..c5cf9f2 100644 --- a/inventoryManager.lua +++ b/inventoryManager.lua @@ -659,50 +659,23 @@ end -- Get items filtered by search query local function getFilteredItems() ensureItemList() - local filtered = {} - for _, item in ipairs(cache.itemList) do - if searchQuery == "" then - table.insert(filtered, item) - else - local lower = item.name:lower():gsub("minecraft:", ""):gsub("_", " ") - if lower:find(searchQuery:lower(), 1, true) then - table.insert(filtered, item) - end - end - end - return filtered + return ui.getFilteredItems(cache.itemList, searchQuery) end local function addZone(x1, y1, x2, y2, action, data) - table.insert(pendingZones, { - x1 = x1, y1 = y1, x2 = x2, y2 = y2, - action = action, data = data - }) + ui.addZone(pendingZones, x1, y1, x2, y2, action, data) end local function hitTest(x, y) - for _, zone in ipairs(touchZones) do - if x >= zone.x1 and x <= zone.x2 and y >= zone.y1 and y <= zone.y2 then - return zone.action, zone.data - end - end - return nil, nil + return ui.hitTest(touchZones, x, y) end local function addSmelterZone(x1, y1, x2, y2, action, data) - table.insert(smelterPendingZones, { - x1 = x1, y1 = y1, x2 = x2, y2 = y2, - action = action, data = data - }) + ui.addZone(smelterPendingZones, x1, y1, x2, y2, action, data) end local function smelterHitTest(x, y) - for _, zone in ipairs(smelterTouchZones) do - if x >= zone.x1 and x <= zone.x2 and y >= zone.y1 and y <= zone.y2 then - return zone.action, zone.data - end - end - return nil, nil + return ui.hitTest(smelterTouchZones, x, y) end -------------------------------------------------