Thread Tools Display Modes
06-03-09, 11:57 AM   #1
jadakren
A Flamescale Wyrmkin
 
jadakren's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 103
GroupHeader: PartyMembers, PartyTargets & PartyPets

I have some questions about spawning party target&pet frames, but first I shall show you roughly how I implement my setup.

The Situation

Currently the desired method of spawning frames for partypets and partytargets is via a secureFramesTemplate.

1. create the template.xml
your_ouf_layout/partyTemplate.xml
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="oUF_Smee2_Groups_Party" inherits="SecureUnitButtonTemplate" hidden="true" virtual="true">
		<Frames>
			<Button name="$parent_Target" inherits="SecureUnitButtonTemplate">
				<Anchors>
					<Anchor point="BOTTOM" relativePoint="TOP" relativeTo="$parent">
						<Offset>
							<AbsDimension x="0" y="3"/>
						</Offset>
					</Anchor>
				</Anchors>
				<Attributes>
					<Attribute name="unitsuffix" type="string" value="target"/>
					<Attribute name="unitprefix" type="string" value="party"/>
					<Attribute name="useparent-unit" type="boolean" value="true"/>
					<Attribute name="type1" type="string" value="target"/>
					<Attribute name="initial-unitWatch" type="boolean" value="true"/>
				</Attributes>
			</Button>
			<Button name="$parent_Pet" inherits="SecureUnitButtonTemplate">
				<Anchors>
					<Anchor point="TOP" relativePoint="BOTTOM" relativeTo="$parent">
						<Offset>
							<AbsDimension x="0" y="-3"/>
						</Offset>
					</Anchor>
				</Anchors>
				<Attributes>
					<Attribute name="unitsuffix" type="string" value="pet"/>
					<Attribute name="unitprefix" type="string" value="party"/>
					<Attribute name="useparent-unit" type="boolean" value="true"/>
					<Attribute name="type1" type="string" value="pet"/>
					<Attribute name="initial-unitWatch" type="boolean" value="true"/>
				</Attributes>
			</Button>
		</Frames>
	</Button>
</Ui>
2. link it in your toc file, prior to all the other files.
your_ouf_layout/your_ouf_layout.toc
Code:
## Interface: 30100
## Title: <<your_ouf_layout>>
## Author: <<your_name>>
## Version: 0.1

## Notes: oUF layout.
## OptionalDeps: oUF_Banzai, oUF_HealComm, oUF_DebuffHighlight,oUF_SpellRange, oUF_ReadyCheck
## RequiredDeps: oUF
## DefaultState: enabled
party-template.xml

core.lua
3. Refer to it
your_ouf_layout/core.lua
Refer to it by the template name in your spawn function. specifying that it is the template which we wish to use in order to define aspects about our group frames.
Code:
	local party = oUF:Spawn("header", "oufparty")
	party:SetPoint(anchorFromPoint,
		UIParent,
    		anchorToPoint,
    		anchorX,
    		anchorY)

	party:SetManyAttributes(
		"template",		"oUF_Smee2_Groups_Party",
		"showRaid",		false,
		"showParty",		true,
		"showPlayer", 		true,
		"yOffSet",		partySettings.unit.yOffSet,
		"xOffSet", 		partySettings.unit.xOffSet,
		"point",		partySettings.unit.anchorFromPoint,
		"initial-height", 	partySettings.unit.height,
		"initial-width", 	partySettings.unit.width)

The Question

As you see above, the xml template names each child frame based on the framename of the parent. (a pet frame of the party3 frame becomes part3_pet)

I am trying to work out if it is also possible to send in other variables. i want to be able to control the x y coord of the child frames after spawning (out of combat of course).

perhaps something like :

Code:
	party:SetManyAttributes(
		"target_xOffset",	0,
		"target_yOffset",	-24,
		"pet_xOffset",		0,
		"pet_yOffset",		-24)
Then I could use those attribute names in the anchoring sections of the child frames :

Code:
			<Button name="$parent_Pet" inherits="SecureUnitButtonTemplate">
				<Anchors>
					<Anchor point="TOP" relativePoint="BOTTOM" relativeTo="$parent">
						<Offset>
							<AbsDimension x="$pet_xOffset" y="$pet_yOffset"/>
						</Offset>
					</Anchor>
				</Anchors>
				<Attributes>
					<Attribute name="unitsuffix" type="string" value="pet"/>
					<Attribute name="unitprefix" type="string" value="party"/>
					<Attribute name="useparent-unit" type="boolean" value="true"/>
					<Attribute name="type1" type="string" value="pet"/>
					<Attribute name="initial-unitWatch" type="boolean" value="true"/>
				</Attributes>
			</Button>
Or do I not include those <Anchors> section at all and instead modify these aspects when these frames are passed through my layout function.
  Reply With Quote
06-03-09, 12:10 PM   #2
Alestane
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 234
If your template also inherits from SecureHandlerAttributeTemplate, you may also be able to reposition child frames accroding to certain circumstances, including doing so during combat. I'm not sure off the top of my head what attributes the header would set on the template that you'd want to respond to, though, other than perhaps "unit".
  Reply With Quote
06-03-09, 04:46 PM   #3
jadakren
A Flamescale Wyrmkin
 
jadakren's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 103
The reason I wanted to be able to use the SetAttributes function of the template header was that doing so makes it a simple matter of fire and forget.
Code:
function addon:UpdatePartyFrames(dbSettings)
 for key,value in pairs(dbSettings)do
  party:SetAttributes(key,value)
 end
end
However, if I am to be forced into using a manual approach of iteration :

Code:
function addon:UpdatePartyFrames(dbSettings)
 for name,frame in pairs(oUF.units)do
  if (name:gmatch("party")) then
   if (name:gmatch("target")) then
    --update frame according to partytarget frame settings
   elseif (name:gmatch("pet")) then
    --update frame according to partypet frame settings
   end
  end
 end
end
I much prefer to use the former method than working out if a framename contains a string.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » GroupHeader: PartyMembers, PartyTargets & PartyPets


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