Thread Tools Display Modes
08-09-12, 12:02 AM   #1
dragonrealms
An Aku'mai Servant
Join Date: Feb 2007
Posts: 30
Raid frames not spawning properly

When I log in or reload, the units in my raid frames spawn all stacked up on top of each other. If I move a player into another group, they all get fixed (this is with only two people in the raid, though; I haven't been able to get more people to help me test things yet).

I found some code from zork for raid frame creation (http://www.wowinterface.com/forums/s...t=42538&page=2) and implemented it into the layout I've been working on as a learning platform. I know the code worked before I tinkered with it, but I can't figure out where my tinkering went wrong to cause an issue like this. The tinkering I did was to make the frames moveable. The code I use to move them and save their positions works for my other frames such as player, target, pet, party, etc, and it works for the raid frames after doing what I said above to fix them; it's just on the initial load that they're acting weirdly

Lua Code:
  1. --Relevant options
  2. ["raid"] =
  3. {
  4.     show = true,
  5.     anchor = {point = "TOPLEFT", relTo = nil, relPt = "TOPLEFT", xOff = 0, yOff = 0},
  6.     hBar = {width = 100, height = 25, classColor = true},
  7.     pBar = {width = 100, height = 5},
  8.     scale = 1,
  9.     attributes =
  10.         {
  11.             visibility1 = "custom [@raid11,exists] hide;[group:raid] show; hide",
  12.             visibility2 = "custom [@raid26,exists] hide; [@raid11,exists] show; hide",
  13.             visibility3 = "custom [@raid26,exists] show; hide",
  14.             showPlayer = false,  
  15.             showSolo  = false,  
  16.             showParty = false,
  17.             showRaid = true,  
  18.             point = "TOP",
  19.             yOffset = -10,
  20.             xoffset = 10,
  21.             maxColumns = 8,
  22.             unitsPerColumn = 5,
  23.             columnSpacing = 10,
  24.             columnAnchorPoint = "LEFT"
  25.         },
  26. }

Lua Code:
  1. --Relevant functions
  2. lib.moveable = function(frame, style)
  3.     local locked = ns.db.profile.framesLocked
  4.     local mover = SqUI.movers[style]
  5.        
  6.     if (locked) then
  7.         frame:SetMovable(false)
  8.         mover:SetMovable(false)
  9.         mover:SetResizable(false)
  10.         mover:RegisterForDrag()
  11.         mover:SetScript("OnDragStart", nil)
  12.         mover:SetScript("OnDragStop", nil)
  13.        
  14.         if (style == "party") then
  15.             frame:ClearAllPoints()
  16.  
  17.             if (frame:GetName() ~= "SqUIPartyUnitButton1") then
  18.                 frame:SetPoint("TOP", SqUIPartyUnitButton1, "BOTTOM", 0, -50)
  19.             else
  20.                 frame:SetPoint(mover:GetPoint())
  21.             end
  22.         elseif (style == "raid") then
  23.             local att = ns.db.profile.frames[style].attributes
  24.            
  25.             if (strsub(frame:GetName(), -1) == "1") then
  26.                 frame:SetPoint(mover:GetPoint())
  27.             elseif att.columnAnchorPoint == "TOP" then
  28.                 frame:SetPoint("TOPLEFT", frame.prev, "BOTTOMLEFT", 0, att.columnSpacing)
  29.             elseif att.columnAnchorPoint == "BOTTOM" then
  30.                 frame:SetPoint("BOTTOMLEFT", frame.prev, "TOPLEFT", 0, att.columnSpacing)
  31.             elseif att.columnAnchorPoint == "LEFT" then
  32.                 frame:SetPoint("TOPLEFT", frame.prev, "TOPRIGHT", att.columnSpacing, 0)
  33.             else
  34.                 frame:SetPoint("TOPRIGHT", frame.prev, "TOPLEFT", att.columnSpacing, 0)
  35.             end
  36.         else
  37.             frame:ClearAllPoints()
  38.             frame:SetPoint(mover:GetPoint())
  39.         end
  40.                
  41.         mover:Hide()
  42.     else
  43.         mover:Show()
  44.        
  45.         if (style == "party") then
  46.             if (frame:GetName() ~= "SqUIPartyUnitButton1") then
  47.                 frame:SetPoint("TOP", SqUIPartyUnitButton1, "BOTTOM", 0, -50)
  48.             else
  49.                 frame:SetAllPoints(mover)
  50.             end
  51.         elseif (style == "raid") then
  52.             local att = ns.db.profile.frames[style].attributes
  53.            
  54.             if (strsub(frame:GetName(), -1) == "1") then
  55.                 frame:SetAllPoints(mover)
  56.             elseif att.columnAnchorPoint == "TOP" then
  57.                 frame:SetPoint("TOPLEFT", frame.prev, "BOTTOMLEFT", 0, att.columnSpacing)
  58.             elseif att.columnAnchorPoint == "BOTTOM" then
  59.                 frame:SetPoint("BOTTOMLEFT", frame.prev, "TOPLEFT", 0, att.columnSpacing)
  60.             elseif att.columnAnchorPoint == "LEFT" then
  61.                 frame:SetPoint("TOPLEFT", frame.prev, "TOPRIGHT", att.columnSpacing, 0)
  62.             else
  63.                 frame:SetPoint("TOPRIGHT", frame.prev, "TOPLEFT", att.columnSpacing, 0)
  64.             end
  65.         else
  66.             frame:SetAllPoints(mover)
  67.         end
  68.        
  69.         frame:SetMovable(true)
  70.         mover:SetMovable(true)
  71.         mover:SetResizable(true)
  72.         mover:EnableMouse(true)
  73.         mover:RegisterForDrag("LeftButton")
  74.         mover:SetScript("OnDragStart",
  75.                         function(mover)
  76.                             mover:ClearAllPoints()
  77.                             mover:StartMoving()                        
  78.                         end)
  79.         mover:SetScript("OnDragStop",
  80.                         function(mover)
  81.                             mover:StopMovingOrSizing()
  82.                            
  83.                             local point, relTo, relPt, xOff, yOff = mover:GetPoint()
  84.                             local db = ns.db.profile.frames[style].anchor
  85.                            
  86.                             db.point = point
  87.                             db.relTo = "UIParent"
  88.                             db.relPt = relPt
  89.                             db.xOff = xOff
  90.                             db.yOff = yOff
  91.                         end)
  92.     end
  93. end
  94.  
  95. lib.Gen_Mover = function(frame)
  96.     if (not SqUI.movers[frame.mystyle]) then
  97.         local mover = CreateFrame("Frame", nil, UIParent)
  98.         local db = ns.db.profile
  99.         local anchor = db.frames[frame.mystyle].anchor
  100.        
  101.         mover:SetSize(frame.width, frame.height)
  102.         mover:SetPoint(anchor.point, anchor.relTo, anchor.relPt, anchor.xOff, anchor.yOff)
  103.         mover:SetBackdrop({
  104.             bgFile = db.bgTex,
  105.             tile = false,
  106.             tileSize = 0,
  107.             insets =
  108.             {
  109.                 left   = 0,
  110.                 right  = 0,
  111.                 top    = 0,
  112.                 bottom = 0
  113.             }
  114.         })
  115.         mover:SetBackdropColor(0, .45, 0, .7)
  116.         mover:SetFrameStrata("HIGH")
  117.  
  118.         mover.text = lib.Gen_FontString(mover, nil, db.fontPath, db.fontSize, db.fontOutline)
  119.        
  120.         if (frame.mystyle == "party" or frame.mystyle == "raid") then
  121.             mover.text:SetText(strsub(frame:GetParent():GetName(), 5)..": Move Me")
  122.         else
  123.             mover.text:SetText(strsub(frame:GetName(), 5)..": Move Me")
  124.         end
  125.        
  126.         mover.text:SetTextColor(1, 1, 1)
  127.         mover.text:SetPoint("CENTER", mover, "CENTER")
  128.         mover.text:SetJustifyH("CENTER")
  129.            
  130.         SqUI.movers[frame.mystyle] = mover
  131.     end
  132. end

Lua Code:
  1. --Relevant core code
  2. local function CreateRaidStyle(self)
  3.     local db = ns.db.profile.frames["raid"]
  4.  
  5.     self.width = db.hBar.width
  6.     self.height = db.hBar.height
  7.     self.mystyle = "raid"
  8.     self.hptag = "[SqUI:hpraid]"
  9.     self.hidename = true
  10.  
  11.     initHeader(self)
  12.  
  13.     self.Health.colorDisconnected = true
  14.     self.Health.colorClass = db.hBar.classColor
  15.     self.Health.colorReaction = true
  16.     self.Health.colorHealth = true
  17.     self.Health.bg.multiplier = 0.3
  18.     self.Power.colorPower = true
  19.     self.Power.bg.multiplier = 0.3
  20.    
  21.     lib.Gen_Mover(self)
  22.     lib.moveable(self, self.mystyle)
  23. end
  24.  
  25. if db.frames["raid"].show then
  26.     --die raid panel, die
  27.     CompactRaidFrameManager:UnregisterAllEvents()
  28.     CompactRaidFrameManager.Show = CompactRaidFrameManager.Hide
  29.     CompactRaidFrameManager:Hide()
  30.        
  31.     CompactRaidFrameContainer:UnregisterAllEvents()
  32.     CompactRaidFrameContainer.Show = CompactRaidFrameContainer.Hide
  33.     CompactRaidFrameContainer:Hide()
  34.    
  35.     oUF:RegisterStyle("SqUIRaid", CreateRaidStyle)
  36.     oUF:SetActiveStyle("SqUIRaid")
  37.        
  38.     local anchor = db.frames["raid"].anchor
  39.     local att = db.frames["raid"].attributes
  40.     local raid, group, i, j, prev
  41.        
  42.     local function getRaidScale(id)
  43.         if id == 1 then
  44.             return db.frames["raid"].scale
  45.         elseif id == 2 then
  46.             return db.frames["raid"].scale*0.9
  47.         else
  48.             return db.frames["raid"].scale*0.75
  49.         end
  50.     end
  51.  
  52.     local function getRaidVisibility(id)
  53.         if id == 1 then
  54.             return att.visibility1
  55.         elseif id == 2 then
  56.             return att.visibility2
  57.         else
  58.             return att.visibility3
  59.         end
  60.     end
  61.    
  62.     for j = 1, 3 do
  63.         raid = {}
  64.         for i = 1, NUM_RAID_GROUPS do
  65.             group = oUF:SpawnHeader("SqUIRaid"..j.."Group"..i, nil, getRaidVisibility(j),  
  66.                         "showPlayer",         att.showPlayer,
  67.                         "showSolo",           att.showSolo,
  68.                         "showParty",          att.showParty,
  69.                         "showRaid",           att.showRaid,
  70.                         "point",              att.point,
  71.                         "yOffset",            att.yOffset,
  72.                         "xOffset",            att.xOffset,
  73.                         "columnSpacing",      att.columnSpacing,
  74.                         "columnAnchorPoint",  att.columnAnchorPoint,
  75.                         "groupFilter",        tostring(i),
  76.                         "groupBy",            "GROUP",
  77.                         "groupingOrder",      "1,2,3,4,5,6,7,8",
  78.                         "sortMethod",         "NAME",
  79.                         "maxColumns",         att.maxColumns,
  80.                         "unitsPerColumn",     att.unitsPerColumn,
  81.                         "oUF-initialConfigFunction", ([[
  82.                             self:SetHeight(%d)
  83.                             self:SetWidth(%d)
  84.                     ]]):format(db.frames["raid"].hBar.height, db.frames["raid"].hBar.width))
  85.  
  86.             group:SetScale(getRaidScale(j))
  87.            
  88.             if (i == 1) then
  89.                 group:SetPoint(anchor.point, anchor.relTo, anchor.relPt)
  90.                 prev = group:GetName()
  91.             else
  92.                 group.prev = prev
  93.                 prev = group:GetName()
  94.                 if att.columnAnchorPoint == "TOP" then
  95.                     group:SetPoint("TOPLEFT", group.prev, "BOTTOMLEFT", 0, att.columnSpacing)
  96.                 elseif att.columnAnchorPoint == "BOTTOM" then
  97.                     group:SetPoint("BOTTOMLEFT", group.prev, "TOPLEFT", 0, att.columnSpacing)
  98.                 elseif att.columnAnchorPoint == "LEFT" then
  99.                     group:SetPoint("TOPLEFT", group.prev, "TOPRIGHT", att.columnSpacing, 0)
  100.                 else
  101.                     group:SetPoint("TOPRIGHT", group.prev, "TOPLEFT", att.columnSpacing, 0)
  102.                 end
  103.             end
  104.            
  105.             raid[i] = group
  106.         end
  107.     end
  108. end
  Reply With Quote
08-09-12, 01:30 AM   #2
Freebaser
A Molten Kobold Bandit
 
Freebaser's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 135
When dealing with raid frames it's best to create a separate movable dummy frame and then anchor the first Header(not unit) to that. Making each raid unit movable doesn't work since the header already does that internally.
  Reply With Quote
08-09-12, 01:50 AM   #3
dragonrealms
An Aku'mai Servant
Join Date: Feb 2007
Posts: 30
I don't make each moveable; the Gen_Mover function creates the frames I use to move other frames (1 mover per frame type, so only 1 raid mover). All I do is anchor the frame I want to move to the mover frame when unlocked and de-anchor it when the frames get locked, and I said in the op, the initial load is the only time it does this. After changing a player's group in the raid, the raid frames show up as normal (even after moving the person back to the original group); they also can be locked/unlocked/moved around just fine.

Edit again: The reason I touch the specific unit button at all (and only on the party), is because when I tried it with the header, the party frames didn't move with the mover frame, though they would pop over to where the mover was after a reload. Once I set it up the way it's set up now, they moved around just fine. Also, that's only done on the party frames; when it gets a raid frame, it only messes with the group headers.

Last edited by dragonrealms : 08-09-12 at 02:01 AM.
  Reply With Quote
08-09-12, 02:24 AM   #4
Freebaser
A Molten Kobold Bandit
 
Freebaser's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 135
Your still moving the unit, instead of the header that creates the unit. Try using the gen_mover and moveable on the headers you created rather than each unit that is spawned.
  Reply With Quote
08-09-12, 03:32 AM   #5
dragonrealms
An Aku'mai Servant
Join Date: Feb 2007
Posts: 30
I did originally try that before I even implemented raid frames and was just sitting on party frames. The mover frame moved, but the rest of the party frames stayed put until I reloaded. And again, the raid frames portion moves the group headers (if it's a raid style, I send lib.moveable the unit's parent, which would be the header as I understand it); the party portion, as I've admitted, is moving the first party unit button because I couldn't get it working any other way (mover moved, party did not follow), and if the frame is neither party nor raid, there's no header for it anyway.

I'm not trying to be argumentative here, but you're telling me to do something I've already tried and to do it to something that's producing the results I expect (again, if it's a raid unit, the move function is already being sent the header not the unit itself).

I should also say that yes, I do understand that the way the party frames are getting moved is not the "right" way to do it, but it IS working whereas the raid frames aren't 100% working by using the headers, so the party frames currently being "wrong" isn't a priority for me right now; rather, I'm viewing that as something to clean up later when everything is working as I expect.

Last edited by dragonrealms : 08-09-12 at 03:41 AM.
  Reply With Quote
08-09-12, 07:40 AM   #6
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Check
http://code.google.com/p/rothui/sour.../party.lua#208
or
http://code.google.com/p/rothui/sour...s/raid.lua#467

It shows how to work with a dragFrame on header units.
Don't get disturbed by my raid frames. I spawn 3 different raids that will show/hide based on macro condtions. The raid frames use different scaling that's why.

On the other side...you could just remove the drag functionality and use the oUF_MovableFrames module.
__________________
| 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 : 08-09-12 at 07:44 AM.
  Reply With Quote
08-09-12, 02:18 PM   #7
dragonrealms
An Aku'mai Servant
Join Date: Feb 2007
Posts: 30
Thanks zork. I did understand what your code was doing (and liked the functionality of it which is why I used it). I just am not able to figure out why the initial spawn gets all the units stacked on top of each other until a player group switch happens.

As for the oUF_MovableFrames plugin, I eventually want to make more than just unit frames, so that really wouldn't be an answer for me down the road when I want to move things that aren't based off the oUF framework because they're out of its scope of functionality, and I'd end up having to make my own move capability anyway; may as well just learn how to do it now so I can use it whenever I come to that point.
  Reply With Quote
08-10-12, 04:22 AM   #8
dragonrealms
An Aku'mai Servant
Join Date: Feb 2007
Posts: 30
Got it working properly now. Thanks for the code links, zork; they helped a lot. I had the right idea of what to do, but your code helped me iron out the implementation a lot more cleanly.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Raid frames not spawning properly


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