11-27-10, 10:51 PM | #21 | |
DHUD and all the others use only one texture and they reverse the tex coords. Last edited by Grimsin : 11-27-10 at 10:53 PM. |
||
11-27-10, 11:20 PM | #22 |
Your setpoint get method works fine as far as the orientation of how the bar fills but if you want to flip the bar fill texture we will have to add the if's like i did or something of that nature. So that a texture that looks like "(" will now look like ")"
|
|
11-28-10, 12:06 AM | #23 | |
Hmm... After thinking through the code for a while, I think I found the flaw inherit to the original design. The fact it is incapable of flipping on an axis unrelated to its fill direction. Example, you want to flip horizontally while the bar is set to fill vertically.
It was written from the view that you'd be doing a horizontal fill with a horizontal flip, which honestly, isn't seen in any HUD addon other than my current in-house one. Here's a new version using the old fill direction code with a separate flip processing section. lua Code:
__________________
WoWInterface AddOns
|
||
11-28-10, 07:08 AM | #24 |
That does it Ive noticed one thing... the bars are somewhat inaccurate, the bar does not appear to begin to empty until almost 100 or more life lost. same with mana... anyway to make it more accurate with its calculations? The mana bar is much worse it thinks its full with over 2000 mana out.
|
|
11-28-10, 07:22 AM | #25 | |
What values are being passed to it? The function only accepts percent values in the range of 0-1.
__________________
WoWInterface AddOns
|
||
11-28-10, 09:19 AM | #26 |
this is the to event handlers for the health and mana, pretty much the same as you had it although the mana one is adjusted to change the color of the bar according to what type of power and does not use the other coloring method.
lua Code:
|
|
11-28-10, 09:37 AM | #27 | |
The code "looks" fine, what are the dimensions for the bar texture and what is your max health/mana?
__________________
WoWInterface AddOns
|
||
11-28-10, 12:13 PM | #28 | |
edit- okay so its 128x256 on all the textures, i changed up the sizes to reflect that but still its off. my max health is 36604 and mana is 31626 Last edited by Grimsin : 11-28-10 at 12:20 PM. |
||
11-28-10, 01:01 PM | #29 |
what if we change the math from turning it into a percent to making it the actual number. That would be most accurate and i think it is why it fills before it should... when it hits a less then 1% amount it shows it filled all the way. so from 0 - 0.99% the bar is filled... or instead of changing it from percent add a decimal to the number system so that it reads the 0.01 - 0.99% which would also make it more accurate... not as accurate as the actual number. Im good with the theory just not so good with the actual math in code
edit - my numbers are off it would actually be when the bar displays 99.00- 99.99% i would imagine although i have not tested it the same will go for the low end. ex. your bar will show empty before you actually die when it trys to display the 0.99-0.01% edit - another thought... the math system most likely rounds percents that do not have decimals in the equation. My guess is its right at 99.50% that it shows filled and that last .50 gets lost. yet another edit - thinking about it and trying to come up with a solution i realized the heal prediction bar is most likely off by the same .xx% amounts. yet again... - im not positive i understand this entirely but would it be as simple as changing local hppcnt=hcur/math.max(1,hmax); to local hppcnt=hcur/math.max(0.01,hmax); And no its not at 99.50% its more like 95% Last edited by Grimsin : 11-28-10 at 01:17 PM. |
|
11-28-10, 03:11 PM | #30 |
same issue with the pet bars only a lot worse since they are much smaller textures but the same canvas size. The problem is not with the numbers and %'s but with the texture getting its top origin from the canvas edge..
Okay... one last variable needs to be added to the function. One that allows you to set the texture edge offset. So lets say your ( is 250 pixels top to bottom but your canvas itself is 256, as all textures have to be powers of 2, the new variable would allow for one to set the graphic within the textures offset... hmmm crap well depending on the orientation of the bar you would actually need 4 settings. For my bar layout i only need the top to bottom settings but yea.... need another variable to accommodate for textures that do not fill the canvas size. The way things are right now what ever the difference is between the graphic and the texture canvas edges is being lost. Is there any limit to the number of variables passed to a function? hope not lol... Last edited by Grimsin : 11-28-10 at 03:23 PM. |
|
11-28-10, 05:02 PM | #31 | |
I was talking about the UI texture object that you load the image into, and with health and mana at 40k+ starting at 80, you'd have to have a pretty large chunk taken out of your pool before the bar can even move one pixel. Also be aware of any transparent pixels padding the bar in the actual image, they'd be read in as part of the bar too.
__________________
WoWInterface AddOns
|
||
11-28-10, 05:19 PM | #32 | |
lua Code:
|
||
11-28-10, 06:43 PM | #33 | |
Here's the modified function. The default values for the arguments noted below will apply if an argument is missing or is nil. Values marked required are as such.
Syntax: SetBarValue(bar,val1,val2,flipH,flipV,cropx1,cropx2,cropy1,cropy2) bar = Bar texture (required) val1, val2 = Upper and lower values for the bar to be drawn (default 0) flipH, flipV = Boolean true/false, flips texture horizontally/vertically if true (default false) cropx1, cropx2, cropy1, cropy2 = Crop values, swapping high and low values within the xy pairs will not affect flipping (default 0, 1, 0, 1) lua Code:
__________________
WoWInterface AddOns
|
||
11-28-10, 07:40 PM | #34 |
if you put the crop vars before the flip ones you dont HAVE to enter a flip entry. If you put them ahead of the crop vars you have to enter something for both flips or it trys to pass flip entrys to the crop entrys...
edit -- somthing else is wrong to the bars are not working at all with those changes. edit-- okay so it has to do with the croping. when i set the bar with the function what exactly show it look like? this is what it looks like right now. does work if i remove all the crop settings. this is what it looks like and does not work. addon:SetBarValue(self.ManaBar,0,mppcnt, true, false, 175, 50, 0 ,0); hmm how do you bypass a var? ...? or _? Last edited by Grimsin : 11-28-10 at 08:13 PM. |
|
11-28-10, 08:39 PM | #35 |
The cropping does not appear to work at all. It understands 1 and 0 and thats it. what kind of numbers do i need to enter? i found if i enter a - and a + it at lest shows the texture again but its not cropping it... ex:
addon:SetBarValue(self.ManaBar,0,mppcnt, true, false, -175, 50, -175, 50); |
|
11-28-10, 09:56 PM | #36 | ||||
I find it easier to understand when texcoords are written in fraction notation. This would have each x and y coordinate written as x/w and y/h. For example, your image file has the dimensions of 128x256. Say I wanted to grab a piece from it using two corners at coordinates (32,64) and (96,192). This could be written the following ways. Fraction notation: Code:
(32/128,96/128,64/256,192/256) Code:
(0.25,0.75,0.25,0.75) This would end up with the function call looking something like this. Code:
addon:SetBarValue(self.ManaBar,0,mppcnt,true,false,32/128,96/128,64/256,192/256);
__________________
WoWInterface AddOns
|
|||||
11-28-10, 11:50 PM | #37 |
<you see a light bulb appear above Grimsin's head> its all much clearer now. Heh i wish someone had explained texcoords like that on the wiki because it would have made a lot more sense there to.
Now to figure out what direction things are going. I already noticed strange reactions to my settings... edit--the light has flickered out... umm im not even sure how to explain whats happening... its putting the texture all over the place... doing strange things. It moves it up and down and cuts it and chops it weird ways and what in the world? It kind of looks like if we crop the texture that it then needs to have new setpoints as well im not sure on this. Alright what would you put in order to cut the top 150 pixels off a 256 pixel texture with the code you posted? i only need to set the cropy1 or cropy2 right? and 1 and 2 stands for the top of the texture and the bottom? Last edited by Grimsin : 11-28-10 at 11:58 PM. |
|
11-29-10, 01:20 AM | #38 | |
It's the same order as texture:SetTexCoord(). The numbers are in order of Left, Right, Top, and Bottom. These numbers are expressed as a decimal in the range of 0-1. If you look at your image as a coordinate system, the origin is in the upper left corner, top left is (0,0). The coordinates approach (1,1) as you move toward the lower right corner.
Now, to move the top in 150 pixels, you need to set Top to 150/256, Bottom needs to remain at 1. If you're not cropping left/right, leave those values at 0 and 1 respectively. There are also two things you should modify as well, when you do this, the rendered texture is no longer 256px, it'll be more like 106px. You should change the frame and initial texture object heights to reflect this, and don't forget to use the same coordinates to set the background's texcoord or it'll look a but funky. An example of applying this texcoord to the render function. Code:
addon:SetBarValue(self.ManaBar,0,mppcnt,true,false,0,1,150/256,1); Be sure to do this to the background texture too. Code:
texture:SetTexCoord(0,1,150/256,1); Edit: Oh, right... and when you set the texcoord on the background, be sure to flip the first two values if the bar is to be flipped. Code:
texture:SetTexCoord(1,0,150/256,1); In all honesty, the function was written to not allow you to flip the texture from the crop coordinates. So for the xy pairs, it would select the lowest from the x pair for left, the highest for right. From the y pair, the lowest would be selected for top and highest for bottom. Although, if you pass nil to any coordinate value, it would substitute for what would be the default for that position. For example, x1 is sent nil while x2 is sent 0.5, the pair result would be 0 and 0.5. If x1 was 0.5 and x2 was nil, the pair would result as 0.5 and 1. The same would happen for y1 and y2.
__________________
WoWInterface AddOns
Last edited by SDPhantom : 11-29-10 at 02:21 AM. |
||
11-29-10, 04:31 PM | #39 |
so to shave the top and bottom do i need to make the second variable passed reflect the changes of the first? so if i do the 150/256 then the last entry would be like -10/106? er wait it would be more like 1/10 wouldnt it
Last edited by Grimsin : 11-29-10 at 04:44 PM. |
|
11-29-10, 05:09 PM | #40 | |
No, it would be more like 150/256 to take 150 off the top and the second y value would be something like 246/256... which is (256-10)/256.
__________________
WoWInterface AddOns
|
||
WoWInterface » Developer Discussions » Lua/XML Help » Hud status bar questions. |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|