Quantcast visibility state driver on unitframes? - WoWInterface
Thread Tools Display Modes
01-20-18, 06:11 AM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,685
visibility state driver on unitframes?

Hi guys,

I tried adding a visibility state driver to my player unitframe.
I cannot get it to work.

Lua Code:
  1. --show/hide the frame on a given state driver
  2.   if cfg.frameVisibility then
  3.     frame.frameVisibility = cfg.frameVisibility
  4.     frame.frameVisibilityFunc = cfg.frameVisibilityFunc
  5.     RegisterStateDriver(frame, cfg.frameVisibilityFunc or "visibility", cfg.frameVisibility)
  6.   end

What am I missing?

Wierdly enough if I enter /run oUF_SimplePlayer:Hide() into chat it pops right back up.

I use the following modifier on my actionbar which works just fine:

Lua Code:
  1. frameVisibility = "[combat][modifier][@target,exists] show; hide"

How do I register a custom visibility state driver on oUF unit frames?

I tried adding a seperate state handler frame. The handler is working properly. The show/hide has an effect according to the chat output but the visual effect is not there. The player frame stays visible.

Lua Code:
  1. --show/hide player frame on state change
  2.   local player = oUF:Spawn("player", A.."Player")
  3.   local frame = CreateFrame("frame",nil,nil,"SecureHandlerStateTemplate")
  4.   frame:SetFrameRef("player", player)
  5.   frame:SetAttribute("_onstate-combat", [=[
  6.     player = self:GetFrameRef("player")
  7.     print(newstate,player:GetName())
  8.     if newstate == "show" then
  9.       player:Show()
  10.       print(player:IsShown())
  11.     else
  12.       player:Hide()
  13.       print(player:IsShown())
  14.     end
  15.   ]=])
  16.   RegisterStateDriver(frame, "combat", "[target,exists][modifier] show; hide")

I added this:

Lua Code:
  1. hooksecurefunc(player, 'Show', function(self)
  2.     print("func call Show",self:GetName(),self:IsShown())
  3.   end)

It literally spams my chat with Show calls. What the heck is going on? The same is true for target if I have a target and the hook is applied to target aswell.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 01-20-18 at 07:31 AM.
  Reply With Quote
01-20-18, 07:04 AM   #2
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,025
Single unit frames are handled by the SecureStateDriveManager. Just unregister the frame and it should let you override it:
Lua Code:
  1. UnregisterUnitWatch(frame)

You can also use oUF's own API for it:
Lua Code:
  1. frame:Disable()

It's the same as just calling UnregisterUnitWatch, but it also calls frame:Hide().
__________________
「貴方は1人じゃないよ」
  Reply With Quote
01-20-18, 07:40 AM   #3
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,685
Thanks will give it a go.

*edit* Tested it. Works perfectly, thanks haste.

Lua Code:
  1. local player = oUF:Spawn("player", A.."Player")
  2. player:Disable()
  3. RegisterStateDriver(player, "visibility", "[combat][target,exists][modifier] show; hide")
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 01-20-18 at 07:45 AM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » visibility state driver on unitframes?

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