Thread Tools Display Modes
07-25-16, 08:38 PM   #1
Vranx
A Flamescale Wyrmkin
 
Vranx's Avatar
Join Date: May 2008
Posts: 101
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?
  Reply With Quote
07-25-16, 08:48 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Without a RelativePoint specified, SetPoint anchors to it's current parent

Maybe SetPoint("CENTER", UIParent)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 07-25-16 at 08:54 PM.
  Reply With Quote
07-25-16, 08:49 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
/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)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
07-25-16, 09:05 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
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
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
07-25-16, 10:43 PM   #5
Vranx
A Flamescale Wyrmkin
 
Vranx's Avatar
Join Date: May 2008
Posts: 101
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.
  Reply With Quote
07-25-16, 11:19 PM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
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.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 07-26-16 at 01:16 AM.
  Reply With Quote
07-26-16, 04:55 AM   #7
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
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
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 07-26-16 at 04:59 AM.
  Reply With Quote
07-26-16, 07:34 AM   #8
Vranx
A Flamescale Wyrmkin
 
Vranx's Avatar
Join Date: May 2008
Posts: 101
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.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Default Casting Bar

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off