diff --git a/Code/CombatEvents.lua b/Code/CombatEvents.lua index 297cd87..c5fdb0f 100644 --- a/Code/CombatEvents.lua +++ b/Code/CombatEvents.lua @@ -385,6 +385,12 @@ function module:OnOptionsCreate() db[category][arg][name] = value end + local qualityPoor = select(4, GetItemQualityColor(0)) + local qualityCommon = select(4, GetItemQualityColor(1)) + local qualityUncommon = select(4, GetItemQualityColor(2)) + local qualityRare = select(4, GetItemQualityColor(3)) + local qualityEpic = select(4, GetItemQualityColor(4)) + local events_opt events_opt = { type = 'group', @@ -421,6 +427,66 @@ function module:OnOptionsCreate() }, }, }, + lootoptions = { + name = "Loot options", + type = 'group', + inline = true, + args = { + lootQuestItem = { + type = 'toggle', + name = L["Always show quest items"], + set = function(info, value) + setOption(info, value) + end, + order = 1, + }, + sep = { + type = "description", + name = "", + order = 2, + }, + lootQualityPoor = { + type = 'toggle', + name = "|c"..qualityPoor..L["Poor"].."|r", + set = function(info, value) + setOption(info, value) + end, + order = 3, + }, + lootQualityCommon = { + type = 'toggle', + name = "|c"..qualityCommon..L["Common"].."|r", + set = function(info, value) + setOption(info, value) + end, + order = 4, + }, + lootQualityUncommon = { + type = 'toggle', + name = "|c"..qualityUncommon..L["Uncommon"].."|r", + set = function(info, value) + setOption(info, value) + end, + order = 5, + }, + lootQualityRare = { + type = 'toggle', + name = "|c"..qualityRare..L["Rare"].."|r", + set = function(info, value) + setOption(info, value) + end, + order = 6, + }, + lootQualityEpic = { + type = 'toggle', + name = "|c"..qualityEpic..L["Epic"].."|r", + set = function(info, value) + setOption(info, value) + end, + order = 7, + }, + }, + }, textoptions = { name = L["Text options"], type = 'group', diff --git a/Data/Loot.lua b/Data/Loot.lua index 5304b01..a890520 100644 --- a/Data/Loot.lua +++ b/Data/Loot.lua @@ -3,6 +3,7 @@ local Parrot = ns.addon if not Parrot then return end local L = LibStub("AceLocale-3.0"):GetLocale("Parrot") +local mod = Parrot:NewModule("LootData") local newDict = Parrot.newDict local Deformat = Parrot.Deformat @@ -17,6 +18,44 @@ local LOOT_ITEM_REFUND = _G.LOOT_ITEM_REFUND local LOOT_ITEM_REFUND_MULTIPLE = _G.LOOT_ITEM_REFUND_MULTIPLE local ITEM_QUALITY_COLORS = _G.ITEM_QUALITY_COLORS +local db + +function mod:OnEnable() + db = Parrot.db:GetNamespace("CombatEvents").profile +end + +function mod:OnProfileChanged() + db = Parrot.db:GetNamespace("CombatEvents").profile +end + +local function parrotShowItemLooted(quality, itemClassID) + if db.lootQuestItem and itemClassID == 12 then + return true + end + + if quality == 0 and db.lootQualityPoor then + return true + end + + if quality == 1 and db.lootQualityCommon then + return true + end + + if quality == 2 and db.lootQualityUncommon then + return true + end + + if quality == 3 and db.lootQualityRare then + return true + end + + if quality >= 4 and db.lootQualityEpic then + return true + end + + return false +end + local function parse_CHAT_MSG_LOOT(chatmsg) -- check for multiple local itemLink, amount = Deformat(chatmsg, LOOT_ITEM_SELF_MULTIPLE) @@ -49,18 +88,21 @@ local function parse_CHAT_MSG_LOOT(chatmsg) if not amount then amount = 1 end - local name, _, quality, _, _, _, _, _, _, texture = GetItemInfo(itemLink) - local color = ITEM_QUALITY_COLORS[quality] - if color then - name = ("%s%s|r"):format(color.hex, name) - end + local name, _, quality, _, _, itemType, _, _, _, texture, _, itemClassID = GetItemInfo(itemLink) + + if parrotShowItemLooted(quality, itemClassID) then + local color = ITEM_QUALITY_COLORS[quality] + if color then + name = ("%s%s|r"):format(color.hex, name) + end - return newDict( - "name", name, - "amount", amount, - "total", GetItemCount(itemLink) + amount, - "icon", texture - ) + return newDict( + "name", name, + "amount", amount, + "total", GetItemCount(itemLink) + amount, + "icon", texture + ) + end end end diff --git a/Locales/enUS.lua b/Locales/enUS.lua index cd11960..6682873 100644 --- a/Locales/enUS.lua +++ b/Locales/enUS.lua @@ -1,7 +1,7 @@ local debug = true ---@debug@ +--[==[@debug@ debug = nil ---@end-debug@ +--@end-debug@]==] local L = LibStub("AceLocale-3.0"):NewLocale("Parrot", "enUS", true, debug) @@ -600,3 +600,10 @@ L["[Text] (crit)"] = true L["[Text] (crushing)"] = true L["[Text] (glancing)"] = true L["[[Spell] ready!]"] = true +L["Loot options"] = true +L["Always show quest items"] = true +L["Poor"] = true +L["Common"] = true +L["Uncommon"] = true +L["Rare"] = true +L["Epic"] = true