Separate auto loot into logic and icon

This commit is contained in:
M. David
2022-08-19 14:22:17 +02:00
parent e32f26ffad
commit 4980c875c2
6 changed files with 51 additions and 27 deletions

View File

@@ -1,9 +1,6 @@
-- LOOT_READY
function(allstates, e)
aura_env.allstates = allstates
function(e)
local lootInfo = GetLootInfo()
aura_env.filterService:run(lootInfo)
CloseLoot()
return true
end

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,7 @@
local debug = false
local iconDisplayDuration = 3
if not WeakAurasSaved then WeakAurasSaved = {} end
if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
if not WeakAurasSaved.Cyka.ItemCache then WeakAurasSaved.Cyka.ItemCache = {} end
-- itemName, itemLink, itemQuality, itemLevel, itemMinLevel, itemType, itemSubType,itemStackCount, itemEquipLoc, itemTexture, sellPrice, classID, subclassID, bindType,expacID, setID, isCraftingReagent = GetItemInfo(slot)
-- lootIcon, lootName, lootQuantity, currencyID, lootQuality, locked, isQuestItem, questID, isActive = GetLootSlotInfo(slot)
@@ -67,29 +69,14 @@ local doLoot = function(slot)
local itemIcon = getItemIcon(slot) or 134400
local itemName = getItemName(slot) or "Unknown"
itemName = itemName:gsub("\n", ", ")
local itemQuantity = getItemQuantity(slot) or 1
local itemQuality = getItemQuality(slot) or 0
aura_env.debugLog("Drawing icon for " .. itemName .. " with quality " .. itemQuality)
local nameWithColor = aura_env.qualityColors[itemQuality + 1] .. "[" .. itemName .. "]\124r"
local nameWithQuantity = nameWithColor .. " x" .. itemQuantity
aura_env.debugLog("Assigning name" .. nameWithQuantity)
aura_env.allstates[#aura_env.allstates + 1] = {
show = true,
changed = true,
index = GetTime(),
resort = true,
icon = itemIcon,
name = nameWithQuantity,
amount = itemQuantity,
progressType = "timed",
expirationTime = GetTime() + iconDisplayDuration,
duration = iconDisplayDuration,
autoHide = true,
}
if not WeakAurasSaved.Cyka.ItemCache[itemName] then
WeakAurasSaved.Cyka.ItemCache[itemName] = {
icon = itemIcon,
quality = itemQuality,
}
end
end

View File

@@ -0,0 +1,7 @@
-- CHAT_MSG_LOOT
function(allstates, e, msg)
aura_env.allstates = allstates
aura_env.drawIcon(msg)
return true
end

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,32 @@
local iconDisplayDuration = 3
aura_env.getItemInfo = function(msg)
DevTools_Dump(msg)
local name = msg:match("h%[(.+)%]") or ""
local quantity = msg:match("x(%d+)") or 1
local icon = WeakAurasSaved.Cyka.ItemCache[name].icon or 134400
local color = msg:match("%|cff(.){6}") or "ffffff"
return name, icon, quantity, color
end
aura_env.drawIcon = function(msg)
local name, icon, quantity, color = aura_env.getItemInfo(msg)
local formattedName = "\124cff" .. color .. name .. "\124r x" .. quantity
aura_env.allstates[#aura_env.allstates + 1] = {
show = true,
changed = true,
index = GetTime(),
resort = true,
icon = icon,
name = formattedName,
progressType = "timed",
expirationTime = GetTime() + iconDisplayDuration,
duration = iconDisplayDuration,
autoHide = true,
}
end