Thread: frame replacing
View Single Post
10-05-14, 07:05 PM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
1. Never use an OnUpdate script if there's an event you can respond to instead. OnUpdate scripts run every time a new video output frame is drawn -- if you're running at 60 FPS, every OnUpdate script is getting run 60 times per second. In this case, there is an event that tells you when modifier keys are pressed or released -- MODIFIER_STATE_CHANGED.

2. Simply checking for the modifier state in the aura filter won't really work, because modifier state changes don't trigger an aura display update -- only aura changes do that.

3. I already do this in my layout; here's a standalone adaptation that will work with any oUF layout to show all auras while Shift is pressed, and restore whatever filter you normally have when it's released:

Code:
local f = CreateFrame("Frame")
f:RegisterEvent("MODIFIER_STATE_CHANGED")
f:SetScript("OnEvent", function(f, event, key, state)
	if key ~= "LSHIFT" and key ~= "RSHIFT" then
		return
	end
	local a, b
	if state == 1 then
		a, b = "CustomFilter", "__CustomFilter"
	else
		a, b = "__CustomFilter", "CustomFilter"
	end
	for i = 1, #oUF.objects do
		local object = oUF.objects[i]
		local buffs = object.Auras or object.Buffs
		if buffs and buffs[a] then
			buffs[b] = buffs[a]
			buffs[a] = nil
			buffs:ForceUpdate()
		end
		local debuffs = object.Debuffs
		if debuffs and debuffs[a] then
			debuffs[b] = debuffs[a]
			debuffs[a] = nil
			debuffs:ForceUpdate()
		end
	end
end)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote