Quantcast
Download
(4 Kb)
Download
Updated: 09-30-16 04:48 PM
Compatibility:
Legion (7.0.3)
Updated:09-30-16 04:48 PM
Created:03-14-15 07:01 PM
Downloads:707
Favorites:3
MD5:

SetMacroIcon

Version: 7.703
by: Banknorris [More]

This is not an addon.
This is a very small library that provides five API functions that addons can use to overcome the limitations of SetMacroSpell and SetMacroItem to change a macro icon during combat.
Usage:
Once you extract the zip file into your addon folder, edit your .toc file to have this line inserted before the .lua files that will use the API functions:
Libs\SetMacroIcon.lua

The most important API function of this library is:

Code:
SetMacroIcon(<macro name or index>,<icon file>) --works in combat
that allows you to set a macro icon by giving the icon file path. The effect is only visible in the action bars, not in the macro interface (maybe in a near future...). For example:
Lua Code:
  1. SetMacroIcon("travel","Interface\\Icons\\achievement_guildperk_mountup")
will set a macro named "travel" with the icon "Interface\\Icons\\achievement_guildperk_mountup"
Using
Lua Code:
  1. ResetMacroIcon("travel")
will cancel the effect.
This function can be called in combat. Out of combat you could just
EditMacro("travel",nil,"achievement_guildperk_mountup")
but during combat you were limited to SetMacroSpell and SetMacroItem.
And you are not only restricted to Interface\Icons, this also works:
Lua Code:
  1. SetMacroIcon("travel","Interface\\Pictures\\14679_Tirion_256.png")

Known caveats
The current implementation uses the macro name as the macro identity. I don't use the index because the index of a given macro can change when you create or delete other macros. There is a price to pay for this approach:
All macros with the same name of the macro referenced with SetMacroIcon will use the same override icon. If you rename the macro the override icon will follow if no macros with the old name remains and if there is no override macro already set for the new name (meaning there are already other macros with the new name).

The library also provides:

Code:
GetMacroIcon(<macro name or index>) --works in combat
Will return the override icon set with SetMacroIcon for the specified macro or nil if there is not an override icon defined.


Code:
SetMacroSpell(<macro name or index>,<spell name>[,<target>]) --works in combat
Will initially cancel the override icon (if there is one) and then call the original SetMacroSpell function with the same arguments.


Code:
SetMacroItem(<macro name or index>,<item name>[,<target>]) --works in combat
Will initially cancel the override icon (if there is one) and then call the original SetMacroItem function with the same arguments.


Code:
SetMacroStatus(<macro name or index>,<status>) --works in combat
<status> being either "enabled" or "disabled". Use this when you want to control if a macro status (icon grayed or not) should be enabled or disabled regardless of the macro spell or macro item.

_________________________________________________________________________

My addon MandrillMount uses this library to display the random mount icon and the Nagrand Garrison mount icon for the macro icon. So maybe it is a good idea to check that code in order to see how the library is used.

5.623 Now allows the user to define a addon-escope function addon_table.fix_tooltip(macro_name,icon_texture) that will be called with macro_name and override_icon parameters and should set the GameTooltip based on those informations (probably calling GameTooltip:SetSpellByID() or such)

4.620 Improved performance by calling the SetTexture hook for relevant buttons (instead of all) when SetMacroIcon is used. Included a function SetMacroStatus to better control of macro status (enabled or disabled).

3.620 Using EnumerateFrames() instead of recursive calls to {frame:GetChildren()}, forced garbagecollection no longer needed. Included support to track renamed macros. Improved the behavior of the Border texture alpha.
Optional Files (0)


Archived Files (6)
File Name
Version
Size
Author
Date
6.703
4kB
Banknorris
09-10-16 09:32 AM
5.623
4kB
Banknorris
02-14-16 10:12 AM
4.620
4kB
Banknorris
08-31-15 02:56 PM
3.620
4kB
Banknorris
07-29-15 01:02 PM
2.610
2kB
Banknorris
03-17-15 01:47 PM
1.610
4kB
Banknorris
03-14-15 07:01 PM


There have been no comments posted to this file.
Be the first to add one.



Category Jump: