WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Cladhaire's Mods (https://www.wowinterface.com/forums/forumdisplay.php?f=75)
-   -   HOWTO: Integrate your addon with Clique (under Cataclysm/4.x) (https://www.wowinterface.com/forums/showthread.php?t=35284)

Cladhaire 10-05-10 04:52 PM

HOWTO: Integrate your addon with Clique (under Cataclysm/4.x)
 
Adding support for Clique - Non-Group-Headers

During the initialisation of your addon, do:

Code:

ClickCastFrames = ClickCastFrames or {}
Then for any button you create and want to register for click-casting:

Code:

ClickCastFrames[frameObject] = true
That's it!

Adding support for Clique - Group Headers

Unfortunately there was a rather drastic change to the group headers in 4.x that cause the registration process to be a bit convoluted. There are four requirements:
  1. Clique should be an optional dependency for your addon
  2. A frame reference on your group header to the Clique header.
  3. Some bootstrap code in your XML template for your unit frame
  4. Registration code in the initialConfigFunction

The first step is simple, simply include the following in your table of contents file, required to ensure the header exist before you try and use it.

Code:

## OptionalDeps: Clique
You will need to include some bootstrap code in an XML template for your unit frames. You can use the following code as an example:

Code:

<Button name="ClickCastUnitTemplate" virtual="true" inherits="SecureActionButtonTemplate,SecureHandlerEnterLeaveTemplate">
    <Attributes>
        <Attribute name="_onenter" type="string" value="local snippet = self:GetAttribute('clickcast_onenter'); if snippet then self:Run(snippet) end"/>
        <Attribute name="_onleave" type="string" value="local snippet = self:GetAttribute('clickcast_onleave'); if snippet then self:Run(snippet) end"/>
    </Attributes>
</Button>

Next, after the group header frame has been created but before you've shown it, set a frame reference on it:

Code:

yourHeader:SetFrameRef("clickcast_header", ClickCastHeader)
Finally, in the initialConfigFunction snippet, run the following:

Code:

local header = self:GetParent():GetFrameRef("clickcast_header")
-- do not add this conditional in without testing, it will allow for incorrect
-- integration, so you should verify it works before adding this check.
if header then
  header:SetAttribute("clickcast_button", self)
  header:RunAttribute("clickcast_register")
end

If you have any suggestions for how to make this process easier, please let me know.

Shefki 10-06-10 08:37 PM

You'll need to wrap the SetFrameRef like so:

Code:

if ClickCastHeader then
  yourHeader:SetFrameRef("clickcast_header", ClickCastHeader)
end

SetFrameRef throws an error if you pass it nil.

Cladhaire 10-07-10 03:05 AM

That has the problem that is silently breaks, so that's why I did not suggest it.

Shefki 10-07-10 08:29 PM

You also should mention that you need to do:
SecureHandler_OnLoad(yourHeader)

otherwise SetFrameRef isn't available on the frame.

Alternatively you can just run:
SecureHandlerSetFrameRef(yourHeader,"clickcast_header", ClickCastHeader)

Cladhaire 10-08-10 12:53 AM

Correct, or you can inherit from the header base template.

Shefki 10-09-10 11:10 AM

You can't inherit it because the group headers already have an OnLoad.

Bobtehbuildr 10-14-10 06:03 PM

OK, I got it mostly working. Here's what I have done.

My Party Frame had to inherit from both SecurePartyHeaderTemplate and SecureHandlerBaseTemplate.

Now I could do the Frame:SetFrameRef("clickcast_header", ClickCastHeader)";

I updated the initialConfigFunction as an attribute and used the following snippet for the value.

[[
local header = self:GetParent():GetFrameRef("clickcast_header")
-- do not add this conditional in without testing, it will allow for incorrect
-- integration, so you should verify it works before adding this check.
if header then
header:SetAttribute("clickcast_button", self)
header:RunAttribute("clickcast_register")
end
]];

My template for my unit button also needed to inherit from both SecureUnitButtonTemplate and SecureHandlerEnterLeaveTemplate.

I added the following attributes to the template also.

<Attributes>
<Attribute name="_onenter" type="string" value="local snippet = self:GetAttribute('clickcast_onenter'); if snippet then self:Run(snippet) end"/>
<Attribute name="_onleave" type="string" value="local snippet = self:GetAttribute('clickcast_onleave'); if snippet then self:Run(snippet) end"/>
</Attributes>

The only problems I have left are as follows.

How do I get the new buttons that are created into the ClickCastFrames table? The buttons are generated dynamically by SecurePartyHeaderTemplate and I don't get "notified" until the initialConfigFunction snippet is processed. I'm going to try to add it to the snippet but I'm not sure if that will work.

Also I can't seem to get the menu to work on my buttons. The menu works on the stock UI frames.

Cladhaire 10-15-10 02:02 AM

Quote:

Originally Posted by Bobtehbuildr (Post 210176)
OK, I got it mostly working. Here's what I have done.

My Party Frame had to inherit from both SecurePartyHeaderTemplate and SecureHandlerBaseTemplate.

This is actually the only tricky bit. You can't do this, because they both have OnLoad scripts, and only one of them will run. Inherit from SecurePartyHeaderTemplate, and then run the following code after you've created the header:

SecureHandler_OnLoad(yourHeader)

That adds the methods that we get from SecureHandlerBaseTempate without conflicting!

Quote:

Now I could do the Frame:SetFrameRef("clickcast_header", ClickCastHeader)";

I updated the initialConfigFunction as an attribute and used the following snippet for the value.

[[
local header = self:GetParent():GetFrameRef("clickcast_header")
-- do not add this conditional in without testing, it will allow for incorrect
-- integration, so you should verify it works before adding this check.
if header then
header:SetAttribute("clickcast_button", self)
header:RunAttribute("clickcast_register")
end
]];

My template for my unit button also needed to inherit from both SecureUnitButtonTemplate and SecureHandlerEnterLeaveTemplate.

I added the following attributes to the template also.

<Attributes>
<Attribute name="_onenter" type="string" value="local snippet = self:GetAttribute('clickcast_onenter'); if snippet then self:Run(snippet) end"/>
<Attribute name="_onleave" type="string" value="local snippet = self:GetAttribute('clickcast_onleave'); if snippet then self:Run(snippet) end"/>
</Attributes>

The only problems I have left are as follows.

How do I get the new buttons that are created into the ClickCastFrames table? The buttons are generated dynamically by SecurePartyHeaderTemplate and I don't get "notified" until the initialConfigFunction snippet is processed. I'm going to try to add it to the snippet but I'm not sure if that will work.
You can't, but you don't need to. You setting clickcast_button and then calling clickcast_register is the group header equivalent of ClickcastFrames[frame] = true.

Quote:

Also I can't seem to get the menu to work on my buttons. The menu works on the stock UI frames.
Clique uses the WoW standard, where the menu function goes in the frame.menu slot and you use the "menu" attribute. If you use that, it should work.

Bobtehbuildr 10-15-10 05:21 AM

Is there a better way to do party frames? Without WoWs Secure Party Template?

I used to do my own layout but I had issues where I couldn't rearrange the buttons if I was in combat. Any ideas?

If I'm doing it the "wrong" way I don't mind changing it. :banana:

Cladhaire 10-15-10 09:39 AM

I'm not really sure I understand your question. If you want party frames, you can create them ahead of time without using the group headers. If you want frames created during combat without having to create all of them ahead of time, you can use the headers. That's what they are there for.

Bobtehbuildr 10-15-10 05:20 PM

Quote:

Originally Posted by Cladhaire (Post 210730)
I'm not really sure I understand your question. If you want party frames, you can create them ahead of time without using the group headers. If you want frames created during combat without having to create all of them ahead of time, you can use the headers. That's what they are there for.

First off thank you for your time and your addon. I know how much time an addon can take. Your mod is going to take a lot of load off me. I also really like the interface.

Back to the question at hand. I know I can create the frames before combat but what happens when a UI is reloaded while in combat? I will not be able to create the frames right?

Maybe I need to learn a little more about secure frames. Is there a time during load that you can create secure frames and move them around without tainting the system?

Thanks again for your time.

Cladhaire 10-16-10 03:01 AM

Quote:

Originally Posted by Bobtehbuildr (Post 211083)
First off thank you for your time and your addon. I know how much time an addon can take. Your mod is going to take a lot of load off me. I also really like the interface.

Back to the question at hand. I know I can create the frames before combat but what happens when a UI is reloaded while in combat? I will not be able to create the frames right?

Maybe I need to learn a little more about secure frames. Is there a time during load that you can create secure frames and move them around without tainting the system?

Thanks again for your time.

If the user interface is loaded while you are in combat, you are able to create frames and set attributes until just after the PLAYER_REGEN_DISABLED event, where InCombatLockdown() returns true and you can no longer to do this.

Bobtehbuildr 10-17-10 01:20 PM

Quote:

Originally Posted by Cladhaire (Post 211295)
If the user interface is loaded while you are in combat, you are able to create frames and set attributes until just after the PLAYER_REGEN_DISABLED event, where InCombatLockdown() returns true and you can no longer to do this.

Thanks so much. I never new this! My addon has been updated and I now support Clique. ROXORS!


All times are GMT -6. The time now is 11:06 AM.

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