Resort overview every 30seconds
This commit is contained in:
+33
-23
@@ -404,42 +404,52 @@ end
|
|||||||
|
|
||||||
drawOverview = function()
|
drawOverview = function()
|
||||||
local items = getBaseItemIds()
|
local items = getBaseItemIds()
|
||||||
local itemCounts = getMeItemCounts(items)
|
|
||||||
local sortedItemIds = {}
|
local sortedItemIds = {}
|
||||||
|
local visibleItemCount = 0
|
||||||
|
|
||||||
for i = 1, #items do
|
local function renderOverview()
|
||||||
sortedItemIds[i] = items[i]
|
local itemCounts = getMeItemCounts(items)
|
||||||
end
|
|
||||||
|
|
||||||
table.sort(sortedItemIds, function(a, b)
|
for i = 1, #items do
|
||||||
local countA = itemCounts[a] or 0
|
sortedItemIds[i] = items[i]
|
||||||
local countB = itemCounts[b] or 0
|
|
||||||
|
|
||||||
if countA ~= countB then
|
|
||||||
return countA > countB
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return a < b
|
table.sort(sortedItemIds, function(a, b)
|
||||||
end)
|
local countA = itemCounts[a] or 0
|
||||||
|
local countB = itemCounts[b] or 0
|
||||||
|
|
||||||
local visibleItemCount = math.min(#sortedItemIds, 9)
|
if countA ~= countB then
|
||||||
|
return countA > countB
|
||||||
|
end
|
||||||
|
|
||||||
frame.buffer:clear()
|
return a < b
|
||||||
|
end)
|
||||||
|
|
||||||
for i = 1, visibleItemCount do
|
visibleItemCount = math.min(#sortedItemIds, 9)
|
||||||
local itemId = sortedItemIds[i]
|
|
||||||
local item = getItemById(itemId)
|
frame.buffer:clear()
|
||||||
local icon = getItemIcon(item) or getFallbackIcon()
|
|
||||||
drawItem(icon, 4+(8+4)*((i-1)%3), 2+(5+1)*math.floor((i-1)/3), itemCounts[itemId] or 0)
|
for i = 1, visibleItemCount do
|
||||||
|
local itemId = sortedItemIds[i]
|
||||||
|
local item = getItemById(itemId)
|
||||||
|
local icon = getItemIcon(item) or getFallbackIcon()
|
||||||
|
drawItem(icon, 4+(8+4)*((i-1)%3), 2+(5+1)*math.floor((i-1)/3), itemCounts[itemId] or 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
assertBufferValid(frame)
|
||||||
|
frame:drawBuffer()
|
||||||
end
|
end
|
||||||
|
|
||||||
assertBufferValid(frame)
|
renderOverview()
|
||||||
frame:drawBuffer()
|
local refreshTimer = os.startTimer(30)
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local _, side, x, y = os.pullEvent("monitor_touch")
|
local event, p1, x, y = os.pullEvent()
|
||||||
|
|
||||||
if side == monName then
|
if event == "timer" and p1 == refreshTimer then
|
||||||
|
renderOverview()
|
||||||
|
refreshTimer = os.startTimer(30)
|
||||||
|
elseif event == "monitor_touch" and p1 == monName then
|
||||||
local col = math.floor((x - 4) / 12)
|
local col = math.floor((x - 4) / 12)
|
||||||
local row = math.floor((y - 2) / 6)
|
local row = math.floor((y - 2) / 6)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user