LibCandyBar groups and animation
1 Attachment(s)
I would like to create groups of bars from LibCandyBar-3.0 but the default API does not have this functionality; presumably I can use metatables to simulate, but as many times as I've read the official docs or other people have asked similar questions, I just can't wrap my head around the concept.
In order to do what I'd like, I think I'd need to sort the bars within the group by duration, but LCB's API doesn't have a GetDuration. It does have a Get, which returns a user key, but I don't know if this is the same thing. To further complicate things, the idea of animating the bars sounds appealing, and I sort of grasp Blizzard's animation API. But melding it to the group of bars is breaking my brain to the point where I can't even pseudo-code. Attached is a picture of SmartRes2's bars, using LibBars-1.0 (which I am trying to replace) to provide an idea of what I want to accomplish, minus the animation because LB1's animation API predates Blizzard's, and thus isn't usable. |
Metatables to emulate bar groups, what about just a table?
What about using GetMinMaxValues() on the StatusBar? Lua Code:
Melding, like in the image? Just sort by time remaining, maxValue - GetValue() every time a new bar is added or removed. |
Melding the two ideas (groups and animating the bars) together. Sorry for the confusion.
A simple table, like this? Lua Code:
|
I think that that was about what I was thinking.
|
Re: Grouping bars
Just handle it like any other variable-length collection of objects or values. Creating a bar group: Code:
local barGroup = CreateFrame("Frame", nil, UIParent) Code:
local bar = LibStub("LibCandyBar-3.0"):New(texture, 100, 16) Code:
function MyAddon:ArrangeBars() Code:
LibStub("LibCandyBar-3.0"):RegisterCallback(MyAddon, "LibCandyBar_Stop") Re: Animation What are you trying to animate? Any half-decent timer bar library should already handle animating the bar to show time elapsed/remaining. The animations you see on Blizzard bars like your health bar would not make sense on a timer bar, since the value of a timer bar changes very frequently in very small increments -- there are no sudden large changes you want to smooth out or call attention to (eg. by flashing). Re: Sorting Just sort the table that contains a list of active bars before you position them: Code:
local function sortBarsByRemainingTime(a, b) |
Wow Phanx. My mind is blown as usual. The impressive thing is that you always make everything so clear and easy to understand. :D
As for animating, I was thinking of having an option to flash bars, yet you suggest not to do that because the duration will be too short? Since I will be dealing with resurrections, that is cast time as provided by LibResInfo. I thought about one flash per second, nothing epileptic. |
Flashing every second sounds pretty annoying, and wouldn't actually communicate any useful information. Generally a UI element should only flash to grab the user's attention. However, if nothing important has changed (a spellcast going from having 8s left to having 7s left isn't imporant) then you're just distracting the user for no reason.
What could be a good animation would be to animate the height of incoming (just added) bars -- start them at 1px height and quickly grow them up to full height. This would make it easier to see which bar was added, and make it feel less "jumpy" when other bars were pushed up/down as a result. Animating outgoing bars in a similar way would be a nice touch, too, but I'm not sure how feasible that is within the framework of LibCandyBar. Maybe you could use the "pause" API to freeze the bar just before it ended, animate its height down to 1px, then use the "cancel" API to remove it. If the bars are anchored to each other, then animating the height of the incoming/outgoing bar automatically animates the position change of the surrounding bars. Otherwise, since the value of a timer bar is constantly changing, I just don't think any additional animation on top of that would be useful; at that point you're just adding noise. If you wanted to highlight "ending soon" bars, just change the bar color --- at, say, 3s remaining, start a 1s transition to your highlight color, so 2s and below is the new color. |
Hmm, I guess my mind's eye film was more entertaining than reality. You are probably right about the noise. At this point, I most likely won't put in any animation, but to be clear, I wanted to flash the collision bars (any bar in the default colour of red).
That would definitely be distracting if the player just wanted to see non-collision or mass resurrection bars clearly. So toss the flash animation idea into the bin. :p:o:cool: *edit* I like your idea of animating in and out via height, but that's something else I know nothing about. When I get to working bars without that feature, I'll revisit the topic. Basics first. |
Okay, I have turned Phanx's code into a library that is a wrapper (zing! :D ) for LibCandyBar-3.0. I will test it after some sleep.
LibCandyStore-1.0 adds three functions to LibCandyBar:
Lua Code:
|
All times are GMT -6. The time now is 03:55 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI