Skip to content

Commit

Permalink
better compatibility with DejaCharacterStats (item level on character…
Browse files Browse the repository at this point in the history
… page)
  • Loading branch information
kodewdle committed Jul 30, 2024
1 parent 28e5830 commit 750fe81
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 49 deletions.
5 changes: 3 additions & 2 deletions ElvUI/Cata/Modules/Skins/Character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ local function TabTextureCoords(tex, x1)
end

local function FixSidebarTabCoords()
local hasDejaCharacterStats = E:IsAddOnEnabled('DejaCharacterStats')

local index = 1
local tab = _G['PaperDollSidebarTab'..index]
while tab do
Expand All @@ -116,8 +118,7 @@ local function FixSidebarTabCoords()
tab.Highlight:SetColorTexture(1, 1, 1, 0.3)
tab.Highlight:SetAllPoints()

-- Check for DejaCharacterStats. Lets hide the Texture if the AddOn is loaded.
if E:IsAddOnEnabled('DejaCharacterStats') then
if hasDejaCharacterStats then
tab.Hider:SetTexture()
else
tab.Hider:SetColorTexture(0, 0, 0, 0.8)
Expand Down
90 changes: 46 additions & 44 deletions ElvUI/Core/Modules/Misc/InfoItemLevel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,48 +120,50 @@ function M:ClearPageInfo(frame, which)
end
end

function M:CheckStatsItemLevel()
return E.Retail and not E:IsAddOnEnabled('DejaCharacterStats')
end

function M:ToggleItemLevelInfo(setupCharacterPage, config)
if E.Classic then return end

if not E:IsAddOnEnabled('DejaCharacterStats') then
if setupCharacterPage then
M:CreateSlotStrings(_G.CharacterFrame, 'Character')
end

if E.db.general.itemLevel.displayCharacterInfo then
M:RegisterEvent('AZERITE_ESSENCE_UPDATE', 'UpdateCharacterInfo')
M:RegisterEvent('PLAYER_EQUIPMENT_CHANGED', 'UpdateCharacterInfo')
M:RegisterEvent('PLAYER_AVG_ITEM_LEVEL_UPDATE', 'UpdateCharacterInfo')
M:RegisterEvent('UPDATE_INVENTORY_DURABILITY', 'UpdateCharacterInfo')
if setupCharacterPage then
M:CreateSlotStrings(_G.CharacterFrame, 'Character')
end

if E.Retail then
_G.CharacterStatsPane.ItemLevelFrame.Value:Hide()
end
if E.db.general.itemLevel.displayCharacterInfo then
M:RegisterEvent('AZERITE_ESSENCE_UPDATE', 'UpdateCharacterInfo')
M:RegisterEvent('PLAYER_EQUIPMENT_CHANGED', 'UpdateCharacterInfo')
M:RegisterEvent('PLAYER_AVG_ITEM_LEVEL_UPDATE', 'UpdateCharacterInfo')
M:RegisterEvent('UPDATE_INVENTORY_DURABILITY', 'UpdateCharacterInfo')

if not _G.CharacterFrame.CharacterInfoHooked then
_G.CharacterFrame:HookScript('OnShow', M.UpdateCharacterInfo)
_G.CharacterFrame.CharacterInfoHooked = true
end
if M:CheckStatsItemLevel() then
_G.CharacterStatsPane.ItemLevelFrame.Value:Hide()
end

if not setupCharacterPage then
if config then
M:UpdateSlotPoints('Character')
end
if not _G.CharacterFrame.CharacterInfoHooked then
_G.CharacterFrame:HookScript('OnShow', M.UpdateCharacterInfo)
_G.CharacterFrame.CharacterInfoHooked = true
end

M:UpdateCharacterInfo()
if not setupCharacterPage then
if config then
M:UpdateSlotPoints('Character')
end
else
M:UnregisterEvent('AZERITE_ESSENCE_UPDATE')
M:UnregisterEvent('PLAYER_EQUIPMENT_CHANGED')
M:UnregisterEvent('PLAYER_AVG_ITEM_LEVEL_UPDATE')
M:UnregisterEvent('UPDATE_INVENTORY_DURABILITY')

if E.Retail then
_G.CharacterStatsPane.ItemLevelFrame.Value:Show()
end
M:UpdateCharacterInfo()
end
else
M:UnregisterEvent('AZERITE_ESSENCE_UPDATE')
M:UnregisterEvent('PLAYER_EQUIPMENT_CHANGED')
M:UnregisterEvent('PLAYER_AVG_ITEM_LEVEL_UPDATE')
M:UnregisterEvent('UPDATE_INVENTORY_DURABILITY')

M:ClearPageInfo(_G.CharacterFrame, 'Character')
if M:CheckStatsItemLevel() then
_G.CharacterStatsPane.ItemLevelFrame.Value:Show()
end

M:ClearPageInfo(_G.CharacterFrame, 'Character')
end

if E.db.general.itemLevel.displayInspectInfo then
Expand Down Expand Up @@ -262,30 +264,30 @@ function M:UpdateAverageString(frame, which, iLevelDB)
avgItemLevel = E:CalculateAverageItemLevel(iLevelDB, frame.unit)
end

if avgItemLevel then
if avgItemLevel and (not charPage or not E:IsAddOnEnabled('DejaCharacterStats')) then
if charPage then
frame.ItemLevelText:SetText(avgItemLevel)

if E.Retail then
if M:CheckStatsItemLevel() then
frame.ItemLevelText:SetTextColor(_G.CharacterStatsPane.ItemLevelFrame.Value:GetTextColor())
end
else
frame.ItemLevelText:SetText(avgItemLevel)
end
else
frame.ItemLevelText:SetText('')
end

-- we have to wait to do this on inspect so handle it in here
if not E.db.general.itemLevel.itemLevelRarity then
for i = 1, numInspectItems do
local ilvl = i ~= 4 and iLevelDB[i]
if ilvl then
local inspectItem = _G[which..InspectItems[i]]
local r, g, b = E:ColorizeItemLevel(ilvl - (avgTotal or avgItemLevel))
inspectItem.iLvlText:SetTextColor(r, g, b)
end
-- we have to wait to do this on inspect so handle it in here
if not E.db.general.itemLevel.itemLevelRarity then
for i = 1, numInspectItems do
local ilvl = i ~= 4 and iLevelDB[i]
local inspectItem = ilvl and _G[which..InspectItems[i]]
if inspectItem then
local r, g, b = E:ColorizeItemLevel(ilvl - (avgTotal or avgItemLevel or 0))
inspectItem.iLvlText:SetTextColor(r, g, b)
end
end
else
frame.ItemLevelText:SetText('')
end
end

Expand Down
5 changes: 3 additions & 2 deletions ElvUI/Mainline/Modules/Skins/Character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ local function TabTextureCoords(tex, x1)
end

local function FixSidebarTabCoords()
local hasDejaCharacterStats = E:IsAddOnEnabled('DejaCharacterStats')

local index = 1
local tab = _G['PaperDollSidebarTab'..index]
while tab do
Expand All @@ -204,8 +206,7 @@ local function FixSidebarTabCoords()
tab.Highlight:SetColorTexture(1, 1, 1, 0.3)
tab.Highlight:SetAllPoints()

-- Check for DejaCharacterStats. Lets hide the Texture if the AddOn is loaded.
if E:IsAddOnEnabled('DejaCharacterStats') then
if hasDejaCharacterStats then
tab.Hider:SetTexture()
else
tab.Hider:SetColorTexture(0, 0, 0, 0.8)
Expand Down
2 changes: 1 addition & 1 deletion ElvUI_Options/Core/General.lua
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ blizz.lootRollGroup.args.fontGroup.inline = true

blizz.itemLevelInfo = ACH:Group(L["Item Level"], nil, 40, nil, function(info) return E.db.general.itemLevel[info[#info]] end, function(info, value) E.db.general.itemLevel[info[#info]] = value M:ToggleItemLevelInfo(nil, true) end, nil, E.Classic)
blizz.itemLevelInfo.args.displayInspectInfo = ACH:Toggle(L["Display Inspect Info"], L["Shows item level of each item, enchants, and gems when inspecting another player."], 1)
blizz.itemLevelInfo.args.displayCharacterInfo = ACH:Toggle(L["Display Character Info"], L["Shows item level of each item, enchants, and gems on the character page."], 2, nil, nil, nil, nil, nil, function() return E:IsAddOnEnabled('DejaCharacterStats') end)
blizz.itemLevelInfo.args.displayCharacterInfo = ACH:Toggle(L["Display Character Info"], L["Shows item level of each item, enchants, and gems on the character page."], 2)
blizz.itemLevelInfo.args.enchantAbbrev = ACH:Toggle(L["Abbreviate Enchants"], nil, 3)
blizz.itemLevelInfo.args.itemLevelRarity = ACH:Toggle(L["Rarity Color"], nil, 4)
blizz.itemLevelInfo.args.showEnchants = ACH:Toggle(L["Show Enchants"], nil, 10)
Expand Down

0 comments on commit 750fe81

Please sign in to comment.