Thread Tools Display Modes
01-13-16, 02:12 AM   #21
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
I ended up downloading the entire addon to see what I can do with it. After many hours of testing I think I came up with a solution. (Modified files temporarily attached)



The first thing I ended up doing was to stop PlayerPet:UpdatePortrait() from reloading the model if it's already being displayed. This should stop the portrait jitter. The optional force arg forces the update to happen and is for use with the UNIT_PORTRAIT_UPDATE event.
Lua Code:
  1. function PlayerPet:UpdatePortrait(force)
  2.     local unit = self.frame.unit
  3.     local guid = UnitGUID(unit)
  4.  
  5.     local texture = self.frame.portrait.texture.texture
  6.     local model = self.frame.portrait.model
  7.  
  8.     if UnitIsVisible(unit) then
  9.         texture:Hide()
  10.         if force or guid ~= model.guid or not model:IsShown() or model:GetModel() == "" then
  11.             model:ClearModel()
  12.             model:SetUnit(unit)
  13.             model:SetPortraitZoom(1)
  14.             model:Show()
  15.             model.guid = guid
  16.         end
  17.     else
  18.         model:Hide()
  19.         SetPortraitTexture(texture, unit)
  20.         texture:Show()
  21.     end
  22. end



While RegisterAttributeDriver() is being used for both UnitFrames now, to keep things simple, the OnAttributeChanged script was removed entirely. (It was firing at the wrong time anyway.)



I ended up using UNIT_PET to synchronize the swapping of the player and pet frames. The quirk about this is the vehicle UnitID doesn't work, but you can still access the vehicle data using the pet UnitID. Fortunately, UnitHasVehicleUI() does seem to return the correct state here for both entering and exiting a vehicle. None of the UNIT_*_VEHICLE events are used anymore.

Player.lua
Lua Code:
  1. function Player:UNIT_PET()
  2.     self.frame.unit = UnitHasVehicleUI("player") and "pet" or "player"
  3.     self:UpdateDisplay()
  4. end

PlayerPet.lua
Lua Code:
  1. function PlayerPet:UNIT_PET(...)
  2.     self.frame.unit = UnitHasVehicleUI("player") and "player" or "pet"
  3.     self:UpdateDisplay()
  4. end



Edit: Attachments deleted, see later posts.
__________________
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 : 01-18-16 at 08:52 PM.
  Reply With Quote
01-13-16, 06:28 AM   #22
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Holy shit dude, thats exactly what i wanted to be like. Thanks a lot.
  Reply With Quote
01-15-16, 08:22 PM   #23
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
I have some issues again.
While it's working prefectly when you enter/exit vehilces with a summoned pet. Now it doesn't work properly when you don't have a pet.
  Reply With Quote
01-16-16, 06:12 AM   #24
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
If you're referring to the fraction of a second that the unitframe appears blank, it looks like that's the UnitWatchFrame stepping in when it detects the vehicle as a pet. It was probably there before, but not as noticeable. Technically, the UnitWatchFrame is supposed to check the OnUpdate after we update our frame. I'm not sure how it gets in before that happens.

With more testing, I've been getting varied results between the rare occasion where the pair of UnitFrames got stuck on exit and showed up blank, to the issue noted above, and many times running with perfect timing (no issues at all).
__________________
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 : 01-16-16 at 06:33 AM.
  Reply With Quote
01-16-16, 06:41 AM   #25
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by SDPhantom View Post
If you're referring to the fraction of a second that the unitframe appears blank, it looks like that's the UnitWatchFrame stepping in when it detects the vehicle as a pet. It was probably there before, but not as noticeable. Technically, the UnitWatchFrame is supposed to check the OnUpdate after we update our frame. I'm not sure how it gets in before that happens.

With more testing, I've been getting varied results between the rare occasion where the pair of UnitFrames got stuck on exit and showed up blank, to the issue noted above, and many times running with perfect timing (no issues at all).
Nah, i found some other type of vehicles which does not triggger the UNIT_PET events at the right time, reporting UnitHasVehicleUI("player") to false and the whole swap does not occour.

So i'm not sure how reliable this UNIT_PET method is. However i could not came up with a better soution i tried almost all the vehicle releated events.

https://www.youtube.com/watch?v=M_O3JryZVBQ
  Reply With Quote
01-18-16, 08:49 PM   #26
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
How do these work? They use a more brute force method that piggybacks on RegisterAttributeDriver() and reacts whenever the driver does so. This is because it not only triggers on UNIT_PET, but every 200ms as well. I also added additional conditions to the driver that makes it delay the trigger until there is unit information that the display functions can act on. Apparently, the [vehicleui] condition can trigger before or after UNIT_PET.



Edit: I had to replace all the instances of self.frame.unit to use SecureButton_GetUnit(self.frame) instead. My previous attachment to this post replaced the UNIT_PET event with an update from the frame's OnAttributeChanged script. This worked well when you didn't have a pet, but showed the pet's stats instead of the vehicle if there was one out. The new hybrid method uses the attribute driver to determine the unit shown and uses UNIT_PET to make sure the display code gets the vehicle if the pet unit swaps after the attribute driver changes units.

<Attachments removed to save space>
__________________
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 : 11-02-16 at 12:48 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SecureHandlerState


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