-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPetCard.lua
52 lines (42 loc) · 1.46 KB
/
PetCard.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
local addon_name, addon = ...
local module = addon:NewModule("PetCard", "AceEvent-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("BattlePetCount")
--
--
--
function module:OnInitialize()
if not self:Setup() then
self:RegisterEvent("ADDON_LOADED", function()
if self:Setup() then
self:UnregisterEvent("ADDON_LOADED")
end
end)
end
end
function module:Setup()
if not C_AddOns.IsAddOnLoaded("Blizzard_Collections") then
return false
end
hooksecurefunc("PetJournal_UpdatePetCard", function()
self:UpdatePetCard()
end)
self:UpdatePetCard()
return true
end
function module:UpdatePetCard()
local QualityFrame = PetJournalPetCard.QualityFrame
if addon.db.profile.enablePetCard and PetJournalPetCard.petID and PetJournalPetCard.speciesID then
local ownedElse = addon:ShortOwnedListOnly(PetJournalPetCard.speciesID, PetJournalPetCard.petID)
if ownedElse then
local _, _, _, _, rarity = C_PetJournal.GetPetStats(PetJournalPetCard.petID)
if rarity then
local color = ITEM_QUALITY_COLORS[rarity-1]
QualityFrame.quality:SetVertexColor(1, 1, 1)
QualityFrame.quality:SetText(format("%s%s|r (%s%s)",
color.hex,
_G["BATTLE_PET_BREED_QUALITY"..rarity],
L["ALSO_OWN_COLON"], ownedElse))
end
end
end
end