Skip to content

Commit

Permalink
handle character frame item flyouts
Browse files Browse the repository at this point in the history
  • Loading branch information
kodewdle committed Apr 24, 2024
1 parent 83a20d6 commit e010890
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 9 deletions.
78 changes: 71 additions & 7 deletions ElvUI/Cata/Modules/Skins/Character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ local UnitResistance = UnitResistance
local GetItemQualityColor = GetItemQualityColor
local GetInventoryItemQuality = GetInventoryItemQuality
local HasPetUI = HasPetUI
local GetCVar = GetCVar

local PAPERDOLLFRAME_TOOLTIP_FORMAT = PAPERDOLLFRAME_TOOLTIP_FORMAT
local HIGHLIGHT_FONT_COLOR_CODE = HIGHLIGHT_FONT_COLOR_CODE
Expand All @@ -20,6 +19,12 @@ local HONOR_CURRENCY = HONOR_CURRENCY

local spellSchoolIcon = [[Interface\PaperDollInfoFrame\SpellSchoolIcon]]

local FLYOUT_LOCATIONS = {
[0xFFFFFFFF] = 'PLACEINBAGS',
[0xFFFFFFFE] = 'IGNORESLOT',
[0xFFFFFFFD] = 'UNIGNORESLOT'
}

local function EquipmentManagerPane_Update(frame)
for _, child in next, { frame.ScrollTarget:GetChildren() } do
if child.icon and not child.isSkinned then
Expand All @@ -46,16 +51,16 @@ local function TitleManagerPane_Update(frame)
end
end

local function PaperDollItemSlotButtonUpdate(frame)
if not frame.SetBackdropBorderColor then return end
local function HandleItemButtonQuality(button)
if not button.SetBackdropBorderColor then return end

local id = frame:GetID()
local id = button.id or button:GetID()
local rarity = id and GetInventoryItemQuality('player', id)
if rarity and rarity > 1 then
local r, g, b = GetItemQualityColor(rarity)
frame:SetBackdropBorderColor(r, g, b)
button:SetBackdropBorderColor(r, g, b)
else
frame:SetBackdropBorderColor(unpack(E.media.bordercolor))
button:SetBackdropBorderColor(unpack(E.media.bordercolor))
end
end

Expand Down Expand Up @@ -208,6 +213,51 @@ local function HandleTabs()
end
end

local function EquipmentDisplayButton(button)
if not button.isHooked then
button:SetNormalTexture(E.ClearTexture)
button:SetPushedTexture(E.ClearTexture)
button:SetTemplate()
button:StyleButton()

button.icon:SetInside()
button.icon:SetTexCoord(unpack(E.TexCoords))

button.isHooked = true
end

if FLYOUT_LOCATIONS[button.location] then -- special slots
button:SetBackdropBorderColor(unpack(E.media.bordercolor))
end
end

local function EquipmentUpdateItems()
local frame = _G.EquipmentFlyoutFrame.buttonFrame
if not frame.template then
frame:StripTextures()
frame:SetTemplate('Transparent')
end

local width, height = frame:GetSize()
frame:Size(width+3, height)

for _, button in next, _G.EquipmentFlyoutFrame.buttons do
EquipmentDisplayButton(button)
end
end

local function EquipmentUpdateNavigation()
local navi = _G.EquipmentFlyoutFrame.NavigationFrame
if not navi then return end

navi:ClearAllPoints()
navi:Point('TOPLEFT', _G.EquipmentFlyoutFrameButtons, 'BOTTOMLEFT', 0, -E.Border - E.Spacing)
navi:Point('TOPRIGHT', _G.EquipmentFlyoutFrameButtons, 'BOTTOMRIGHT', 0, -E.Border - E.Spacing)

navi:StripTextures()
navi:SetTemplate('Transparent')
end

function S:CharacterFrame()
if not (E.private.skins.blizzard.enable and E.private.skins.blizzard.character) then return end

Expand Down Expand Up @@ -430,7 +480,21 @@ function S:CharacterFrame()
hooksecurefunc('TokenFrame_Update', UpdateCurrencySkins)
hooksecurefunc('PaperDollFrame_UpdateSidebarTabs', FixSidebarTabCoords)
hooksecurefunc('PaperDollFrame_SetResistance', PaperDollFrameSetResistance)
hooksecurefunc('PaperDollItemSlotButton_Update', PaperDollItemSlotButtonUpdate)
hooksecurefunc('PaperDollItemSlotButton_Update', HandleItemButtonQuality)

-- Equipment Flyout
_G.EquipmentFlyoutFrameHighlight:StripTextures()
_G.EquipmentFlyoutFrameButtons.bg1:SetAlpha(0)
_G.EquipmentFlyoutFrameButtons:DisableDrawLayer('ARTWORK')

S:HandleNextPrevButton(_G.EquipmentFlyoutFrame.NavigationFrame.PrevButton)
S:HandleNextPrevButton(_G.EquipmentFlyoutFrame.NavigationFrame.NextButton)

hooksecurefunc('EquipmentFlyout_SetBackgroundTexture', EquipmentUpdateNavigation)
hooksecurefunc('EquipmentFlyout_UpdateItems', EquipmentUpdateItems) -- Swap item flyout frame (shown when holding alt over a slot)

hooksecurefunc('EquipmentFlyout_DisplayButton', HandleItemButtonQuality)
hooksecurefunc('EquipmentFlyout_DisplaySpecialButton', HandleItemButtonQuality)

-- Tabs
for i = 1, #_G.CHARACTERFRAME_SUBFRAMES do
Expand Down
4 changes: 2 additions & 2 deletions ElvUI/Mainline/Modules/Skins/Character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local E, L, V, P, G = unpack(ElvUI)
local S = E:GetModule('Skins')

local _G = _G
local pairs, ipairs = pairs, ipairs
local pairs = pairs
local unpack, next = unpack, next
local hooksecurefunc = hooksecurefunc
local CreateColor = CreateColor
Expand Down Expand Up @@ -161,7 +161,7 @@ local function EquipmentUpdateItems()
local width, height = frame:GetSize()
frame:Size(width+3, height)

for _, button in ipairs(_G.EquipmentFlyoutFrame.buttons) do
for _, button in next, _G.EquipmentFlyoutFrame.buttons do
EquipmentDisplayButton(button)
end
end
Expand Down

0 comments on commit e010890

Please sign in to comment.