View Single Post
03-06-11, 11:28 AM   #10
grom
A Deviate Faerie Dragon
Join Date: Jun 2006
Posts: 17
Originally Posted by Saiket View Post
WoW actually manipulates the nameplates directly in C++, bypassing their Lua methods and thus skipping any hooks. Unfortunately, that leaves no way to detect color changes short of checking their color every time the screen repaints.

If you're determined to make the nameplates match though, you could overlay a transparent black texture over the nameplate bars as soon as they get created.
How would i do that? The 'as soon as they get created' part. I thought that there'd be an event to look for but i couldn't find one. Then i looked through rNameplates and it looks for nameplates every 0.33 sec via WorldFrame:GetChildren(). I suppose that's the 'brute force' method hank spoke of.

This is my latest approach (similar to rNameplates):

lua Code:
  1. local frame = CreateFrame("Frame")
  2. frame:SetScript("OnEvent", function(self, event)
  3.     if event == "NAMEPLATEPOPUPEVENT" then
  4.         local num = select('#', WorldFrame:GetChildren())
  5.         for i=2, num do
  6.             select(i, WorldFrame:GetChildren()):HookScript("OnShow", function(self)
  7.                 local name = string.find(self:GetName(), "NamePlate")
  8.                 if name then
  9.                     local R, G, B, A = self:GetChildren():GetStatusBarColor()
  10.                     self:GetChildren():SetStatusBarColor(R*0.5, G*0.5, B*0.5, A)
  11.                 end
  12.             end)
  13.         end
  14.     end
  15. end)
  16. frame:RegisterEvent("NAMEPLATEPOPUPEVENT")

Edit: So after further blatant copying from rNameplates i tried this:

lua Code:
  1. local frame = CreateFrame("Frame")
  2. local lastupdate = 0
  3.  
  4. frame:SetScript("OnUpdate", function(self, elapsed)
  5.     lastupdate = lastupdate + elapsed
  6.     if lastupdate > 0.33 then
  7.         lastupdate = 0
  8.         local num = select('#', WorldFrame:GetChildren())
  9.         for i=2, num do
  10.             select(i, WorldFrame:GetChildren()):HookScript("OnShow", function(self)
  11.                 local name = string.find(self:GetName(), "NamePlate")
  12.                 if name then
  13.                     local R, G, B = self:GetChildren():GetStatusBarColor()
  14.                     self:GetChildren():SetStatusBarColor(1, 0, 0)
  15.                 end
  16.             end)
  17.         end
  18.     end
  19. end)

It works for some time, then stops working, starts working again. Hiding nameplates and showing them again sometimes helps, sometimes it doesn't. I get a serious urge to give up on the case.

Edit: I just thought that there's little reason to hook the script at this point?!

Last edited by grom : 03-06-11 at 12:43 PM.
  Reply With Quote