Skip to content

Instantly share code, notes, and snippets.

/Bindings.xml Secret

Created November 6, 2016 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/733fc4a4d30d54ce6aec50d0c83ddffb to your computer and use it in GitHub Desktop.
Save anonymous/733fc4a4d30d54ce6aec50d0c83ddffb to your computer and use it in GitHub Desktop.
Cycle Arena -> Party
<Bindings>
<Binding name="CLICK CyclePartyTarget:LeftButton" header="CYCLEPARTY" category="ADDONS"/>
<Binding name="CLICK CyclePartyTarget:RightButton" category="ADDONS"/>
<Binding name="CLICK CyclePartyFocus:LeftButton" category="ADDONS"/>
<Binding name="CLICK CyclePartyFocus:RightButton" category="ADDONS"/>
</Bindings>
BINDING_HEADER_CYCLEARENA = "Cycle Party"
_G["BINDING_NAME_CLICK CyclePartyTarget:LeftButton"] = "Cycle Target Forward"
_G["BINDING_NAME_CLICK CyclePartyTarget:RightButton"] = "Cycle Target Backward"
_G["BINDING_NAME_CLICK CyclePartyFocus:LeftButton"] = "Cycle Focus Forward"
_G["BINDING_NAME_CLICK CyclePartyFocus:RightButton"] = "Cycle Focus Backward"
-- creating a parent frame so both target and focus can rotate from common unit
local parent = CreateFrame("Button", nil, nil, "SecureActionButtonTemplate")
parent:SetAttribute("partyUnit",0)
-- setup target cycle
local target = CreateFrame("Button", "CyclePartyTarget", parent, "SecureActionButtonTemplate")
target:SetAttribute("type1","target")
target:SetAttribute("type2","target")
SecureHandlerWrapScript(target, "OnClick", target, [[
local unit
local index = self:GetParent():GetAttribute("partyUnit")
local direction = button=="RightButton" and -1 or 1
for i=1,5 do
index = (index+direction)
unit = "party"..index+1
if UnitExists(unit) then
self:GetParent():SetAttribute("partyUnit",index)
self:SetAttribute("unit",unit)
return
end
end
self:SetAttribute("unit",nil) -- if no party enemy, don't target
]])
-- setup focus cycle
local focus = CreateFrame("Button", "CyclePartyFocus", parent, "SecureActionButtonTemplate")
focus:SetAttribute("type1","focus")
focus:SetAttribute("type2","focus")
SecureHandlerWrapScript(focus, "OnClick", focus, [[
local unit
local index = self:GetParent():GetAttribute("partyUnit")
local direction = button=="RightButton" and -1 or 1
for i=1,5 do
index = (index+direction)
unit = "party"..index+1
if UnitExists(unit) then
self:GetParent():SetAttribute("partyUnit",index)
self:SetAttribute("unit",unit)
return
end
end
self:SetAttribute("unit",nil) -- if no party enemy, don't focus
]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment