Refactor touch zone functions to utilize shared UI helpers
This commit is contained in:
@@ -659,50 +659,23 @@ end
|
|||||||
-- Get items filtered by search query
|
-- Get items filtered by search query
|
||||||
local function getFilteredItems()
|
local function getFilteredItems()
|
||||||
ensureItemList()
|
ensureItemList()
|
||||||
local filtered = {}
|
return ui.getFilteredItems(cache.itemList, searchQuery)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function addZone(x1, y1, x2, y2, action, data)
|
local function addZone(x1, y1, x2, y2, action, data)
|
||||||
table.insert(pendingZones, {
|
ui.addZone(pendingZones, x1, y1, x2, y2, action, data)
|
||||||
x1 = x1, y1 = y1, x2 = x2, y2 = y2,
|
|
||||||
action = action, data = data
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function hitTest(x, y)
|
local function hitTest(x, y)
|
||||||
for _, zone in ipairs(touchZones) do
|
return ui.hitTest(touchZones, x, y)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function addSmelterZone(x1, y1, x2, y2, action, data)
|
local function addSmelterZone(x1, y1, x2, y2, action, data)
|
||||||
table.insert(smelterPendingZones, {
|
ui.addZone(smelterPendingZones, x1, y1, x2, y2, action, data)
|
||||||
x1 = x1, y1 = y1, x2 = x2, y2 = y2,
|
|
||||||
action = action, data = data
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function smelterHitTest(x, y)
|
local function smelterHitTest(x, y)
|
||||||
for _, zone in ipairs(smelterTouchZones) do
|
return ui.hitTest(smelterTouchZones, x, y)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user