Thread Tools Display Modes
01-27-11, 05:33 PM   #1
szoltomi
A Defias Bandit
Join Date: May 2008
Posts: 3
statusbar - mask instead of resize

Hello!

I've just started using oUF to make a custom layout by first modifying others work, then stripping them down, and adding my ideas.
A problem I ran into very early on, the texture of statusbars is shrinked as they deplete, instead of getting their end "cut off" or masked. Could someone explain it how to make one simple healthbar on the player frame this way? I could work on it later then.

I checked out this thread, then tried to understand it from Zork's D3 addon, but it's a bit too big and complex, and I get lost when I try to understand it.

Thanks for the help!
  Reply With Quote
01-27-11, 08:19 PM   #2
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Take a look at "SetHorizTile(true/false)".
__________________
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
01-27-11, 08:50 PM   #3
szoltomi
A Defias Bandit
Join Date: May 2008
Posts: 3
Thanks, though it didn't solve my problem, it's a step in the right direction.
The problem is, it now pushes the texture off, instead of cutting off the missing part, and the texture is in it's original size, showing only a part of it, even while full.

Is the solution for the former the PostUpdateHealth min-max playing, or something else? I have a hunch that the latter can be fixed by a texture resize, or not?

Edit: hpBar:GetStatusBarTexture():SetSize(20, 100) doesn't have an effect. Something else then.

Edit2: Dangit, It seems it works totally differently with a horizontal health bar (actually correctly), I forgot to mention that I have vertical oriented statusbars.

Last edited by szoltomi : 01-27-11 at 09:16 PM.
  Reply With Quote
01-28-11, 02:29 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Correct. Using textures on vertical alight statusbars always bug out. I had to outplay it aswell. I'm using a statusbar with a transparent layer (horizontal) just for the values.

But I register a new texture that I have call self.Health.Filling ontop of that statusbar. To make it work you have to calculate the texture size via SetTexCoord on each UNIT_HEALTH event.

But that was long time ago. (and still works)

But Blizzard added
- SetVertTile()
- SetHorizTile()

in the time beeing.

Code:
local t = hpBar:GetStatusBarTexture()
t:SetVertTile(true)
t:SetSize(20,100)
That is the only thing that might help you without hacking everything.
__________________
| 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
01-28-11, 06:39 AM   #5
szoltomi
A Defias Bandit
Join Date: May 2008
Posts: 3
Indeed, I have to hack everything. Maybe I'll have more luck with your workaround now, that I got a night's sleep.

Taking the D3 Layout as an example, do I only need to use the corresponding parts of the CreateOrb and UpdatePlayerHealth functions, or there is something else needed as well?

Edit: I've aswered my own question, I got it to work :> Thanks for your help (This time, in providing the example code)

--------------------------------------------------

Completely new problem, here is what my current unit frame looks like, and the texture for the bars:

Click image for larger version

Name:	pic1.png
Views:	175
Size:	15.0 KB
ID:	5645Click image for larger version

Name:	Bar1.png
Views:	186
Size:	21.6 KB
ID:	5646

The problem is, I want the bars resized, but without changing the anle of the slope (since if I make it more narrow, the slope becomes more steep).

I thought about using a stock status bar texture, making it as wide as I want it, then disort it to the sloped shape. I started playing with SetTexCoord, but it outputs a rectangular texture from any given region, and I need it the other way around: A disorted region from a rectangle.

I saw you did some nice tricks in texture transformations with your ring addon, so maybe you could point me to a method I could use, or a different trick to make these bars.

Thanks!

Edit x+1: It seems I'm able to keep answering my own questions. I found out you can give coordinates outside the 0-1 region of the texture, and this way I can get it skewed and thinner without issues. Now I'll just have to figure out the formula to display paralelograms with the correct height, width and slope.

Edit x+2:

It's alive, it's aliiive!
Click image for larger version

Name:	pic2.png
Views:	198
Size:	18.6 KB
ID:	5647
With a little math and geometry, I managed to make the transformations which makes the needed texture

Code:
local updatePlayerHealth = function(bar, unit, min, max)
	fill=min/max
	textureWidth = SLOPE*BAR_HEIGHT + HEALTH_WIDTH
	bar.filling:SetTexCoord(
		fill,-(fill*(textureWidth-HEALTH_WIDTH)/HEALTH_WIDTH),
		0,0,	
		fill,1   +((1-fill)*(textureWidth-HEALTH_WIDTH)/HEALTH_WIDTH),	
		0,1+(textureWidth-HEALTH_WIDTH)/HEALTH_WIDTH)
	bar.filling:SetWidth(textureWidth)
	bar.filling:SetHeight(BAR_HEIGHT*fill)
end
Works perfectly, with one little issue: The bar texture needs a 1px transparent border around it, otherwise it will disort in an ugly fashion (on the pic the alpha is not completely 0 I think, that's why there is a slight color artifact)

Last edited by szoltomi : 01-28-11 at 12:53 PM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » statusbar - mask instead of resize


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