View Single Post
08-08-16, 11:55 AM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Ravenevar View Post
Lastly, a side question, is there an easy way to show frames that are normally not shown, say if I wanted to put the same background on my party frames and wanted to see what it looks like? I'm no longer at my computer atm, but would it just be a case of PartyFrame1:Show() kind of deal?
For unit frames specifically, just calling :Show() on it will make it appear for about 1 frame, and then it will disappear again, because unit frames are automatically shown or hidden based on whether or not the unit they are assigned to show currently exists.

To work around this, you can temporarily set the frame to show the player unit:

Code:
PartyMemberFrame1.unit = "player"
PartyMemberFrame1:SetAttribute("unit", "player")
Just remember to re-set the unit back to the original one when you're done testing (or just reload the UI).

Here's a small addon that provides a /fakeunits command to toggle the unit on a bunch of Blizzard unit frames:

Code:
local frames = {
    "PetFrame",
    "PartyMemberFrame1",
    "PartyMemberFrame2",
    "PartyMemberFrame3",
    "PartyMemberFrame4",
    "Boss1TargetFrame",
    "Boss2TargetFrame",
    "Boss3TargetFrame",
    "Boss4TargetFrame",
    "ArenaEnemyFrame1",
    "ArenaEnemyFrame2",
    "ArenaEnemyFrame3",
    "ArenaEnemyFrame4",
}

local inFakeMode
function ToggleFakeUnits()
    if InCombatLockdown() then
        return print("Can't change frame units in combat.")
    end
    for i = 1, #frames do
        local f = _G[frames[i]]
        if inFakeMode then
            f.unit = f.__realunit
            f.__realunit = nil
            f:SetAttribute("unit", f.unit)
        else
            f.__realunit = f.unit
            f.unit = "player"
            f:SetAttribute("player")
        end
    end
    inFakeMode = not inFakeMode
end

SLASH_TOGGLEFAKEUNITS1 = "/fakeunits"
SlashCmdList.TOGGLEFAKEUNITS = ToggleFakeUnits

local ef = CreateFrame("Frame")
ef:RegisterEvent("PLAYER_REGEN_DISABLED")
ef:SetScript("OnEvent", function()
    if inFakeMode and UnitAffectingCombat("player") then
        ToggleFakeUnits()
    end
end)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote