Thread Tools Display Modes
03-10-13, 11:28 AM   #1
Aryae21
A Deviate Faerie Dragon
Join Date: Jan 2013
Posts: 18
KG Panel Script - Changing on Spec

Not even sure if this is possible, but is there a way to change a texture based on a player/targets spec?
Basically I was planning on making a texture for my Unit frames (Player,target,focus target,target of target and such. NOT raid frames.) That change on the players class. Was planning on using the class icons. Then I thought how awesome it'd be to show a spec specific icon instead of just class. Is that possible, and if not then how about changing on class only?
  Reply With Quote
03-10-13, 01:13 PM   #2
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
For a player spec icon that is easy:

Panel OnLoad script:
lua Code:
  1. self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
  2. self:RegisterEvent("PLAYER_LOGIN")
  3.  
  4. -- to strip the ugly border
  5. self.bg:SetTexCoord(.08, .92, .08, .92)

Panel OnEvent script:
lua Code:
  1. local specId = GetSpecialization()
  2. if not specId then return end
  3. local _, _, _, icon, background =GetSpecializationInfo(specId)
  4. -- you can also use background if you wish
  5. self.bg:SetTexture(icon)

As for target/focus spec icons, this becomes somewhat harder as you have to wait for the inspection queue so you can use it to query the talents of your target or focus.
  Reply With Quote
03-10-13, 03:24 PM   #3
Aryae21
A Deviate Faerie Dragon
Join Date: Jan 2013
Posts: 18
Hmm figured as much. What about for classes then? Would that be easier for target/focus then specs?
  Reply With Quote
03-17-13, 06:16 AM   #4
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Yes, it would.
Player Onload:
lua Code:
  1. local _, class = UnitClass("player")
  2. local t = CLASS_ICON_TCOORDS[class]
  3. self.bg:SetTexture([[Interface\TargetingFrame\UI-Classes-Circles]])
  4. self.bg:SetTexCoord(unpack(t))
Target Onload:
lua Code:
  1. self.coords = CLASS_ICON_TCOORDS
  2. self:RegisterEvent("PLAYER_TARGET_CHANGED")
Target OnEvent:
lua Code:
  1. if not UnitExists("target") or not UnitIsPlayer("target") then
  2.     self:Hide()
  3.     return
  4. end
  5. local _, class = UnitClass("target")
  6. local t = self.coords[class]
  7. if t then
  8.     self.bg:SetTexture([[Interface\TargetingFrame\UI-Classes-Circles]])
  9.     self.bg:SetTexCoord(unpack(t))
  10.     self:Show()
  11. else
  12.     self:Hide()
  13. end
For focus, just change PLAYER_TARGET_CHANGED to PLAYER_FOCUS_CHANGED.
This is untested, but something along the lines of that should work.

Last edited by ravagernl : 03-17-13 at 06:20 AM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » KG Panel Script - Changing on Spec


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