View Single Post
11-17-15, 01:18 AM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
XML, lines 13-15:
This does nothing, since you don't set any drag-related scripts on bars, only on buttons. Get rid of this.

XML, lines 63-75:
You probably don't actually want to create a separate dropdown frame for every button. Just create one dropdown for your whole addon, and pass the correct arguments to the toggle function to position it relative to the specific button that was clicked to open it.

XML, line 86:
Based on the Lua code you posted, this is the mouseover trigger for tooltips -- get rid of this, you don't need it, the whole button can (and should) trigger a tooltip.

Lua, line 37:
If you're going to create a dedicated function for concatenating values to form a button name, you should also use that same function to get the name you pass to CreateFrame.

Lua, line 39:
If you're going to use XML, you should actually use XML, and add a cooldown to your button template.

Also (and much more importantly) you are creating a new cooldown object every time you update the button, which is bad.

Lua, line 54:
You should really try to find a way to do this that doesn't require creating a new function every time you update the button. See your "MyAddon_wpnenchScan_Onupdate" function as an example. An easy way to do this would be to attach keys to the button whose values contain the appopriate values of "bar" and "i", eg "f.bar = <reference to the bar frame>" and "f.id = i", and then refer to those in the function, so it can be called on any button and still have the data it needs.

Also, while "0,005" may be correct for human language in your region, Lua requires "0.005" notation for decimal values; currently you're passing "0" and then "005" as separate arguments.

Lua, line 58:
Again, try to generalize this function and define it outside of this update function, so you don't need to create a new one every time you update a button.

Lua, line 64:
Same thing, except Blizzard has already defined a generic version of this function; just use SetScript("OnLeave", GameTooltip_Hide) to get this behavior.

Lua, line 68:
Your button doesn't have a "highlight" member. It has a highlight texture, but that's not automatically assigned to the "highlight" key. If you want to do that, you need to write "f.highlight = f:GetHighlightTexture()" somewhere (like in your button's OnLoad script) first.

Lua, line 90:
Now we finally get to Masque! Most like you don't need your individual bars to be skinned differently, so you should just use Group("MyAddon") to just create one entry in the Masque options UI for your whole addon.

Masque's AddButton function can just take a reference to the button -- "f" in this context -- so you don't need to look up its name -- though if you did need to, you should just do "f:GetName()" instead of this!

Your button's button data table should probably look like this:

Code:
{
    -- Things your button does have:
    Icon = f.texture,

    -- Textures your button doesn't have:
    AutoCastable = false,
    Backdrop = false,
    Border = false,
    Checked = false,
    Disabled = false,
    Flash = false,
    Normal = false,
    Pushed = false,

    -- Font strings your button doesn't have:
    Name = false,
    Count = false,
    Duration = false,
    HotKey = false,

    -- Frames your button doesn't have:
    AutoCast = false,
    SpellAlert = false,
}
Things that aren't included in the table:

Cooldown: Masque can find this on its own since your cooldown object is named <buttonName>Cooldown like "real" action buttons.

Highlight: Masque will just call button:GetHighlightTexture() to find this on its own.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote