Skip to content

Commit

Permalink
simplify addonlist skin
Browse files Browse the repository at this point in the history
  • Loading branch information
kodewdle committed Oct 29, 2024
1 parent 0a1dd94 commit 1ead8d1
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 158 deletions.
72 changes: 19 additions & 53 deletions ElvUI/Cata/Modules/Skins/AddonManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ local _G = _G
local unpack = unpack
local hooksecurefunc = hooksecurefunc

local UIDropDownMenu_GetSelectedValue = UIDropDownMenu_GetSelectedValue

local GetAddOnInfo = C_AddOns.GetAddOnInfo
local GetNumAddOns = C_AddOns.GetNumAddOns

Expand All @@ -15,26 +13,20 @@ function S:AddonList()

local AddonList = _G.AddonList
local maxShown = _G.MAX_ADDONS_DISPLAYED
local AddonCharacterDropDown = _G.AddonCharacterDropDown

S:HandleFrame(AddonList, true)
S:HandleButton(AddonList.EnableAllButton, true)
S:HandleButton(AddonList.DisableAllButton, true)
S:HandleButton(AddonList.OkayButton, true)
S:HandleButton(AddonList.CancelButton, true)
S:HandleDropDownBox(AddonCharacterDropDown, 165)
S:HandleScrollBar(_G.AddonListScrollFrameScrollBar)
S:HandleDropDownBox(_G.AddonCharacterDropDown)
S:HandleCheckBox(_G.AddonListForceLoad)

_G.AddonListForceLoad:Size(26)

S:HandleFrame(_G.AddonListScrollFrame, true, nil, -14, 0, 0, -1)

for i = 1, maxShown do
S:HandleCheckBox(_G['AddonListEntry'..i..'Enabled'], nil, nil, true)
S:HandleButton(_G['AddonListEntry'..i].LoadAddonButton)
end

hooksecurefunc('AddonList_Update', function()
local numEntrys = GetNumAddOns()
for i = 1, maxShown do
Expand All @@ -43,64 +35,38 @@ function S:AddonList()
local entry = _G['AddonListEntry'..i]
local entryTitle = _G['AddonListEntry'..i..'Title']
local checkbox = _G['AddonListEntry'..i..'Enabled']
local name, title, _, loadable, reason = GetAddOnInfo(index)

-- Get the character from the current list (nil is all characters)
local checkall
local character = UIDropDownMenu_GetSelectedValue(AddonCharacterDropDown)
if character == true then
character = nil
else
checkall = E:GetAddOnEnableState(index)
end

local checkstate = E:GetAddOnEnableState(index, character)
local enabled = checkstate > 0
local _, _, _, _, reason = GetAddOnInfo(index)

entryTitle:SetFontObject('ElvUIFontNormal')
entry.Status:SetFontObject('ElvUIFontSmall')
entry.Reload:SetFontObject('ElvUIFontSmall')
entry.Reload:SetTextColor(1.0, 0.3, 0.3)
entry.LoadAddonButton.Text:SetFontObject('ElvUIFontSmall')
if not entry.IsSkinned then
S:HandleCheckBox(_G['AddonListEntry'..i..'Enabled'], nil, nil, true)
S:HandleButton(entry.LoadAddonButton)

local enabledForSome = not character and checkstate == 1
local disabled = not enabled or enabledForSome
entryTitle:SetFontObject('ElvUIFontNormal')
entry.Status:SetFontObject('ElvUIFontSmall')
entry.Reload:SetFontObject('ElvUIFontSmall')
entry.Reload:SetTextColor(1.0, 0.3, 0.3)
entry.LoadAddonButton.Text:SetFontObject('ElvUIFontSmall')

if disabled then
entry.Status:SetTextColor(0.4, 0.4, 0.4)
else
entry.Status:SetTextColor(0.7, 0.7, 0.7)
end

if disabled or reason == 'DEP_DISABLED' then
entryTitle:SetText(E:StripString(title or name, true))
entry.IsSkinned = true
end

if enabledForSome then
entryTitle:SetTextColor(0.5, 0.5, 0.5)
elseif enabled and (loadable or reason == 'DEP_DEMAND_LOADED' or reason == 'DEMAND_LOADED') then
entryTitle:SetTextColor(0.9, 0.9, 0.9)
elseif enabled and reason ~= 'DEP_DISABLED' then
entryTitle:SetTextColor(1.0, 0.2, 0.2)
local checkstate = E:GetAddOnEnableState(index)
if checkstate == 2 then
entry.Status:SetTextColor(0.7, 0.7, 0.7)
else
entryTitle:SetTextColor(0.3, 0.3, 0.3)
entry.Status:SetTextColor(0.4, 0.4, 0.4)
end

local checktex = checkbox:GetCheckedTexture()
if not enabled and checkall == 1 then
checktex:SetVertexColor(0.3, 0.3, 0.3)
checktex:SetDesaturated(true)
checktex:Show()
elseif not checkstate or checkstate == 0 then
checktex:Hide()
elseif checkstate == 1 or reason == 'DEP_DISABLED' then
if reason == 'DEP_DISABLED' then
checktex:SetVertexColor(0.6, 0.6, 0.6)
checktex:SetDesaturated(true)
checktex:Show()
elseif checkstate == 1 then
checktex:SetVertexColor(1, 0.8, 0.1)
checktex:SetDesaturated(false)
elseif checkstate == 2 then
checktex:SetVertexColor(unpack(E.media.rgbvaluecolor))
checktex:SetDesaturated(false)
checktex:Show()
end
end
end
Expand Down
70 changes: 18 additions & 52 deletions ElvUI/Classic/Modules/Skins/AddonManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ local _G = _G
local unpack = unpack
local hooksecurefunc = hooksecurefunc

local UIDropDownMenu_GetSelectedValue = UIDropDownMenu_GetSelectedValue

local GetAddOnInfo = C_AddOns.GetAddOnInfo
local GetNumAddOns = C_AddOns.GetNumAddOns

Expand All @@ -15,7 +13,6 @@ function S:AddonList()

local AddonList = _G.AddonList
local maxShown = _G.MAX_ADDONS_DISPLAYED
local AddonListDropdown = _G.AddonList.Dropdown

S:HandleFrame(AddonList, true)
S:HandleButton(AddonList.EnableAllButton, true)
Expand All @@ -30,11 +27,6 @@ function S:AddonList()

S:HandleFrame(_G.AddonListScrollFrame, true, nil, -14, 0, 0, -1)

for i = 1, maxShown do
S:HandleCheckBox(_G['AddonListEntry'..i..'Enabled'], nil, nil, true)
S:HandleButton(_G['AddonListEntry'..i].LoadAddonButton)
end

hooksecurefunc('AddonList_Update', function()
local numEntrys = GetNumAddOns()
for i = 1, maxShown do
Expand All @@ -43,64 +35,38 @@ function S:AddonList()
local entry = _G['AddonListEntry'..i]
local entryTitle = _G['AddonListEntry'..i..'Title']
local checkbox = _G['AddonListEntry'..i..'Enabled']
local name, title, _, loadable, reason = GetAddOnInfo(index)

-- Get the character from the current list (nil is all characters)
local checkall
local character = UIDropDownMenu_GetSelectedValue(AddonListDropdown)
if character == true then
character = nil
else
checkall = E:GetAddOnEnableState(index)
end

local checkstate = E:GetAddOnEnableState(index, character)
local enabled = checkstate > 0
local _, _, _, _, reason = GetAddOnInfo(index)

entryTitle:SetFontObject('ElvUIFontNormal')
entry.Status:SetFontObject('ElvUIFontSmall')
entry.Reload:SetFontObject('ElvUIFontSmall')
entry.Reload:SetTextColor(1.0, 0.3, 0.3)
entry.LoadAddonButton.Text:SetFontObject('ElvUIFontSmall')
if not entry.IsSkinned then
S:HandleCheckBox(_G['AddonListEntry'..i..'Enabled'], nil, nil, true)
S:HandleButton(entry.LoadAddonButton)

local enabledForSome = not character and checkstate == 1
local disabled = not enabled or enabledForSome
entryTitle:SetFontObject('ElvUIFontNormal')
entry.Status:SetFontObject('ElvUIFontSmall')
entry.Reload:SetFontObject('ElvUIFontSmall')
entry.Reload:SetTextColor(1.0, 0.3, 0.3)
entry.LoadAddonButton.Text:SetFontObject('ElvUIFontSmall')

if disabled then
entry.Status:SetTextColor(0.4, 0.4, 0.4)
else
entry.Status:SetTextColor(0.7, 0.7, 0.7)
end

if disabled or reason == 'DEP_DISABLED' then
entryTitle:SetText(E:StripString(title or name, true))
entry.IsSkinned = true
end

if enabledForSome then
entryTitle:SetTextColor(0.5, 0.5, 0.5)
elseif enabled and (loadable or reason == 'DEP_DEMAND_LOADED' or reason == 'DEMAND_LOADED') then
entryTitle:SetTextColor(0.9, 0.9, 0.9)
elseif enabled and reason ~= 'DEP_DISABLED' then
entryTitle:SetTextColor(1.0, 0.2, 0.2)
local checkstate = E:GetAddOnEnableState(index)
if checkstate == 2 then
entry.Status:SetTextColor(0.7, 0.7, 0.7)
else
entryTitle:SetTextColor(0.3, 0.3, 0.3)
entry.Status:SetTextColor(0.4, 0.4, 0.4)
end

local checktex = checkbox:GetCheckedTexture()
if not enabled and checkall == 1 then
checktex:SetVertexColor(0.3, 0.3, 0.3)
checktex:SetDesaturated(true)
checktex:Show()
elseif not checkstate or checkstate == 0 then
checktex:Hide()
elseif checkstate == 1 or reason == 'DEP_DISABLED' then
if reason == 'DEP_DISABLED' then
checktex:SetVertexColor(0.6, 0.6, 0.6)
checktex:SetDesaturated(true)
checktex:Show()
elseif checkstate == 1 then
checktex:SetVertexColor(1, 0.8, 0.1)
checktex:SetDesaturated(false)
elseif checkstate == 2 then
checktex:SetVertexColor(unpack(E.media.rgbvaluecolor))
checktex:SetDesaturated(false)
checktex:Show()
end
end
end
Expand Down
67 changes: 14 additions & 53 deletions ElvUI/Mainline/Modules/Skins/AddonManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,80 +5,41 @@ local _G = _G
local unpack = unpack
local hooksecurefunc = hooksecurefunc

local UIDropDownMenu_GetSelectedValue = UIDropDownMenu_GetSelectedValue
local GetAddOnInfo = C_AddOns.GetAddOnInfo

local function HandleButton(entry, addonIndex)
if not entry.IsSkinned then
S:HandleCheckBox(entry.Enabled)
S:HandleButton(entry.LoadAddonButton)

entry.IsSkinned = true
end
entry.Title:SetFontObject('ElvUIFontNormal')
entry.Status:SetFontObject('ElvUIFontSmall')
entry.Reload:SetFontObject('ElvUIFontSmall')
entry.Reload:SetTextColor(1.0, 0.3, 0.3)
entry.LoadAddonButton.Text:SetFontObject('ElvUIFontSmall')

local checkall -- Get the character from the current list (nil is all characters)
local character = UIDropDownMenu_GetSelectedValue(_G.AddonList.Dropdown)
if character == true then
character = nil
else
checkall = E:GetAddOnEnableState(addonIndex)
entry.IsSkinned = true
end

entry.Title:SetFontObject('ElvUIFontNormal')
entry.Status:SetFontObject('ElvUIFontSmall')
entry.Reload:SetFontObject('ElvUIFontSmall')
entry.Reload:SetTextColor(1.0, 0.3, 0.3)
entry.LoadAddonButton.Text:SetFontObject('ElvUIFontSmall')

local checkstate = E:GetAddOnEnableState(addonIndex, character)
local enabledForSome = not character and checkstate == 1
local enabled = checkstate > 0
local disabled = not enabled or enabledForSome

if disabled then
entry.Status:SetTextColor(0.4, 0.4, 0.4)
else
local checkstate = E:GetAddOnEnableState(addonIndex)
if checkstate == 2 then
entry.Status:SetTextColor(0.7, 0.7, 0.7)
end

local name, title, _, loadable, reason = GetAddOnInfo(addonIndex)
if disabled or reason == 'DEP_DISABLED' then
entry.Title:SetText(E:StripString(title or name, true))
end

if enabledForSome then
entry.Title:SetTextColor(0.5, 0.5, 0.5)
elseif enabled and (loadable or reason == 'DEP_DEMAND_LOADED' or reason == 'DEMAND_LOADED') then
entry.Title:SetTextColor(0.9, 0.9, 0.9)
elseif enabled and reason ~= 'DEP_DISABLED' then
entry.Title:SetTextColor(1.0, 0.2, 0.2)
else
entry.Title:SetTextColor(0.3, 0.3, 0.3)
entry.Status:SetTextColor(0.4, 0.4, 0.4)
end

local _, _, _, _, reason = GetAddOnInfo(addonIndex)
local checktex = entry.Enabled:GetCheckedTexture()
checktex.SetVertexColor = nil
checktex.SetDesaturated = nil

if not enabled and checkall == 1 then
checktex:SetVertexColor(0.3, 0.3, 0.3)
checktex:SetDesaturated(true)
checktex:Show()
elseif not checkstate or checkstate == 0 then
checktex:Hide()
elseif checkstate == 1 or reason == 'DEP_DISABLED' then
if reason == 'DEP_DISABLED' then
checktex:SetVertexColor(0.6, 0.6, 0.6)
checktex:SetDesaturated(true)
checktex:Show()
elseif checkstate == 1 then
checktex:SetVertexColor(1, 0.8, 0.1)
checktex:SetDesaturated(false)
elseif checkstate == 2 then
checktex:SetVertexColor(unpack(E.media.rgbvaluecolor))
checktex:SetDesaturated(false)
checktex:Show()
end

-- TriStateCheckbox_SetState interferes (checktex all share the same name)
checktex.SetVertexColor = E.noop
checktex.SetDesaturated = E.noop
end

function S:AddonList()
Expand Down

0 comments on commit 1ead8d1

Please sign in to comment.