Thread Tools Display Modes
10-17-12, 08:38 PM   #1
bacardee
A Defias Bandit
Join Date: Nov 2010
Posts: 2
Hide player frame out of combat

Hi, I'm simply trying to hide the player frame out of combat. I've tried creating events that trigger

oUF_Caellian_Player:Show and oUF_Caellian_Player:Hide, but I'm not really that good with LUA.

Also typing /script oUF_Caellian_Player:Hide in game only briefly hides it, it disappears for half a second then comes right back. If anyone else is using Caellian's oUF and knows how to hide the player frame out of combat I would greatly appreciate it. I'm trying to keep everything minimal.

Here's the code i was trying to add:

Code:
local inCombat = UnitAffectingCombat('player')
	if(inCombat) then
		oUF_Caellian_Player:Show()
	else
		oUF_Caellian_Player:Hide()
	end
And here's where the playerframe is spawned (I think)

Code:
self:SetActiveStyle("Caellian")
	
	self:Spawn("player", "oUF_Caellian_Player"):SetPoint("BOTTOM", UIParent, caelLib.scale(oUF_Caellian.config.coords.playerX), caelLib.scale(oUF_Caellian.config.coords.playerY))
	self:Spawn("target", "oUF_Caellian_Target"):SetPoint("BOTTOM", UIParent, caelLib.scale(oUF_Caellian.config.coords.targetX), caelLib.scale(oUF_Caellian.config.coords.targetY))
  Reply With Quote
10-17-12, 10:14 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You can't just :Hide() and :Show() unitframes, because they are tied to the existence of a specific unit -- in this case, the player -- and the game constantly checks for the existence of that unit and shows or hides the frame depending on the result.

There are two easy ways to hide a unit frame:

1. Set the frame's opacity to 0. This requires only one line of code, but the frame will still be clickable even though it's not visible.

2. Reparent the frame to a hidden frame. This requires a little more code, but the frame will be completely gone:
Code:
local hider = CreateFrame("Frame")
hider:Hide()

-- To hide the frame:
oUF_Caellian_Player:SetParent(hider)

-- To show the frame:
oUF_Caellian_Player:SetParent(oUF_PetBattleFrameHider or UIParent)
I did notice a weird issue with reparenting recently, though... when I reparent my oUF player frame, it somehow screws up the points on the first aura icon, causing it to disappear, and I have to manually reset the icon's position (ForceUpdate doesn't reposition existing icons).
__________________
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.

Last edited by Phanx : 10-18-12 at 05:57 PM.
  Reply With Quote
10-18-12, 03:28 PM   #3
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
That piece of code will break slightly with commit 4efb78c75c7ed2afa2aaee572bc8e7bc1c69a695. A quick fix would be to parent the hider to oUF_PetBattleFrameHider, if it exists.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
10-18-12, 05:59 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Updated my post... did oUF_PetBattleFrameHider or UIParent since oUF_PetBattleFrameHider won't exist for people using the latest version on WoWI.
__________________
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

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Hide player frame out of combat

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