ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   AddOn Help/Support (https://www.esoui.com/forums/forumdisplay.php?f=164)
-   -   Removing 'gloss' from attribute bars? (https://www.esoui.com/forums/showthread.php?t=1179)

myslex 04/26/14 04:55 AM

Removing 'gloss' from attribute bars?
 
Helu esoui,

Ever since I discovered theres an alternative way to display the attribute bars by adding these lines:

Quote:

ZO_PlayerAttributeHealthBarLeftGloss:SetHidden(true)
ZO_PlayerAttributeHealthBarRightGloss:SetHidden(true)
.. I've been inlove, and I cannot imagine going back to using the original 'glossy' version.. However there's a slight issue with this..

It would seem that some function is re-enabling the 'glossyness' when player gain a buff or loses/gain health.. It is then automatically reversed after the 'translation effect'..

Is there a way to completely disable the gloss, and preventing the default functions from 're-enabling' the gloss?

EDIT: also TL;DR
Gloss also has a 'alpha value'. Is it possible to set a 'max alpha value' to say 0 for gloss, like in this example:

Quote:

ZO_PlayerAttributeHealth.playerAttributeBarObject.timeline:GetAnimation():SetStartAlpha(1.0)
Any help is grately appreciated, thank you in advance!
MYSLxxx

Fathis Ules 04/26/14 06:15 AM

what about hooking it directly

Lua Code:
  1. local function newSetHidden(...)
  2.     --origZO_PlayerAttributeHealthBarLeftGloss(...)
  3. end
  4. local origZO_PlayerAttributeHealthBarLeftGloss.SetHidden = ZO_PlayerAttributeHealthBarLeftGloss.SetHidden
  5. local origZO_PlayerAttributeHealthBarRightGloss.SetHidden = ZO_PlayerAttributeHealthBarLeftGloss.SetHidden
  6. ZO_PlayerAttributeHealthBarLeftGloss.SetHidden = newSetHidden
  7. ZO_PlayerAttributeHealthBarRightGloss.SetHidden = newSetHidden

that's a sample of course but that's how you can change the SetHidden behaviour after you changed it once

myslex 04/26/14 06:52 AM

Quote:

Originally Posted by Fathis Ules (Post 5954)
what about hooking it directly

Lua Code:
  1. local function newSetHidden(...)
  2.     --origZO_PlayerAttributeHealthBarLeftGloss(...)
  3. end
  4. local origZO_PlayerAttributeHealthBarLeftGloss.SetHidden = ZO_PlayerAttributeHealthBarLeftGloss.SetHidden
  5. local origZO_PlayerAttributeHealthBarRightGloss.SetHidden = ZO_PlayerAttributeHealthBarLeftGloss.SetHidden
  6. ZO_PlayerAttributeHealthBarLeftGloss.SetHidden = newSetHidden
  7. ZO_PlayerAttributeHealthBarRightGloss.SetHidden = newSetHidden

that's a sample of course but that's how you can change the SetHidden behaviour after you changed it once

I must start this post with saying that I am a mediocre c# programmer, and have never worked with lua before.. and while I :REALLY: appreciate you taking the time to reply in this thread, I have no idea what to make of this proposition you made regarding hooking it directly..

Would it be to much to ask for a 'working' example, since I am too stupid to understand what you're trying to teach me?

/hugs
MYSleX

Fathis Ules 04/26/14 08:18 AM

If :SetHidden(true) is your solution but something calls again :SetHidden(false) to revert your solution then you need to replace SetHidden by your function to filter out the calls made to SetHidden with false

In the sample I show you how to replace the SetHidden function by yours so you can decide then to pass the original execution to origZO_PlayerAttributeHealthBarLeftGloss to have the result of a normal SetHidden, or to not continue the execution , that's how you can forbid any call made to SetHidden

It is not specific to Lua, it is just called function hooking and is present in all the programming language, the only requirement is overwrite the pointer of the original function by your and to store a pointer of the original function in a local variable before you replace it so you can call later the original function from your.

Lua Code:
  1. local originalSetHiddenLeft = ZO_PlayerAttributeHealthBarLeftGloss.SetHidden
  2. local originalSetHiddenRight = ZO_PlayerAttributeHealthBarRightGloss.SetHidden
  3.  
  4. local function newSetHiddenLeft(self, hidden, ...)
  5.     if hidden == false then
  6.         --do nothing, meaning, SetHidden is disabled
  7.         return
  8.     end
  9.     originalSetHiddenLeft(self, hidden, ...) -- Calls the normal ZO_PlayerAttributeHealthBarLeftGloss.SetHidden
  10. end
  11.  
  12. local function newSetHiddenRight(self, hidden, ...)
  13.     if hidden == false then
  14.         --do nothing, meaning, SetHidden is disabled
  15.         return
  16.     end
  17.     originalSetHiddenRight (self, hidden, ...) -- Calls the normal ZO_PlayerAttributeHealthBarRightGloss.SetHidden
  18. end
  19.  
  20. ZO_PlayerAttributeHealthBarLeftGloss.SetHidden = newSetHiddenLeft
  21. ZO_PlayerAttributeHealthBarRightGloss.SetHidden = newSetHiddenRight

myslex 04/26/14 08:29 AM

Quote:

Originally Posted by Fathis Ules (Post 5967)
If :SetHidden(true) is your solution but something calls again :SetHidden(false) to revert your solution then you need to replace SetHidden by your function to filter out the calls made to SetHidden with false

In the sample I show you how to replace the SetHidden function by yours so you can decide then to pass the original execution to origZO_PlayerAttributeHealthBarLeftGloss to have the result of a normal SetHidden, or to not continue the execution , that's how you can forbid any call made to SetHidden

It is not specific to Lua, it is just called function hooking and is present in all the programming language, the only requirement is overwrite the pointer of the original function by your and to store a pointer of the original function in a local variable before you replace it so you can call later the original function from your.

Lua Code:
  1. local function newSetHiddenLeft(self, hidden, ...)
  2.     if hidden == false then
  3.         --do nothing, meaning, SetHidden is disabled
  4.         return
  5.     end
  6.     originalSetHiddenLeft(self, hidden, ...) -- Calls the normal ZO_PlayerAttributeHealthBarLeftGloss.SetHidden
  7. end
  8.  
  9. local function newSetHiddenRight(self, hidden, ...)
  10.     if hidden == false then
  11.         --do nothing, meaning, SetHidden is disabled
  12.         return
  13.     end
  14.     originalSetHiddenRight (self, hidden, ...) -- Calls the normal ZO_PlayerAttributeHealthBarRightGloss.SetHidden
  15. end
  16.  
  17. local originalSetHiddenLeft = ZO_PlayerAttributeHealthBarLeftGloss.SetHidden
  18. local originalSetHiddenRight = ZO_PlayerAttributeHealthBarRightGloss.SetHidden
  19.  
  20. ZO_PlayerAttributeHealthBarLeftGloss.SetHidden = newSetHiddenLeft
  21. ZO_PlayerAttributeHealthBarRightGloss.SetHidden = newSetHiddenRight

This is very impressive, A new way (for me) to tackle the problem. Its kind of like overriding a function, isnt it?

However.. Hiding the 'glossy frame' and then disabling the sethidden function, still results in the 'glossyness' being shown when first aggroing an enemy thinking theres something glossy somewhere else.. Damn it!!

I appreciate you helping me out, really! thank you!
MysLEx

myslex 04/26/14 08:33 AM

Quote:

Originally Posted by myslex (Post 5968)
This is very impressive, A new way (for me) to tackle the problem. Its kind of like overriding a function, isnt it?

However.. Hiding the 'glossy frame' and then disabling the sethidden function, still results in the 'glossyness' being shown when first aggroing an enemy thinking theres something glossy somewhere else.. Damn it!!

I appreciate you helping me out, really! thank you!
MysLEx

It seems that the game's default behaviour to fade in the attribute bar on combat begin is messing with the alpha of the 'glossy frame' .. requires further investigation.. Any help is always appreciated. Again.. thanks =)

MsysELx

Fathis Ules 04/26/14 08:43 AM

did you tried the same with SetAlpha, SetAlpha(0) can sets an object invisible and SetAlpha(1) visible



and yeah btw it is just function oiverwriting, hooking is the commong term, that's a very powerfull way to change the way the default client is working, I use this in my anti spam addon to hook message comming before they reach the chatwindow and also to inject special command when you right click player names

myslex 04/26/14 08:47 AM

Quote:

Originally Posted by Fathis Ules (Post 5970)
did you tried the same with SetAlpha, SetAlpha(0) can sets an object invisible and SetAlpha(1) visible



and yeah btw it is just function oiverwriting, hooking is the commong term, that's a very powerfull way to change the way the default client is working, I use this in my anti spam addon to hook message comming before they reach the chatwindow and also to inject special command when you right click player names

That is... excuse the choice of words... ****ing awesome!! I'll try it! thanks man! you're awesome!

myslex 04/26/14 09:12 AM

Quote:

Originally Posted by myslex (Post 5971)
That is... excuse the choice of words... ****ing awesome!! I'll try it! thanks man! you're awesome!

I tried it but i think im doing something wrong..

This is declared at the most top of the lua file:

Quote:

local originalSetAlphaLeft = ZO_PlayerAttributeHealthBarLeftGloss.SetAlpha
local originalSetAlphaRight = ZO_PlayerAttributeHealthBarRightGloss.SetAlpha
These are my two functions declared outside the 'OnAddonLoaded' event:

Quote:

function newSetAlphaLeft(self, alpha, ...)
if alpha > 0 then
--do nothing, meaning, SetHidden is disabled
return
end
originalSetAlphaLeft(self, alpha, ...) -- Calls the normal ZO_PlayerAttributeHealthBarLeftGloss.SetAlpha
end

function newSetAlphaRight(self, alpha, ...)
if alpha > 0 then
--do nothing, meaning, SetHidden is disabled
return
end
originalSetAlphaRight (self, alpha, ...) -- Calls the normal ZO_PlayerAttributeHealthBarRightGloss.SetAlpha
end
And this is declared 'OnAddonLoaded', aka 'initialized function':

Quote:

ZO_PlayerAttributeHealthBarLeftGloss.SetAlpha = newSetAlphaLeft
ZO_PlayerAttributeHealthBarRightGloss.SetAlpha = newSetAlphaRight
Please tell me if im doing something wrong, or if this should infact work. I am able to write this after the changes:

Quote:

ZO_PlayerAttributeHealthBarRightGloss:SetAlpha(1)
Shouldnt work should it?

MSSYLex

myslex 04/26/14 09:30 AM

Quote:

Originally Posted by myslex (Post 5974)
alot of text in previous post

OK so I got it to block both SetHidden and SetAlpha with method overriding (or hooking) like you suggested and the values are not changable from addon nor ingame /script .. However.. Upon entering combat the gloss is still showing and then disappearing shortly after. very weird..

investigation continues...

Biki 04/26/14 09:32 AM

Lua Code:
  1. ZO_PlayerAttributeHealthBarLeftGloss:SetHandler("OnUpdate", function()
  2.     ZO_PlayerAttributeHealthBarLeftGloss:SetHidden(true)
  3.   end)
  4.   ZO_PlayerAttributeHealthBarRightGloss:SetHandler("OnUpdate", function()
  5.     ZO_PlayerAttributeHealthBarRightGloss:SetHidden(true)
  6.   end)

Will work too, quick and dirty. Just tested it. But there might be more performant options available.

myslex 04/26/14 09:55 AM

Quote:

Originally Posted by Biki (Post 5979)
Lua Code:
  1. ZO_PlayerAttributeHealthBarLeftGloss:SetHandler("OnUpdate", function()
  2.     ZO_PlayerAttributeHealthBarLeftGloss:SetHidden(true)
  3.   end)
  4.   ZO_PlayerAttributeHealthBarRightGloss:SetHandler("OnUpdate", function()
  5.     ZO_PlayerAttributeHealthBarRightGloss:SetHidden(true)
  6.   end)

Will work too, quick and dirty. Just tested it. But there might be more performant options available.

Oh this is progress!

Allthough im ashamed to admit, i am allergic to 'onupdate' functions that run continuesly. As you said, im a performance junkie.. All addons Im using / have written are triggered on events..

Small update to my problem..
It would seem my problem is directly related to the
Quote:

ZO_PlayerAttributeHealth.playerAttributeBarObject.timeline:GetAnimation() ..
the animation is running when engaging in combat, aswell as when using an 'power up' ability such as increase armor buff..

If only there was a way to remove an existing animation................

MSLex

Fathis Ules 04/26/14 10:13 AM

your hook probably not registered , try to debug with adding d("text") inside the functions

Biki 04/26/14 10:13 AM

Ok so I've tested a little more, seeing I also like the non-glossy version :D

Lua Code:
  1. ZO_PlayerAttributeHealthBarLeftGloss:SetHidden(true)
  2.   ZO_PlayerAttributeHealthBarLeftGloss:SetDimensions(0, 0)
  3.   ZO_PlayerAttributeHealthBarLeftGloss:SetDimensionConstraints(0, 0, 0, 0)
  4.   ZO_PlayerAttributeHealthBarRightGloss:SetHidden(true)
  5.   ZO_PlayerAttributeHealthBarRightGloss:SetDimensions(0, 0)
  6.   ZO_PlayerAttributeHealthBarRightGloss:SetDimensionConstraints(0, 0, 0, 0)

Seems to work and only gets called once. It avoids the re-showing problem by just setting the dimensions of the glow to 0 width and 0 height.

myslex 04/26/14 10:24 AM

Quote:

Originally Posted by Fathis Ules (Post 5986)
your hook probably not registered , try to debug with adding d("text") inside the functions

You were right, I did as you instructed and and its working again. Thank you!

Quote:

Originally Posted by Biki (Post 5987)
Ok so I've tested a little more, seeing I also like the non-glossy version :D

Lua Code:
  1. ZO_PlayerAttributeHealthBarLeftGloss:SetHidden(true)
  2.   ZO_PlayerAttributeHealthBarLeftGloss:SetDimensions(0, 0)
  3.   ZO_PlayerAttributeHealthBarLeftGloss:SetDimensionConstraints(0, 0, 0, 0)
  4.   ZO_PlayerAttributeHealthBarRightGloss:SetHidden(true)
  5.   ZO_PlayerAttributeHealthBarRightGloss:SetDimensions(0, 0)
  6.   ZO_PlayerAttributeHealthBarRightGloss:SetDimensionConstraints(0, 0, 0, 0)

Seems to work and only gets called once. It avoids the re-showing problem by just setting the dimensions of the glow to 0 width and 0 height.

THIS!!!!!!! exactly what I wanted. Minimal testing is pointing towards success, I will do more extensive testing and post back here..

Thank you all so much for helping me. Been annoyed the whole day! LOL!


All times are GMT -6. The time now is 10:44 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI