Thread Tools Display Modes
06-02-16, 11:54 PM   #1
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
How to detect pet after reloadUI?

I've looked at blizzard pet bar code, but can't figure out how theirs knows to show the pet bar right after a reloadUI. No events get fired to detect this. I tried every pet event they use and none of them fire after a /console reloadui.

For testing using a frost mage water elemental.

Any ideas?
  Reply With Quote
06-03-16, 01:07 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,883
I think you looking for the secure RegisterUnitWatch see under
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
06-03-16, 11:25 AM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,327
The code behind RegisterUnitWatch() essentially falls back to a throttled OnUpdate script with events registered bypassing the throttle, which isn't exactly the best idea. You can have your pet frame listen to both UNIT_PET and PLAYER_LOGIN. PLAYER_LOGIN is one of the first events to fire after logging in and signifies that all player-specific data should be available at this point. It does fire after a reload even though all player data is already in memory and could be queried beforehand.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 06-03-16 at 11:28 AM.
  Reply With Quote
06-03-16, 02:23 PM   #4
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
Well I'm using ace3 which calls OnEnable() which I believe gets called on PLAYER_LOGIN after reloading UI. But functions like PetHasActionBar() or HasPetUI() return false. They return true after second or 2 though.

I already use UNIT_PET but it doesn't fire on a reloadui.
  Reply With Quote
06-03-16, 02:57 PM   #5
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,327
Looks like the default UI triggers off these 3 in addition to OnLoad.

PET_BAR_UPDATE
PET_UI_UPDATE
UNIT_PET

PET_BAR_HIDE is also used to force-hide the action bar.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
06-03-16, 04:09 PM   #6
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
Just tested those they don't fire after reloadUI.

But even if I call PetHasActionBar() or HasPetUI() they both return false right after reloadUI.

Looks like pet stuff doesn't load at the same time as a player does.

The only way is I may have to do a timer that polls for it for X amount of time, then stop. Its ugly but not sure if anything else will work.
  Reply With Quote
06-03-16, 04:36 PM   #7
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Lua Code:
  1. local tx = UIParent:CreateTexture()
  2. tx:SetTexture('interface/icons/inv_mushroom_11')
  3. tx:SetPoint('CENTER')
  4. tx:SetSize(64, 64)
  5. tx:Hide()
  6.  
  7. local f = CreateFrame('frame')
  8. f:SetScript('OnEvent', function(self, event, ...)
  9.     print(event, GetTime(), PetHasActionBar(), HasPetUI())
  10.     tx:SetShown(PetHasActionBar() and UnitIsVisible('pet'))
  11. end)
  12. f:RegisterEvent('UNIT_PET')

UNIT_PET works fine after a reload (although it inexplicably doesn't work with RegisterUnitEvent).

Last edited by semlar : 06-03-16 at 04:39 PM.
  Reply With Quote
06-03-16, 04:43 PM   #8
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
That was it, I was registering it under UnitEvent. Changed it to normal and it fires after reloadUI.

I just don't want every UNIT_PET going off for everyone in a raid. So I tend to use UnitEvents when ever possible.

Thanks, that was driving me nuts

Last edited by galvin : 06-03-16 at 04:46 PM.
  Reply With Quote
06-03-16, 04:48 PM   #9
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Originally Posted by galvin View Post
Must be by the time OnEnable() gets called that its too late, and events like UNIT_PET are not seen. I'm pretty sure OnEnable() gets called after PLAYER_LOGIN. And the pet events may be firing before that or at the same time. I don't register events till after OnEnable().

I really cant do anything before that cause no profile has been loaded yet.
If UNIT_PET has already fired by the time your code runs, then you can simply check whether your pet is out.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to detect pet after reloadUI?


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