Reply
Thread Tools Display Modes
Unread 03-19-14, 06:46 PM   #1
Duugu
Premium Member
 
Duugu's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 737
SecureHandlers and 'equipmentset'

Holla everyone

I'm working on my action bar addon an would like to support equipment sets from the Blizz equipment manager.

I've found the following code in SecureHandlers.lua:

Lua Code:
  1. local function PickupAny(kind, target, detail, ...)
  2.     if (kind == "clear") then
  3.         ClearCursor();
  4.         kind, target, detail = target, detail, ...;
  5.     end
  6.  
  7.     if kind == 'action' then
  8.         PickupAction(target);
  9.     elseif kind == 'bag' then
  10.         PickupBagFromSlot(target)
  11.     elseif kind == 'bagslot' then
  12.         PickupContainerItem(target, detail)
  13.     elseif kind == 'inventory' then
  14.         PickupInventoryItem(target)
  15.     elseif kind == 'item' then
  16.         PickupItem(target)
  17.     elseif kind == 'macro' then
  18.         PickupMacro(target)
  19.     elseif kind == 'merchant' then
  20.         PickupMerchantItem(target)
  21.     elseif kind == 'petaction' then
  22.         PickupPetAction(target)
  23.     elseif kind == 'money' then
  24.         PickupPlayerMoney(target)
  25.     elseif kind == 'spell' then
  26.         PickupSpell(target)
  27.     elseif kind == 'companion' then
  28.         PickupCompanion(target, detail)
  29.     elseif kind == 'equipmentset' then
  30.         PickupEquipmentSet(target);
  31.     end
  32. end
  33. function SecureHandler_OnDragEvent(self, snippetAttr, button)
  34.     local body = self:GetAttribute(snippetAttr);
  35.     if (body) then
  36.         PickupAny( SecureHandler_Self_Execute(self,
  37.                                               "self,button,kind,value,...",
  38.                                               body, button, GetCursorInfo()) );
  39.     end
  40. end

Doesn't that mean that a frame that inherits SecureActionButtonTemplate will support the type 'equipmentset'?

Unfortunatly something like
Lua Code:
  1. frame:SetAttribute("type", "equipmentset")
  2. frame:SetAttribute("equipmentset", "<nameofavalidset>")
does not work.

Does someone know if "equipmentset" actually is a valid value for "type"?
Duugu is offline   Reply With Quote
Unread 03-19-14, 07:05 PM   #2
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,387
Based on that code and the API documentation for PickupEquipmentSet, it looks like you need to use the set index, not the set name, and I'd expect this to work:

Code:
frame:SetAttribute("type", "equipmentset")
frame:SetAttribute("equipmentset", 4)
If you want to let the user enter a name instead of an index, you can find the index like this:

Code:
local function GetEquipmentSetIDByName(name)
    for i = 1, GetNumEquipmentSets() do
        if GetEquipmentSetInfo(i) == name then
            return i
        end
    end
end
I'm not that knowledgable about the equipment set API in general, though... if the indices are not fixed (eg. they can change if the user renames the set or adds a new set) then you probably want to store the set by name, and check its ID every time something changes.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!

Last edited by Phanx : 03-19-14 at 07:10 PM.
Phanx is offline   Reply With Quote
Unread 03-19-14, 07:21 PM   #3
Duugu
Premium Member
 
Duugu's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 737
Thank you white cat.
I've tried this:

Lua Code:
  1. local button = CreateFrame("CheckButton", "testbutton1", UIParent, "SecureActionButtonTemplate, ActionButtonTemplate")
  2.     button:RegisterForClicks("AnyUp")
  3.     button:SetPoint("CENTER", UIParent, "CENTER")
  4.     button:SetHeight(50)
  5.     button:SetWidth(50)
  6.     button:SetAttribute("type", "spell")
  7.     button:SetAttribute("spell", "1459")
  8.     local button = CreateFrame("CheckButton", "testbutton2", UIParent, "SecureActionButtonTemplate, ActionButtonTemplate")
  9.     button:RegisterForClicks("AnyUp")
  10.     button:SetPoint("CENTER", UIParent, "CENTER", 0, 55)
  11.     button:SetHeight(50)
  12.     button:SetWidth(50)
  13.     button:SetAttribute("type", "equipmentset")
  14.     button:SetAttribute("equipmentset", "1")

The first button does work (at least on my mage *g*).
The second button still does not. :/

I've created a set named "test". GetEquipmentSetIDByName("test") does return '1', so I'm sure that this is the right index.

I've still no idea what's wrong with it or if "equipmentset" is even a valid type. Any other ideas?
Duugu is offline   Reply With Quote
Unread 03-19-14, 08:01 PM   #4
Vrul
A Cobalt Mageweaver
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 202
That code from SecureHandlers.lua is for handling dragging. The code to handle clicking/using a button is in SecureTemplates.lua, specifically the possible options for "type" are the entries in the SECURE_ACTIONS table. Based on that you will probably want:
Code:
button:SetAttribute("type", "macro")
button:SetAttribute("macrotext", "/equipset test")
Vrul is offline   Reply With Quote
Unread 03-19-14, 08:05 PM   #5
Duugu
Premium Member
 
Duugu's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 737
Oh. Ok. I'll use a macro. :/ Thank you.

But why the hell do they implement draging for a type that is not handled?
Duugu is offline   Reply With Quote
Unread 03-19-14, 08:28 PM   #6
Vrul
A Cobalt Mageweaver
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 202
Those were possible returns from GetCursorInfo that it was checking.
Vrul is offline   Reply With Quote
Unread 03-24-14, 12:28 AM   #7
Duugu
Premium Member
 
Duugu's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 737
I'm again digging into this. Now with flyout buttons.

I've finally managed to set up a flyout button without using the type "action".
Lua Code:
  1. btn:SetAttribute("type", "flyout")
  2. btn:SetAttribute("spell", <flyoutnumber>)
But ... I didn't found a way to support a pick up action for the button.
Right now I'm picking up the button via the flyout id and the PickupSpellBookItem.

Lua Code:
  1. local name = GetFlyoutInfo(value)
  2.     local found
  3.     local spellName = ""
  4.     local i = 1
  5.     while true do
  6.        local spellName = GetSpellBookItemName(i, BOOKTYPE_SPELL)
  7.         if spellName == name then
  8.             found = i
  9.             break
  10.         end
  11.        if not spellName then
  12.           do break end
  13.        end
  14.        i = i + 1
  15.     end
  16.    
  17.     if found then
  18.         PickupSpellBookItem(found, BOOKTYPE_SPELL)
  19.     end

But, well ... this is unsecure. Is there really no way to support dragging flyout buttons from the button frame without using "action" and an action id?

Last edited by Duugu : 03-24-14 at 12:30 AM.
Duugu is offline   Reply With Quote
Unread 03-24-14, 05:49 AM   #8
Lombra
A Cobalt Mageweaver
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 233
I have no idea, but I wouldn't be surprised if there wasn't. If you want to make real custom action buttons outside of the action scope (in API terms), it's suddenly a whole other deal. There's lots of events and function for "actions" only.
__________________
Grab your sword and fight the Horde!
Lombra is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » General Authoring Discussion » SecureHandlers and 'equipmentset'

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off