Thread Tools Display Modes
03-14-10, 06:51 PM   #1
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
Most efficient button range check

I'm using the default Blizzard buttons and I want to make the icon go red instead of having the keybinding text go red.

As this basically has to be an OnUpdate I'm trying to think of ways of doing this the most efficiently.

Currently what I am doing is hooking the default ActionButton_OnUpdate function and thottling it by checking if the rangeTimer is equal to 0.2 (magic number). rangeTimer goes up to 2 before being reset by the default code.

Now what I'm thinking about is how this ranks up against creating a new OnUpdate for every button or creating a single OnUpdate for all buttons.
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.

Last edited by v6o : 03-14-10 at 06:54 PM.
  Reply With Quote
03-14-10, 07:35 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
There are three mods you can look at for this: RedRange, tullaRange, and rActionBarStyler. Actually, there are probably more, but those are what I can think of off the top of my head.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
03-14-10, 11:51 PM   #3
Shadowed
...
Premium Member
Featured
Join Date: Feb 2006
Posts: 387
A single OnUpdate is the most efficient, ultimately any range checker is going to be inefficient because you are checking the range on anywhere from 10 to 50 spells consistently.
  Reply With Quote
03-15-10, 02:52 AM   #4
Zidomo
A Cliff Giant
 
Zidomo's Avatar
Join Date: Apr 2006
Posts: 76
^^ most mods like that are far (far) from "efficient", as what Shadowed said. Nearly all (but not all) I have tested in the past use far more CPU time than nearly any other mod. Except, perhaps, QuestHelper.

Ones tested in the past (with OptionHouse, CPU profiling enabled) below. None of them seem to vary much/at all in CPU usage whether you are idle and not targeting anything or targeting an enemy so that the buttons change color. All tested with the default Blizzard action bars and nothing else:
--RedRange (tied for the worst, uses 24-28 CPU/second average which can potentially cause massive lag)
--Buttonrange (similar, 25-28 average)
--RangeColors (better than the above: 5.3-6 average. The latest version 2.14 is much improved over older versions which used double what RedRange does. It's still very high compared with most mods, though.)
--tullaRange (far and away the best: 0.4-0.5 average. Its actually usable in a mod-heavy raid configuration)

There also used to be one called "ActionButtonColors" by "Nirriti" on Curse. It used around 18-20 CPU/second average; slightly better than RedRange/Buttonrange, but still outrageous. Does not seem to be downloadable anymore, though.

Unless you can improve on what Tuller has done with tullaRange, I wouldn't spend time on a new mod like this . If you still want to, though, tullaRange uses a single global OnUpdate handler instead of one for each button, which appears to reduce CPU usage massively.

Last edited by Zidomo : 03-15-10 at 02:55 AM.
  Reply With Quote
03-15-10, 09:30 AM   #5
Lord Rappian
A Murloc Raider
Join Date: Jan 2007
Posts: 8
My data mining has yielded this nugget (Cited from Briggster on the RangeColors site at Curse):

I'll just citate Tuller, author of the actionbar mod "Dominos". He explains it very well:

"Do you notice any discernible difference in performance with redrange enabled versus when its disabled?

Basically, every time a frame is rendered, RedRange asks each visible action button:
* Is it time to check my status again?
* Should I be red or not?
* Is this a change from last time?
If all of those conditions are true, then the action button's redness is updated. Otherwise, RedRange does nothing.

Now, the blizzard CPU profiler sees that check and says, "hey this addon is doing something, I better record its time" So it then increment's red range's CPU count. Now, what I suspect happens here is that, even though its a very very tiny amount of CPU work being done, the CPU profiler can only insert a value greater than say 0.05, and nothing lower than that. So the redrange addon may just be doing 0.00001 work, but is counted as 0.05. and thus you see the inflated number for CPU usage.

It is within my ability to write a more efficient version, but unless red range is really killing someone's FPS, I do not think there's a need to."

So, RedRange or RangeColors are "forced" to update with all these "ActionButton_OnUpdate" events, that means, every frame.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Most efficient button range check


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