Thread Tools Display Modes
02-26-19, 03:52 AM   #1
Naga'an
A Defias Bandit
Join Date: Feb 2019
Posts: 2
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.
  Reply With Quote
02-26-19, 05:23 AM   #2
Terenna
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 105
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.
  Reply With Quote
02-26-19, 09:09 AM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
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
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
02-26-19, 03:37 PM   #4
Naga'an
A Defias Bandit
Join Date: Feb 2019
Posts: 2
Hey Fizzlemizz, that worked perfectly. Thank you for the solution! Thank you as well Terenna.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Flipping a default frame

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