Thread Tools Display Modes
07-14-14, 09:33 AM   #21
Kygo
A Theradrim Guardian
 
Kygo's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 64
Alright!
The unit frames are taking more and more shape every hour
Even started to make the basic UI around them, not sure tho if I will ever upload the entire UI Might just only upload the unit frames

Got any ideas what more I should add to the unit frames? I feel quite satisfied with them atm ^^

  Reply With Quote
07-14-14, 01:26 PM   #22
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
- Your power bar text is using a different font than the rest of the fontstrings on the frames.

- I don't think there are two fontstrings with the same font size anywhere on the frames... I'd suggest picking two sizes, and stick to them, with important stuff using the larger size, and everything else using the smaller size. Having everything in a different size makes it look more cluttered than it really is.

- You've also got a bunch of different fonts throughout your UI. Again, picking one or two fonts (eg. a more decorative one for short text on unit frames and cast bars, and a more readable one for the chat frame) and sticking to them will make the whole thing look more like a cohesive UI, rather than a collection of random stuff that happen to be on the same screen at the same time.

- Give your poor pet a real name already!
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
07-15-14, 05:09 AM   #23
Kygo
A Theradrim Guardian
 
Kygo's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 64
- Your power bar text is using a different font than the rest of the fontstrings on the frames.
--Fixed!
- I don't think there are two fontstrings with the same font size anywhere on the frames... I'd suggest picking two sizes, and stick to them, with important stuff using the larger size, and everything else using the smaller size. Having everything in a different size makes it look more cluttered than it really is.
Also fixed! Every font that the Frames are using are the same, sizes are 10px and 6px on less important stuff (eg the % on target and targettarget frame)

- You've also got a bunch of different fonts throughout your UI. Again, picking one or two fonts (eg. a more decorative one for short text on unit frames and cast bars, and a more readable one for the chat frame) and sticking to them will make the whole thing look more like a cohesive UI, rather than a collection of random stuff that happen to be on the same screen at the same time.
Also fixed, some addons did not have the option to change the font from within the game, two addons did I have to change inside the lua file to set the font and so the addon could find it and add it to the dropdown menu

- Give your poor pet a real name already!
Changed!

http://imgur.com/a/Lqf39 Two screens, one out of combat and one in combat
  Reply With Quote
07-25-14, 02:08 AM   #24
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by Phanx View Post
oUF uses its own tag system, unrelated to the tag systems used by SUF or other addons.
SUF's tag system is actually heavily based on oUF's
__________________
「貴方は1人じゃないよ」
  Reply With Quote
08-01-14, 02:38 PM   #25
Kygo
A Theradrim Guardian
 
Kygo's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 64
I've been thinking for a while now that I've been using these unitframes, how difficult would it be to add Aurabars to player and target frame? For trinkets, pots and other short (<30sec) buffs on the player and debuffs on the target casted by the player (such as Rake, Rip, Serpent Sting etc)

Would it be possible to achive this without needing to define all the spell id's?

Something like this, or is this completely wrong?
Lua Code:
  1. local AuraBar = CreateFrame("StatusBar", nil, frame)
  2. AuraBar:SetPoint("TOPLEFT", frame, "TOPRIGHT")
  3. AuraBar:SetPoint("CENTER", frame, 0, 5)
  4. AuraBar:SetStatusBarTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
  5.  
  6. -- Text?
  7. local AuraBartxt = AuraBar:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  8. AuraBartxt:SetPoint("LEFT", frame, 0, 0)
  9. AuraBartxt:SetFont("Interface\\Addons\\oUF_Kygo\\Media\\neuropol.ttf", 10)
  10. AuraBartxt:SetTextColor(1, 1, 1, 1)

Last edited by Kygo : 08-01-14 at 02:42 PM.
  Reply With Quote
08-01-14, 07:56 PM   #26
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Kygo View Post
I've been thinking for a while now that I've been using these unitframes, how difficult would it be to add Aurabars to player and target frame? For trinkets, pots and other short (<30sec) buffs on the player and debuffs on the target casted by the player (such as Rake, Rip, Serpent Sting etc)

Would it be possible to achive this without needing to define all the spell id's?
Yes, and you can just use oUF's built-in aura element.

Main chunk:
Code:
local function bar_OnUpdate(self, elapsed)
	local t = self.timeLeft - elapsed
	self:SetValue(t > 0 and t or 0)
	self.timeLeft = t
end

local function auras_PostCreateIcon(self, icon)
	local frame = self.__owner

	local bar = CreateFrame("StatusBar", nil, icon)
	bar:SetPoint("LEFT", icon, "RIGHT")
	bar:SetWidth(frame:GetWidth() - BUFF_HEIGHT)
	bar:SetHeight(BUFF_HEIGHT)
	bar:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")
	bar:SetStatusBarColor(0, 0.6, 0)

	local bg = bar:CreateTexture(nil, "BACKGROUND")
	bg:SetAllPoints(true)
	bg:SetTexture("Interface\\TargetingFrame\\UI-StatusBar")
	bg:SetVertexColor(0, 0.2, 0)
	bar.bg = bg

	bar.timeLeft = 0
	icon.bar = bar
end
In your spawn function:
Code:
if unit == "player" or unit == "target" then
	local BUFF_HEIGHT = 20

	local Auras = CreateFrame("Frame", nil, self)
	Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 10)
	Auras:SetWidth(BUFF_HEIGHT) -- no, Width/HEIGHT is not a mistake

	Auras["initialAnchor"] = "BOTTOMLEFT"
	Auras["growth-y"] = "UP"
	Auras["spacing-y"] = 1 -- 1px gap between bars, adjust as desired
	Auras["num"] = 10 -- limit to showing 5 bars, adjust as desired
	Auras["size"] = BUFF_HEIGHT

	Auras.PostCreateIcon = auras_PostCreateIcon

	if unit == "player" then
		function Auras:CustomFilter(unit, icon, name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff)
			if duration < 30 then
				icon.bar.timeLeft = timeLeft
				icon.bar:SetMinMaxValues(0, duration)
				icon.bar:SetValue(timeLeft)
				return true
			end
		end
		self.Buffs = Auras
	elseif unit == "target" then
		function Auras:CustomFilter(unit, icon, name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff)
			if canApplyAura then
				icon.bar.timeLeft = timeLeft
				icon.bar:SetMinMaxValues(0, duration)
				icon.bar:SetValue(timeLeft)
				return true
			end
		end
		self.Debuffs = Auras
	end
end
Not tested at all, so there may be errors, but that should give you the general idea.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-02-14, 06:22 AM   #27
Kygo
A Theradrim Guardian
 
Kygo's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 64
Originally Posted by Phanx View Post
Yes, and you can just use oUF's built-in aura element.

Main chunk:
Code:
Lots of code
Not tested at all, so there may be errors, but that should give you the general idea.
The "BUFF_HEIGHT" is giving a nil value error. The whole error is here > http://pastebin.com/Hmfre6RX (its to long to post here)
Never encountered a error like this so I don't really know what to do to fix it, did open oUF\elements\aura.lua as stated in the error to see if I can make any sense but it didn't.

Had to swap out your "self" into frame because I don't have "self" defined anywhere.
Full code updated today is found here > http://pastebin.com/pkVwFrn5

By the looks of the code it seems to be way out of my knowledge
  Reply With Quote
08-02-14, 09:53 AM   #28
Sjak
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 13
Originally Posted by Kygo View Post
The "BUFF_HEIGHT" is giving a nil value error. The whole error is here > http://pastebin.com/Hmfre6RX (its to long to post here)
Never encountered a error like this so I don't really know what to do to fix it, did open oUF\elements\aura.lua as stated in the error to see if I can make any sense but it didn't.

Had to swap out your "self" into frame because I don't have "self" defined anywhere.
Full code updated today is found here > http://pastebin.com/pkVwFrn5

By the looks of the code it seems to be way out of my knowledge
BUFF_HEIGHT is giving a nil value because it's defined as a local in the spawn function so it won't be accessible inside of other functions. If you move it out of the spawn function to the top of the file then it should work fine.

"Self" doesn't need to be defined because it's a parameter of the function. I'm not great at explaining things so it's probably best just to read this to understand why you use "self".
  Reply With Quote
08-02-14, 10:56 PM   #29
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Kygo View Post
The "BUFF_HEIGHT" is giving a nil value error. The whole error is here > http://pastebin.com/Hmfre6RX (its to long to post here)
Originally Posted by Sjak View Post
BUFF_HEIGHT is giving a nil value because it's defined as a local in the spawn function so it won't be accessible inside of other functions. If you move it out of the spawn function to the top of the file then it should work fine.
Yes, this. I wrote it all in one file and then copy/pasted the blocks into my post... missed that bit in the first block, apparently.

Originally Posted by Kygo View Post
Had to swap out your "self" into frame because I don't have "self" defined anywhere.
Originally Posted by Sjak View Post
"Self" doesn't need to be defined because it's a parameter of the function. I'm not great at explaining things so it's probably best just to read this to understand why you use "self".
No, it does actually need to be "frame" here, as his code is using that instead of the more traditional "self" in that parcitular context.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-03-14, 05:06 AM   #30
Kygo
A Theradrim Guardian
 
Kygo's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 64
No more errors!
But it does not "generate" or what to call it any bars. I'm very confused

Been looking through the code over and over but can't seem the find the missing element.

How it looks right now:
Above the spawn function.
Code:
-- Aura Bars
local BUFF_HEIGHT = 20
local function bar_OnUpdate(frame, elapsed)
	local t = frame.timeLeft - elapsed
	frame:SetValue(t > 0 and t or 0)
	frame.timeLeft = t
end

local function auras_PostCreateIcon(frame, icon)
	local frame = frame.__owner
	
	local bar = CreateFrame("StatusBar", nil, icon)
	bar:SetPoint("LEFT", icon, "RIGHT")
	bar:SetWidth(frame:GetWidth() - BUFF_HEIGHT)
	bar:SetHeight(BUFF_HEIGHT)
	bar:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")
	bar:SetStatusBarColor(0, 0.6, 0)

	local bg = bar:CreateTexture(nil, "BACKGROUND")
	bg:SetAllPoints(true)
	bg:SetTexture("Interface\\TargetingFrame\\UI-StatusBar")
	bg:SetVertexColor(0, 0.2, 0)
	bar.bg = bg

	bar.timeLeft = 0
	icon.bar = bar
end
--
So far so good yeah?


Below the spawn function. (Below CPoints in my code)
And the second block:
The "icon.bar" segments I don't really get, there are no functions called "icon" in my code? Does it grab that from oUF it self or how does that work?
Did try to add "local icon = CreateIcon("Icon", nil, frame)" without success.
I think I did bite off more than I can chew on this one.
Code:
	---------------------------------
	--			Aurabars		   --
	---------------------------------
	if unit == "player" or unit == "target" then
	

	local Auras = CreateFrame("Frame", nil, frame)
	Auras:SetPoint("BOTTOMLEFT", frame, "TOPLEFT", 0, 10)
	Auras:SetWidth(BUFF_HEIGHT) -- no, Width/HEIGHT is not a mistake

	Auras["initialAnchor"] = "BOTTOMLEFT"
	Auras["growth-y"] = "UP"
	Auras["spacing-y"] = 1 -- 1px gap between bars, adjust as desired
	Auras["num"] = 10 -- limit to showing 5 bars, adjust as desired
	Auras["size"] = BUFF_HEIGHT

	Auras.PostCreateIcon = auras_PostCreateIcon

	if unit == "player" then
		function Auras:CustomFilter(unit, icon, name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff)
			if duration < 30 then
				icon.bar.timeLeft = timeLeft
				icon.bar:SetMinMaxValues(0, duration)
				icon.bar:SetValue(timeLeft)
				return true
			end
		end
		frame.Buffs = Auras
	elseif unit == "target" then
		function Auras:CustomFilter(unit, icon, name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff)
			if canApplyAura then
				icon.bar.timeLeft = timeLeft
				icon.bar:SetMinMaxValues(0, duration)
				icon.bar:SetValue(timeLeft)
				return true
			end
		end
		frame.Debuffs = Auras
	end
	end
  Reply With Quote
08-03-14, 01:19 PM   #31
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Kygo View Post
The "icon.bar" segments I don't really get, there are no functions called "icon" in my code? Does it grab that from oUF it self or how does that work?
Yes, "icon" is one of the variables your filter function receives from oUF, and contains a reference to the icon button object -- the same icon button object you added a "bar" key to in the PostCreateIcon callback.

new icon created -> PostCreateIcon callback -> create bar -> Filter callback -> do stuff with bar

As for why it's not working, do you have BugSack running? If not, go fix that now. If so, does it report any errors? If so, what are they? I'll try to test it myself later, but no guarantees.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-03-14, 02:07 PM   #32
Kygo
A Theradrim Guardian
 
Kygo's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 64
Originally Posted by Phanx View Post
Yes, "icon" is one of the variables your filter function receives from oUF, and contains a reference to the icon button object -- the same icon button object you added a "bar" key to in the PostCreateIcon callback.

new icon created -> PostCreateIcon callback -> create bar -> Filter callback -> do stuff with bar

As for why it's not working, do you have BugSack running? If not, go fix that now. If so, does it report any errors? If so, what are they? I'll try to test it myself later, but no guarantees.
Okey! Thanks for the explination!

And yea, I have BugSack running Got a few errors, but nothing that the aurabars did generate after the local BUFF_HEIGHT issue.
Only errors BugSack did pickup was some failures I did attempt with (like the "local icon = CreateIcon thing) and making a new tag.
  Reply With Quote
08-10-14, 12:48 PM   #33
Kygo
A Theradrim Guardian
 
Kygo's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 64
Been trying to figure out why the aurabars dosent show up (or generate any errors) for the last couple of days, soon ready to give up on them.
Meanwhile, I have managed to add some other (pretty irrelevant, but still quite usefull) features to the unit frame/s. Such as resting icon, leader icon etc..

Features left to be added:
Readycheck icon on player frame and on party1-5 frames.
Boss frames with seperate code segment for various variables and settings. (In progress)
Working aurabars (if someone is able to give me a hand on this one, Phanx's code I'm using are a few posts up)
Might think of more usefull features down the road.


Code is available to be seen here
  Reply With Quote
08-11-14, 02:48 AM   #34
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You're never setting the OnUpdate script on the bars. Not sure if this was missing in my original code or not since I'm too lazy to go look, but this should fix that:
Code:
     bar.timeLeft = 0
     bar:SetMinMaxValues(0, 1)
     bar:SetScript("OnUpdate", bar_OnUpdate)
     icon.bar = bar
Another thing I noticed is this:
Code:
local function auras_PostCreateIcon(frame, icon)
     local frame = frame.__owner
Blindly renaming all "self" variables to "frame" is not a good idea. Here, you're overwriting your own variable, and losing access to whatever the first one referred to. In this case it doesn't end up affecting anything, since you didn't want to access the first one after reading its "__owner" key, but it's not something you should be in the habit of doing, as it's also fairly confusing for people reading your code, and will probably be confusing to you if you don't look at this code for a few months or years. If you really don't want any variables named "self" then there are still plenty of other things you can name your variables that make more sense:
Code:
local function auras_PostCreateIcon(element, icon)
     local frame = element.__owner
You may want to double-check the rest of the code where you've searched-and-replaced "self" with "frame" to make sure you haven't overwritten any frame references you actually need.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-11-14, 04:40 AM   #35
Kygo
A Theradrim Guardian
 
Kygo's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 64
Originally Posted by Phanx View Post
You may want to double-check the rest of the code where you've searched-and-replaced "self" with "frame" to make sure you haven't overwritten any frame references you actually need.
I've done that now! Did try to swap out various frames to element back and forth with diffrent combinations to see if it made any diffrence. Did not sadly. No errors either.
Not sure if I have overlooked any frame references in the code , did what I knew to it (which is not a whole lot..)


Would it be easier for me and others who look through my code if it was using "self" over "frame"?

Updated code (today 11/8-14) is found here
  Reply With Quote
08-11-14, 05:19 AM   #36
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Kygo View Post
Would it be easier for me and others who look through my code if it was using "self" over "frame"?
Not necessarily. Just be consistent. The reason "self" is so popular is that -- partly because it's so popular -- immediately recognizable. When you're reading someone else's code and you see a variable named "self" you know right away that it's a reference to whatever object "owns" the function, so it's not confusing that "self" in different parts of the code refers to different things.

But if you see "frame" at the top of a function, and then jump down 10 lines inside the same function and see "frame" again, it would be insane to assume it referred to something other than what the first "frame" referred to. And if you're looking at a unit frame addon and you see a variable named "frame" it's kind of automatic to assume it's referring to a unit frame, which is why I suggested "element" as an alternative here.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-11-14, 06:03 AM   #37
Kygo
A Theradrim Guardian
 
Kygo's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 64
Originally Posted by Phanx View Post
Not necessarily. Just be consistent. The reason "self" is so popular is that -- partly because it's so popular -- immediately recognizable. When you're reading someone else's code and you see a variable named "self" you know right away that it's a reference to whatever object "owns" the function, so it's not confusing that "self" in different parts of the code refers to different things.

But if you see "frame" at the top of a function, and then jump down 10 lines inside the same function and see "frame" again, it would be insane to assume it referred to something other than what the first "frame" referred to. And if you're looking at a unit frame addon and you see a variable named "frame" it's kind of automatic to assume it's referring to a unit frame, which is why I suggested "element" as an alternative here.
Ah okey! Then I don't have to think about that


Did change the "frame" in the bar_OnUpdate function to element , no diffrence. I have no clue how to continue with this now
With the changes you posted:
Part above the Spawn function.
Code:
-- Aura Bars
local BUFF_HEIGHT = 20
local function bar_OnUpdate(frame, elapsed)
        local t = frame.timeLeft - elapsed
        frame:SetValue(t > 0 and t or 0)
        frame.timeLeft = t
end
 
local function auras_PostCreateIcon(element, icon)
        local frame = element.__owner
       
        local bar = CreateFrame("StatusBar", nil, icon)
        bar:SetPoint("LEFT", icon, "RIGHT")
        bar:SetWidth(frame:GetWidth() - BUFF_HEIGHT)
        bar:SetHeight(BUFF_HEIGHT)
        bar:SetStatusBarTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
        bar:SetStatusBarColor(0, 0.6, 0)
 
        local bg = bar:CreateTexture(nil, "BACKGROUND")
        bg:SetAllPoints(true)
        bg:SetTexture("Interface\\AddOns\\oUF_Kygo\\Media\\Neal")
        bg:SetVertexColor(0, 0.2, 0)
        bar.bg = bg
 
        bar.timeLeft = 0
        bar:SetMinMaxValues(0, 1)
        bar:SetScript("OnUpdate", bar_OnUpdate)
        icon.bar = bar
end
And the part below the Spawn function:
Did try to change "frame.Buffs = Auras" to "element.buffs = Auras" and same with the "Debuffs = Auras" only to see if it threw the "nil" error I expected.
Code:
        ---------------------------------
        --                      Aurabars                   --
        ---------------------------------
        if unit == "player" or unit == "target" then
       
        local Auras = CreateFrame("Frame", nil, element)
        Auras:SetPoint("BOTTOMLEFT", frame, "TOPLEFT", 0, 10)
        Auras:SetWidth(BUFF_HEIGHT) -- no, Width/HEIGHT is not a mistake
 
        Auras["initialAnchor"] = "BOTTOMLEFT"
        Auras["growth-y"] = "UP"
        Auras["spacing-y"] = 1 -- 1px gap between bars, adjust as desired
        Auras["num"] = 10 -- limit to showing 5 bars, adjust as desired
        Auras["size"] = BUFF_HEIGHT
 
        Auras.PostCreateIcon = auras_PostCreateIcon
       
        if unit == "player" then
                function Auras:CustomFilter(unit, icon, name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff)
                        if duration < 30 then
                                icon.bar.timeLeft = timeLeft
                                icon.bar:SetMinMaxValues(0, duration)
                                icon.bar:SetValue(timeLeft)
                                return true
                        end
                end
                frame.Buffs = Auras
        elseif unit == "target" then
                function Auras:CustomFilter(unit, icon, name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff)
                        if canApplyAura then
                                icon.bar.timeLeft = timeLeft
                                icon.bar:SetMinMaxValues(0, duration)
                                icon.bar:SetValue(timeLeft)
                                return true
                        end
                end
                frame.Debuffs = Auras
        end
        end
  Reply With Quote
08-11-14, 01:52 PM   #38
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Your variable renaming the Spawn callback will not work; there is no variable "element" defined in that scope. The third value passed to CreateFrame needs to be a reference to (or the global name of) the desired parent frame. You're effectively passing nil, causing the created frame to have no parent. You want that frame to parented to the unit frame, so the previous "frame" was appropriate there, since in that scope, the variable "frame" points to the unit frame.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-12-14, 08:45 AM   #39
Kygo
A Theradrim Guardian
 
Kygo's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 64
The code is know back to it's original state (except the "self" stuff). On this I did definitely bite off more than I can chew.
For some of you (or most of you) this is a piece of cake to handle, but for me this is really hard. Call me a rookie and I would agree to 100%. I am a extreme rookie when it comes to this type of stuff.



First part of the code (Above the Style function)

Code:
-- Aura Bars
local BUFF_HEIGHT = 20  
local function bar_OnUpdate(frame, elapsed)
	local t = frame.timeLeft - elapsed 
	frame:SetValue(t > 0 and t or 0)
	frame.timeLeft = t
end

local function auras_PostCreateIcon(element, icon)  
	local frame = element.__owner
	
	local bar = CreateFrame("StatusBar", nil, frame) --anchor the StatusBar to frame
	bar:SetPoint("LEFT", icon, "RIGHT")
	bar:SetWidth(frame:GetWidth() - BUFF_HEIGHT)  --It fetches the width of the created frame
	bar:SetHeight(BUFF_HEIGHT)
	bar:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")
	bar:SetStatusBarColor(0, 0.6, 0)

	local bg = bar:CreateTexture(nil, "BACKGROUND")
	bg:SetAllPoints(true)
	bg:SetTexture("Interface\\TargetingFrame\\UI-StatusBar")
	bg:SetVertexColor(0, 0.2, 0)
	bar.bg = bg

	bar.timeLeft = 0
	bar:SetMinMaxValues(0, 1)
	bar:SetScript("OnUpdate", bar_OnUpdate)
	icon.bar = bar
end

Second part (near the end of the code, just above the out-commented "Misc PvE Stuff")

Code:
---------------------------------
	--			Aurabars        --
	---------------------------------
	if unit == "player" or unit == "target" then
	
	local Auras = CreateFrame("Frame",nil ,frame) --anchor the Frame to frame
	Auras:SetPoint("BOTTOMLEFT", frame, "TOPLEFT", 0, 10)  --Where the anchors should be
	Auras:SetWidth(BUFF_HEIGHT) -- no, Width/HEIGHT is not a mistake

	Auras["initialAnchor"] = "BOTTOMLEFT"
	Auras["growth-y"] = "UP"
	Auras["spacing-y"] = 1 -- 1px gap between bars, adjust as desired
	Auras["num"] = 10 -- limit to showing 5 bars, adjust as desired
	Auras["size"] = BUFF_HEIGHT

	Auras.PostCreateIcon = auras_PostCreateIcon
	
	if unit == "player" then
		function Auras:CustomFilter(unit, icon, name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff)
			if duration < 30 then
				icon.bar.timeLeft = timeLeft
				icon.bar:SetMinMaxValues(0, duration)
				icon.bar:SetValue(timeLeft)
				return true
			end
		end
		frame.Buffs = Auras
	elseif unit == "target" then
		function Auras:CustomFilter(unit, icon, name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff)
			if canApplyAura then
				icon.bar.timeLeft = timeLeft
				icon.bar:SetMinMaxValues(0, duration)
				icon.bar:SetValue(timeLeft)
				return true
			end
		end
		frame.Debuffs = Auras
	end
	end
See attachment for what it does.
Attached Thumbnails
Click image for larger version

Name:	WoWScrnShot_081214_161837.jpg
Views:	196
Size:	340.6 KB
ID:	8175  
  Reply With Quote
08-16-14, 06:02 AM   #40
Kygo
A Theradrim Guardian
 
Kygo's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 64
Ok, I have put that project to add aurabars directly into the code on the side. What I've done instead (for now) is added support for oUF_AuraBars which I've setup to my liking on the unit frames (player + target).
(Support for oUF_Smooth and oUF_SpellRange is also added.)

The code I wrote in Frames.lua:
Code:
	--------------------
	--   oUF_AuraBars --
	--------------------
	if IsAddOnLoaded("oUF_AuraBars") then
		if unit == "player" or unit == "target" then
			frame.AuraBars = CreateFrame("Frame", nil, frame)
			frame.AuraBars:SetHeight(1)
			frame.AuraBars:SetWidth(143)
			frame.AuraBars:SetPoint("TOP", 0, -4)
			frame.AuraBars:SetPoint("RIGHT", -4, 0)
			frame.AuraBars.auraBarHeight = 10
			frame.AuraBars.spellNameSize = 5
			frame.AuraBars.spellTimeSize = 5
			frame.AuraBars.sort = 1
			frame.AuraBars.auraBarTexture = "Interface\\AddOns\\oUF_Kygo\\Media\\Neal"
			frame.AuraBars.filter =
				function(name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, canApplyAura, isBossDebuff)
					if(unitCaster == "player") and duration > 1 and duration < 300 then
					return true
					end
				end

		end
	end
Ran into a problem adding LFDRole. It shows all 4 icons for everyone, not sure what or how do add it "correctly". Do I need to add checks for units role?
My code for the LFDRole icons:
Code:
local LFDRole = health:CreateTexture(nil, "OVERLAY")
	LFDRole:SetSize(32, 32) --Larger size temp. for easier viewing.
	LFDRole:SetPoint("LEFT", health)
        LFDRole:SetTexture[[Interface\LFGFrame\UI-LFG-ICON-PORTRAITROLES]]
	
	health.LFDRole = LFDRole
Screen of how it looks:


And yes, the frame is off by a few pixles in height compared to the portrait.


On a scale 1-10, how difficult would it be to add element files to the code? I.e for Runes, Soul Shards, Holy power and eclipsebar.
Or would it just be easier to add code directly to the main file doing the same things?

Last edited by Kygo : 08-16-14 at 06:07 AM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF_Kygo, a few tips wanted


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