Quantcast Target castbar centered - WoWInterface
Thread Tools Display Modes
04-20-18, 07:52 PM   #1
GreyFox777
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 54
Target castbar centered

can anybody help me to copy the target castbar? The second one should be larger and placed at the center of monitor. Have spend some hours but still unlucky

I cannot for some reason register 2 events at the target file...


-- Castbar
if self.cfg.castbar.enable then
core:CreateCastbar(self)
core:CreateNewCastbar(self)
end
only one of them are working, another bar remains white colored and has no reaction of anything
Attached Files
File Type: lua castbar.lua (10.8 KB, 24 views)

Last edited by GreyFox777 : 04-20-18 at 11:43 PM.
  Reply With Quote
04-21-18, 08:56 AM   #2
GreyFox777
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 54
Any one?
  Reply With Quote
04-21-18, 08:59 AM   #3
Tim
A Cobalt Mageweaver
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 233
Code:
  elseif(self.mystyle == "target") then
    core:setBackdrop(castbar, cfg.units.target.castbar.height + 4, 2, 2, 2)
    castbar:SetBackdropColor(unpack(cfg.elements.castbar.backdrop.color))
--    castbar:SetStatusBarColor(unpack(cfg.units.target.castbar.color))
--    castbar:SetWidth(cfg.units.target.castbar.width - cfg.units.target.castbar.height + 6)
--    castbar:SetHeight(cfg.units.target.castbar.height)
	castbar:SetWidth(126)
	castbar:SetHeight(15)
--    castbar:SetPoint("CENTER", "UIParent", "CENTER", 0, 350)
    castbar:SetPoint("RIGHT", "oUF_LumenTarget", "RIGHT", -67,9)

You really should look over all the code you're working with while trying to learn. In this block of code you can see the last line of it tells the castbar where to be positioned. If you're wanting the targets castbar directly in the center of the screen with all setpoint parameters...


Code:
castbar:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
__________________
AddOns: [email protected]
Website: Ciraxe' Shenanigans
Chars: Monk, Viskaz, Mage, Shaman
  Reply With Quote
04-21-18, 09:34 AM   #4
GreyFox777
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 54
Tim, i don't just need to place it at the center, i need to copy it and place at center. One castbar should go on the unit frame and other separately on the center of monitor if this is a hostile unit

But everytime i try to copy the code, only one castbar are working, and the another one stays just white and have no reaction on everything...

I need somehow register 2 castbars at oUF for one unit
  Reply With Quote
04-21-18, 09:39 AM   #5
Tim
A Cobalt Mageweaver
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 233
You copy the entire block of code for the target and paste it but rename the castbar to like castbar2.
__________________
AddOns: [email protected]
Website: Ciraxe' Shenanigans
Chars: Monk, Viskaz, Mage, Shaman
  Reply With Quote
04-21-18, 09:42 AM   #6
GreyFox777
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 54
Originally Posted by Tim View Post
You copy the entire block of code for the target and paste it but rename the castbar to like castbar2.
no no!!! im noob at coding but not stupid

I tried to create new core function

from
function core:CreateCastbar(self)
to
function core:CreateCastbarNew(self)
and all their stuff and
  Reply With Quote
04-21-18, 09:43 AM   #7
GreyFox777
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 54
Originally Posted by Tim View Post
You copy the entire block of code for the target and paste it but rename the castbar to like castbar2.
no no!!! im noob at coding but not stupid

I tried to create new core function

from
function core:CreateCastbar(self)
to
function core:CreateCastbarNew(self)
and all their stuff.


Then i added CreateCastbarNew to the target unit. But it stays white and no reaction at anything



Edited this block in the target unit file:

-- Castbar
if self.cfg.castbar.enable then
core:CreateCastbar(self)
end
to
-- Castbar
if self.cfg.castbar.enable then
core:CreateCastbar(self)
core:CreateCastbarNew(self)
end
  Reply With Quote
04-21-18, 10:10 AM   #8
Tim
A Cobalt Mageweaver
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 233
Here's another function like you're wanting.. give it a try

Code:
function core:CreateCastbar2(self)

if(self.mystyle ~= "target") then return end

  local castbar = CreateFrame("StatusBar", "oUF_LumenCastBar2", self)
  castbar:SetStatusBarTexture(m.textures.status_texture)
  castbar:GetStatusBarTexture():SetHorizTile(false)
    castbar:SetFrameStrata("BACKGROUND")
    castbar:SetFrameLevel(13)

--  castbar:SetFrameStrata("HIGH")
--  castbar:SetToplevel(true)

  castbar.bg = castbar:CreateTexture(nil, 'BORDER')
  castbar.bg:SetAllPoints()
  castbar.bg:SetAlpha(0.3)
  castbar.bg:SetTexture(m.textures.bg_texture)
  castbar.bg:SetColorTexture(1/3, 1/3, 1/3)

  castbar.Text = castbar:CreateFontString(nil, "OVERLAY")
  castbar.Text:SetTextColor(1, 1, 1)
  castbar.Text:SetShadowOffset(1, -1)
  castbar.Text:SetJustifyH("LEFT")
  castbar.Text:SetHeight(12)

  castbar.Time = castbar:CreateFontString(nil, "OVERLAY")
  castbar.Time:SetTextColor(1, 1, 1)
  castbar.Time:SetJustifyH("RIGHT")

  castbar.Icon = castbar:CreateTexture(nil, 'ARTWORK')
  castbar.Icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)

    core:setBackdrop(castbar, cfg.units.target.castbar.height + 4, 2, 2, 2)
    castbar:SetBackdropColor(unpack(cfg.elements.castbar.backdrop.color))
--    castbar:SetStatusBarColor(unpack(cfg.units.target.castbar.color))
--    castbar:SetWidth(cfg.units.target.castbar.width - cfg.units.target.castbar.height + 6)
--    castbar:SetHeight(cfg.units.target.castbar.height)
	castbar:SetWidth(126)
	castbar:SetHeight(15)
--    castbar:SetPoint("CENTER", "UIParent", "CENTER", 0, 350)
    castbar:SetPoint("CENTER", UIParent, "CENTER", 0, 0)

    castbar.Text:SetFont(font, cfg.fontsize +1, "THINOUTLINE")
    castbar.Text:SetWidth(cfg.units.target.castbar.width - 20)
    castbar.Text:SetPoint("RIGHT", castbar, -1, 0)

    castbar.Time:SetFont(font, cfg.fontsize -1, "THINOUTLINE")
    castbar.Time:SetJustifyH("CENTER")
    castbar.Time:SetPoint("CENTER", castbar, 102, 0)
    castbar.CustomTimeText = CustomCastTimeText

    castbar.Icon:SetHeight(cfg.units.target.castbar.height)
    castbar.Icon:SetWidth(cfg.units.target.castbar.height)
--    castbar.Icon:SetPoint("RIGHT", castbar, -(cfg.units.target.castbar.height + 2), 0)
    castbar.Icon:SetPoint("RIGHT", castbar, 17, 0)

    -- Interrupt
    core:setglowBorder(castbar)
    castbar.Glowborder:SetPoint("TOPLEFT", castbar, "TOPLEFT", - (cfg.units.target.castbar.height + 2) - 6, 6) -- Resize to include icon
    castbar.PostCastStart = myPostCastStart
    castbar.PostChannelStart = myPostChannelStart

   	castbar.PostCastStart = PostUpdateCastColor
	castbar.PostChannelStart = PostUpdateCastColor
	castbar.PostCastInterruptible = PostUpdateCastColor
	castbar.PostCastNotInterruptible = PostUpdateCastColor
	castbar.PostCastFailed = PostCastFailedOrInterrupted
	castbar.PostCastInterrupted = PostCastFailedOrInterrupted
  self.Castbar = castbar -- register with oUF
end
__________________
AddOns: [email protected]
Website: Ciraxe' Shenanigans
Chars: Monk, Viskaz, Mage, Shaman
  Reply With Quote
04-21-18, 10:20 AM   #9
runamonk
An Aku'mai Servant
 
runamonk's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 32
I don't think just creating another castbar will work since when you register it with the ouf unit it will overwrite the original one.

Maybe spawn a secondary target unit, link the new castbar to that and then hide the secondary target unit. No clue how well that will work though.
  Reply With Quote
04-21-18, 10:34 AM   #10
GreyFox777
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 54
The same happens. Now the only in center one working, the another on unitframe stays white and has no reaction.

Maybe the target lua file helps...
Attached Files
File Type: lua target.lua (7.5 KB, 19 views)

Last edited by GreyFox777 : 04-21-18 at 10:47 AM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Target castbar centered

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