Thread: Exp bar color
View Single Post
07-27-11, 04:48 PM   #12
Aprikot
A Frostmaul Preserver
 
Aprikot's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 284
I appreciate all the replies...

Originally Posted by Haleth View Post
@ OP; In your second attempt, you refer to exhaustionStateID without defining it. Local values are not

inherited from hooked functions.

Try it when you define it as GetRestState(), as the original Blizzard function does.

Thanks, this is good to know. When I "For giggles I used the whole thing in my hooksecurefunc()" the definition was there (but I didn't know it needed to be defined there ):

lua Code:
  1. hooksecurefunc("ExhaustionTick_OnEvent", function(self, event, ...)
  2.         local exhaustionStateID = GetRestState();
  3.         if (exhaustionStateID == 1) then
  4.             MainMenuExpBar:SetStatusBarColor(0, 1, 0);
  5.             ExhaustionLevelFillBar:SetVertexColor(0, 1, 0, .2);
  6.             ExhaustionTickHighlight:SetVertexColor(0, 1, 0);
  7.         elseif (exhaustionStateID == 2) then
  8.             MainMenuExpBar:SetStatusBarColor(0.58, 0.0, 0.55, 1.0);
  9.             ExhaustionLevelFillBar:SetVertexColor(0.58, 0.0, 0.55, 0.15);
  10.             ExhaustionTickHighlight:SetVertexColor(0.58, 0.0, 0.55);
  11.         end
  12.     end)

Originally Posted by SDPhantom View Post
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"
  20.  
  21. alphaMode="ADD"/>
  22. </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);




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);

This is good info, and both code examples work perfectly.


Originally Posted by Mischback View Post
Could you "noop" the original function?

Code:
local function noop()
    return
end

    MainMenuExpBar:SetStatusBarColor(1, 1, 1, 1)
    MainMenuExpBar.SetStatusBarColor = noop

This also works perfectly. So is return nothing just putting the kibosh on any subsequent SetStatusBarColor attempts from Blizzard?

Both methods acheive the desired result...

Click image for larger version

Name:	WoWScrnShot_072711_163000.jpg
Views:	419
Size:	1.41 MB
ID:	6393
  Reply With Quote