Can anyone fix this script or tell me an addon that does it? (Original thread here w w w. arenajunkies . c o m/topic/239000-focusframe-inverter-script/) It inverts the focus frame, problem is, it doesn't put the status text in the right place on the frame (the health # and %). Also, in PVP it doesn't move the prestige icon.
Code:
local Script = CreateFrame("Frame")
-- xInvert()
-- Inverts the anchor points of a frame horizontally.
-- > Frame: Frame reference
local InvertPoint = {
["TOPLEFT"] = "TOPRIGHT",
["TOPRIGHT"] = "TOPLEFT",
["BOTTOMLEFT"] = "BOTTOMRIGHT",
["BOTTOMRIGHT"] = "BOTTOMLEFT",
["TOP"] = "TOP",
["BOTTOM"] = "BOTTOM",
["LEFT"] = "RIGHT",
["RIGHT"] = "LEFT",
["CENTER"] = "CENTER"
}
local function xInvert(Frame)
local AnchorData = {}
for i = 1, Frame:GetNumPoints() do AnchorData[i] = { Frame:GetPoint(i) } end
Frame:ClearAllPoints()
for _, A in pairs(AnchorData) do Frame:SetPoint(InvertPoint[A[1]], A[2], InvertPoint[A[3]], A[4] * -1, A[5]) end
end
-- FocusCastRepos()
-- Corrects the X-offset of the FocusFrame castbar, to adapt it to the inverted focus.
local function FocusCastRepos()
local FocusRight = FocusFrameManaBar:GetRight() * FocusFrameManaBar:GetEffectiveScale() / FocusFrameSpellBar:GetEffectiveScale()
local CastRight = FocusFrameSpellBar:GetRight()
local P = { FocusFrameSpellBar:GetPoint() }
FocusFrameSpellBar:SetPoint(P[1], P[2], P[3], P[4] + FocusRight - CastRight + 2, P[5])
Script:SetScript("OnUpdate", nil)
end
-- Inverting FocusFrame textures and frames
FocusFrame.borderTexture:SetTexCoord(1.0, 0.09375, 0, 0.78125)
FocusFrameFlash:SetTexCoord(0.9453125, 0, 0, 0.181640625)
FocusFrameFlash.SetTexCoord = function() end
FocusFrame.pvpIcon:SetPoint("TOPRIGHT", -149, -20)
FocusFrame.levelText:SetPoint("CENTER", -61, -17)
for _, v in pairs({FocusFrameFlash, FocusFrameTextureFrameHealthBarText, FocusFrameTextureFrameManaBarText}) do xInvert(v) end
for _, v in pairs({"name", "deadText", "threatNumericIndicator", "portrait", "Background", "healthbar", "manabar", "nameBackground", "questIcon", "petBattleIcon", "leaderIcon", "raidTargetIcon"}) do xInvert(FocusFrame[v]) end
FocusFrameFlash.SetPoint = function() end
FocusFrame.levelText.SetPoint = function() end
FocusFrame.Background.SetPoint = function() end
-- Inverting Focus-target
FocusFrameToTTextureFrameTexture:SetTexCoord(0.7265625, 0.015625, 0, 0.703125)
FocusFrameToT:ClearAllPoints()
FocusFrameToT:SetPoint("BOTTOMRIGHT", FocusFrame, "BOTTOMRIGHT", -135, -18)
FocusFrameToT.name:SetPoint("BOTTOMLEFT", 1, 2)
for _, v in pairs({"portrait", "healthbar", "manabar", "deadText", "background"}) do xInvert(FocusFrameToT[v]) end
for i = 1, 4 do xInvert(_G["FocusFrameToTDebuff"..i]) end -- Mini debuffs
-- Correcting castbar position in the next frame (when the anchor changes will be updated)
hooksecurefunc(FocusFrameSpellBar, "SetPoint", function() Script:SetScript("OnUpdate", FocusCastRepos) end)
-- Adjusting buff/debuff positions
hooksecurefunc("TargetFrame_UpdateAuras", function(s)
if s ~= FocusFrame then return end
for _, Aura in pairs({ FocusFrameBuff1, FocusFrameDebuff1 }) do
if Aura then
local P = { Aura:GetPoint() } -- Anchor point data
if P[2] == FocusFrame then Aura:SetPoint(P[1], P[2], P[3], 105, P[5]) end
end
end
end)