From 9ad678a5411494a52b79d4ca152d9193f652edd9 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Sun, 21 Feb 2021 14:24:31 -0500 Subject: [PATCH 1/5] First pass at adding ilvl to inspect frame --- MyAddon.lua | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/MyAddon.lua b/MyAddon.lua index 6686649..a7ac4cb 100755 --- a/MyAddon.lua +++ b/MyAddon.lua @@ -34,11 +34,44 @@ MyAddon.taunts = { [1161] = true, -- Challenging Shout [204079] = true -- Final Stand } +inspectInitialized = false +local InspectFontStrings = {} function MyAddon.OnEvent(self, event, ...) events[event](self, ...) end +function GetUnitFromGuid(guid) + if UnitGUID("target") == guid then return "target" + elseif IsInRaid() then + for i = 1, MAX_RAID_MEMBERS do + if UnitGUID("raid"..i) == guid then return "raid"..i end + end + elseif IsInGroup() then + for i = 1, MAX_PARTY_MEMBERS do + if UnitGUID("party"..i) == guid then return "party"..i end + end + else return nil end +end + +function events:INSPECT_READY(guid) + local itemLevel = C_PaperDollInfo.GetInspectItemLevel(GetUnitFromGuid(guid)) + print(itemLevel) + + if not inspectInitialized then + print("initializing") + InspectFontStrings["itemLevel"] = InspectFrame:CreateFontString(nil, "OVERLAY") + InspectFontStrings["itemLevel"]:SetPoint("BOTTOMRIGHT", -5, 5) + InspectFontStrings["itemLevel"]:SetFont("Fonts\\FRIZQT__.ttf", 24, "OUTLINE") + InspectFontStrings["itemLevel"]:SetTextColor(1, 1, 1) + + inspectInitialized = true + end + + InspectFontStrings["itemLevel"]:SetText(itemLevel) + print(InspectFontStrings["itemLevel"]:GetText()) +end + function events:GOSSIP_SHOW() local isNecroticWake = GetZoneText() == 'The Necrotic Wake' local isSteward = GetUnitName('npc') == 'Steward' -- 2.45.2 From c2df6ac9820c11a7194a108d7acd6dfa1b3e5583 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Sun, 21 Feb 2021 14:26:38 -0500 Subject: [PATCH 2/5] Only add when we know it --- MyAddon.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/MyAddon.lua b/MyAddon.lua index a7ac4cb..eef31fc 100755 --- a/MyAddon.lua +++ b/MyAddon.lua @@ -55,9 +55,6 @@ function GetUnitFromGuid(guid) end function events:INSPECT_READY(guid) - local itemLevel = C_PaperDollInfo.GetInspectItemLevel(GetUnitFromGuid(guid)) - print(itemLevel) - if not inspectInitialized then print("initializing") InspectFontStrings["itemLevel"] = InspectFrame:CreateFontString(nil, "OVERLAY") @@ -68,8 +65,12 @@ function events:INSPECT_READY(guid) inspectInitialized = true end - InspectFontStrings["itemLevel"]:SetText(itemLevel) - print(InspectFontStrings["itemLevel"]:GetText()) + + unit = GetUnitFromGuid(guid) + if unit then + local itemLevel = C_PaperDollInfo.GetInspectItemLevel(unit) + InspectFontStrings["itemLevel"]:SetText(itemLevel) + end end function events:GOSSIP_SHOW() -- 2.45.2 From 201078c9268128d5fdee6480b7d13b8c25ddb8f8 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Sun, 21 Feb 2021 14:26:52 -0500 Subject: [PATCH 3/5] Remove debug statement --- MyAddon.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/MyAddon.lua b/MyAddon.lua index eef31fc..80f6654 100755 --- a/MyAddon.lua +++ b/MyAddon.lua @@ -56,7 +56,6 @@ end function events:INSPECT_READY(guid) if not inspectInitialized then - print("initializing") InspectFontStrings["itemLevel"] = InspectFrame:CreateFontString(nil, "OVERLAY") InspectFontStrings["itemLevel"]:SetPoint("BOTTOMRIGHT", -5, 5) InspectFontStrings["itemLevel"]:SetFont("Fonts\\FRIZQT__.ttf", 24, "OUTLINE") -- 2.45.2 From 4b034effe8e0d4b31e34b9be51d3c64e98ac12e9 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Sun, 21 Feb 2021 14:31:21 -0500 Subject: [PATCH 4/5] Make sure we can inspect the init --- MyAddon.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MyAddon.lua b/MyAddon.lua index 80f6654..22ac618 100755 --- a/MyAddon.lua +++ b/MyAddon.lua @@ -66,7 +66,7 @@ function events:INSPECT_READY(guid) unit = GetUnitFromGuid(guid) - if unit then + if unit and CanInspect(unit) then local itemLevel = C_PaperDollInfo.GetInspectItemLevel(unit) InspectFontStrings["itemLevel"]:SetText(itemLevel) end -- 2.45.2 From 36a10010b3382d7e0022cc2c0427fb3164284c96 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Sun, 21 Feb 2021 15:29:53 -0500 Subject: [PATCH 5/5] Protect self xD --- MyAddon.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MyAddon.lua b/MyAddon.lua index 7d822a5..1b389fb 100755 --- a/MyAddon.lua +++ b/MyAddon.lua @@ -59,7 +59,7 @@ function GetUnitFromGuid(guid) end function events:INSPECT_READY(guid) - if not inspectInitialized then + if not inspectInitialized and InspectFrame then InspectFontStrings["itemLevel"] = InspectFrame:CreateFontString(nil, "OVERLAY") InspectFontStrings["itemLevel"]:SetPoint("BOTTOMRIGHT", -5, 5) InspectFontStrings["itemLevel"]:SetFont("Fonts\\FRIZQT__.ttf", 24, "OUTLINE") -- 2.45.2