WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   oUF_Phanx edit (https://www.wowinterface.com/forums/showthread.php?t=46366)

lynce 04-28-13 11:03 AM

oUF_Phanx edit
 
So im looking for a way to make all the buffs and debuffs show on the target frame, and not just the filtered ones.

Rainrider 04-28-13 01:21 PM

Open oUF_Phanx\Frames.lua and search for elseif unit == "target" then. Slightly below that you will find 2 lines containing:
Code:

self.Debuffs.CustomFilter  = ns.CustomAuraFilters.target
and
Code:

self.Buffs.CustomFilter  = ns.CustomAuraFilters.target
respectively. Comment these out (put -- in front of each of them), save the file and reload your interface.

lynce 04-28-13 03:39 PM

Thanks it worked:) I was messing around in auras.lua and could not get it to work.

I have another question tho. I'm trying to make the castbar to turn red, and fade out(almost like the default castbar)

I tried to add something like this in function.lua line 425
Code:

function ns.PostCastStop(self, unit, name, rank, castid)
        if not self.fadeOut then
                self:SetStatusBarColor(unpack(self.CompleteColor))
                self.fadeOut = true
        end
        self:SetValue(self.max)
        self:Show()
end

But of course it does not work(no errors tho^^) I't pretty much a copy/paste from another layout.

Phanx 04-28-13 06:15 PM

Simply adding a "fadeOut" key to the frame doesn't do anything. You would need to write some additional code to animate the opacity of the castbar to achieve that. I'd suggest using the animation API but I don't have time to write the actual code for you. If you have another layout that already does this, you'd need to find and copy the rest of the code it uses to handle fading.

Also, the code you posted is only not raising an error because it's never actually run. You need to attach it to the castbar so oUF will run it when the active cast stops. Find the line in Frames.lua that sets "Castbar.PostCastStart = ns.PostCastStart" and add a similar line attaching your PostCastStop function.

However, your PostCastStop function as written will not work, and will raise an error about passing a nil value to "unpack". Most likely you should just change "unpack(self.CompleteColor)" to just hardcode the color you want, eg. "self:SetStatusBarColor(1, 0, 0)".

Rainrider 04-28-13 07:06 PM

Not able to tell much about that without seeing further code. Have you registered your callback handler with oUF? What reacts to changing castbar.fadeOut? Is CompleteColor defined?

Edit: don't start writing something and go watch tv inbetween :)

lynce 04-29-13 05:03 AM

This is the code i was copying from:
Code:

  local addon, ns = ...
  local cfg = ns.cfg
  local cast = CreateFrame("Frame") 

  -----------------------------
  -- FUNCTIONS
  -----------------------------
  -- special thanks to Allez for coming up with this solution
local channelingTicks = {
        -- warlock
        [GetSpellInfo(1120)] = 5, -- drain soul
        [GetSpellInfo(689)] = 5, -- drain life
        [GetSpellInfo(5740)] = 4, -- rain of fire
        -- druid
        [GetSpellInfo(740)] = 4, -- Tranquility
        [GetSpellInfo(16914)] = 10, -- Hurricane
        -- priest
        [GetSpellInfo(15407)] = 3, -- mind flay
        [GetSpellInfo(48045)] = 5, -- mind sear
        [GetSpellInfo(47540)] = 2, -- penance
        -- mage
        [GetSpellInfo(5143)] = 5, -- arcane missiles
        [GetSpellInfo(10)] = 5, -- blizzard
        [GetSpellInfo(12051)] = 4, -- evocation
        -- shaman
        [GetSpellInfo(61882)] = 8, -- earthquake
        --monk
        [GetSpellInfo(115175)] = 9 -- soothing mists
}

local ticks = {}

cast.setBarTicks = function(castBar, ticknum)
        if ticknum and ticknum > 0 then
                local delta = castBar:GetWidth() / ticknum
                for k = 1, ticknum do
                        if not ticks[k] then
                                ticks[k] = castBar:CreateTexture(nil, 'OVERLAY')
                                ticks[k]:SetTexture(cfg.statusbar_texture)
                                ticks[k]:SetVertexColor(0, 0, 0)
                                ticks[k]:SetWidth(1)
                                ticks[k]:SetHeight(castBar:GetHeight())
                        end
                        ticks[k]:ClearAllPoints()
                        ticks[k]:SetPoint("CENTER", castBar, "LEFT", delta * k, 0 )
                        ticks[k]:Show()
                end
        else
                for k, v in pairs(ticks) do
                        v:Hide()
                end
        end
end

cast.OnCastbarUpdate = function(self, elapsed)
        local currentTime = GetTime()
        if self.casting or self.channeling then
                local parent = self:GetParent()
                local duration = self.casting and self.duration + elapsed or self.duration - elapsed
                if (self.casting and duration >= self.max) or (self.channeling and duration <= 0) then
                        self.casting = nil
                        self.channeling = nil
                        return
                end
                if parent.unit == 'player' then
                        if self.delay ~= 0 then
                                self.Time:SetFormattedText('%.1f / |cffff0000%.1f|r', duration, self.casting and self.max + self.delay or self.max - self.delay)
                        else
                                self.Time:SetFormattedText('%.1f / %.1f', duration, self.max)
                                --self.Lag:SetFormattedText("%d ms", self.SafeZone.timeDiff * 1000)
                        end
                else
                        self.Time:SetFormattedText('%.1f / %.1f', duration, self.casting and self.max + self.delay or self.max - self.delay)
                end
                self.duration = duration
                self:SetValue(duration)
                self.Spark:SetPoint('CENTER', self, 'LEFT', (duration / self.max) * self:GetWidth(), 0)
        else
                self.Spark:Hide()
                local alpha = self:GetAlpha() - 0.02
                if alpha > 0 then
                        self:SetAlpha(alpha)
                else
                        self.fadeOut = nil
                        self:Hide()
                end
        end
end

cast.OnCastSent = function(self, event, unit, spell, rank)
        if self.unit ~= unit or not self.Castbar.SafeZone then return end
        self.Castbar.SafeZone.sendTime = GetTime()
end

cast.PostCastStart = function(self, unit, name, rank, text)
        local pcolor = {255/255, 128/255, 128/255}
        local interruptcb = {95/255, 182/255, 255/255}
        self:SetAlpha(1.0)
        self.Spark:Show()
        self:SetStatusBarColor(unpack(self.casting and self.CastingColor or self.ChannelingColor))
        if unit == "player"then
                -- local sf = self.SafeZone
                -- if sf.sendTime then
                        -- sf.timeDiff = GetTime() - sf.sendTime
                        -- sf.timeDiff = sf.timeDiff > self.max and self.max or sf.timeDiff
                        -- sf:SetWidth(self:GetWidth() * sf.timeDiff / self.max)
                        -- sf:Show()
                -- end
                if self.casting then
                        cast.setBarTicks(self, 0)
                else
                        local spell = UnitChannelInfo(unit)
                        self.channelingTicks = channelingTicks[spell] or 0
                        cast.setBarTicks(self, self.channelingTicks)
                end
        elseif (unit == "target" or unit == "focus" or unit == "boss" ) and not self.interrupt then
                self:SetStatusBarColor(interruptcb[1],interruptcb[2],interruptcb[3],1)
        else
                self:SetStatusBarColor(pcolor[1], pcolor[2], pcolor[3],1)
        end
end

cast.PostCastStop = function(self, unit, name, rank, castid)
        if not self.fadeOut then
                self:SetStatusBarColor(unpack(self.CompleteColor))
                self.fadeOut = true
        end
        self:SetValue(self.max)
        self:Show()
end

cast.PostChannelStop = function(self, unit, name, rank)
        self.fadeOut = true
        self:SetValue(0)
        self:Show()
end

cast.PostCastFailed = function(self, event, unit, name, rank, castid)
        self:SetStatusBarColor(unpack(self.FailColor))
        self:SetValue(self.max)
        if not self.fadeOut then
                self.fadeOut = true
        end
        self:Show()
end
  --hand the lib to the namespace for further usage
  ns.cast = cast

(yes im trying to add tick marks aswell)

Now i don't know if any of this has to do with fade-out effect, but there is not much else about castbar in the layout(oUF_Fail).

I tired to add ns.OnCastbarUpdate, ns.PostCastStop ect. in frame.lua, and set the CompleteColor to just some random color. End result is: nothing happens:S Tbh i'm kida confused:S

Rainrider 04-29-13 08:49 AM

Correct me if I missed something but the layout you pointed at does not have any fading effects whatsoever.

Phanx 04-29-13 07:30 PM

It's in the OnCastbarUpdate function, which I assume is used as "castbar.OnUpdate = ns.cast.OnCastbarUpdate" in the actual frame creation code. However, I'm not really sure how that would produce a reasonably visible effect, as the code simply reduces the alpha by 20% in each OnUpdate -- assuming you start at 100%, it would only take 5 frame draws to completely hide the frame. Even at 30 FPS, that means the bar is disappearing in 1/6th of a second. At 60 FPS, it's disappearing in 1/10th of a second. It would be better to use an actual animation so your fade duration wasn't dependent on your framerate. But, it should work as written, assuming you attach the relevant functions to the castbar on frame creation.

On a side note, the "local currentTime = GetTime()" line in the OnCastBarUpdate is just a wasted function call, since the variable is never used. Also, I have no idea why "cast" is defined as a frame, instead of a simple table; if a container object isn't a visible UI, and you're not registering for events or setting scripts, it should just be a table. :confused:

lynce 04-30-13 04:21 AM

Yes it in the OnUpdate function. And the fade-out effect looks normal to me. Takes about a second to fade out. It may be better to use animation as you mentioned, but i'm clueless on how to use it so its out of the question.
This is the closest thing i have to seeing a fadeout effect:
Code:

function ns.OnCastbarUpdate(self, elapsed)
                local alpha = self:GetAlpha() - 0.02
                if alpha > 0 then
                        self:SetAlpha(alpha)
                else
                        self.fadeOut = nil
                        self:Hide()
                end
        end
end

Fade out instantly on cast and does not show up again. The code makes no sense.

I also tried to implement a cast failed color and channel tick marks.
Code:

Castbar.PostCastFailed = ns.PostCastFailed i frames.lua and

function ns.PostCastFailed(self, event, unit, name, rank, castid)
        self:SetStatusBarColor(1, 0, 1)
        self:SetValue(self.max)
        if not self.fadeOut then
                self.fadeOut = true
        end
        self:Show()
end

and this in PostCastStart.
Code:

if self.casting then
        cast.setBarTicks(self, 0)
else
        local spell = UnitChannelInfo(unit)
        self.channelingTicks = channelingTicks[spell] or 0
        cast.setBarTicks(self, self.channelingTicks)
end

(local channelingTicks and function ns.setBarTicks there aswell

Nothing. I feel like a complete idiot messing around with this stuff:S
So to sum it up, this is what i'm trying to achieve: fade-out effect, channel tick marks, interrupt/failed color and successful cast color.

Phanx 04-30-13 04:35 AM

Oh, I read that as 0.2, not 0.02, so yeah, that will produce a visible effect. I'll try to look into your actual code issues sometime in the next few days.

lynce 05-03-13 03:04 AM

I would very much appreciate that. I can't figure out how OnUpdate and the fading code works. Which means i won't be able to see if my "cast complete" and "interrupt" color-change code works.

I added this to Frames.lua to get a spark effect:
Code:

local Spark = Castbar:CreateTexture(nil, "OVERLAY")
Spark:SetTexture(spark)
Spark:SetBlendMode("ADD")
Spark:SetVertexColor(1, 1, 1, 1)
Spark:SetHeight(Castbar:GetHeight()*2.5)
Spark:SetWidth(Castbar:GetWidth()/18)
Castbar.Spark = Spark

However, don't know how the layers work so can't get the spark effect to stay ontop of the border.


Edit: Ok think i fixed the spark problem with SetDrawLayer.

lynce 05-12-13 08:30 AM

After much trial and error, i kinda abandon the attempt to make the bar fade:/ No biggy.

I have another problem though that i hope someone can help me with:P
I made a custom border that i want to apply only on the buffs/debuffs(or better yet, only the debuffs). How would i go about making this possible? Would i have to create a new function in Border.lua?

Phanx 05-12-13 01:21 PM

No; if you want a different border on your buffs, just apply that in Functions.lua, in the PostCreateIcon function, and remove the AddBorder call in the same location.

lynce 05-13-13 09:31 AM

Clearly i'm doing something wrong because the result is not satisfying



Top picture is with the added code, and the bellow picture is original(i use another main border as you can see)
If i did it right, they should have looked the same:P


I basically removed line 317 - "ns.CreateBorder" and added something like this:
Code:

button.overlay:SetTexture("Interface\\AddOns\\oUF_Phanx\\Media\\SimpleSquare")
button.overlay:SetTexCoord(0,0.95,0.05,0.95)
button.overlay.Hide = function(self) self:SetVertexColor(0, 0, 0) end

The border does not seem to be on top of the icon, but inside it. And the size of it is also wrong.

Phanx 05-13-13 10:39 PM

Your "below" picture is missing, but based on your code the problem is that you are not sizing the texture correctly, and your texcoords are wrong for the border texture; it's not an icon.

Code:

local size = button:GetWidth() / (46/64)
button.overlay:ClearAllPoints()
button.overlay:SetPoint("CENTER")
button.overlay:SetSize(size, size)
button.overlay:SetTexture("Interface\\AddOns\\oUF_Phanx\\Media\\SimpleSquare")
button.overlay.Hide = function(self) self:SetVertexColor(0, 0, 0) end

However, I'm not really sure why you're doing this at all, when you're using the same texture that's already used by default?

lynce 05-14-13 04:51 AM

I used the default one so it would be easier to explain:o
The "below" picture i posted is the second row of buffs(It is to differen pictuers). Anyway applying your code gives me this:



But i think i fixed it with making a new function in Border.lua:P (function ns.CreateBuffBorder ect..) just a copy of ns.CreateBorder.
Now, how do i only apply it to the debuffs:confused:

Phanx 05-14-13 08:45 AM

Well, that's what happens when you post some useless fake snippet instead of your actual code -- you get answers that aren't relevant to your goal. In this case, the code I posted was specific to the texture file you indicated you were using. :rolleyes:

If the texture you actually want to use fills the entire canvas, just use the code you originally posted, but get rid of the texcoords -- your overlay texture isn't an icon texture, so it shouldn't need to be trimmed like an icon texture. If it doesn't look right, post a screenshot and your actual code.

lynce 05-14-13 10:45 AM

I don't think I explained myself very well:o I'l try again.

Everything is default(forget the pictures i posted). I took the default border(SimpleSquare) and added a inner glow effect to it in Photoshop. Now i want to use this new border but only on the debuffs. So far i have managed to set it on the auras by adding this in Border.lua:
(basically just a copy/paste)
Code:

function ns.CreateBuffBorder(self, size, offset, parent, layer)
        if type(self) ~= "table" or not self.CreateTexture or self.BorderTextures then return end

        local t = {}

        for i = 1, #sections do
                local x = self:CreateTexture(nil, layer or "ARTWORK")
                x:SetTexture([[Interface\AddOns\oUF_Phanx\media\BuffBorder]])
                t[sections[i]] = x
        end

        t.TOPLEFT:SetTexCoord(0, 1/3, 0, 1/3)
        t.TOPRIGHT:SetTexCoord(2/3, 1, 0, 1/3)
        t.TOP:SetTexCoord(1/3, 2/3, 0, 1/3)
        t.BOTTOMLEFT:SetTexCoord(0, 1/3, 2/3, 1)
        t.BOTTOMRIGHT:SetTexCoord(2/3, 1, 2/3, 1)
        t.BOTTOM:SetTexCoord(1/3, 2/3, 2/3, 1)
        t.LEFT:SetTexCoord(0, 1/3, 1/3, 2/3)
        t.RIGHT:SetTexCoord(2/3, 1, 1/3, 2/3)

        self.BorderTextures = t

        self.SetBorderColor  = SetBorderColor
        self.SetBorderLayer  = SetBorderLayer
        self.SetBorderParent = SetBorderParent
        self.SetBorderSize  = SetBorderSize

        self.GetBorderColor  = GetBorderColor
        self.GetBorderLayer  = GetBorderLayer
        self.GetBorderParent = GetBorderParent
        self.GetBorderSize  = GetBorderSize

        do
                local backdrop = self:GetBackdrop()
                if type(backdrop) == "table" then
                        if backdrop.edgeFile then
                                backdrop.edgeFile = nil
                        end
                        if backdrop.insets then
                                backdrop.insets.top = 0
                                backdrop.insets.right = 0
                                backdrop.insets.bottom = 0
                                backdrop.insets.left = 0
                        end
                        self:SetBackdrop(backdrop)
                end
        end

        if self.SetBackdropBorderColor then
                self.SetBackdropBorderColor = SetBorderColor
        end

        tinsert(ns.borderedObjects, self)

        self:SetBorderColor()
        self:SetBorderParent(parent)
        self:SetBorderSize(size, offset)

        return true
end

And then i just put ns.CreateBuffBorder(button.. in function.lua. Works, but i don't think this "fix" will do if i only want it on the debuffs:confused:

Phanx 05-14-13 10:15 PM

If you're just modifying the existing texture, you don't even need to replicate the CreateBorder function. Just change the texture in PostCreateAuraIcon, immediately after the call to CreateBorder:

Code:

ns.CreateBorder(button, 12)
for _, tex in pairs(button.BorderTextures) do
    tex:SetTexture([[Interface\AddOns\oUF_Phanx\media\BuffBorder]])
end


lynce 05-22-13 05:15 AM

Thanks for your help Phanx:) Works perfectly.


All times are GMT -6. The time now is 08:20 AM.

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