Thread Tools Display Modes
10-22-10, 03:43 AM   #1
sigg
Featured Artist
 
sigg's Avatar
Featured
Join Date: Aug 2008
Posts: 1,251
How To : Right click removing buff

Hello

I know that the new SecuredAuraheader is quite complicated to use, this is a helper to show you how RDX handle that.

Create a file AuraButtonTemplate.xml :
The secureAuraengine need a xml template to create buttons on the fly :

Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
	<Button name="RDXAB30x30Template" inherits="SecureActionButtonTemplate" virtual="true">
		<Size x="30" y="30"/>
		<Attributes>
			<Attribute name="type" value="cancelaura"/>
		</Attributes>
		<Scripts>
			<OnLoad>
				self:RegisterForClicks("RightButtonUp");
			</OnLoad>
			<OnEnter>
				GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT");
				GameTooltip:SetFrameLevel(self:GetFrameLevel() + 2);
				if self:GetAttribute("target-slot") == 16 or self:GetAttribute("target-slot") == 17 or self:GetAttribute("target-slot") == 18 then
					GameTooltip:SetInventoryItem("player", self:GetID());
				else
					GameTooltip:SetUnitAura("player", self:GetID());
				end
			</OnEnter>
			<OnLeave>
				GameTooltip:Hide();
			</OnLeave>
		</Scripts>
	</Button>
</Ui>
Important tags description :
Size This will define the height and width of your buff, example: <Size x="30" y="30"/>
Attribute : indicate the button is a cancelaura type.
<Attributes>
<Attribute name="type" value="cancelaura"/>
</Attributes>


Create the SecureAuraHeader handler :

Code:
local headerAura = CreateFrame("Frame", "SAH", nil, "SecureAuraHeaderTemplate");
headerAura:SetAttribute("unit", "player"); -- to activate UNITAURA event refresh
headerAura:SetAttribute("filter", "HELPFUL");
headerAura:SetAttribute("template", "RDXAB30x30Template"); -- must be the template name of your XML
headerAura:SetAttribute("minWidth", 100);
headerAura:SetAttribute("minHeight", 100);

-- the following code create a buff bar anchor to TOPLEFT and buff orientation goes to right with 10 buttons max on two rows
headerAura:SetAttribute("point", "TOPLEFT"); 
headerAura:SetAttribute("xOffset", 30);
headerAura:SetAttribute("yOffset", 0);
headerAura:SetAttribute("wrapAfter", 10);
headerAura:SetAttribute("wrapXOffset", 0);
headerAura:SetAttribute("wrapYOffset", -30);
headerAura:SetAttribute("maxWraps", 2);

-- sorting
headerAura:SetAttribute("sortMethod", "NAME"); -- INDEX or NAME or TIME
headerAura:SetAttribute("sortDir", "+"); -- - to reverse
headerAura:Show();

-- provide a simple iterator to the header
local function siter_active_children(header, i)
	i = i + 1;
	local child = header:GetAttribute("child" .. i);
	if child and child:IsShown() then
		return i, child, child:GetAttribute("index");
	end
end
function headerAura:ActiveChildren() return siter_active_children, self, 0; end

-- The update style function
local function updateStyle()
	for _,frame in headerAura:ActiveChildren() do
		
		-- create style texture if it doesn't exist
		if not frame.tex then
			frame.tex = CreateTexture(frame);
			frame.tex:SetAllPoints(frame);
			
			frame.cd = CreateFrame("Cooldown");
			frame.cd:SetAllPoints(frame);
			
			frame.txt = CreateFontString(frame);
			frame.txt:SetAllPoints(frame);
			frame.txt:SetFont(GameFontNormal);
		end
		
		local name, _, icon, count, debuffType, duration, expirationTime = UnitAura("player", frame:GetID(), "HELPFUL");
		if name then
			frame.tex:SetTexture(icon);
			frame.cd:SetCooldown(expirationTime - duration, duration);
			if count > 1 then frame.txt:SetText(count); else frame.txt:SetText("");end
			frame.tex:Show();
			frame.cd:Show();
			frame.txt:Show();
		else
			frame.tex:Hide();
			frame.cd:Hide();
			frame.txt:Hide();
		end
	end
end
create a new handler to update the style of each button

Code:
local f = CreateFrame("Frame");
f:RegisterEvent("UNIT_AURA");

-- in the OnEvent UNIT_AURA : 
-- depending of the framework you are using, delay the update to the next frame. I suppose there is a similary function in ace. The example here use our VFL framework
VFLT.NextFrame(math.random(10000000), function() updateStyle() end);
I hope this will help you in your addons.

Cheers
Sigg
  Reply With Quote
10-22-10, 04:38 AM   #2
Sideshow
A Flamescale Wyrmkin
 
Sideshow's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 103
Nice post ! I need that
  Reply With Quote
10-22-10, 05:25 AM   #3
Kurak
A Murloc Raider
Join Date: Feb 2010
Posts: 6
Great, but you could even pray for people like me who have not much idea of it, explain in what folder is it?
  Reply With Quote
10-22-10, 06:44 AM   #4
sigg
Featured Artist
 
sigg's Avatar
Featured
Join Date: Aug 2008
Posts: 1,251
this is a sample code for developer LUA.

  Reply With Quote
10-22-10, 07:43 AM   #5
Luzzifus
A Warpwood Thunder Caller
 
Luzzifus's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 94
I'm trying to set up your example code as a standalone addon right now. I had to change some of these CreateTexture/CreateFontString calls. Also the events fire and call the updateStyle function. However I don't see any buffs ingame. Am I missing something?

-- the following code create a buff bar anchor to TOPLEFT and buff orientation goes to right with 10 buttons max on two rows
headerAura:SetAttribute("point", "TOPLEFT");
headerAura:SetAttribute("xOffset", 30);
headerAura:SetAttribute("yOffset", 0);
headerAura:SetAttribute("wrapAfter", 10);
headerAura:SetAttribute("wrapXOffset", 0);
headerAura:SetAttribute("wrapYOffset", -30);
headerAura:SetAttribute("maxWraps", 2);
Which one of these lines would do that red thing?

Also I did a quick search for any documentation on the SecureAuraHeaderTemplate, like.. eh.. usage maybe. ^^ Came up with basically nothing, I can't even find it in the Blizz UI Source Code..

**edit: After your example and explanation it really doesn't sound so complicated anymore, thank you for that! If only I could see my buffs.

Last edited by Luzzifus : 10-22-10 at 07:49 AM.
  Reply With Quote
10-22-10, 07:50 AM   #6
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
Originally Posted by Luzzifus View Post
I can't even find it in the Blizz UI Source Code..
http://github.com/tekkub/wow-ui-sour...oupHeaders.xml
http://github.com/tekkub/wow-ui-sour...oupHeaders.lua

Thanks for the code, gonna play around with it a bit. But why does the update have to happen "on next frame"?
__________________
Oh, the simulated horror!
  Reply With Quote
10-22-10, 07:43 AM   #7
Maul
Ion Engines, Engage!
 
Maul's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 401
Woot, thanks
__________________

Twitter: @IonMaul | Windows Live: [email protected] | Google Talk: [email protected]
  Reply With Quote
10-22-10, 07:52 AM   #8
sigg
Featured Artist
 
sigg's Avatar
Featured
Join Date: Aug 2008
Posts: 1,251
Hello

About the style function, you have to call it in the next frame call, because the engine auraheader also use the event "UNIT_AURA" to update itself.

What I saw, was the style function is called before the auraheader update.

Goes to right :
headerAura:SetAttribute("xOffset", 30);
headerAura:SetAttribute("yOffset", 0);

Goes to left :
headerAura:SetAttribute("xOffset", -30);
headerAura:SetAttribute("yOffset", 0);

Goes to down :
headerAura:SetAttribute("xOffset", 0);
headerAura:SetAttribute("yOffset", -30);

Goes to up:
headerAura:SetAttribute("xOffset", 0);
headerAura:SetAttribute("yOffset", 30);

You should be able to move your mouse on the button and see the gametooltip.
  Reply With Quote
10-22-10, 08:10 AM   #9
sigg
Featured Artist
 
sigg's Avatar
Featured
Join Date: Aug 2008
Posts: 1,251
the SecureAuraHeaderTemplate is located in the SecureGroupHeaders.lua
  Reply With Quote

WoWInterface » Developer Discussions » Tutorials & Other Helpful Info. » How To : Right click removing buff

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