WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Flipping a default frame (https://www.wowinterface.com/forums/showthread.php?t=57032)

Naga'an 02-26-19 03:52 AM

Flipping a default frame
 
How do I flip the WarlockPowerFrame? Specifically the Demonology power frame. I’ve tried /run WarlockPowerFrame:SetRotation() and /run WarlockPowerFrame:SetTexCoords() with appropriate values but neither work; I always get an error stating SetRotation() or SetTexCoords() are nil values.

I’m trying to flip the power frame upside-down.

With some free time I managed to flip it, but the shards remained unflipped.

https://i.imgur.com/8BhMXTE.jpg

This is what I used:

Code:

local Addon = CreateFrame("Frame")
    Addon:SetScript("OnEvent", function(self, event, ...) return self[event](self, ...) end)
    Addon:RegisterEvent("PLAYER_ENTERING_WORLD")

local function yOffset(Frame, Offset)
    local P = { Frame:GetPoint() }
    Frame:SetPoint(P[1], P[2], P[3], P[4], Offset)
end

-- Inverts texture vertically.
local function yInvertTexture(Texture)
    local Left, Top, _, Bottom, Right = Texture:GetTexCoord()
    Texture:SetTexCoord(Left, Right, Bottom, Top)
end

-- Inverts all child textures of a frame.
local function yInvertAllTextures(Frame)
    for _, Region in pairs({ Frame:GetRegions() }) do
        if Region:IsObjectType("Texture") then yInvertTexture(Region) end
    end
end

function Addon:PLAYER_ENTERING_WORLD()
    yOffset(WarlockPowerFrame, 180)
    yInvertAllTextures(WarlockPowerFrame)
end

Any help would be greatly appreciated.

Terenna 02-26-19 05:23 AM

One guess might be that the shards are populated after the player entering world event. You might want to RegisterUnitEvent unit_power, player, and flip the shards there. Since you only care about gaining/losing shards, I would include an if check at the beginning to see if the power type that is changing is shards.

Fizzlemizz 02-26-19 09:09 AM

The shards are added to the Shards table. Given the complexity of the shard template I'm not sure a crude "flip"will work for everything but...

Lua Code:
  1. -- Inverts all child textures of a frame.
  2. local function yInvertAllTextures(Frame)
  3.     for _, Region in pairs({ Frame:GetRegions() }) do
  4.         if Region:IsObjectType("Texture") then yInvertTexture(Region) end
  5.     end
  6.     for i=1, #Frame.Shards do
  7.         for _, Region in pairs({ Frame.Shards[i]:GetRegions() }) do
  8.             if Region:IsObjectType("Texture") then yInvertTexture(Region) end
  9.         end
  10.     end
  11. end

Naga'an 02-26-19 03:37 PM

Hey Fizzlemizz, that worked perfectly. Thank you for the solution! Thank you as well Terenna.


All times are GMT -6. The time now is 02:27 PM.

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