[Classic] Toggled spells: stance bar, action bars, and :SetTexture
1 Attachment(s)
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 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 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? |
I would look at <button>:SetHighlightTexture(id or path) and / or <button>::SetPushedTexture(id or path)
|
The "checked" texture is the yellow/white border around the icon when the ability is active. The pushed and highlight textures are similar border styles and not the actual icon either.
Hooking directly into the function that sets the icons worked for me. Lua Code:
The actionbars on the other hand don't have a clear way to identify if a toggled ability is active. You could compare the action texture with the spell texture and see if they differ, but this causes some false positives for auto-attack type abilities that show the equipped weapon's icon instead of their internal spell texture. |
Thank you both for the replies!
Quote:
Code:
hooksecurefunc("ActionButton_UpdateState",function(button) Edit 1: The default code is calling GetActionTexture() instead of GetSpellTexture(). GetActionTexture returns the wisp icon. Solved it, sort of. I needed to hook ActionButton_Update, as opposed to ActionButton_UpdateState. The mostly-working code for the action bars is: Code:
hooksecurefunc("ActionButton_Update",function(self) After some further testing, it seems as though both ActionButton_Update and ActionButton_OnEvent need to be hooked in order to cover all of the apparent cases where the default code is changing the icon. |
All times are GMT -6. The time now is 04:39 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI