WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Search/Requests (https://www.wowinterface.com/forums/forumdisplay.php?f=6)
-   -   Default Casting Bar (https://www.wowinterface.com/forums/showthread.php?t=54023)

Vranx 07-25-16 08:38 PM

Default Casting Bar
 
I have been able to put together simple addons for my unit frames and minimap by looking at the code from other addons. I haven't been able to find code that works for moving the casting bar. I found this:
CastingBarFrame:ClearAllPoints()
CastingBarFrame:SetPoint("CENTER", 0, 0)
but it doesn't do anything. Can someone help?

Fizzlemizz 07-25-16 08:48 PM

Without a RelativePoint specified, SetPoint anchors to it's current parent

Maybe SetPoint("CENTER", UIParent)

Seerah 07-25-16 08:49 PM

/me waves at Vranx

Welcome back! :) Since the SetPoint call doesn't reference a frame to anchor it to, it will anchor the casting bar to the center of its parent. I don't remember what the parent is (though I would assume UIParent).

Just in case, try this:
CastingBarFrame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)

Fizzlemizz 07-25-16 09:05 PM

It gets roped into the PlayerFrame with the where depending on class and what is showing:
Lua Code:
  1. function PlayerFrame_AdjustAttachments()
  2.     if ( not PLAYER_FRAME_CASTBARS_SHOWN ) then
  3.         return;
  4.     end
  5.     if ( PetFrame and PetFrame:IsShown() ) then
  6.         CastingBarFrame:SetPoint("TOP", PetFrame, "BOTTOM", 0, -4);
  7.     elseif ( TotemFrame and TotemFrame:IsShown() ) then
  8.         CastingBarFrame:SetPoint("TOP", TotemFrame, "BOTTOM", 0, 2);
  9.     else
  10.         local _, class = UnitClass("player");
  11.         if ( class == "PALADIN" ) then
  12.             CastingBarFrame:SetPoint("TOP", PlayerFrame, "BOTTOM", 0, -6);
  13.         elseif ( class == "DRUID" ) then
  14.             if ( EclipseBarFrame and EclipseBarFrame:IsShown() ) then
  15.                 CastingBarFrame:SetPoint("TOP", PlayerFrame, "BOTTOM", 0, -2);
  16.             else
  17.                 CastingBarFrame:SetPoint("TOP", PlayerFrame, "BOTTOM", 0, 10);
  18.             end
  19.         elseif ( class == "PRIEST" and PriestBarFrame:IsShown() ) then
  20.             CastingBarFrame:SetPoint("TOP", PlayerFrame, "BOTTOM", 0, -2);
  21.         elseif ( class == "DEATHKNIGHT" or class == "WARLOCK" ) then
  22.             CastingBarFrame:SetPoint("TOP", PlayerFrame, "BOTTOM", 0, 4);
  23.         elseif ( class == "MONK" ) then
  24.             CastingBarFrame:SetPoint("TOP", PlayerFrame, "BOTTOM", 0, -1);
  25.         else
  26.             CastingBarFrame:SetPoint("TOP", PlayerFrame, "BOTTOM", 0, 10);
  27.         end
  28.     end
  29. end

Vranx 07-25-16 10:43 PM

I tried both of your codes and it didnt move. I must not be coding it right. I appreciate your help. I will try to figure it out tomorrow.

Fizzlemizz 07-25-16 11:19 PM

Just tried

/run CastingBarFrame:ClearAllPoints(); CastingBarFrame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)

Edit and after a /reload, /run CastingBarFrame:ClearAllPoints(); CastingBarFrame:SetPoint("CENTER", UIParent)

Both worked.

It might be a matter of when you're running your code. If it's during ADDON_LOADED or just as your .lua files are loading, Blizzard may be resetting the bar later in the load process like OnEvent for the Totem frame. PlayerFrame_AdjustAttachments() gets called from various places depending on class.

zork 07-26-16 04:55 AM

Lua Code:
  1. frame.ignoreFramePositionManager = true --optional but sometimes helpful for Blizzard frames
  2. frame:SetMovable(true)
  3. frame:SetUserPlaced(true)
  4. frame:ClearAllPoints()
  5. frame:SetPoint("CENTER",0,0)
  6. frame:SetMovable(false) --not sure if you need this line

Vranx 07-26-16 07:34 AM

I figured it out. It moves the castbar that is under the unitframe, not the default castbar that is in the middle of the screen. I just had to switch the option. Thanks all.


All times are GMT -6. The time now is 03:45 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI