WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   GetRight() positioning problem (https://www.wowinterface.com/forums/showthread.php?t=48696)

Spyro 12-19-13 10:44 PM

GetRight() positioning problem
 
Hi guyz. :cool:

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? :confused:

Vrul 12-20-13 12:09 AM

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.

Spyro 12-20-13 12:37 AM

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.

Vrul 12-20-13 12:56 AM

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)


Spyro 12-20-13 01:20 AM

It works perfect Vrul, THX! :D
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. :p


I will release it tomorrow, now I need to sleep. :p
THX :banana:


All times are GMT -6. The time now is 07:00 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI