WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Masque ButtonData (https://www.wowinterface.com/forums/showthread.php?t=52871)

Benalish 11-10-15 04:07 PM

Masque ButtonData
 
I am trying to assign a skin to my addon buttons with Masque, but there are some trouble with the cooldown layer. In fact, it often happens that the size of the cooldown are greater than those of the button. I think this is due to the fact that Masque not skins the cooldown layer. Reading the documentation, I came across this page. Honestly is not very clear explanation, and from what little I understood I should "feed" Masque with this table, but there no mention of how it should be done. The buttons are created and skinned in this way:

Lua Code:
  1. local MSQ = LibStub("Masque", true)
  2.  
  3. local f = CreateFrame("Button", "myButton",)
  4. f.cooldown = CreateFrame("Cooldown", f:GetName().."Cooldown", f, "CooldownFrameTemplate")
  5.  
  6. if (MSQ) then
  7.     MSQ:Group("MyAddon", "MyAddon group"):AddButton(f:GetName())
  8. end

How should do to get the right skin?

Phanx 11-10-15 06:10 PM

1. Masque does "skin" the cooldown, by moving and resizing it according to the skin's definitions. If it's misplaced or incorrectly sized, either Masque isn't able to identify your button's cooldown object, or the skin you're using is broken. Compare to the same skin on other action buttons (eg. Bartender or Dominos) to see if it's a skin issue or not.

2. You only need to provide a button data table if your button (a) doesn't have all of the regions/children Masque expects, or (b) doesn't use the standard names/keys for its regions/children. It's not necessary for typical action buttons with the expected structure.

3. Please post your entire, actual button creation code. What you posted is just not enough to identify any issues, and is making my eye twitch with awful (hopefully fake example) globals like "myButton". :(

Benalish 11-11-15 05:44 AM

Quote:

Originally Posted by Phanx (Post 311721)

3. Please post your entire, actual button creation code. What you posted is just not enough to identify any issues, and is making my eye twitch with awful (hopefully fake example) globals like "myButton". :(

XML code: http://nopaste.linux-dev.org/?830226 (I know I'm a bad person 'cause I use XML :()
Lua code: http://nopaste.linux-dev.org/?830227

I use nopaste service 'cause is a bit long code, and I did not want write a flood post

Benalish 11-13-15 02:57 PM

MyAddon:iconLocation() is just an icon reposizioning function

Lua Code:
  1. function MyAddon:iconLocation(idx) -- how the icons will be arranged according to the number of rows and columns
  2.     local row = db.profile["Bars"][idx]["rows"]
  3.     local col = db.profile["Bars"][idx]["columns"]
  4.     local frm = "MyAddon_Frame"..idx
  5.     for r = 1, row do
  6.         local line = col * r
  7.         local first = line - (col - 1)
  8.         for i = first, line do
  9.             local icona = MyAddon:iconName(idx, i)
  10.             if (i == 1) then
  11.                 icona:SetPoint("TOPLEFT",0,0)
  12.             elseif (i == first) and (i ~= 1) then
  13.                 local up =  first - col
  14.                 icona:SetPoint("TOPLEFT", frm.."MyAddon_Icon"..up , "BOTTOMLEFT", 0, db.profile.Vspacing)
  15.             else
  16.                 icona:SetPoint("TOPLEFT", frm.."MyAddon_Icon"..i-1 ,"TOPRIGHT", db.profile.Hspacing, 0)
  17.             end
  18.         end
  19.     end
  20. end

Phanx 11-17-15 01:18 AM

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.

Benalish 11-19-15 02:28 PM

This is my new attempt, and its results:

The XML skeleton: https://gist.github.com/anonymous/2eebedd2141d3106f108

And the lua code:

Lua Code:
  1. function MyAddon:iconUpdate(total, frm) -- Icons (where buffs displayed)
  2.     local bar = frm:GetID()
  3.    
  4.     for i = 1, total do
  5.         local f = MyAddon:iconName(bar, i) or CreateFrame("Button", frm:GetName().."MyAddon_Icon"..i, frm, "MyAddon_IconTemplate", i)
  6.         local ButtonData = {
  7.                 -- Things your button does have:
  8.                 Icon = f.texture,
  9.  
  10.                 -- Textures your button doesn't have:
  11.                 AutoCastable = false,
  12.                 Backdrop = false,
  13.                 Border = false,
  14.                 Checked = false,
  15.                 Disabled = false,
  16.                 Flash = false,
  17.                 Normal = false,
  18.                 Pushed = false,
  19.  
  20.                 -- Font strings your button doesn't have:
  21.                 Name = false,
  22.                 Count = false,
  23.                 Duration = false,
  24.                 HotKey = false,
  25.  
  26.                 -- Frames your button doesn't have:
  27.                 AutoCast = false,
  28.                 SpellAlert = false,
  29.             }  
  30.         --the rest of the stuff is the same, with your hints
  31.         if (MSQ) then
  32.             MSQ:Group("MyAddon", "Icon bar\32"..bar):AddButton(f, ButtonData)
  33.         end
  34.     end
  35. end

The result is different from what I expected: http://imgur.com/ggJhCQo. As one can see from the picture, the cooldown overflow from icon because Masque failed to skin it. You should see the border, according to Masque settings: http://imgur.com/tLSEuSk

The only thing I can add is that the buttons are created at the call of this function:

Lua Code:
  1. function MyAddon:OnInitialize()
  2.     -- Called when the addon is loaded
  3.     self.db = LibStub("AceDB-3.0"):New("MyAddonDB", defaults)
  4.     db = self.db
  5.     MyAddon:RegisterEvent("PLAYER_ENTERING_WORLD", function()  
  6.         MyAddon:barUpdate()
  7.     end)
  8. end

Where did I go wrong?

jeffy162 11-19-15 03:29 PM

The button skin tells Masque the dimensions of the cooldown swipe.
Lua Code:
  1. Cooldown = {
  2.         Width = 32,
  3.         Height = 32,
  4.     },
From the "Death Knight" part of my Masque_CB-Elv.
I don't think you can change that with another addon, but I guess maybe you can if you have the dimensions to change. Anyway, if I'm wrong I'm sure someone will chime in here to tell me. :o

Phanx 11-19-15 09:54 PM

As I mentioned earlier:

Quote:

Originally Posted by Phanx (Post 311721)
1. Masque does "skin" the cooldown, by moving and resizing it according to the skin's definitions. If it's misplaced or incorrectly sized, either Masque isn't able to identify your button's cooldown object, or the skin you're using is broken. Compare to the same skin on other action buttons (eg. Bartender or Dominos) to see if it's a skin issue or not.

Does the same skin show the same issue on other addons?

If not, then it's likely the problem actually stems from the fact that your buttons don't have most of the textures a "regular" buttons have, but the skin is constructed with "regular" buttons in mind, where the border and/or normal textures would be filling up that space around the icon texture where the cooldown appears to be sticking out. If this is what's happening, then you'll probably just have to (1) tell Masque not to touch your cooldown (by setting Cooldown = false) in the buttonData table, and (2) manage the size of the cooldown yourself by registering for a OnSkinChanged callback from Masque, checking the size of the icon, and sizing/placing your cooldown object appropriately.

jeffy162 11-20-15 08:12 AM

Keep in mind: Masque DOES NOT skin default objects. IE default action bars or buffs, debuffs and there may be more objects that I'm missing (imagine that!). :o

Benalish 11-22-15 08:15 AM

After several attempts, I found that the problem lies in the texture structure, but I don't know how to configure it properly so Masque is able to skin it correctly. Any advice is welcome :D

jeffy162 11-22-15 12:42 PM

Try resizing the cool down in whatever skin you are using. That should resize the swipe.

Look for something like
Lua Code:
  1. Cooldown = {
  2.         Width = 36,
  3.         Height = 36,
  4.     },
in the skin's Lua file. Just change the numbers.

EDIT: You are using a Masque skin, right? /EDIT

Phanx 11-22-15 01:11 PM

Quote:

Originally Posted by jeffy162 (Post 311910)
Try resizing the cool down in whatever skin you are using. That should resize the swipe.

It will, but it will also resize the swipe for all addons that you apply the skin to (which probably won't result in a good appearance, since other addons have things like border textures on their buttons) and it won't solve the problem for anyone else if the addon is published for other people to use.

Quote:

Originally Posted by Benalish (Post 311907)
After several attempts, I found that the problem lies in the texture structure, but I don't know how to configure it properly so Masque is able to skin it correctly. Any advice is welcome :D

Without more information, there's not much I can tell you, but I am going to repeat myself for a third time:

Quote:

Originally Posted by Phanx (Post 311865)
Does the same skin show the same issue on other addons?

If yes, your skin is broken, try a different one.

If no, post screenshots of the same skin applied to both your addon (where it looks wrong) and another addon (where it looks correct) and post your entire addon (not just parts of it).


All times are GMT -6. The time now is 04:01 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI