Thread Tools Display Modes
04-09-13, 04:39 PM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Changing a box in combat

I have a frame.

I want to resize or repoint it while being in combat.

Any idea on how to do it?

The problem is I need to to it in an OnClick script. I cannot drag the size manually.

*edit*

I fixed my problem. I'm now using:
Lua Code:
  1. --frame
  2.   local hoverFrame = CF("BUTTON", addon.."HoverFrame", manager, "SecureHandlerClickTemplate")
  3.   hoverFrame:SetAttribute("_onclick", [=[
  4.     local ref = self:GetFrameRef("manager")
  5.     if not ref:GetAttribute("state") then
  6.       ref:SetAttribute("state","closed")
  7.     end
  8.     local state = ref:GetAttribute("state")
  9.     if state == "closed" then
  10.       ref:SetAlpha(1)
  11.       ref:SetWidth(275)
  12.       ref:SetAttribute("state","open")
  13.     else
  14.       ref:SetAlpha(0.4)
  15.       ref:SetWidth(200)
  16.       ref:SetAttribute("state","closed")
  17.     end
  18.   ]=])
  19.   hoverFrame:SetFrameRef("manager", manager)
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 04-09-13 at 05:51 PM.
  Reply With Quote
04-09-13, 05:00 PM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Are you talking about a protected frame?

Do you want it to be resized by the user or automatically?
  Reply With Quote
04-09-13, 05:28 PM   #3
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
No. That is a frame I made on my own. Using SecureHandlerClickTemplate did what I needed though.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 04-09-13 at 05:49 PM.
  Reply With Quote
04-10-13, 07:42 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Ok...I'm still on this topic since I want to get into secure frames a bit more.

I have a panel frame. Ontop of that panel frame is a clickframe that will change the size/alpha of the panel frame. This works already thanks to the "SecureHandlerClickTemplate" posted above.

Now I want to take it a step further. I want to hide the frame if I'm not in a group and I want to show it if I am. Of course this should happen securely.

My current question is: How would you do sth like this?

My current guess is the following code. Basically I'm inheriting "SecureHandlerAttributeTemplate" on the frame. Next I'm registern "PARTY_MERMBERS_CHANGED" event. Once that fires I change an attribute. The attribute change triggers "_onattributechanged" and I use it to Show/Hide the frame. Is that the way to do it?

Lua Code:
  1. --manager onevent
  2.   local function ManagerOnEvent(self, event)
  3.     if GetNumGroupMembers() > 0 then
  4.       self:SetAttribute("in-group",1)      
  5.     else
  6.       self:SetAttribute("in-group",0)      
  7.     end
  8.   end
  9.  
  10.   --create manager frame
  11.   local manager = CreateFrame("Frame", addon, UIP, "SecureHandlerAttributeTemplate")
  12.  
  13.   --manager onattributechanged
  14.   manager:SetAttribute("_onattributechanged", [=[
  15.     --self, name, value
  16.     if name ~= "in-group" then return end
  17.     if value == 1 and self:IsShown() then return end
  18.     if value == 1 then
  19.       self:Show()
  20.     else
  21.       self:Hide()
  22.     end
  23.   ]=])
  24.   manager:RegisterEvent("PARTY_LOGIN")  
  25.   manager:RegisterEvent("PARTY_MEMBERS_CHANGED")
  26.   manager:SetScript("OnEvent", ManagerOnEvent)

Sources:
http://www.wowwiki.com/SecureHandlers
http://www.iriel.org/wow/docs/Secure...20-%20pre1.pdf
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 04-10-13 at 07:47 AM.
  Reply With Quote
04-10-13, 09:54 AM   #5
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
The event you want is GROUP_ROSTER_UPDATE, then do the usual if IsInGroup() then ... in your event handler.
  Reply With Quote
04-10-13, 11:26 AM   #6
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I decided to go with this for now. SetAttribute is blocked in combat.
Lua Code:
  1. local manager = CreateFrame("Frame", addon, UIP, "SecureHandlerStateTemplate")
  2. RegisterStateDriver(manager, "visibility", "[group:party][group:raid] show; hide")
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
04-10-13, 05:00 PM   #7
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
You can use just [group] as a synonym for [group:raid][group:party]. I believe the world markers are only available to party and raid leaders and assistants, don't know if you'd get a warning when trying to use them without the proper permissions.

Last edited by Rainrider : 04-10-13 at 05:01 PM. Reason: Damn smilies
  Reply With Quote
04-10-13, 05:23 PM   #8
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
raid targets: solo, party, raid assist+
world markers: party, raid assist+
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Changing a box in combat


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