Anchoring cast bar to personal resource display
I've anchored the default casting bar to the default personal resource display (so they don't overlap anymore) with some very basic code:
Code:
CastingBarFrame:ClearAllPoints() I took a peak at the WeakAuras code (as it allows anchoring to the PRD without glitches), but it's a bit out of my league to fully grasp what is going on there. Any suggestions are much appreciated! |
This happens because Personal Resource display is just another nameplate. Nameplates get recycled when not in use so the nameplate associated with your character may end up being assigned to some other random player/NPC if you walk in range while out of combat.
In your case, the best course of action would probably be to add a check when you begin casting to ensure the cast bar is currently anchored to the player's resource frame, and if not, set its position elsewhere (for example, its default anchor, but it can be anywhere.) Something like this should help: Code:
if CastingBarFrame:GetParent() ~= NamePlatePlayerResourceFrame and NamePlatePlayerResourceFrame then You can probably hook into UNIT_SPELLCAST_CHANNEL_START for this. |
Thanks! Unfortunately the first if-statement doesn't seem to work the way one might assume though. The cast bar still anchors to a random nameplate when the PRD is hidden:
Code:
local function attach() Code:
if (UnitExists("target")) then |
Quote:
Code:
local function attach() Works with both default cast bar, and with "Cast Bar Underneath" enabled. Quote:
Either way it breaks because CastingBarFrame:SetPoint() is calling CastingBarFrame.SetPoint, so if you zero out the latter it prevents the former from working. |
Very nice work! There's a CVAR for always showing the PRD with a target (even out of combat), but your method is way cleaner. Still there is some glitchiness with the cast bar though. It has happened on all kinds of casts, but only sporadically. Can't pinpoint it. I've recorded a vid so you can see what I mean: https://www.useloom.com/share/a23202...fe2b4ccb4f7e6f. Thoughts are appreciated.
|
Interesting, I didn't know there was a CVar for that.
(tfw Blizzard adds hidden options that never really get officially documented) Yeah, I've managed to reproduce the error. I don't know why it happens and since Blizzard didn't assign a name to the actual progress bar frame inside the cast bar I can't begin to try and prevent it from happening (that, and it doesn't consistently happen so it's hard to troubleshoot.) Somebody else who knows more about the cast bar frame (or who knows how to deal with unnamed frames) would have to pitch in. In the meantime, this doesn't seem to happen if Cast Bar Underneath is enabled, in the right-click menu on your character portrait. This changes the appearance of the cast bar so it's possible you may not like it, but I've not seen that bug happen when using this. You may have to add some code to prevent the cast bar from sometimes re-anchoring itself under the character portrait, though (it happens for a split second when I mount and fly away too quickly, but haven't seen it happen any other time.) The code for that is in PlayerFrame.lua Also, I think I should have suggested NAME_PLATE_UNIT_ADDED and NAME_PLATE_UNIT_REMOVED instead; those make a lot more sense. That way the castbar should more reliably re-anchor itself to the personal resource display when it appears (and vice-versa when it disappears) instead of only anchoring itself when you begin casting. Otherwise I can start casting something at an enemy and it isn't until the third cast that the castbar anchors itself to the Personal Resource Display. |
So you ended up with something like this?
Code:
local function attach() |
No, that's no good. This tries to attach the castbar to Personal Resource Display whenever -any- nameplate appears on screen and puts it back in your default location whenever any nameplate disappears.
So you'd be out of combat and your castbar doesn't show up anymore because it tried attaching to a nameplate that isn't in view, or you'd be in middle of combat and castbar goes back to default location when you want it to stay on personal resource display. Just replace RegisterUnitEvent in the previous code with RegisterEvent and use NAMEPLATE_UNIT_ADDED/NAMEPLATE_UNIT_REMOVED instead of the spellcast events. |
Thanks, was a bit confused by the NAMEPLATE events. Appreciate your time and please let me know if you ever find a solution for the stretching issue (of course I'll share whatever I may find on the subject)!
|
Update: Haven't tested it much yet, but adding CastingBarFrame.ignoreFramePositionManager = true seems to do the trick! :)
|
Figure out how to make it into addon, but i wonder if it possible to do the same thing with target and focus castbars?
|
All times are GMT -6. The time now is 08:44 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI