Skip to content

Commit

Permalink
pull char skin update from cata branch
Browse files Browse the repository at this point in the history
  • Loading branch information
kodewdle committed Apr 13, 2024
1 parent 19d5eea commit 9515250
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 98 deletions.
64 changes: 33 additions & 31 deletions ElvUI/Classic/Modules/Skins/Character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local S = E:GetModule('Skins')
local _G = _G
local next = next
local unpack, pairs = unpack, pairs
local hooksecurefunc = hooksecurefunc

local HasPetUI = HasPetUI
local GetNumFactions = GetNumFactions
Expand All @@ -12,7 +13,6 @@ local GetItemQualityColor = GetItemQualityColor
local GetInventoryItemQuality = GetInventoryItemQuality
local FauxScrollFrame_GetOffset = FauxScrollFrame_GetOffset

local hooksecurefunc = hooksecurefunc
local NUM_FACTIONS_DISPLAYED = NUM_FACTIONS_DISPLAYED
local CHARACTERFRAME_SUBFRAMES = CHARACTERFRAME_SUBFRAMES

Expand All @@ -24,6 +24,36 @@ local ResistanceCoords = {
{ 0.21875, 0.8125, 0.4765625, 0.55078125}, --Shadow
}

local function ReputationFrameUpdate()
local factionOffset = FauxScrollFrame_GetOffset(_G.ReputationListScrollFrame)
local numFactions = GetNumFactions()

for i = 1, NUM_FACTIONS_DISPLAYED do
local factionIndex = factionOffset + i
if factionIndex <= numFactions then
local factionHeader = _G['ReputationHeader'..i]
if factionHeader.isCollapsed then
factionHeader:SetNormalTexture(E.Media.Textures.PlusButton)
else
factionHeader:SetNormalTexture(E.Media.Textures.MinusButton)
end
end
end
end

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

local id = frame: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)
else
frame:SetBackdropBorderColor(unpack(E.media.bordercolor))
end
end

local function HandleTabs()
local lastTab
for index, tab in next, { _G.CharacterFrameTab1, HasPetUI() and _G.CharacterFrameTab2 or nil, _G.CharacterFrameTab3, _G.CharacterFrameTab4, _G.CharacterFrameTab5 } do
Expand Down Expand Up @@ -128,8 +158,6 @@ function S:CharacterFrame()
slot:SetTemplate(nil, true, true)
slot:StyleButton()

slot.characterSlot = true -- for color function

S:HandleIcon(icon)
icon:SetInside()

Expand All @@ -139,17 +167,7 @@ function S:CharacterFrame()
end
end

hooksecurefunc('PaperDollItemSlotButton_Update', function(frame)
if frame.characterSlot then
local rarity = GetInventoryItemQuality('player', frame:GetID())
if rarity and rarity > 1 then
local r, g, b = GetItemQualityColor(rarity)
frame:SetBackdropBorderColor(r, g, b)
else
frame:SetBackdropBorderColor(unpack(E.media.bordercolor))
end
end
end)
hooksecurefunc('PaperDollItemSlotButton_Update', PaperDollItemSlotButtonUpdate)

-- PetPaperDollFrame
_G.PetPaperDollFrame:StripTextures()
Expand Down Expand Up @@ -222,23 +240,7 @@ function S:CharacterFrame()
factionWar.Icon:SetTexture([[Interface\Buttons\UI-CheckBox-SwordCheck]])
end

hooksecurefunc('ReputationFrame_Update', function()
local numFactions = GetNumFactions()
local factionIndex, factionHeader
local factionOffset = FauxScrollFrame_GetOffset(_G.ReputationListScrollFrame)

for i = 1, NUM_FACTIONS_DISPLAYED, 1 do
factionHeader = _G['ReputationHeader'..i]
factionIndex = factionOffset + i
if factionIndex <= numFactions then
if factionHeader.isCollapsed then
factionHeader:SetNormalTexture(E.Media.Textures.PlusButton)
else
factionHeader:SetNormalTexture(E.Media.Textures.MinusButton)
end
end
end
end)
hooksecurefunc('ReputationFrame_Update', ReputationFrameUpdate)

_G.ReputationListScrollFrame:StripTextures()
S:HandleScrollBar(_G.ReputationListScrollFrameScrollBar)
Expand Down
136 changes: 69 additions & 67 deletions ElvUI/Mainline/Modules/Skins/Character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,70 @@ local showInsetBackdrop = {
TokenFrame = true
}

local function TokenFrame_ScrollUpdate(frame)
for _, child in next, { frame.ScrollTarget:GetChildren() } do
if child.Highlight and not child.IsSkinned then
child.CategoryLeft:SetAlpha(0)
child.CategoryRight:SetAlpha(0)
child.CategoryMiddle:SetAlpha(0)
child.Stripe:SetAlpha(0.75)

child.Highlight:SetInside()
child.Highlight:SetColorTexture(1, 1, 1, .25)

child.Highlight.SetPoint = E.noop
child.Highlight.SetTexture = E.noop

S:HandleIcon(child.Icon, true)
child.Icon.backdrop:SetFrameLevel(child:GetFrameLevel())

if child.ExpandIcon then
child.ExpandIcon:CreateBackdrop('Transparent')
child.ExpandIcon.backdrop:SetInside(3, 3)
end

child.IsSkinned = true
end

child.Icon.backdrop:SetShown(not child.isHeader)
child.ExpandIcon.backdrop:SetShown(child.isHeader)
child.Stripe:SetShown(not child.isHeader)
end
end

local function EquipmentManagerPane_Update(frame)
for _, child in next, { frame.ScrollTarget:GetChildren() } do
if child.icon and not child.isSkinned then
child.BgTop:SetTexture(E.ClearTexture)
child.BgMiddle:SetTexture(E.ClearTexture)
child.BgBottom:SetTexture(E.ClearTexture)
S:HandleIcon(child.icon)
child.HighlightBar:SetColorTexture(1, 1, 1, .25)
child.HighlightBar:SetDrawLayer('BACKGROUND')
child.SelectedBar:SetColorTexture(0.8, 0.8, 0.8, .25)
child.SelectedBar:SetDrawLayer('BACKGROUND')

child.isSkinned = true
end
end
end

local function TitleManagerPane_Update(frame)
for _, child in next, { frame.ScrollTarget:GetChildren() } do
if not child.isSkinned then
child:DisableDrawLayer('BACKGROUND')
child.isSkinned = true
end
end
end

local function PaperDollItemSlotButtonUpdate(slot)
local highlight = slot:GetHighlightTexture()
highlight:SetTexture(E.Media.Textures.White8x8)
highlight:SetVertexColor(1, 1, 1, .25)
highlight:SetInside()
end

local function UpdateCharacterInset(name)
_G.CharacterFrameInset.backdrop:SetShown(showInsetBackdrop[name])
end
Expand Down Expand Up @@ -234,13 +298,6 @@ function S:CharacterFrame()
end
end

hooksecurefunc('PaperDollItemSlotButton_Update', function(slot)
local highlight = slot:GetHighlightTexture()
highlight:SetTexture(E.Media.Textures.White8x8)
highlight:SetVertexColor(1, 1, 1, .25)
highlight:SetInside()
end)

--Give character frame model backdrop it's color back
for _, corner in pairs({'TopLeft','TopRight','BotLeft','BotRight'}) do
local bg = _G['CharacterModelFrameBackground'..corner]
Expand Down Expand Up @@ -304,36 +361,13 @@ function S:CharacterFrame()
S:HandleModelSceneControlButtons(_G.CharacterModelScene.ControlFrame)

--Titles
hooksecurefunc(_G.PaperDollFrame.TitleManagerPane.ScrollBox, 'Update', function(frame)
for _, child in next, { frame.ScrollTarget:GetChildren() } do
if not child.isSkinned then
child:DisableDrawLayer('BACKGROUND')
child.isSkinned = true
end
end
end)
hooksecurefunc(_G.PaperDollFrame.TitleManagerPane.ScrollBox, 'Update', TitleManagerPane_Update)

--Equipement Manager
hooksecurefunc(_G.PaperDollFrame.EquipmentManagerPane.ScrollBox, 'Update', EquipmentManagerPane_Update)
S:HandleButton(_G.PaperDollFrameEquipSet)
S:HandleButton(_G.PaperDollFrameSaveSet)

hooksecurefunc(_G.PaperDollFrame.EquipmentManagerPane.ScrollBox, 'Update', function(frame)
for _, child in next, { frame.ScrollTarget:GetChildren() } do
if child.icon and not child.isSkinned then
child.BgTop:SetTexture(E.ClearTexture)
child.BgMiddle:SetTexture(E.ClearTexture)
child.BgBottom:SetTexture(E.ClearTexture)
S:HandleIcon(child.icon)
child.HighlightBar:SetColorTexture(1, 1, 1, .25)
child.HighlightBar:SetDrawLayer('BACKGROUND')
child.SelectedBar:SetColorTexture(0.8, 0.8, 0.8, .25)
child.SelectedBar:SetDrawLayer('BACKGROUND')

child.isSkinned = true
end
end
end)

-- Icon selection frame
_G.GearManagerPopupFrame:HookScript('OnShow', function(frame)
if frame.isSkinned then return end -- set by HandleIconSelectionFrame
Expand Down Expand Up @@ -371,8 +405,6 @@ function S:CharacterFrame()
S:HandleCheckBox(_G.ReputationDetailInactiveCheckBox)
S:HandleButton(_G.ReputationDetailViewRenownButton)

hooksecurefunc(_G.ReputationFrame.ScrollBox, 'Update', UpdateFactionSkins)

-- Currency Frame
_G.TokenFramePopup:StripTextures()
_G.TokenFramePopup:SetTemplate('Transparent')
Expand All @@ -385,40 +417,10 @@ function S:CharacterFrame()
S:HandleCloseButton(_G.TokenFramePopup.CloseButton)
end

hooksecurefunc(_G.TokenFrame.ScrollBox, 'Update', function(frame)
for _, child in next, { frame.ScrollTarget:GetChildren() } do
if child.Highlight and not child.IsSkinned then
child.CategoryLeft:SetAlpha(0)
child.CategoryRight:SetAlpha(0)
child.CategoryMiddle:SetAlpha(0)
child.Stripe:SetAlpha(0.75)

child.Highlight:SetInside()
child.Highlight:SetColorTexture(1, 1, 1, .25)

child.Highlight.SetPoint = E.noop
child.Highlight.SetTexture = E.noop

S:HandleIcon(child.Icon, true)
child.Icon.backdrop:SetFrameLevel(child:GetFrameLevel())

if child.ExpandIcon then
child.ExpandIcon:CreateBackdrop('Transparent')
child.ExpandIcon.backdrop:SetInside(3, 3)
end

child.IsSkinned = true
end

child.Icon.backdrop:SetShown(not child.isHeader)
child.ExpandIcon.backdrop:SetShown(child.isHeader)
child.Stripe:SetShown(not child.isHeader)
end
end)

--Buttons used to toggle between equipment manager, titles, and character stats
hooksecurefunc(_G.ReputationFrame.ScrollBox, 'Update', UpdateFactionSkins)
hooksecurefunc(_G.TokenFrame.ScrollBox, 'Update', TokenFrame_ScrollUpdate)
hooksecurefunc('PaperDollFrame_UpdateSidebarTabs', FixSidebarTabCoords)

hooksecurefunc('PaperDollItemSlotButton_Update', PaperDollItemSlotButtonUpdate)
hooksecurefunc('CharacterFrame_ShowSubFrame', UpdateCharacterInset)
end

Expand Down

0 comments on commit 9515250

Please sign in to comment.