Thread Tools Display Modes
11-16-10, 04:07 PM   #1
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
smooth bar filling question / changing oUF_Smooth

I'm filling my health background like this (the healthbar itself has about 30% opacity).

Code:
	local Framewidth = self:GetWidth()
	self.Health.bg:SetPoint('LEFT', Framewidth * (min / max), 0)
My question is:
How do I change oUF_Smooth to smoothly fill the healthbar's background without losing the normal smoothing functionality - which is still used for power and the transparent (real) healthbar.


I think this is the relevant code from oUF_Smooth
Code:
local f, min, max = CreateFrame("Frame"), math.min, math.max
f:SetScript("OnUpdate", function()
	local limit = 30/GetFramerate()
	for bar, value in pairs(smoothing) do
		local cur = bar:GetValue()
		local barmin, barmax = bar:GetMinMaxValues()
		local new = cur + min((value-cur)/20, max(value-cur, limit))
		if new ~= new then
			new = value
		end
		bar:SetValue_(new)
    if bar.Filling then
      if barmax == 0 then
        bar.Filling:SetHeight(0)
        bar.Filling:SetTexCoord(0,1,1,1)
      else
        bar.Filling:SetHeight((new / barmax) * bar:GetWidth())
        bar.Filling:SetTexCoord(0,1,  math.abs(new / barmax - 1),1)
      end
    end
		if cur == value or abs(cur - value) < 2 then
			bar:SetValue_(value)
			smoothing[bar] = nil
		end
	end
end)
I tried to get the SetPoint/Framewidth code from my healthupdate function in there, but to no success. Probably did it horribly wrong. Any ideas?


edit: The bar filling code is still in there for when I use/make a layout that fills "textures" like oUF_Diablo. I could live without that part.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."


Last edited by Dawn : 11-16-10 at 06:20 PM.
  Reply With Quote
11-16-10, 04:43 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Dawn View Post
How do I change oUF_Smooth to smoothly fill the healthbar without losing the normal smoothing functionality (which is still used for power)?!?
What "normal smoothing functionality" are you talking about? Neither oUF nor the deafult UI provide any smoothing functionality; when you call SetValue on a StatusBar object, the status bar is immediately set to that value. What oUF_Smooth does is hook the SetValue call, so when you call SetValue, the status bar is set to a series of intermediate value in quick succession, to give the appearance of an animated, smoothly filling bar.

If you're talking about the "frequentUpdates" property in oUF, that has nothing to do with oUF_Smooth, and the two do not conflict. All frequentUpdates does is cause oUF to update the power bar via polling (eg. in an OnUpdate script) instead of only in response to the UNIT_POWER event.
  Reply With Quote
11-16-10, 05:06 PM   #3
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
I was talking about oUF_Smooth and how it smoothly fills/depletes bars.

I'm asking for a way to adept/change oUF_Smooth code, since I'm using a different healthupdate function than what oUF_Smooth supports by default.

What I want is to smooth the background's filling/depleting. The background is filling, when the unit is losing health. Thus allowing for a transparent healthbar WITH a background.

see picture ...



To explain it further. I still want the healthbar (the transparent part) to fill/deplete smoothly, but ALSO the background to match that smooth filling/depleting.
Which means I need something like

Code:
		bar.bg:SetValue_(new)
Just something that works. Since this spits out a nil error which I can't fix.

The tricky part is that the background doesn't seem to have a real value, due to
Code:
self.Health.bg:SetPoint('LEFT', Framewidth * (min / max), 0)

Edited my first post to highlight that the healthbar has 30% opacity, I was using zero opacity before.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."


Last edited by Dawn : 11-16-10 at 06:17 PM.
  Reply With Quote
11-17-10, 05:21 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
You can check Roth UI Beta. I embedded a changed version of oUF smooth. My orb texture object is called self.Filling and I'm adjusting that in the smooth function if self.Filling is found. Maybe you adept that.

http://code.google.com/p/rothui/sour...oUF_Smooth.lua

You need to keep self.Health alive, just use a transparent texture.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 11-17-10 at 06:59 AM.
  Reply With Quote
11-19-10, 05:57 AM   #5
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
I'm currently trying to use 2 healthbars per frame to achieve the same look as before. 2 bars, because a real bar should be smoothable with oUF_Smooth.

However I'm stuck with getting the second bar into the right position and filling/depleting right.

It should basically behave just the other way around like the normal (transparent) healthbar to mimic a background.

I have attached 2 picture, picture one is what I have right now and picture 2 is what it should look like and how it's supposed to work.


Right now I'm using one health update function like this
Code:
local PostUpdateHealthTM = function(Health, unit, min, max)
	local self = Health:GetParent()
	Health.second:SetMinMaxValues(0, max)	
	Health.second:SetValue(max - min)
end
and I create these 2 bars

the transparent bar (supposed to be the left one)
Code:
	-- hp
	local hp = CreateFrame("StatusBar", nil, self)
	hp:SetHeight(cfg.heightHP)	
	hp:SetStatusBarTexture(cfg.HPtex)
	hp:SetPoint"TOP"
	hp:SetPoint"LEFT"
	hp:SetPoint"RIGHT"
	hp:GetStatusBarTexture():SetHorizTile(true)
	hp:SetFrameLevel(3)
	hp.frequentUpdates = true
	hp:SetStatusBarColor(0,0,0,0.3)	
	self.Health = hp
the white one (supposed to be the right bar)
Code:
	local hp2 = CreateFrame("StatusBar", nil, self)
	hp2:ClearAllPoints()
	hp2:SetHeight(cfg.heightHP)	
	hp2:SetStatusBarTexture(cfg.HPtex)
	hp2:SetPoint"TOPRIGHT"		
	hp2:SetPoint"TOPLEFT"	
	hp2:GetStatusBarTexture():SetHorizTile(true)
	hp2:SetFrameLevel(3)
	hp2.frequentUpdates = true
	self.Health.second = hp2
post update ...
Code:
	self.Health.PostUpdate = PostUpdateHealthTM

Question
1. How do I get the white bar to be placed on the right and to be empty @ 100% health and fully filled @ 0% health?
While maintaining the normal behaviour of the transparent bar.
Attached Thumbnails
Click image for larger version

Name:	pic1.png
Views:	754
Size:	56.8 KB
ID:	5262  Click image for larger version

Name:	pic2.png
Views:	725
Size:	75.5 KB
ID:	5263  
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
11-20-10, 01:26 AM   #6
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
Shouldn't you transparent bar be really the background (never changing as it seems) and the white one be the real hp bar that fills from right to left with the postupdate (SetMinMax(max,0) as to (0,max)).
Just a thought.

EDIT : or maybe just attach the white bar to the right of the transparent one and to the right of the frame, just like the ecplisebar does.
  Reply With Quote
11-20-10, 08:22 AM   #7
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Yes that is what I suggest aswell. Read my thread on raid background for out of range units. I use two textures. I only change the width of one but the other one will follow because it's right point is set to the left point of the other texture. That is possible.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
11-20-10, 09:28 AM   #8
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
My current solution is setting the starting point (SetPoint) of the white bar within the health update function. Which is all fine, but doesn't update smoothly the white part. There will be a gap between the transparent bar and the white bar until the "smooth" of the transparent bar finishes. That's why I can't use oUF_Smooth for this method, atm. Which is why I'm looking for another solution.

I've read through statusbars API and it seems only be able to fill/deplete from bottom to top and from left to right. No right to left possible at all?! And I mean RIGHT to left not the bar being anchored/starting to the left, but anchored/starting on the right.

Anyway, I'll see if I attaching the white bar to the the transparent bar will allow for smooth updates. But afaik oUF_Smooth needs values to work with, not sure if this method supplies any or if it will just work because it attaches to each "smoothed step", instead of my current method which jumps directly to the final step.


Long story short, this is completely cosmetic stuff. But it looks awesome IMHO. That's why I keep bothering to improve it even further.


Edit: Sorted it out, oUF_Slim r10 will have it ... smoooooth sailing all way long!!1n8elf
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."


Last edited by Dawn : 11-20-10 at 01:41 PM.
  Reply With Quote
11-20-10, 03:03 PM   #9
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
What method did you use to achieve what you wanted ?
Anchoring ?
I'm no longer playing but this is interesting
  Reply With Quote
11-20-10, 03:09 PM   #10
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
I'm doing the same with the background like what the eclipsebar does for lunar and solar power. Thanks for the hint, totally forgot about that way.

update function
Code:
	local HPheight = Health:GetHeight()
	self.Health.bg:SetPoint('LEFT', Health:GetStatusBarTexture(), 'RIGHT')	
	self.Health.bg:SetHeight(HPheight)

shared style
Code:
	hpbg = hp:CreateTexture(nil, "BACKGROUND")
	hpbg:SetTexture(cfg.Itex)
	hp.bg = hpbg	
	hpbg:SetPoint"LEFT"
	hpbg:SetPoint"RIGHT"
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."


Last edited by Dawn : 11-20-10 at 03:11 PM.
  Reply With Quote
11-20-10, 03:15 PM   #11
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
Glad I could help, i'm also enjoying your Slim layout even if I dislike pixel font.
Messing with oUF layout is the only thing that could take me back to this game :P so I like following some people in their projects like you or zork and add a little of my brain in this.
  Reply With Quote
11-20-10, 03:23 PM   #12
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Yeah, but changing the font, especially with a config, is like ... I don't know ... Way to easy, boring, fast, and just meh to find a word for it.

That can't be an issue, me thinks.

Btw, I'm playing World of Addoncraft for Month! Is there any other? What's your game?!
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » smooth bar filling question / changing oUF_Smooth


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