Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added options to show loot based on item quality and always show quest items #104

Open
wants to merge 1 commit into
base: classic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions Code/CombatEvents.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
64 changes: 53 additions & 11 deletions Data/Loot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand Down
11 changes: 9 additions & 2 deletions Locales/enUS.lua
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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