Hi everyone.
I enjoy writing small addons that are by no means practical but address personal visual gripes and help me learn a bit about the addon API in the process.
In this instance, I dislike how toggled spells (Devotion Aura, druid forms, hunter Aspects, shadow form) have their icons all change to the same icon whenever they are active, which seems to be: Interface\Icons\Spell_Nature_WispSplode
My goal is to prevent the icon from changing and simply desaturate it. I think the ideal approach would be to intercept the function that changes these icons to begin with, but looking through the default interface code, I haven't determined if that's possible.
In lieu of that, I've temporarily narrowed my scope to the stance bar and have come up with a method that fires on UNIT_SPELLCAST_SUCCEEDED to desaturate the icon, but I haven't successfully reverted the actual icon texture.
Code:
for i = 1, 10 do
local btn = _G["StanceButton" .. i]
if not btn then return end
local icon, isActive, isCastable, spellID = GetShapeshiftFormInfo(btn:GetID())
local iconTexture = _G[btn:GetName() .. "Icon"] -- the button's icon
local texture = GetSpellTexture(spellID) -- the texture ID/path
if isActive then
iconTexture:SetTexture(texture) -- doesn't change the texture; is this because by the time this code runs, the icon has already changed?
iconTexture:SetDesaturated(true) -- works
iconTexture:Show() -- force the icon to update?
else
iconTexture:SetDesaturated(false) -- works
iconTexture:SetTexture(texture)
end
end
In terms of the default interface code for the stance bar, I believe the icon switching might be occurring in the function StanceBarMixin:UpdateState():
Code:
if ( isActive ) then
self.lastSelected = button:GetID();
button:SetChecked(true); -- it's most likely this that is changing the icon
else
button:SetChecked(false);
end
However, based on the searching I've done through the code so far, SetChecked() seems to be a fairly common function and thus far I haven't found any specific code that where this function is switching the icon.
I am by no means an experienced addon developer, so I would be grateful for any perspectives here. Is this even feasible?