Thread Tools Display Modes
01-29-11, 01:19 PM   #1
sacrife
An Onyxian Warder
 
sacrife's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 384
Preventing "player" in party/raid frames from inheriting "player" properties

I've created a function for my raid frames (which also functions as party frames) which only shows dispellable debuffs, otherwise hide's the icon. However since I have show player (me) on in the raid frames that frame in the raid shows every debuff as the if unit=='player' setting has different goals (shows every debuff).

How can I modify the check for 'player' to NOT modify the myself in the raid frames?

lua Code:
  1. -- debuff highlight
  2. local CanDispel = {
  3.     PRIEST = { Magic = true, Disease = false, },
  4.     SHAMAN = { Poison = true, Disease = true, },
  5.     PALADIN = { Magic = true, Poison = true, Disease = true, },
  6.     MAGE = { Curse = true, },
  7.     DRUID = { Curse = true, Poison = true, }
  8. }
  9. local dispellist = CanDispel[playerClass] or {}
  10.  
  11. -- update icon
  12. local PostUpdateIcon
  13. do
  14.     local playerUnits = {
  15.         player = true,
  16.         pet = true,
  17.         vehicle = true,
  18.     }
  19.  
  20.     PostUpdateIcon = function(icons, unit, icon, index, offset, filter, isDebuff)
  21.     local name, _, _, _, dtype, duration, expirationTime, unitCaster, _ = UnitAura(unit, index, icon.filter)
  22.     local texture = icon.icon
  23.    
  24.     -- icon timers
  25.     if unit == "target" or unit == "focus" then
  26.         icon.time:Show()
  27.         icon.timeLeft = expirationTime
  28.         icon:SetScript("OnUpdate", CreateAuraTimer)
  29.     else
  30.         if duration and duration > 0 then
  31.             icon.time:Show()
  32.             icon.timeLeft = expirationTime
  33.             icon:SetScript("OnUpdate", CreateAuraTimer)
  34.         else
  35.             icon:SetScript("OnUpdate", CreateAuraTimer)
  36.             icon.time:Hide()
  37.             if unit == 'player' then
  38.                 icon:Hide()
  39.             end
  40.         end
  41.     end
  42.  
  43.     -- Debuff coloring
  44.     if unit == "target" or unit == "focus" then
  45.         if (playerUnits[icon.owner]) then
  46.             if icon.debuff then
  47.                 local color = DebuffTypeColor[dtype] or {r=0,g=0,b=0}
  48.                 icon.bd:SetBackdropBorderColor(color.r*0.9, color.g*0.9, color.b*0.9)
  49.             end
  50.             texture:SetDesaturated(false)
  51.         else
  52.             if icon.debuff then
  53.                 icon.bd:SetBackdropBorderColor(unpack(cfg.brdcolor))
  54.                 texture:SetDesaturated(true)
  55.             end
  56.         end
  57.     else
  58.         if ((unit=='player') or unit == 'pet' or unit == 'targettarget') then
  59.             if icon.debuff then
  60.                 local color = DebuffTypeColor[dtype] or {r=1,g=0,b=0}
  61.                 icon.bd:SetBackdropBorderColor(color.r*0.9, color.g*0.9, color.b*0.9)
  62.                 texture:SetDesaturated(false)
  63.             end
  64.         else
  65.             if dispellist[dtype] and icon.debuff then
  66.                 local color = DebuffTypeColor[dtype] or {r=0,g=0,b=0}
  67.                 icon.bd:SetBackdropBorderColor(color.r*0.9, color.g*0.9, color.b*0.9)
  68.                 texture:SetDesaturated(false)
  69.                 icon:SetFrameStrata("HIGH")
  70.                 icon.bd:SetFrameStrata("MEDIUM")
  71.             else
  72.                 icon:Hide()
  73.             end
  74.         end
  75.     end
  76.     icon.first = true
  77.     end
  78. end

Spawn raid code for reference if needed:

lua Code:
  1. if cfg.RaidFrames then 
  2.     self:SetActiveStyle"Shakes - Raid"
  3.     --local raid = self:SpawnHeader('oUF_Raid', nil, 'raid10', 
  4.     local raid = self:SpawnHeader('oUF_Raid', nil, 'party,raid,solo',  
  5.     'showRaid', true,
  6.     'showParty', true,
  7.     'showPlayer', true,
  8.     'xOffset', 5,
  9.     --'yOffset', -3,
  10.     'groupFilter', '1,2,3,4,5,6,7,8',
  11.     'groupingOrder', '1,2,3,4,5,6,7,8',
  12.     'groupBy', 'GROUP',
  13.     'maxColumns', 8,
  14.     'unitsPerColumn', 5,
  15.     'columnSpacing', 1,
  16.     'point', 'LEFT',
  17.     'columnAnchorPoint', "TOP",
  18.  
  19.  
  20.     'oUF-initialConfigFunction', ([[
  21.             self:SetWidth(%d)
  22.             self:SetHeight(%d)
  23.     ]]):format(cfg.widthR, cfg.heightR + 8 + cfg.PPyOffset-1))
  24.    
  25.     local raidanchor
  26.     local spec = GetPrimaryTalentTree()
  27.    
  28.     if ((unitClass == "DRUID" and spec == 3) or (unitClass == "PRIEST" and spec < 3) or (unitClass == "SHAMAN" and spec == 3) or (unitClass == "PALADIN" and spec == 1)) then
  29.         raidanchor = oUF_ShakesTarget
  30.     else
  31.         raidanchor = oUF_ShakesPlayer
  32.     end
  33.    
  34.     local RWatcher = CreateFrame("Frame")
  35.         RWatcher:RegisterEvent("RAID_ROSTER_UPDATE")
  36.         RWatcher:RegisterEvent("PARTY_CONVERTED_TO_RAID")
  37.         RWatcher:RegisterEvent("PARTY_MEMBERS_CHANGED")
  38.         RWatcher:RegisterEvent("PLAYER_ENTERING_WORLD")
  39.         RWatcher:SetScript("OnEvent", function(self,event,...)
  40.             if GetNumRaidMembers() <= 25 then
  41.                 raid:SetPoint("TOPLEFT", raidanchor, "BOTTOMLEFT", 0, -5)
  42.             else
  43.                 raid:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 20, -20)
  44.             end
  45.         end)
  46. end
__________________


Last edited by sacrife : 01-29-11 at 01:21 PM.
  Reply With Quote
01-29-11, 07:50 PM   #2
Akkorian
A Flamescale Wyrmkin
 
Akkorian's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 111
Hi sacrife,

One easy way to tell the difference is to look at the frame’s parent. Unless you’ve changed it, regular frames are parented to the UIParent, but group frames are parented to a header frame.

You could check the parent like this:

Code:
if icons.__owner:GetParent() ~= UIParent then
	-- This is a group frame!
end
You could make it a little more efficient by checking the frame’s parent once in your spawn function, and setting a flag on it:

Code:
if self:GetParent() ~= UIParent then
	-- This is a group frame!
	self.isGroupFrame = true
end
And then check for it later:

Code:
if icons.__owner.isGroupFrame then
	-- This is a group frame!
end
__________________
“Be humble, for you are made of earth. Be noble, for you are made of stars.”
  Reply With Quote
01-30-11, 07:34 AM   #3
sacrife
An Onyxian Warder
 
sacrife's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 384
Thanks.
One more semi-related question.

How do I make the icon not clickable? (As in if I click it I select the frame behind it instead of the actual icon), but still maintaining it's tooltip function.
__________________

  Reply With Quote
01-30-11, 07:05 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Not possible. Either the frame is aware of the mouse, in which case it responds to mouseover, mouseout, click, and/or drag events, or it's not aware of the mouse, in which case it can't respond to any mouse-related events.
  Reply With Quote
01-30-11, 08:01 PM   #5
sacrife
An Onyxian Warder
 
sacrife's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 384
Can I hook the icon's click function to target it's parent frame instead?
__________________

  Reply With Quote
02-01-11, 01:53 PM   #6
sacrife
An Onyxian Warder
 
sacrife's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 384
lua Code:
  1. if dispellist[dtype] and icon.debuff then
  2.                 local color = DebuffTypeColor[dtype] or {r=0,g=0,b=0}
  3.                 icon.bd:SetBackdropBorderColor(color.r*0.9, color.g*0.9, color.b*0.9)
  4.                 texture:SetDesaturated(false)
  5.                 icon:SetFrameStrata("HIGH")
  6.                 icon.bd:SetFrameStrata("MEDIUM")
  7.                 icon:HookScript("OnClick", function(self, button)
  8.                        print(self:GetName() .. " clicked with " .. button)
  9.                 end)
  10.             else
  11.                 icon:Hide()
  12.             end

am I on to something here? I need it to click it's parent though :P
__________________

  Reply With Quote
02-01-11, 04:24 PM   #7
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by sacrife View Post
Can I hook the icon's click function to target it's parent frame instead?
No, targeting is a secure action and can't be executed by add-ons (without going through the Secure API).
__________________
「貴方は1人じゃないよ」
  Reply With Quote
02-01-11, 05:01 PM   #8
Akkorian
A Flamescale Wyrmkin
 
Akkorian's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 111
Hmmm. Maybe something like this would work?

Code:
local function UpdateTooltip( self )
	local icons = self.Buffs
	for i = 1, #icons do
		local button = icons[ i ]
		if button:IsShown() and button:IsMouseOver() then
			GameTooltip:SetOwner( self, "ANCHOR_CURSOR" )
			GameTooltip:SetUnitAura( self.unit, button:GetID(), button.filter )
			return
		end
	end
	UnitFrame_OnEnter( self )
end
Code:
unitFrame:SetScript( "OnEnter", function( self )
	self:SetScript( "OnUpdate", UpdateTooltip )
end )

unitFrame:SetScript( "OnLeave", function( self )
	self:SetScript( "OnUpdate", nil )
end )
__________________
“Be humble, for you are made of earth. Be noble, for you are made of stars.”
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Preventing "player" in party/raid frames from inheriting "player" properties


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