View Single Post
06-14-11, 01:51 PM   #15
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I spent some time now testing. Doing dungeon in the dungeonfinder. I have to push another fix my first post was OK, but incomplete. Swapping between questionmark and model bugs so I had to fix it.

This works for me currently in any situation (going from mark to model or from model to mark or model to model)

lua Code:
  1. local Update = function(self, event, unit)
  2.     if(not unit or not UnitIsUnit(self.unit, unit)) then return end
  3.  
  4.     local portrait = self.Portrait
  5.     if(portrait.PreUpdate) then portrait:PreUpdate(unit) end
  6.  
  7.     if(portrait:IsObjectType'Model') then
  8.         local guid = UnitGUID(unit)
  9.         if(not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit)) then
  10.             portrait:ClearModel()
  11.             portrait:SetModel('interface\\buttons\\talktomequestionmark.m2')
  12.             portrait:SetCamDistanceScale(0.25)
  13.             portrait:SetPortraitZoom(0)
  14.             portrait:SetPosition(0,0,0.5)          
  15.             portrait.guid = nil
  16.         elseif(portrait.guid ~= guid or event == 'UNIT_MODEL_CHANGED') then
  17.             portrait:ClearModel()
  18.             portrait:SetUnit(unit)
  19.             portrait:SetCamDistanceScale(1)
  20.             portrait:SetPortraitZoom(1)
  21.             portrait:SetPosition(0,0,0)
  22.             portrait.guid = guid
  23.         end
  24.     else
  25.         SetPortraitTexture(portrait, unit)
  26.     end

The else condition can be removed entirely.
What was important is to reset the GUID on questionmark (because it would not change back if you had the GUI, got mark later. It would stuck in mark)
To make the model values apply the model must be cleared. Doesn't work otherwise.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

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

Last edited by zork : 06-14-11 at 01:53 PM.
  Reply With Quote