Thread: Exp bar color
View Single Post
07-27-11, 01:00 PM   #11
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,334
Originally Posted by Aprikot View Post
... For giggles I used the whole thing in my hooksecurefunc() to no avail...I'm not seeing the SetStatusBarColor() values being applied. I appreciate any thoughts.
Here's a clip of MainMenuBar.xml...
xml Code:
  1. <Button name="ExhaustionTick" parent="MainMenuExpBar" hidden="false" frameStrata="DIALOG">
  2.     <Size>
  3.         <AbsDimension x="32" y="32"/>
  4.     </Size>
  5.     <Anchors>
  6.         <Anchor point="CENTER" relativeTo="MainMenuExpBar">
  7.             <Offset>
  8.                 <AbsDimension x="0" y="0"/>
  9.             </Offset>
  10.         </Anchor>
  11.     </Anchors>
  12.     <Scripts>
  13.         <OnLoad function="ExhaustionTick_OnLoad"/>
  14.         <OnEvent function="ExhaustionTick_OnEvent"/>
  15.         <OnEnter function="ExhaustionToolTipText"/>
  16.         <OnLeave function="GameTooltip_Hide"/>
  17.     </Scripts>
  18.     <NormalTexture name="ExhaustionTickNormal" file="Interface\MainMenuBar\UI-ExhaustionTickNormal"/>
  19.     <HighlightTexture name="ExhaustionTickHighlight" file="Interface\MainMenuBar\UI-ExhaustionTickHighlight" alphaMode="ADD"/>
  20. </Button>

Notice the way the script functions are registered. This grabs the function immediately and sets it to the associated script. hooksecurefunc() will not work on this. You'll have to hook the frame's script handler directly with something like this.
lua Code:
  1. ExhaustionTick:HookScript("OnEvent",function(self,event,...)
  2.     MainMenuExpBar:SetStatusBarColor(1,1,1,1);
  3. end);



Originally Posted by Aprikot View Post
I'm trying to do the same thing with the rep bar (recolor it), and having an issue where the bar will not recolor on load (but will recolor on exp gain):

...

Any idea why this doesn't work with PLAYER_ENTERING_WORLD? It works for the exp bar (code in post above this).
Your code is conflicting with Blizzards and the event API will randomly choose which it'll fire the event first for. This one seems to actually be called instead of set as a script handler, so hooksecurefunc() will work on this one.
lua Code:
  1. hooksecurefunc("ReputationWatchBar_Update",function()
  2.     ReputationWatchStatusBar:SetStatusBarColor(1,1,1,1);
  3. end);
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote