Skip to content

Commit

Permalink
support custom class colors directly in elvui (under blizz improvemen…
Browse files Browse the repository at this point in the history
…ts), this *probably* is not complete
  • Loading branch information
kodewdle committed Dec 7, 2024
1 parent 46f15cd commit 8941611
Show file tree
Hide file tree
Showing 25 changed files with 172 additions and 76 deletions.
2 changes: 1 addition & 1 deletion ElvUI/Cata/Modules/Blizzard/ObjectiveFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function BL:ObjectiveTracker_Setup()
holder:Point('TOPRIGHT', E.UIParent, -135, -300)
holder:Size(130, 22)

E:CreateMover(holder, 'ObjectiveFrameMover', L["Objective Frame"], nil, nil, nil, nil, nil, 'general,blizzUIImprovements')
E:CreateMover(holder, 'ObjectiveFrameMover', L["Objective Frame"], nil, nil, nil, nil, nil, 'general,blizzardImprovements')
holder:SetAllPoints(_G.ObjectiveFrameMover)

-- prevent it from being moved by blizzard (the hook below will most likely do nothing now)
Expand Down
1 change: 1 addition & 0 deletions ElvUI/Core/Defaults/Private.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ V.general = {
blizzardFontSize = false,
noFontScale = false,
totemTracker = true,
classColors = false,
queueStatus = true,
minimap = {
enable = true,
Expand Down
17 changes: 16 additions & 1 deletion ElvUI/Core/Defaults/Profile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,21 @@ P.general = {
talkingtitle = { enable = false, font = 'Expressway', size = 20, outline = 'SHADOW' },
talkingtext = { enable = false, font = 'Expressway', size = 18, outline = 'SHADOW' }
},
classColors = {
HUNTER = { b = 0.44, g = 0.82, r = 0.66 },
WARRIOR = { b = 0.42, g = 0.60, r = 0.77 },
ROGUE = { b = 0.40, g = 0.95, r = 1 },
MAGE = { b = 0.92, g = 0.78, r = 0.24 },
PRIEST = { b = 1, g = 1, r = 1 },
EVOKER = { b = 0.49, g = 0.57, r = 0.20 },
SHAMAN = { b = 0.86, g = 0.43, r = 0 },
WARLOCK = { b = 0.93, g = 0.53, r = 0.52 },
DEMONHUNTER = { b = 0.78, g = 0.18, r = 0.63 },
DEATHKNIGHT = { b = 0.22, g = 0.11, r = 0.76 },
DRUID = { b = 0.03, g = 0.48, r = 1 },
MONK = { b = 0.59, g = 1, r = 0 },
PALADIN = { b = 0.72, g = 0.54, r = 0.95 }
},
debuffColors = { -- handle colors of LibDispel
none = { r = 0.8, g = 0, b = 0 },
Magic = { r = 0.2, g = 0.6, b = 1 },
Expand All @@ -88,9 +103,9 @@ P.general = {
Poison = { r = 0, g = 0.6, b = 0 },

-- These dont exist in Blizzards color table
Bleed = { r = 1, g = 0.2, b = 0.6 },
EnemyNPC = { r = 0.9, g = 0.1, b = 0.1 },
BadDispel = { r = 0.05, g = 0.85, b = 0.94 },
Bleed = { r = 1, g = 0.2, b = 0.6 },
Stealable = { r = 0.93, g = 0.91, b = 0.55 },
},
bordercolor = { r = 0, g = 0, b = 0 }, -- updated in E.Initialize
Expand Down
78 changes: 71 additions & 7 deletions ElvUI/Core/General/API.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local wipe, max, next, tinsert, date, time = wipe, max, next, tinsert, date, tim
local strfind, strlen, tonumber, tostring = strfind, strlen, tonumber, tostring
local hooksecurefunc = hooksecurefunc

local CopyTable = CopyTable
local CreateFrame = CreateFrame
local GetBattlefieldArenaFaction = GetBattlefieldArenaFaction
local GetClassInfo = GetClassInfo
Expand Down Expand Up @@ -429,6 +430,18 @@ function E:IsDispellableByMe(debuffType)
return DispelTypes[debuffType]
end

function E:UpdateDispelColor(debuffType, r, g, b)
local color = DebuffColors[debuffType]
if color then
color.r, color.g, color.b = r, g, b
end

local db = E.db.general.debuffColors[debuffType]
if db then
db.r, db.g, db.b = r, g, b
end
end

function E:UpdateDispelColors()
local colors = E.db.general.debuffColors
for debuffType, db in next, colors do
Expand All @@ -440,15 +453,66 @@ function E:UpdateDispelColors()
end
end

function E:UpdateDispelColor(debuffType, r, g, b)
local color = DebuffColors[debuffType]
if color then
color.r, color.g, color.b = r, g, b
do
local callbacks = {}
function E:CustomClassColorUpdate()
for func in next, callbacks do
func()
end
end

local db = E.db.general.debuffColors[debuffType]
if db then
db.r, db.g, db.b = r, g, b
function E:CustomClassColorRegister(func)
callbacks[func] = true
end

function E:CustomClassColorUnregister(func)
callbacks[func] = nil
end

E.CustomClassColorMeta = {
RegisterCallback = E.CustomClassColorRegister,
UnregisterCallback = E.CustomClassColorUnregister
}

function E:SetupCustomClassColors()
local object = CopyTable(_G.RAID_CLASS_COLORS)

_G.CUSTOM_CLASS_COLORS = setmetatable(object, { __index = E.CustomClassColorMeta })

return object
end

function E:UpdateCustomClassColor(classTag, r, g, b)
local colors = _G.CUSTOM_CLASS_COLORS
local color = colors and colors[classTag]
if color then
color.r, color.g, color.b = r, g, b
color.colorStr = E:RGBToHex(r, g, b, 'ff')
end

local db = E.db.general.classColors[classTag]
if db then
db.r, db.g, db.b = r, g, b
end

E:CustomClassColorUpdate()
end

function E:UpdateCustomClassColors()
if not E.private.general.classColors then return end

local custom = _G.CUSTOM_CLASS_COLORS or E:SetupCustomClassColors()
local colors = E.db.general.classColors

for classTag, db in next, colors do
local color = custom[classTag]
if color then
E:UpdateClassColor(db)

color.r, color.g, color.b = db.r, db.g, db.b
color.colorStr = E:RGBToHex(db.r, db.g, db.b, 'ff')
end
end
end
end

Expand Down
2 changes: 2 additions & 0 deletions ElvUI/Core/General/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,7 @@ end
function E:UpdateMediaItems(skipCallback)
E:UpdateMedia()
E:UpdateDispelColors()
E:UpdateCustomClassColors()
E:UpdateFrameTemplates()
E:UpdateStatusBars()

Expand Down Expand Up @@ -2027,6 +2028,7 @@ function E:Initialize()
E:LoadMovers()
E:UpdateMedia()
E:UpdateDispelColors()
E:UpdateCustomClassColors()
E:UpdateCooldownSettings('all')
E:Contruct_StaticPopups()

Expand Down
2 changes: 1 addition & 1 deletion ElvUI/Core/Modules/Blizzard/AlertFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function BL:AlertMovers()
AlertFrameHolder:Size(180, 20)
AlertFrameHolder:Point('TOP', E.UIParent, 'TOP', 0, -20)

E:CreateMover(AlertFrameHolder, 'AlertFrameMover', L["Loot / Alert Frames"], nil, nil, E.PostAlertMove, nil, nil, 'general,blizzUIImprovements')
E:CreateMover(AlertFrameHolder, 'AlertFrameMover', L["Loot / Alert Frames"], nil, nil, E.PostAlertMove, nil, nil, 'general,blizzardImprovements')

_G.GroupLootContainer:EnableMouse(false) -- Prevent this weird non-clickable area stuff since 8.1; Monitor this, as it may cause addon compatibility.

Expand Down
2 changes: 1 addition & 1 deletion ElvUI/Core/Modules/Blizzard/Blizzard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function BL:HandleAddonCompartment()
compartment:SetFrameLevel(10) -- over minimap mover
compartment:ClearAllPoints()
compartment:Point('RIGHT', _G.ElvUI_MinimapHolder or _G.Minimap, -5, 10)
E:CreateMover(compartment, 'AddonCompartmentMover', L["Addon Compartment"], nil, nil, nil, nil, nil, 'general,blizzUIImprovements,addonCompartment')
E:CreateMover(compartment, 'AddonCompartmentMover', L["Addon Compartment"], nil, nil, nil, nil, nil, 'general,blizzardImprovements,addonCompartment')
end

local db = E.db.general.addonCompartment
Expand Down
2 changes: 1 addition & 1 deletion ElvUI/Core/Modules/Blizzard/Vehicle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function BL:PositionVehicleFrame()
indicator:SetPoint('TOPRIGHT', _G.MinimapCluster, 'BOTTOMRIGHT', 0, 0)
indicator:Size(E.db.general.vehicleSeatIndicatorSize)

E:CreateMover(indicator, 'VehicleSeatMover', L["Vehicle Seat Frame"], nil, nil, nil, nil, nil, 'general,blizzUIImprovements')
E:CreateMover(indicator, 'VehicleSeatMover', L["Vehicle Seat Frame"], nil, nil, nil, nil, nil, 'general,blizzardImprovements')
indicator.PositionVehicleFrameHooked = true
end

Expand Down
2 changes: 1 addition & 1 deletion ElvUI/Core/Modules/Misc/Loot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ function M:LoadLoot()
M:RegisterEvent('OPEN_MASTER_LOOT_LIST')
M:RegisterEvent('UPDATE_MASTER_LOOT_LIST')

E:CreateMover(lootFrameHolder, 'LootFrameMover', L["Loot Frame"], nil, nil, nil, nil, nil, 'general,blizzUIImprovements')
E:CreateMover(lootFrameHolder, 'LootFrameMover', L["Loot Frame"], nil, nil, nil, nil, nil, 'general,blizzardImprovements')

_G.LootFrame:UnregisterAllEvents()
tinsert(_G.UISpecialFrames, 'ElvLootFrame')
Expand Down
2 changes: 1 addition & 1 deletion ElvUI/Core/Modules/Misc/QueueStatus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function M:LoadQueueStatus()
M.QueueStatus:Point('BOTTOMRIGHT', _G.ElvUI_MinimapHolder or _G.Minimap, 'BOTTOMRIGHT', -5, 25)
M.QueueStatus:SetFrameLevel(10) -- over minimap mover
M.QueueStatus:Size(32)
E:CreateMover(M.QueueStatus, 'QueueStatusMover', L["Queue Status"], nil, nil, nil, nil, nil, 'general,blizzUIImprovements,queueStatus')
E:CreateMover(M.QueueStatus, 'QueueStatusMover', L["Queue Status"], nil, nil, nil, nil, nil, 'general,blizzardImprovements,queueStatus')

local statusFrame = _G.QueueStatusFrame
if statusFrame then
Expand Down
16 changes: 16 additions & 0 deletions ElvUI_Options/Core/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ local UnitExists = UnitExists
local UnitIsUnit = UnitIsUnit
local UnitIsFriend = UnitIsFriend
local UnitIsPlayer = UnitIsPlayer
local GetClassInfo = GetClassInfo
local CLASS_SORT_ORDER = CLASS_SORT_ORDER
local NUM_CLASSES = #CLASS_SORT_ORDER

C.Values = {
GrowthDirection = {
Expand All @@ -41,6 +44,8 @@ C.Values = {
LEFT_DOWN = format(L["%s and then %s"], L["Left"], L["Down"]),
LEFT_UP = format(L["%s and then %s"], L["Left"], L["Up"]),
},
MAX_BOSS_FRAMES = 8,
NUM_CLASSES = NUM_CLASSES,
FontFlags = ACH.FontValues,
FontSize = { min = 8, max = 64, step = 1 },
Roman = { 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X', 'XI', 'XII', 'XIII', 'XIV', 'XV', 'XVI', 'XVII', 'XVIII', 'XIX', 'XX' }, -- 1 to 20
Expand All @@ -60,6 +65,17 @@ C.Values = {
}
}

do
C.ClassTable = {}

for i = 1, NUM_CLASSES do
local name, tag = GetClassInfo(i)
if tag then
C.ClassTable[tag] = name
end
end
end

do
C.StateSwitchGetText = function(_, TEXT)
local friend, enemy = strmatch(TEXT, '^Friendly:([^,]*)'), strmatch(TEXT, '^Enemy:([^,]*)')
Expand Down
Loading

0 comments on commit 8941611

Please sign in to comment.