View Single Post
02-17-13, 09:28 AM   #6
Spyro
A Fallenroot Satyr
 
Spyro's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2011
Posts: 23
Cool

Originally Posted by Aanson View Post
If 'TheNameplate' is a stock UI nameplate
Sorry if the code wasn't very clear, I wanted to show the idea in a small piece of code, "TheNameplate" was an example of any nameplate I intercept and work with. I get the nameplates with an OnUpdate that runs only when the number of childrens of the WorldFrame changes. This is my PlateProcess() function if you are curious:
Lua Code:
  1. local NumChildren = -1
  2.  
  3. local function PlateProcess()
  4.   if WorldFrame:GetNumChildren() == NumChildren then return end
  5.   NumChildren = WorldFrame:GetNumChildren()
  6.  
  7.   for _, Plate in pairs({WorldFrame:GetChildren()}) do
  8.     if Plate:GetName() and Plate:GetName():find("NamePlate%d") and not Plate.Scripted then
  9.       if Plate:IsVisible() then Plate_OnShow(Plate) end
  10.       Plate:SetScript("OnShow", Plate_OnShow)
  11.       Plate:SetScript("OnHide", Plate_OnHide)
  12.       Plate.Scripted = true
  13.     end
  14.   end
  15. end
  16.  
  17. SpyroTest:SetScript("OnUpdate", PlateProcess)
Originally Posted by Aanson View Post
If it were me, I'd use print to test the code to make sure you're on the right track. Notably, I'd definitely check the return value of GetThreatRegion().
Yeah I already did this and the change applies, but now after the explaniation of zork I know why I doesn't show anything.
Originally Posted by Phanx View Post
Anyway, the whole GetThreatRegion() function is extremely inefficient. You should identify all of the nameplate's children and regions once -- the first time you see the nameplate -- and attach them to the nameplate as table key/value pairs
On my code I do a ThreatRegion = GetThreatRegion(Plate) and then I work with ThreatRegion, but your idea definitely looks better performance-wise and design-wise, I will implement it. I already add information to the nameplate to mark it as "seen" the first time I see it, so it will be easy.
Originally Posted by zork View Post
I tried playing with the threat frame when I did my nameplate stuff...
Thanks for the info, it's impossible then. I will do the color changes in the nameplate border then, it's and addon for Arenas for altering the nameplate of enemys that are out of combat, to do flashy things like Shadow Dance->Sap and I thought that showing the threat texture in green to show the "out of combat status" would look pretty cool.
  Reply With Quote