Thread Tools Display Modes
12-19-13, 10:44 PM   #1
Spyro
A Fallenroot Satyr
 
Spyro's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2011
Posts: 23
Question GetRight() positioning problem

Hi guyz.

I want to move the FocusFrame's castbar (FocusFrameSpellBar) in a way that both frames (FocusFrame and FocusFrameSpellBar) have its right edges on the same line.



I can only change the X-offset of the anchor, because Blizzard's native code is constantly changing the anchor with different offsets and relative frames, to adjust the position of the castbar to the amount of buffs/debuffs of the FocusFrame.

I'm using GetRight() for the task:

Lua Code:
  1. local function FocusCastbarReposition()
  2.   local FocusRight = FocusFrame:GetRight() * FocusFrame:GetEffectiveScale()
  3.   local CastRight = FocusFrameSpellBar:GetRight() * FocusFrameSpellBar:GetEffectiveScale()
  4.   local Gap = FocusRight - CastRight
  5.   local P = { FocusFrameSpellBar:GetPoint() }
  6.   FocusFrameSpellBar:ClearAllPoints()
  7.   FocusFrameSpellBar:SetPoint(P[1], P[2], P[3], P[4] + Gap, P[5])
  8.   Addon:SetScript("OnUpdate", nil)
  9. end
  10.  
  11. -- Changing the X-offset of FocusFrame's castbar in the
  12. -- next frame (when the anchor values will be updated)
  13. hooksecurefunc(FocusFrameSpellBar, "SetPoint", function()
  14.   Addon:SetScript("OnUpdate", FocusCastbarReposition)
  15. end)

But it doesn't works, the final position is not correct.
I have used the same technique (substraction using GetRight() values) with textures with success, but looks like when it's 2 frames with different scales, it's not that easy. :-/

Does anybody knows the solution?
  Reply With Quote
12-20-13, 12:09 AM   #2
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
The player, target, and focus frames (probably arena and boss frames too) are actually larger than what is visible. The invisible portion is on the portrait side which would be the reason for GetRight seeming to return an incorrect value for the focus frame. To test in game just do /framestack and see when it says you are over the focus frame when mousing over the area around the portrait and just off to the side of it.

Try using the portrait's right instead:
Code:
local function FocusCastbarReposition()
  local focusRight = FocusFramePortrait:GetRight() * FocusFrame:GetEffectiveScale()
  local castRight = FocusFrameSpellBar:GetRight() * FocusFrameSpellBar:GetEffectiveScale()
  local point, relFrame, relPoint, xOffset, yOffset = FocusFrameSpellBar:GetPoint()
  FocusFrameSpellBar:ClearAllPoints()
  FocusFrameSpellBar:SetPoint(point, relFrame, relPoint, xOffset + focusRight - castRight, yOffset)
  Addon:SetScript("OnUpdate", nil)
end
 
-- Changing the X-offset of FocusFrame's castbar in the
-- next frame (when the anchor values will be updated)
hooksecurefunc(FocusFrameSpellBar, "SetPoint", function()
  Addon:SetScript("OnUpdate", FocusCastbarReposition)
end)
I also think you would want to divide the scale and not multiply but it's late and I'm tired so maybe not.

Last edited by Vrul : 12-20-13 at 12:26 AM.
  Reply With Quote
12-20-13, 12:37 AM   #3
Spyro
A Fallenroot Satyr
 
Spyro's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2011
Posts: 23
I have tested it with /framestack and it happens in the portrait side (the extended invisible zone) like you say, although the code is still incorrect because the castbar ends up in a completely different position when I alter its scale (with scale 2 it ends up in the center of the screen lol). If the code were correct the castbar would always end up in the same position.

I have also tried dividing instead of multiplying without success.

Last edited by Spyro : 12-20-13 at 12:40 AM.
  Reply With Quote
12-20-13, 12:56 AM   #4
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Try:
Code:
local function FocusCastbarReposition()
  local focusRight = FocusFramePortrait:GetRight() * FocusFrame:GetEffectiveScale() / FocusFrameSpellBar:GetEffectiveScale()
  local castRight = FocusFrameSpellBar:GetRight()
  local point, relFrame, relPoint, xOffset, yOffset = FocusFrameSpellBar:GetPoint()
  FocusFrameSpellBar:ClearAllPoints()
  FocusFrameSpellBar:SetPoint(point, relFrame, relPoint, xOffset + focusRight - castRight, yOffset)
  Addon:SetScript("OnUpdate", nil)
end
 
-- Changing the X-offset of FocusFrame's castbar in the
-- next frame (when the anchor values will be updated)
hooksecurefunc(FocusFrameSpellBar, "SetPoint", function()
  Addon:SetScript("OnUpdate", FocusCastbarReposition)
end)
  Reply With Quote
12-20-13, 01:20 AM   #5
Spyro
A Fallenroot Satyr
 
Spyro's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2011
Posts: 23
It works perfect Vrul, THX!
My project is complete now, this was the last thing I needed to finish it.

The project consists on an horizontal inversion of Blizzard's FocusFrame, to make it symmetrical with the TargetFrame on UI's that use Target on left and Focus on right (very common frame distribution on high level PvP).


And this is what I really wanted to do (imitate the castbar positioning of the TargetFrame on the inverted FocusFrame, which I can do now using your formula and the FocusFrameManaBar:GetRight() value). I used just the default focus in the question to make it more simple without having to explain the project.


I will release it tomorrow, now I need to sleep.
THX
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » GetRight() positioning problem

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