Reply
Thread Tools Display Modes
Unread 02-01-10, 02:22 AM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,351
Hooking Blizzard Widgets/Functions

For those of you who don't know this already.

It is possible to hook functions like "SetAlpha", "SetVertexColor" or "SetPoint" for a specific frame/button.

This comes in very handy if you rewrite Blizzard stuff and want to make sure it stays the way you want it.

Thanks to "hooksecurefunc" it won't cause tainting aswell.

Code:
  ----------------------
  --FUNCTIONS
  ----------------------
  
  local function am(text)
    DEFAULT_CHAT_FRAME:AddMessage(text)
  end

  local function mySetVertexColorFunc(self, r, g, b, a)
    --do stuff
    am("setvertexcol")
    if r then
      am(r)
    end
  end
  
  local function mySetStatusBarColorFunc(self, r, g, b, a)
    --do stuff
    am("setstatusbarcol")
    if r then
      am(r)
      if r > 0.3 then
        self:SetStatusBarColor(0.2,0.2,0.2,1)
      end
    end
  end  
  
  local function mySetAlphaFunc(self, a)
    --do stuff
    am("setalpha")
    if a then
      am(a)
    end
  end
  
  ----------------------
  --FRAMES
  ----------------------
  
  --set colors for any kind of frame/button
  frame1:SetVertexColor(1,0.2,0.2,1)
  frame2:SetStatusBarColor(0.2,0.2,1,1)

  ----------------------
  --HOOKS
  ----------------------

  --hook functions for that frame/button
  hooksecurefunc(frame1, "SetVertexColor", mySetVertexColorFunc)
  hooksecurefunc(frame1, "SetAlpha", mySetAlphaFunc)

  hooksecurefunc(frame2, "SetStatusBarColor", mySetStatusBarColorFunc)
  hooksecurefunc(frame2, "SetAlpha", mySetAlphaFunc)
That way you can rewrite anything Blizzard does again.

Think of a frame that you want to stay at Alpha(0.2) but Blizzard always sets it to Alpha(1), so just hook SetAlpha() and you can set it to "0.2" again.
__________________
| Simple is beautiful.
| Roth UI | Roth UI FAQ | GoogleCode | Zork | TDMOG

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

Last edited by zork : 02-01-10 at 02:26 AM.
zork is offline   Reply With Quote
Unread 02-01-10, 03:11 AM   #2
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,048
Originally Posted by zork View Post
That way you can rewrite anything Blizzard does again.
Not completely true - the original code still executes, directly before your code does.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of Revelation, Spamalyzer, TravelAgent, Volumizer, and many other AddOns.
Torhal is offline   Reply With Quote
Unread 09-27-10, 02:45 PM   #3
Lane
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Jun 2005
Posts: 36
Can you use this to get the Duration of Debuffs on your target and put them somewhere else? Or should I just write it separately and not worry about hooking Blizzards code?
Lane is offline   Reply With Quote
Unread 10-01-10, 12:58 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,351
Debuffs are handled by the UnitAura event and your debuff could by any of target debuff buttons. You want http://www.wowinterface.com/download...-rFilter2.html or a mod alike.
__________________
| Simple is beautiful.
| Roth UI | Roth UI FAQ | GoogleCode | Zork | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
zork is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Tutorials & Other Helpful Info. » Hooking Blizzard Widgets/Functions

Thread Tools
Display Modes

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