WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Smooth Power Values (Digits) (https://www.wowinterface.com/forums/showthread.php?t=45676)

MiRai 01-17-13 02:54 AM

Smooth Power Values (Digits)
 
I wasn't quite sure how to put what I wanted to ask into words, so I made a quick and dirty mock up video. I will recommend that you watch it at a higher resolution than the default 360p embedded resolution:

Video

Is it possible to make the power value digits count 'up' and 'down' like in the video? If so, what would it take to accomplish that? Is this going to be a boatload of work?

To be completely honest, I'm not entirely sure that I'd like this change, but if at all possible, I would like to see it in action on my screen while playing before I can truly make that call. As always, any help is appreciated. :)

Thanks!

EDIT: Apologies... the layout is oUF_Fail and here is the link.

haste 01-17-13 05:50 AM

Set a OnValueChanged script handler on the power bar and update the text based on the value it receives.

Sauerkraut 01-18-13 07:31 AM

Quote:

Originally Posted by haste (Post 272018)
Set a OnValueChanged script handler on the power bar and update the text based on the value it receives.

Thanks Haste this gave me the starting point I needed to get this working. Really appreciate all the help :o :D

Dawn 01-23-13 06:13 AM

I really like that. Especially, because I currently use "numbers only" unit frames that work fine but could need some ooomph. Please share the solution. :)

Phanx 01-23-13 06:55 PM

I'd imagine something like this:
Code:

self.Power:HookScript("OnValueChanged", function(bar, value)
    bar.value:SetText(value)
end)


Sauerkraut 01-24-13 03:29 PM

Phanx's way is probably better but...

Code:

        local text = lib.gen_fontstring(f.Health, cfg.font, 18, "OUTLINE")
        text:SetPoint("RIGHT", s.arrow, "LEFT", 6, -8)
        s:SetScript("OnValueChanged", function(self, value)
        text:SetFormattedText("%d", value, 0)
        text:SetJustifyH("RIGHT")
        end)


Sauerkraut 01-24-13 03:37 PM

I can't figure out how to color the text to match the bar. Any ideas would be appreciated.

Dawn 01-24-13 05:06 PM

Quote:

Originally Posted by Sauerkraut (Post 272332)
I can't figure out how to color the text to match the bar. Any ideas would be appreciated.

Something along the lines like this should work

Code:

local r, g, b = yourstatusbar:GetStatusBarColor()
and

Code:

yourtext:SetTextColor(r, g, b)
Btw, I'd use HookScript, instead of SetScript.

Sauerkraut 01-24-13 08:44 PM

Thanks Dawn, unfortunately all that did was change the color from white to yellow but I think it is a step in the right direction.

Dawn 01-24-13 09:35 PM

I don't know where you put it and how you color said statusbar. I suppose it's class coloured?

Phanx 01-24-13 09:53 PM

Code:

self.Power:HookScript("OnValueChanged", function(bar, value)
    bar.value:SetText(value)
    local r, g, b = bar:GetStatusBarColor()
    bar.value:SetTextColor(r, g, b)
end)

?

Sauerkraut 01-25-13 05:43 AM

Thanks Phanx I'll try that when I get home from work.

Sauerkraut 01-25-13 05:47 AM

Quote:

Originally Posted by Dawn (Post 272341)
I don't know where you put it and how you color said statusbar. I suppose it's class coloured?

Oops didn't see this. Dawn, I tried the code in two places within my power bar setup. I can't paste the code atm because I'm at work. The bars are colored by power type, but the text stayed yellow regardless of what class I was playing. I'm sure it is something I have done. I'll try the solution Phanx posted and it it doesn't work I'll post the code. Thanks again I really appreciate the help.

Sauerkraut 01-25-13 04:51 PM

Awesome it works!!! Thank you all so much. There is no way I could have done it without you. I'm still such a noob when it comes to lua.

Dawn 01-25-13 05:26 PM

Would it be possible to incorporate this in a tag?

I'm currently trying to get my head around it, but can't really get to it. Thing is I don't use any bars and therefore no hp or pp functions at all, just tags.

Code:

For instance, this is my health percent tag

oUF.Tags.Methods['GhostHPPerc'] = function(u)
        local m = UnitHealthMax(u)       
        local hp_perc = math.floor(UnitHealth(u)/m*100+.5)

        -- set text color and info
        if(UnitIsDead(u)) then
                return "|CFFB80D20".. "RIP" .."|r"
        elseif(UnitIsGhost(u)) then
                return "|CFFB80D20".. "GHO" .."|r"
        elseif(not UnitIsConnected(u)) then       
                return "|CFFFFFFFF".. "OFF" .."|r"
        elseif(UnitIsTapped(u) and not UnitIsTappedByPlayer(u)) then
                return "|CFF969696".. "TPD" .."|r"       
        elseif(hp_perc <= 60 and hp_perc > 35) then
                return format('|CFFF7F774 %d|r', hp_perc)                       
        elseif(hp_perc <= 35 and hp_perc >= 25) then
                return format('|CFFFDEE50 %d|r', hp_perc)
        elseif(hp_perc < 25 and hp_perc >= 20) then
                return format('|CFFFA8200 %d|r', hp_perc)       
        elseif(hp_perc < 20) then
                return format('|CFFB80D20 %d|r', hp_perc)       
        else
                return format('|CFFFFFFFF %d|r', hp_perc)
        end       
       
end
oUF.Tags.Events['GhostHPPerc'] = "UNIT_HEALTH UNIT_MAXHEALTH UNIT_CONNECTION"


zork 01-29-13 05:27 AM

Two options.

Try frequent events first.
http://wowprogramming.com/docs/event...EALTH_FREQUENT
http://wowprogramming.com/docs/event...POWER_FREQUENT

If that is not enough use the onUpdate function haste provides. It can be enabled via:
Lua Code:
  1. fontString.frequentUpdates = true

Hope that helps.

Dawn 01-29-13 05:13 PM

My question is how to "incorporate" the "OnValueChanged" visual effect into a tag.

Since I only have self or a font string in my layout, no self.health or power to :HookScript. :)

Phanx 01-29-13 05:44 PM

You don't. Your only option with the tag is to unconditionally update it many times per second.

Also, you could easily add a Power bar element to your frame, but give it no dimensions and/or points, thus making it invisible. The only way to run some code when a bar's value changes is to actually have a bar whose value is being changed.

Dawn 01-29-13 06:31 PM

Thanks, that's what I was thinking. I was just hoping that I missed something. :(

zork 01-30-13 02:36 AM

Well you can create an invisible statusbar object and use the onValueChanged of that hidden element.


All times are GMT -6. The time now is 09:37 PM.

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