Thread Tools Display Modes
04-02-09, 06:42 AM   #1
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
a question regarding filling/depleting of bars in different directions

I have a question regarding bars and how they fill. By default they fill from left to right and deplete, from right to left. Is there a way to invert that for one unit frame, i.e. have them fill from right to left and deplete from left to right?

And while I'm on it..... ..... set orientation(vertical) just moves the bar texture down and kinda "out of the frame", and doesn't really fill/deplete it. Is that intended ? I know that's what the API says it should do, but is there a way to really fill/deplete bars in all directions? I'm asking, because it doesn't work for bars/textures that are not a plain texture, but have some art on it. And I'm trying to achieve something that fills a wing texture from right to left and optionally another one from bottom to top.
  Reply With Quote
04-02-09, 08:53 AM   #2
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
By using blizzard default API we can only get bars to fill in one direction (except when you change the orientation)

:SetOrientation('VERTICAL') is probably what you are looking for
  Reply With Quote
04-02-09, 02:15 PM   #3
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Is there another variable I can add when setting vertical ? like 'growth direction' for buffs/debuffs? Because, like I said, vertical will just move the bar texture out of the frame, instead of really filling/depleting it.

I'll try to find out how stuf or pitbull make it possible to fill bars in a different direction.

Last edited by Dawn : 04-02-09 at 02:17 PM.
  Reply With Quote
04-02-09, 02:25 PM   #4
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
This seems to be the most important part of how it's done by stuf. Doesn't really looks possible with oUF as it is, right?


Code:
do  -- statusbar texture orientations
	local setwidth = PlayerFrameBackground.SetWidth
	local setheight = PlayerFrameBackground.SetHeight
	local setcoord = PlayerFrameBackground.SetTexCoord
	local setvalues = {  -- setvalue functions for various statusbar orientations
		h = { normal = {
				normal =  function(this, w, val) setwidth(this, w) setcoord(this, 0, val, 0, 1) end,
				reverse = function(this, w, val) setwidth(this, w) setcoord(this, 1-val, 1, 0, 1) end,
			}, hflip = {
				normal =  function(this, w, val) setwidth(this, w) setcoord(this, 1,0, 1,1, 1-val,0, 1-val,1) end,
				reverse = function(this, w, val) setwidth(this, w) setcoord(this, val,0, val,1, 0,0, 0,1) end,
			}, vflip = {
				normal =  function(this, w, val) setwidth(this, w) setcoord(this, 0,1, 0,0, val,1, val,0) end,
				reverse = function(this, w, val) setwidth(this, w) setcoord(this, 1-val,1, 1-val,0, 1,1, 1,0) end,
			}, hvflip = {
				normal =  function(this, w, val) setwidth(this, w) setcoord(this, 1,1, 1,0, 1-val,1, 1-val,0) end,
				reverse = function(this, w, val) setwidth(this, w) setcoord(this, val,1, val,0, 0,1, 0,0) end,
			},
		}, 
		v = { normal = {
				normal =  function(this, h, val) setheight(this, h) setcoord(this, val,0, 0,0, val,1, 0,1) end,
				reverse = function(this, h, val) setheight(this, h) setcoord(this, 1,0, 1-val,0, 1,1, 1-val,1) end,
			}, hflip = {
				normal =  function(this, h, val) setheight(this, h) setcoord(this, 1-val,0, 1,0, 1-val,1, 1,1) end,
				reverse = function(this, h, val) setheight(this, h) setcoord(this, 0,0, val,0, 0,1, val,1) end,
			}, vflip = {
				normal =  function(this, h, val) setheight(this, h) setcoord(this, val,1, 0,1, val,0, 0,0) end,
				reverse = function(this, h, val) setheight(this, h) setcoord(this, 1,1, 1-val,1, 1,0, 1-val,0) end,
			}, hvflip = {
				normal =  function(this, h, val) setheight(this, h) setcoord(this, 1-val,1, 1,1, 1-val,0, 1,0) end,
				reverse = function(this, h, val) setheight(this, h) setcoord(this, 0,1, val,1, 0,0, val,0) end,
			},
		},
	}
	-------------------------------------------------------------------
	function Stuf:GetTexCoordOptions(isvertical, flipoption, isreverse)
	-------------------------------------------------------------------
		return setvalues[(isvertical and "v") or "h"][flipoption or "normal"][(isreverse and "reverse") or "normal"]
	end
end
  Reply With Quote
04-02-09, 02:38 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
It is possible, very easily, and I use "reverse" status bars in my oUF layout.

Basically instead of:
Code:
statusbar:SetValue(value)
You just do:
Code:
statusbar:SetValue(maxValue - value)
Note that for oUF this means you will need to run your own health update function, either OverrideUpdateHealth or PostUpdateHealth. It's also slightly buggy (for oUF) in that the first time you see a frame (other than the player unit) the bar will probably be "backwards". It will fix itself once the health updates though. I should probably report that to Haste...
  Reply With Quote
04-02-09, 06:07 PM   #6
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Cool, thanks. Will this work on all bars, or can this be set to work for just those bars I want it to work? Is you oUf layout available somewhere, to get an idea of how the health update functions are done in this case?

What I try to achieve with oUF is this - have the wings to the left fill to the left side of the screen and deplete to the right and the wings on the right side vice versa.







The wings are hp on the left and power on the right. While the yellowish parts (outer wings) are allways visible the red/blue parts fill/empty when you lose/gain hp/power.

I have to figure out how to set everything up, position, size, .. I'm also thinking about using the wings on the left for player and on the right for target, to save some space. I'm not so sure about the target portrait, either. It's not possible to make a real round one, and that looks stupid from time to time, even more since the game doesn't know all "SetCamera(1) aka full body" models by default and "SetCamera(0) aka Portrait" looks even more stupid on a round shape. I will most likely put the minimap there, instead.
  Reply With Quote
04-03-09, 02:17 AM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Dawn View Post
Will this work on all bars, or can this be set to work for just those bars I want it to work?
Considering that you must use :SetValue in either an OverrideUpdate* or a PostUpdate* function, unless you for some reason use the same function to update all of the bars in your layout, it can only be applied on a per-bar basis.

Originally Posted by Dawn View Post
Is you oUf layout available somewhere, to get an idea of how the health update functions are done in this case?
It's not, but the only difference between it and any other layout's health function relevant to the bar's apparent fill direction is what I posted in my last post. Where your layout does bar:SetValue(blah) change it to :SetValue(max - blah). If it doesn't do it at all, add it. Just try things. If it doesn't work, try something else. If you get stuck, post the code you're having trouble with.
  Reply With Quote
04-03-09, 08:14 AM   #8
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Hi Dawn,

I had the same issue with the Vertical (or was it horizontal...?!) direction of statusbars and had to work around it by using created my own SetTexCoord function.

I wanted my round orbs to deplete from top to bottom but the standard functionality just moves the texture down, which does not work for round textures as you found out aswell.

What I did is the following. I used a transparent texture for my statusbar to make it run and anchored a new frame (called filling) to my statusbar. Based on the HP / MP value I change the SetTexCoord of the filling texture. This is what I used for my square orb texture inside the PostUpdateHealth func:

Code:
    self.Health.Filling:SetHeight((lifeact / lifemax) * self.Health:GetWidth())
    self.Health.Filling:SetTexCoord(0,1,  math.abs(lifeact / lifemax - 1),1)
The direction of the statusbar doesn't matter anymore. You just need the lifeact and lifemax variables to calculate the SetTexCoord. Same goes for mana.

Check my helper image: http://img3.abload.de/img/texcoordcg7s.jpg
SetTexCoord is: Left, Right, Top, Bottom
math.abs makes negativ values be positive, don't let you get disturbed here

SetTexCoord(0,1,0,1) would be a filled orb (filling top to bottom)
SetTexCoord(0,1,0.5,1) would be a half filled orb
SetTexCoord(0,1,1,1) you are dead
You need to adjust the height or width (regarding on filling direction) of the texture before applying the SetTexCoord.

Works for me.
__________________
| 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 : 04-03-09 at 08:36 AM.
  Reply With Quote
04-03-09, 08:49 PM   #9
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Thank you, Zork. I already tried to figure out how you did it on your orbs. That explains it really well. I just wish there would be a more "official" way to do it with oUF.
  Reply With Quote
04-06-09, 02:02 AM   #10
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Dawn I wrote a new mod for managing bottombar styles. It would look godly with your oUF targetframe and mapstyle.

This is the style:


Mod:
http://www.wowinterface.com/download...o.php?id=12975

Style is not impelemented yet but textures are finished.
__________________
| 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 : 04-06-09 at 08:17 AM.
  Reply With Quote
04-06-09, 05:20 AM   #11
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by Dawn View Post
I just wish there would be a more "official" way to do it with oUF. :)
I limit what oUF does to pretty much what the original Blizzard frames do. Implementing a custom statusbar solution to fill bars in the opposite direction is something that can easily be solved from the layout/external add-on. :)
  Reply With Quote
04-06-09, 09:17 AM   #12
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Hehe, haste... oUF is way cooler than what blizz frames do, already. Even if it only uses the same basic functions.

@zork
Looks very nice, I already thought abound abandoning my layout idea. That brings it well back to the table.
  Reply With Quote
04-06-09, 09:42 AM   #13
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Send me the code before you quit

Btw...my AION style in action:
__________________
| 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 : 04-06-09 at 12:04 PM.
  Reply With Quote
04-06-09, 02:01 PM   #14
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Hmm maybe we could work on the UI together. I like the style of the new bars so much that I wanna make a interfrace for it.
__________________
| 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

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » a question regarding filling/depleting of bars in different directions


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