Skip to content

Commit 0ccad85

Browse files
committed
clean up character skins
1 parent de7f4f9 commit 0ccad85

File tree

3 files changed

+193
-207
lines changed

3 files changed

+193
-207
lines changed

ElvUI/Cata/Modules/Skins/Character.lua

Lines changed: 93 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,69 @@ local E, L, V, P, G = unpack(ElvUI)
22
local S = E:GetModule('Skins')
33

44
local _G = _G
5-
local pairs, ipairs = pairs, ipairs
5+
local pairs, format = pairs, format
66
local unpack, next = unpack, next
7-
local hooksecurefunc = hooksecurefunc
8-
local CreateColor = CreateColor
9-
10-
local FLYOUT_LOCATIONS = {
11-
[0xFFFFFFFF] = 'PLACEINBAGS',
12-
[0xFFFFFFFE] = 'IGNORESLOT',
13-
[0xFFFFFFFD] = 'UNIGNORESLOT'
14-
}
157

16-
local showInsetBackdrop = {
17-
ReputationFrame = true,
18-
TokenFrame = true
19-
}
8+
local hooksecurefunc = hooksecurefunc
9+
local UnitResistance = UnitResistance
10+
local GetItemQualityColor = GetItemQualityColor
11+
local GetInventoryItemQuality = GetInventoryItemQuality
12+
local HasPetUI = HasPetUI
13+
local GetCVar = GetCVar
14+
15+
local PAPERDOLLFRAME_TOOLTIP_FORMAT = PAPERDOLLFRAME_TOOLTIP_FORMAT
16+
local HIGHLIGHT_FONT_COLOR_CODE = HIGHLIGHT_FONT_COLOR_CODE
17+
local FONT_COLOR_CODE_CLOSE = FONT_COLOR_CODE_CLOSE
18+
local STAT_FORMAT = STAT_FORMAT
19+
local HONOR_CURRENCY = HONOR_CURRENCY
20+
21+
local spellSchoolIcon = [[Interface\PaperDollInfoFrame\SpellSchoolIcon]]
22+
23+
local function EquipmentManagerPane_Update(frame)
24+
for _, child in next, { frame.ScrollTarget:GetChildren() } do
25+
if child.icon and not child.isSkinned then
26+
child.BgTop:SetTexture(E.ClearTexture)
27+
child.BgMiddle:SetTexture(E.ClearTexture)
28+
child.BgBottom:SetTexture(E.ClearTexture)
29+
S:HandleIcon(child.icon)
30+
child.HighlightBar:SetColorTexture(1, 1, 1, .25)
31+
child.HighlightBar:SetDrawLayer('BACKGROUND')
32+
child.SelectedBar:SetColorTexture(0.8, 0.8, 0.8, .25)
33+
child.SelectedBar:SetDrawLayer('BACKGROUND')
34+
35+
child.isSkinned = true
36+
end
37+
end
38+
end
2039

21-
local function EquipmentDisplayButton(button)
22-
if not button.isHooked then
23-
button:SetNormalTexture(E.ClearTexture)
24-
button:SetPushedTexture(E.ClearTexture)
25-
button:SetTemplate()
26-
button:StyleButton()
40+
local function TitleManagerPane_Update(frame)
41+
for _, child in next, { frame.ScrollTarget:GetChildren() } do
42+
if not child.isSkinned then
43+
child:DisableDrawLayer('BACKGROUND')
44+
child.isSkinned = true
45+
end
46+
end
47+
end
2748

28-
button.icon:SetInside()
29-
button.icon:SetTexCoord(unpack(E.TexCoords))
49+
local function PaperDollItemSlotButtonUpdate(frame)
50+
local id = frame.characterSlot and frame:GetID()
51+
local rarity = id and GetInventoryItemQuality('player', id)
52+
if rarity and rarity > 1 then
53+
local r, g, b = GetItemQualityColor(rarity)
54+
frame:SetBackdropBorderColor(r, g, b)
55+
else
56+
frame:SetBackdropBorderColor(unpack(E.media.bordercolor))
57+
end
58+
end
3059

31-
S:HandleIconBorder(button.IconBorder)
60+
local function PaperDollFrameSetResistance(frame, unit, index)
61+
local _, resistance = UnitResistance(unit, index)
62+
local icon = format('%s%d:12:12:0:0:64:64:4:55:4:55|t', spellSchoolIcon, index + 1)
63+
local name = frame:GetName()
3264

33-
button.isHooked = true
34-
end
65+
_G[name..'Label']:SetFormattedText('%s '..STAT_FORMAT, icon, _G['SPELL_SCHOOL'..index..'_CAP'])
3566

36-
if FLYOUT_LOCATIONS[button.location] then -- special slots
37-
button:SetBackdropBorderColor(unpack(E.media.bordercolor))
38-
end
67+
frame.tooltip = format('%s %s'..PAPERDOLLFRAME_TOOLTIP_FORMAT..' %s%s', icon, HIGHLIGHT_FONT_COLOR_CODE, _G['RESISTANCE'..index..'_NAME'], resistance or 0, FONT_COLOR_CODE_CLOSE)
3968
end
4069

4170
local function TabTextureCoords(tex, x1)
@@ -227,17 +256,6 @@ function S:CharacterFrame()
227256
end
228257
end
229258

230-
hooksecurefunc('PaperDollItemSlotButton_Update', function(frame)
231-
if frame.characterSlot then
232-
local rarity = GetInventoryItemQuality('player', frame:GetID())
233-
if rarity and rarity > 1 then
234-
local r, g, b = GetItemQualityColor(rarity)
235-
frame:SetBackdropBorderColor(r, g, b)
236-
else
237-
frame:SetBackdropBorderColor(unpack(E.media.bordercolor))
238-
end
239-
end
240-
end)
241259
-- Give character frame model backdrop it's color back
242260
for _, corner in pairs({'TopLeft','TopRight','BotLeft','BotRight'}) do
243261
local bg = _G['CharacterModelFrameBackground'..corner]
@@ -286,36 +304,13 @@ function S:CharacterFrame()
286304
S:HandleModelSceneControlButtons(_G.CharacterModelScene.ControlFrame)
287305

288306
-- Titles
289-
hooksecurefunc(_G.PaperDollFrame.TitleManagerPane.ScrollBox, 'Update', function(frame)
290-
for _, child in next, { frame.ScrollTarget:GetChildren() } do
291-
if not child.isSkinned then
292-
child:DisableDrawLayer('BACKGROUND')
293-
child.isSkinned = true
294-
end
295-
end
296-
end)
307+
hooksecurefunc(_G.PaperDollFrame.TitleManagerPane.ScrollBox, 'Update', TitleManagerPane_Update)
297308

298309
-- Equipement Manager
310+
hooksecurefunc(_G.PaperDollFrame.EquipmentManagerPane.ScrollBox, 'Update', EquipmentManagerPane_Update)
299311
S:HandleButton(_G.PaperDollFrameEquipSet)
300312
S:HandleButton(_G.PaperDollFrameSaveSet)
301313

302-
hooksecurefunc(_G.PaperDollFrame.EquipmentManagerPane.ScrollBox, 'Update', function(frame)
303-
for _, child in next, { frame.ScrollTarget:GetChildren() } do
304-
if child.icon and not child.isSkinned then
305-
child.BgTop:SetTexture(E.ClearTexture)
306-
child.BgMiddle:SetTexture(E.ClearTexture)
307-
child.BgBottom:SetTexture(E.ClearTexture)
308-
S:HandleIcon(child.icon)
309-
child.HighlightBar:SetColorTexture(1, 1, 1, .25)
310-
child.HighlightBar:SetDrawLayer('BACKGROUND')
311-
child.SelectedBar:SetColorTexture(0.8, 0.8, 0.8, .25)
312-
child.SelectedBar:SetDrawLayer('BACKGROUND')
313-
314-
child.isSkinned = true
315-
end
316-
end
317-
end)
318-
319314
-- Item Quality Borders and Armor Slots
320315
local CharacterMainHandSlot = _G.CharacterMainHandSlot
321316
CharacterMainHandSlot:ClearAllPoints()
@@ -331,57 +326,44 @@ function S:CharacterFrame()
331326
-- Stats
332327
for i = 1, 7 do
333328
local frame = _G['CharacterStatsPaneCategory'..i]
334-
local name = _G['CharacterStatsPaneCategory'..i..'NameText']
335-
frame.Toolbar = _G['CharacterStatsPaneCategory'..i..'Toolbar']
336-
337329
frame:StripTextures()
338330
frame:SetTemplate('Transparent')
339331

332+
frame.Toolbar = _G['CharacterStatsPaneCategory'..i..'Toolbar']
340333
S:HandleButton(frame.Toolbar, nil, nil, true)
341334

342-
name:ClearAllPoints()
343-
name:Point('CENTER', frame.Toolbar, 'CENTER')
344-
345-
_G['CharacterStatsPaneCategory'..i..'Stat1']:Point('TOPLEFT', frame, 'TOPLEFT', 16, -18)
335+
local name = _G['CharacterStatsPaneCategory'..i..'NameText']
336+
if name then
337+
name:ClearAllPoints()
338+
name:Point('CENTER', frame.Toolbar)
339+
end
346340

347-
--_G['CharacterStatsPaneCategory'..i..'ToolbarSortUpArrow']:Kill()
341+
_G['CharacterStatsPaneCategory'..i..'Stat1']:Point('TOPLEFT', frame, 16, -18)
348342
_G['CharacterStatsPaneCategory'..i..'ToolbarSortDownArrow']:Kill()
343+
--_G['CharacterStatsPaneCategory'..i..'ToolbarSortUpArrow']:Kill()
349344
end
350345

351-
hooksecurefunc('PaperDollFrame_SetResistance', function(statFrame, unit, index)
352-
local _, resistance = UnitResistance(unit, index)
353-
local resistanceIcons = '|TInterface\\PaperDollInfoFrame\\SpellSchoolIcon'..(index + 1)..':12:12:0:0:64:64:4:55:4:55|t'
354-
355-
_G[statFrame:GetName()..'Label']:SetText(resistanceIcons..' '..format(STAT_FORMAT, _G['SPELL_SCHOOL'..index..'_CAP']))
356-
statFrame.tooltip = resistanceIcons..' '..HIGHLIGHT_FONT_COLOR_CODE..format(PAPERDOLLFRAME_TOOLTIP_FORMAT, _G['RESISTANCE'..index..'_NAME'])..' '..resistance..FONT_COLOR_CODE_CLOSE
357-
end)
358-
359-
-- Expand Button
360-
local CharacterFrameExpandButton = _G.CharacterFrameExpandButton
361-
S:HandleNextPrevButton(CharacterFrameExpandButton, nil, nil, nil, nil, nil, 26) -- Default UI button size is 32
362-
CharacterFrameExpandButton:ClearAllPoints()
363-
CharacterFrameExpandButton:Point('BOTTOMRIGHT', _G.CharacterFrameInset, 'BOTTOMRIGHT', -3, 2)
364-
365-
CharacterFrameExpandButton:SetNormalTexture(E.Media.Textures.ArrowUp)
366-
CharacterFrameExpandButton.SetNormalTexture = E.noop
367-
CharacterFrameExpandButton:SetPushedTexture(E.Media.Textures.ArrowUp)
368-
CharacterFrameExpandButton.SetPushedTexture = E.noop
369-
CharacterFrameExpandButton:SetDisabledTexture(E.Media.Textures.ArrowUp)
370-
CharacterFrameExpandButton.SetDisabledTexture = E.noop
371-
372-
local expandButtonNormal, expandButtonPushed = CharacterFrameExpandButton:GetNormalTexture(), CharacterFrameExpandButton:GetPushedTexture()
373-
local expandButtonCvar = GetCVar('characterFrameCollapsed') ~= '0'
374-
expandButtonNormal:SetRotation(expandButtonCvar and -1.57 or 1.57)
375-
expandButtonPushed:SetRotation(expandButtonCvar and -1.57 or 1.57)
376-
377-
hooksecurefunc(CharacterFrame, 'Collapse', function()
378-
expandButtonNormal:SetRotation(-1.57)
379-
expandButtonPushed:SetRotation(-1.57)
380-
end)
381-
hooksecurefunc(CharacterFrame, 'Expand', function()
382-
expandButtonNormal:SetRotation(1.57)
383-
expandButtonPushed:SetRotation(1.57)
384-
end)
346+
do -- Expand Button
347+
local CharacterFrameExpandButton = _G.CharacterFrameExpandButton
348+
S:HandleNextPrevButton(CharacterFrameExpandButton, nil, nil, nil, nil, nil, 26) -- Default UI button size is 32
349+
CharacterFrameExpandButton:ClearAllPoints()
350+
CharacterFrameExpandButton:Point('BOTTOMRIGHT', _G.CharacterFrameInset, 'BOTTOMRIGHT', -3, 2)
351+
352+
CharacterFrameExpandButton:SetNormalTexture(E.Media.Textures.ArrowUp)
353+
CharacterFrameExpandButton.SetNormalTexture = E.noop
354+
CharacterFrameExpandButton:SetPushedTexture(E.Media.Textures.ArrowUp)
355+
CharacterFrameExpandButton.SetPushedTexture = E.noop
356+
CharacterFrameExpandButton:SetDisabledTexture(E.Media.Textures.ArrowUp)
357+
CharacterFrameExpandButton.SetDisabledTexture = E.noop
358+
359+
local expandButtonNormal, expandButtonPushed = CharacterFrameExpandButton:GetNormalTexture(), CharacterFrameExpandButton:GetPushedTexture()
360+
local expandButtonCvar = GetCVar('characterFrameCollapsed') ~= '0'
361+
expandButtonNormal:SetRotation(expandButtonCvar and -1.57 or 1.57)
362+
expandButtonPushed:SetRotation(expandButtonCvar and -1.57 or 1.57)
363+
364+
hooksecurefunc(CharacterFrame, 'Collapse', function() expandButtonNormal:SetRotation(-1.57) expandButtonPushed:SetRotation(-1.57) end)
365+
hooksecurefunc(CharacterFrame, 'Expand', function() expandButtonNormal:SetRotation(1.57) expandButtonPushed:SetRotation(1.57) end)
366+
end
385367

386368
-- Pet Frame
387369
S:HandleStatusBar(_G.PetPaperDollFrameExpBar)
@@ -391,7 +373,7 @@ function S:CharacterFrame()
391373
-- Reputation Frame
392374
_G.ReputationFrame:StripTextures()
393375

394-
for i = 1, NUM_FACTIONS_DISPLAYED do
376+
for i = 1, _G.NUM_FACTIONS_DISPLAYED do
395377
local factionBar = _G['ReputationBar'..i]
396378
local factionStatusBar = _G['ReputationBar'..i..'ReputationBar']
397379
local factionBarButton = _G['ReputationBar'..i..'ExpandOrCollapseButton']
@@ -441,20 +423,20 @@ function S:CharacterFrame()
441423

442424
S:HandleCloseButton(_G.TokenFramePopupCloseButton, _G.TokenFramePopup)
443425

444-
hooksecurefunc('TokenFrame_Update', UpdateCurrencySkins)
445426
hooksecurefunc(_G.TokenFrameContainer, 'update', UpdateCurrencySkins)
427+
hooksecurefunc('TokenFrame_Update', UpdateCurrencySkins)
428+
hooksecurefunc('PaperDollFrame_UpdateSidebarTabs', FixSidebarTabCoords)
429+
hooksecurefunc('PaperDollFrame_SetResistance', PaperDollFrameSetResistance)
430+
hooksecurefunc('PaperDollItemSlotButton_Update', PaperDollItemSlotButtonUpdate)
446431

447432
-- Tabs
448-
for i = 1, #CHARACTERFRAME_SUBFRAMES do
433+
for i = 1, #_G.CHARACTERFRAME_SUBFRAMES do
449434
S:HandleTab(_G['CharacterFrameTab'..i])
450435
end
451436

452437
-- Reposition Tabs
453438
hooksecurefunc('PetPaperDollFrame_UpdateIsAvailable', HandleTabs)
454439
HandleTabs()
455-
456-
-- Buttons used to toggle between equipment manager, titles, and character stats
457-
hooksecurefunc('PaperDollFrame_UpdateSidebarTabs', FixSidebarTabCoords)
458440
end
459441

460442
S:AddCallback('CharacterFrame')

ElvUI/Classic/Modules/Skins/Character.lua

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ local S = E:GetModule('Skins')
44
local _G = _G
55
local next = next
66
local unpack, pairs = unpack, pairs
7+
local hooksecurefunc = hooksecurefunc
78

89
local HasPetUI = HasPetUI
910
local GetNumFactions = GetNumFactions
@@ -12,7 +13,6 @@ local GetItemQualityColor = GetItemQualityColor
1213
local GetInventoryItemQuality = GetInventoryItemQuality
1314
local FauxScrollFrame_GetOffset = FauxScrollFrame_GetOffset
1415

15-
local hooksecurefunc = hooksecurefunc
1616
local NUM_FACTIONS_DISPLAYED = NUM_FACTIONS_DISPLAYED
1717
local CHARACTERFRAME_SUBFRAMES = CHARACTERFRAME_SUBFRAMES
1818

@@ -24,6 +24,34 @@ local ResistanceCoords = {
2424
{ 0.21875, 0.8125, 0.4765625, 0.55078125}, --Shadow
2525
}
2626

27+
local function ReputationFrameUpdate()
28+
local factionOffset = FauxScrollFrame_GetOffset(_G.ReputationListScrollFrame)
29+
local numFactions = GetNumFactions()
30+
31+
for i = 1, NUM_FACTIONS_DISPLAYED, 1 do
32+
local factionIndex = factionOffset + i
33+
if factionIndex <= numFactions then
34+
local factionHeader = _G['ReputationHeader'..i]
35+
if factionHeader.isCollapsed then
36+
factionHeader:SetNormalTexture(E.Media.Textures.PlusButton)
37+
else
38+
factionHeader:SetNormalTexture(E.Media.Textures.MinusButton)
39+
end
40+
end
41+
end
42+
end
43+
44+
local function PaperDollItemSlotButtonUpdate(frame)
45+
local id = frame.characterSlot and frame:GetID()
46+
local rarity = id and GetInventoryItemQuality('player', id)
47+
if rarity and rarity > 1 then
48+
local r, g, b = GetItemQualityColor(rarity)
49+
frame:SetBackdropBorderColor(r, g, b)
50+
else
51+
frame:SetBackdropBorderColor(unpack(E.media.bordercolor))
52+
end
53+
end
54+
2755
local function HandleTabs()
2856
local lastTab
2957
for index, tab in next, { _G.CharacterFrameTab1, HasPetUI() and _G.CharacterFrameTab2 or nil, _G.CharacterFrameTab3, _G.CharacterFrameTab4, _G.CharacterFrameTab5 } do
@@ -139,17 +167,7 @@ function S:CharacterFrame()
139167
end
140168
end
141169

142-
hooksecurefunc('PaperDollItemSlotButton_Update', function(frame)
143-
if frame.characterSlot then
144-
local rarity = GetInventoryItemQuality('player', frame:GetID())
145-
if rarity and rarity > 1 then
146-
local r, g, b = GetItemQualityColor(rarity)
147-
frame:SetBackdropBorderColor(r, g, b)
148-
else
149-
frame:SetBackdropBorderColor(unpack(E.media.bordercolor))
150-
end
151-
end
152-
end)
170+
hooksecurefunc('PaperDollItemSlotButton_Update', PaperDollItemSlotButtonUpdate)
153171

154172
-- PetPaperDollFrame
155173
_G.PetPaperDollFrame:StripTextures()
@@ -222,23 +240,7 @@ function S:CharacterFrame()
222240
factionWar.Icon:SetTexture([[Interface\Buttons\UI-CheckBox-SwordCheck]])
223241
end
224242

225-
hooksecurefunc('ReputationFrame_Update', function()
226-
local numFactions = GetNumFactions()
227-
local factionIndex, factionHeader
228-
local factionOffset = FauxScrollFrame_GetOffset(_G.ReputationListScrollFrame)
229-
230-
for i = 1, NUM_FACTIONS_DISPLAYED, 1 do
231-
factionHeader = _G['ReputationHeader'..i]
232-
factionIndex = factionOffset + i
233-
if factionIndex <= numFactions then
234-
if factionHeader.isCollapsed then
235-
factionHeader:SetNormalTexture(E.Media.Textures.PlusButton)
236-
else
237-
factionHeader:SetNormalTexture(E.Media.Textures.MinusButton)
238-
end
239-
end
240-
end
241-
end)
243+
hooksecurefunc('ReputationFrame_Update', ReputationFrameUpdate)
242244

243245
_G.ReputationListScrollFrame:StripTextures()
244246
S:HandleScrollBar(_G.ReputationListScrollFrameScrollBar)

0 commit comments

Comments
 (0)