CaiClone / GCDTracker

FFXIV Dalamud plugin tracking GCD and OGCDs
MIT License
14 stars 2 forks source link

More Visible Slide/Queue Notifications #22

Closed aspiringnobody closed 3 months ago

aspiringnobody commented 3 months ago

Here's our starting point for these changes.

I've started a bit with making a generic GCDNotifier class that can be called as a one-stop-shop for event notifications. That works pretty well for simple things like the Flyout Clipped/ABC alerts or changing the bar background color.

However, I'm not really sure where to start with the bar coloration and size modification. The function is so integrated into the workings of the bar I'm not even sure how you'd start to call it from an outside class or method. Right now I'm working under the assumption that we will set some bools inside our Notifier class and then BarInfo will watch for them and act accordingly. However, this is problematic because I already ruled out using some kind of iteration based animation approach and instead decided to use the bar progress itself as the timer.

This presents a problem: if we are going to activate this function from outside the BarInfo class, we now need to pass the start-time along with the bool to activate the function (that's pretty straightforward). The Pulse functions are already set up to take a generic start time so we are good there. But, we need to track when this is finished and turn off the bool for the next iteration -- (that's pretty straightforward as well -- we can do that when we get to the end of the animation sequence). But now we have a problem: if somehow the user cancels the cast during an animation, we've left the flag on and that's not ideal. So we need a place to reset the bool and that's not obvious/intuitive. I'll keep plugging on it and see if I can come up with a good solution.

It kind of looks like there will just be a bunch of back-and-forth between BarInfo and GCDNotifier:

  1. BarInfo will tell the notifier that an event has happened
  2. Notifier will set the bool to do the event and cache a start time.
  3. BarInfo will actually do the animation
  4. BarInfo will then reset the bools and clear the cached start time.

Which sort of asks the question why bother with any of the abstraction? The wheel is much more straightforward because the time it triggers is always the same, and it can safely be reset each time the GCD starts.

I'm going to have a sleep on it and think about it. I like being able to do:

notify.Now(EventType.FlyOutAlert, EventReason.ABC, location.X, location.Y)

But that works well because the GCDNotifier can actually tell ui.Draw to draw the notification. The GCDNotifier can't actually perform the size/color modifications unless we move BarInfo inside the GCDNotifier. And I'm not sure that makes sense.

Edit: Unless we wanted to put the notifier into the main loop and execute it every iteration. I had it set up to be invoked as needed but I suppose we could also place events in a queue for the Notifier to process when it runs in the loop.

aspiringnobody commented 3 months ago

I'm working on the alerts changes here:

https://github.com/aspiringnobody/GCDTracker/tree/Unified_Alerts

The battle does not go well. But I've got a working Alerts class and I'm slowly getting the bar pulses added into it.

aspiringnobody commented 3 months ago

I'm working on the alerts changes here:

https://github.com/aspiringnobody/GCDTracker/tree/Unified_Alerts

The battle does not go well. But I've got a working Alerts class and I'm slowly getting the bar pulses added into it.

I've (mostly) re-implemented the Bar Pulses in the EventHandler now. We just:

// Color Pulse notification:
notify.AddAlert(BarColorPulse, Slidecast, Bar, 0f, 0f, bar.CurrentPos, bar.QueueLockScaleFactor);

from anywhere we want start a pulse and bam! away you go.

I already implemented the ABC/Clip floating pop-ups:

// Pop-Up clipped notification:
notify.AddAlert(FlyOutAlert, Clipped, source, relx, rely, 0f, 0f);

I just need to implement the Wheel pulse now, and the background color and that will be all of the alerts implemented. I haven't given any real thought to how to include the floating triangles yet, but I'll get around to that eventually. Maybe not in time for this release because I'm on vacation starting next week. But I'll try to get it finished before I leave.

I've set it up so that events generated on the bar can only be displayed on the bar and events from the wheel can only be shown on the wheel. I've set it up this way because the pop-up alerts are dependent on relative x/y positions from their originator. This way we always send the calls to PluginUI when the parent is active and the X/Y positions make sense.

aspiringnobody commented 3 months ago

Updated again, I've got the wheel pulse added. Just need to do the background color for the bar/wheel and that will be all of the bar/wheel alerts we currently have implemented in the GCDNotifier.

I also switched the pulses to be based on the system time. I didn't really want to do this for performance reasons, but, this will allow us to easily tweak the pulse length in the future, and potentially give the user the option to tune the pulse duration to their liking. We also don't have to pass the bar position or scale factor into GCDNotifier anymore -- we just tell it when we want a Pulse and the system time does the rest.