Thread Tools Display Modes
12-23-13, 01:07 PM   #1
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Trying my hand at ouf

So in this thread Phanx reinspired me to try my hand at making an ouf layout.

So far though I'm trying just to make a player health bar and all I get is just the backround and no status bar. According to the documentation I found in ouf itself the healthbar should default to the standard health bar is you don't imply a texture or color to it. So i'm confused.

code:
Code:
local frame = CreateFrame("Frame", "Bob", UIParent)

frame:SetPoint("CENTER",UIParent,0,0)

local function Spawn(frame, unit, isSingle)
    frame:SetPoint("CENTER", UIParent)
    frame:SetSize(100, 25)

    local bg = frame:CreateTexture(nil, "BACKGROUND")
    bg:SetAllPoints(true)
    bg:SetTexture(0, 0, 0, 0.5)
    frame.bg = bg
end

oUF:RegisterStyle("Bob", Spawn)
oUF:Spawn("player")

-- Position and size
local Health = CreateFrame("StatusBar", nil, frame)
Health:SetHeight(20)
Health:SetPoint('TOP')
Health:SetPoint('LEFT')
Health:SetPoint('RIGHT')

-- Options
Health.frequentUpdates = true
Health.colorTapping = true
Health.colorDisconnected = true
Health.colorClass = true
Health.colorReaction = true
Health.colorHealth = true

-- Register it with oUF
frame.Health = Health
frame.Health.bg = Background
__________________
Tweets YouTube Website
  Reply With Quote
12-23-13, 01:15 PM   #2
MoonWitch
A Firelord
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 455
Congrats and welcome to the oUF'ers

First you declare your health stuff, then you spawn the frames.

https://gist.github.com/8102856 is a boilerplate I made

You add the healthstatusbar to the shared part
  Reply With Quote
12-23-13, 01:40 PM   #3
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
So then I'm doing it backwards, ok well if I rip your code then put my stuff in there I still don't get anything. Probably missing something though now that I think about it....

Code:
------------------------------------------------------------------------
-- oUF Layout boiletplate
-- Author : Kelly Crabbé
------------------------------------------------------------------------
------------------------------------------------------------------------
-- Namespace
------------------------------------------------------------------------
local _, ns = ...
 
------------------------------------------------------------------------
-- Config
------------------------------------------------------------------------
local NORMALFONT = STANDARD_TEXT_FONT
local TEXTURE = [=[Interface\ChatFrame\ChatFrameBackground]=]
local BACKDROP = {
  bgFile = TEXTURE, insets = {top = -1, bottom = -1, left = -1, right = -1}
}
 
-----------------------------
-- Add custom functions (overrides)
 
------------------------------------------------------------------------
-- UnitSpecific settings
------------------------------------------------------------------------
local UnitSpecific = {
  player = function(self)
	-- player specific stuff
	local frame = CreateFrame("Frame", "Bob", UIParent)
	frame:SetPoint("CENTER",UIParent,0,0)
	frame:SetSize(100,100)
  end,
  target = function(self)
	-- target specific stuff
  end,
  party = function(self)
    -- party frames
  end,
  boss = function(self)
    -- boss frames
  end,
  arena = function(self)
    -- arena frames
  end
}
UnitSpecific.raid = UnitSpecific.party  -- raid is equal to party
 
------------------------------------------------------------------------
-- Shared settings
------------------------------------------------------------------------
local function Shared(self, unit)
  self:SetScript("OnEnter", UnitFrame_OnEnter)
  self:SetScript("OnLeave", UnitFrame_OnLeave)
 
  self:RegisterForClicks"AnyUp"
 
  -- shared functions
  	local frame = CreateFrame("Frame", "Bob", UIParent)
	frame:SetPoint("CENTER",UIParent,0,0)
  	-- Position and size
	local Health = CreateFrame("StatusBar", nil, frame)
	Health:SetHeight(50)
	Health:SetPoint('TOP')
	Health:SetPoint('LEFT')
	Health:SetPoint('RIGHT')

	-- Options
	Health.frequentUpdates = true
	Health.colorTapping = true
	Health.colorDisconnected = true
	Health.colorClass = true
	Health.colorReaction = true
	Health.colorHealth = true

	-- Register it with oUF
	frame.Health = Health
	frame.Health.bg = Background
 
  -- leave this in!!
  if(UnitSpecific[unit]) then
    return UnitSpecific[unit](self)
  end
end
 
oUF:RegisterStyle('Bob', Shared)
oUF:Factory(function(self)
  self:SetActiveStyle('Bob')
  self:Spawn('player'):SetPoint('CENTER', -300, -250)
  self:Spawn('target'):SetPoint('CENTER', 300, -250)
 
  self:SpawnHeader(nil, nil, 'custom [group:party] show; [@raid3,exists] show; [@raid26,exists] hide; hide',
    'showParty', true, 'showRaid', true, 'showPlayer', true, 'yOffset', -6,
    'oUF-initialConfigFunction', [[
      self:SetHeight(16)
      self:SetWidth(126)
    ]]
  ):SetPoint('TOP', Minimap, 'BOTTOM', 0, -10)
end)
 
local PreperationHandler = CreateFrame('Frame')
PreperationHandler:RegisterEvent('PLAYER_LOGIN')
PreperationHandler:SetScript('OnEvent', function(self, event)
  -- Insert base function here
end)
__________________
Tweets YouTube Website
  Reply With Quote
12-23-13, 05:10 PM   #4
MoonWitch
A Firelord
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 455
Lua Code:
  1. local frame = CreateFrame("Frame", "Bob", UIParent)
  2.   frame:SetPoint("CENTER",UIParent,0,0)
  3.   frame:SetSize(100,100)
You can just use self, since a frame to hook into isn't needed, oUF handles all that.

Lua Code:
  1. -- Register it with oUF
  2.   self.Health = Health

The Self.Health is a reference to self.Health from oUF itself, in that part you're telling oUF that the frame you called Health is self.Health from oUF. Otherwise oUF doesn't know what to do with it.

And this should purely work...
Lua Code:
  1. ------------------------------------------------------------------------
  2. -- oUF Layout boiletplate
  3. -- Author : Kelly Crabbé
  4. ------------------------------------------------------------------------
  5. ------------------------------------------------------------------------
  6. -- Namespace
  7. ------------------------------------------------------------------------
  8. local _, ns = ...
  9.  
  10. ------------------------------------------------------------------------
  11. -- Config
  12. ------------------------------------------------------------------------
  13. local NORMALFONT = STANDARD_TEXT_FONT
  14. local TEXTURE = [=[Interface\ChatFrame\ChatFrameBackground]=]
  15. local BACKDROP = {
  16.   bgFile = TEXTURE, insets = {top = -1, bottom = -1, left = -1, right = -1}
  17. }
  18.  
  19. -----------------------------
  20. -- Add custom functions (overrides)
  21.  
  22. ------------------------------------------------------------------------
  23. -- UnitSpecific settings
  24. ------------------------------------------------------------------------
  25. local UnitSpecific = {
  26.   player = function(self)
  27.   -- player specific stuff
  28.   end,
  29.   target = function(self)
  30.   -- target specific stuff
  31.   end,
  32.   party = function(self)
  33.     -- party frames
  34.   end,
  35.   boss = function(self)
  36.     -- boss frames
  37.   end,
  38.   arena = function(self)
  39.     -- arena frames
  40.   end
  41. }
  42. UnitSpecific.raid = UnitSpecific.party  -- raid is equal to party
  43.  
  44. ------------------------------------------------------------------------
  45. -- Shared settings
  46. ------------------------------------------------------------------------
  47. local function Shared(self, unit)
  48.   self:SetScript("OnEnter", UnitFrame_OnEnter)
  49.   self:SetScript("OnLeave", UnitFrame_OnLeave)
  50.  
  51.   self:RegisterForClicks"AnyUp"
  52.  
  53.   -- shared functions
  54.   -----------------------------
  55.   -- Health  
  56.   -- Your Health Statusbar
  57.   local Health = CreateFrame("StatusBar", nil, self)
  58.   Health:SetHeight(50)
  59.   Health:SetStatusBarTexture(TEXTURE)
  60.   Health:SetPoint('TOP')
  61.   Health:SetPoint('LEFT')
  62.   Health:SetPoint('RIGHT')
  63.  
  64.  -- Your health background, not needed but handy to see
  65. local Healthbg = Health:CreateTexture(nil, 'BACKGROUND')
  66.  Healthbg:SetAllPoints(Health)
  67.  Healthbg:SetTexture(TEXTURE)
  68.  Healthbg:SetVertexColor(139/255, 70/255, 70/255)
  69.  Healthbg.multiplier = .75
  70.  
  71.   -- Options
  72.   Health.frequentUpdates = true
  73.   Health.colorTapping = true
  74.   Health.colorDisconnected = true
  75.   Health.colorClass = true
  76.   Health.colorReaction = true
  77.   Health.colorHealth = true
  78.  
  79.   -- Register it with oUF
  80.   self.Health = Health
  81.   self.Health.bg = Healthbg
  82.  
  83.   -----------------------------
  84.   -- Power
  85.   -- Your Power Statusbar
  86.   local Power = CreateFrame("StatusBar", nil, self)
  87.   Power:SetHeight(50)
  88.   Power:SetStatusBarTexture(TEXTURE)
  89.   Power:SetPoint('TOP')
  90.   Power:SetPoint('LEFT')
  91.   Power:SetPoint('RIGHT')
  92.  
  93.  -- Your Power background, not needed but handy to see
  94.  local Powerbg = Power:CreateTexture(nil, 'BACKGROUND')
  95.  Powerbg:SetAllPoints(Power)
  96.  Powerbg:SetTexture(TEXTURE)
  97.  Powerbg:SetVertexColor(139/255, 70/255, 70/255)
  98.  Powerbg.multiplier = .75
  99.  
  100.   -- Options
  101.   Power.frequentUpdates = true
  102.   Power.colorPower = true -- powertype colored bar
  103.   Power.colorClassNPC = true -- color power based on NPC
  104.   Power.colorClassPet = true -- color power based on pet type
  105.  
  106.   -- Register it with oUF
  107.   self.Power = Power
  108.   self.Power.bg = Powerbg
  109.  
  110.   -- leave this in!!
  111.   if(UnitSpecific[unit]) then
  112.     return UnitSpecific[unit](self)
  113.   end
  114. end
  115.  
  116. oUF:RegisterStyle('Bob', Shared)
  117. oUF:Factory(function(self)
  118.   self:SetActiveStyle('Bob')
  119.   self:Spawn('player'):SetPoint('CENTER', -300, -250)
  120.   self:Spawn('target'):SetPoint('CENTER', 300, -250)
  121. end)
  Reply With Quote
12-23-13, 09:06 PM   #5
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Originally Posted by MoonWitch View Post
You can just use self, since a frame to hook into isn't needed, oUF handles all that.
Ok I was under a different impression then.

Unfortunately though, still don't get anything that looks like a unitframe. Not certain as to whats going on as I think it should work, but nothing.

code
Attached Thumbnails
Click image for larger version

Name:	WoWScrnShot_122313_215818.jpg
Views:	313
Size:	405.0 KB
ID:	7975  
__________________
Tweets YouTube Website
  Reply With Quote
12-23-13, 09:13 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I see no sign of BugSack in your UI. You should fix that ASAP. Most of the errors you will encounter while developing addons are going to occur during the loading process, which just so happens to be exactly the time when the default UI's error handler can't catch them.

Also, you never give the unit frames a size, so of course you can't see them.
__________________
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.

Last edited by Phanx : 12-23-13 at 09:15 PM.
  Reply With Quote
12-23-13, 09:24 PM   #7
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Originally Posted by Phanx View Post
I see no sign of BugSack in your UI. You should fix that ASAP. Most of the errors you will encounter while developing addons are going to occur during the loading process, which just so happens to be exactly the time when the default UI's error handler can't catch them.

Also, you never give the unit frames a size, so of course you can't see them.
I feel terrible thanks for ruining my hopes of feeling like I'm doing something right Phanx, lmao.

And thus everything is set. Probably dive a bit deeper into all this after the holidays.

code
__________________
Tweets YouTube Website

Last edited by 10leej : 12-23-13 at 09:36 PM.
  Reply With Quote
12-23-13, 09:36 PM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
It's okay, here is a hilarous cat video to cheer you up.
__________________
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.

Last edited by Phanx : 12-23-13 at 09:39 PM. Reason: NO VBULLETIN, I DON'T WANT AN IFRAME, **** OFF.
  Reply With Quote
12-23-13, 09:58 PM   #9
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Originally Posted by Phanx View Post
It's okay, here is a hilarous cat video to cheer you up.
I respond with a cure one! cute one!

Anyways now that I think i got it figured out I can't sleep till I finish it (DAMN YOU DEV BUG!)
__________________
Tweets YouTube Website

Last edited by 10leej : 12-23-13 at 10:00 PM.
  Reply With Quote
12-23-13, 10:00 PM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
BTW the forums are currently breaking Youtube links by trying to convert them into iframes in the middle of links. You have to use a URL shortener or just post the plain URL with nothing around it.
__________________
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
12-23-13, 10:03 PM   #11
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Originally Posted by Phanx View Post
BTW the forums are currently breaking Youtube links by trying to convert them into iframes in the middle of links. You have to use a URL shortener or just post the plain URL with nothing around it.
Yep just found that out.
__________________
Tweets YouTube Website
  Reply With Quote
12-23-13, 11:09 PM   #12
MoonWitch
A Firelord
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 455
http://goo.gl/rEuVFi
1. The angry cat vs dog -> we've got an example of that running around here too :P

Last edited by MoonWitch : 12-23-13 at 11:35 PM.
  Reply With Quote
12-23-13, 11:25 PM   #13
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
ok So got everything about setup for the most part but I keep getting this error with the Eclipse bar.

Code:
12x oUF-1.6.5\elements\eclipsebar.lua:100: attempt to call method "Show" (a nil value)
oUF-1.6.5\elements\eclipsebar.lua:100: in function <oUF\elements\eclipsebar.lua:84>
(tail call): ?
oUF-1.6.5\ouf-1.6.5.lua:158: in function "?"
oUF-1.6.5\events.lua:76: in function <oUF\events.lua:62>

Locals:
(*temporary) = "PLAYER_ENTERING_WORLD"
(*temporary) = "PLAYER_ENTERING_WORLD"
(*temporary) = <function> defined =[C]:-1
code

Also need to figure out how to add the status text.
__________________
Tweets YouTube Website

Last edited by 10leej : 12-23-13 at 11:31 PM.
  Reply With Quote
12-23-13, 11:36 PM   #14
MoonWitch
A Firelord
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 455
Originally Posted by 10leej View Post
ok So got everything about setup for the most part but I keep getting this error with the Eclipse bar.

Code:
12x oUF-1.6.5\elements\eclipsebar.lua:100: attempt to call method "Show" (a nil value)
oUF-1.6.5\elements\eclipsebar.lua:100: in function <oUF\elements\eclipsebar.lua:84>
(tail call): ?
oUF-1.6.5\ouf-1.6.5.lua:158: in function "?"
oUF-1.6.5\events.lua:76: in function <oUF\events.lua:62>

Locals:
(*temporary) = "PLAYER_ENTERING_WORLD"
(*temporary) = "PLAYER_ENTERING_WORLD"
(*temporary) = <function> defined =[C]:-1
code

Also need to figure out how to add the status text.
I'll take a look at that tomorrow, hadn't gotten to eclipse bar yet on mine But you're doing very good!
  Reply With Quote
12-23-13, 11:52 PM   #15
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Originally Posted by MoonWitch View Post
I'll take a look at that tomorrow, hadn't gotten to eclipse bar yet on mine But you're doing very good!
It's a mixture of I already know what I want and I won't be able to sleep till I complete it. Plus oUF seems to handle a lot of things itself so I'm really just doing a lot of copy/paste right now, probably gonna go into the finer details at a later date.

Also need to flip the target frame around so it's not backwards. Not sure how to do that quite yet.

Pretty much at this point I just need to fine tune auras, add text, fix the eclipse bar, figure out how to test arena/boss frames to make sure they work like I want them to, and flip the target frame around then I'm done.

code

Probably gonna add a config file tomorrow or after the holidays.
__________________
Tweets YouTube Website

Last edited by 10leej : 12-24-13 at 12:03 AM.
  Reply With Quote
12-24-13, 12:10 AM   #16
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by 10leej View Post
ok So got everything about setup for the most part but I keep getting this error with the Eclipse bar.
The example in oUF\elements\eclipsebar.lua is wrong. The EclipseBar object cannot be a plain table like that -- it must either be a frame (so it has native :Show() and :Hide() methods) or you must manually emulate those methods by adding functions to the table yourself. I'd just make it a frame.

Also, you are parenting your lunar power bar to your mana bar, but parenting your solar power bar to your frame. You should parent them both to the same object (preferrably the EclipseBar element frame, which itself should be parented directly to your unit frame):

Code:
local EclipseBar = CreateFrame("Frame", nil, self)
EclipseBar:SetPoint("TOP", Power, "BOTTOM", 0, -2) -- are you sure you want this overlapping your power bar by 2px?
EclipseBar:SetSize(width, 10)
self.EclipseBar = EclipseBar

local LunarBar = CreateFrame("StatusBar", nil, EclipseBar)
LunarBar:SetPoint("LEFT")
LunarBar:SetSize(width, 10)
EclipseBar.LunarBar = LunarBar

local SolarBar = CreateFrame("StatusBar", nil, EclipseBar)
SolarBar:SetPoint("LEFT", EclipseBar:GetStatusBarTexture(), "RIGHT")
SolarBar:SetSize(width, 10)
EclipseBar.SolarBar = SolarBar
Originally Posted by 10leej View Post
Also need to figure out how to add the status text.
Status text to what? The eclipse bar? Tags to the rescue!

Code:
local EclipseText = SolarBar:CreateFontString(nil, "OVERLAY", "TextStatusBarText") -- parent to last child to make sure it's on top
EclipseText:SetPoint("CENTER", EclipseBar) -- but anchor to the base element so it doesn't wiggle
self:Tag(EclipseText, "[pereclipse]") -- oUF will automagically update it!
EclipseBar.text = EclipseText
__________________
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
12-24-13, 12:15 AM   #17
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
The example in oUF\elements\eclipsebar.lua is wrong. The EclipseBar object cannot be a plain table like that -- it must either be a frame (so it has native :Show() and :Hide() methods) or you must manually emulate those methods by adding functions to the table yourself. I'd just make it a frame.
Ah well that makes sense, suppsoe someone should tell haste that?

Also, you are parenting your lunar power bar to your mana bar, but parenting your solar power bar to your frame. You should parent them both to the same object (preferrably the EclipseBar element frame, which itself should be parented directly to your unit frame):
my bad >.>

Status text to what? The eclipse bar? Tags to the rescue!
Actually looking at health and power not eclipse, but hey looks like I can do that. There wasn't much documentation in the tags file didn;t think it was that straightforward.

Kinda like this except have the percent on the right side and the value on the left.


-- are you sure you want this overlapping your power bar by 2px?
and yes actually, because I use an older version of !Beautycase for skinning my frame and the border is actually slightly larger than the frame itself so I have to space the bars out a little to make it look neat.
__________________
Tweets YouTube Website

Last edited by 10leej : 12-24-13 at 12:19 AM.
  Reply With Quote
12-24-13, 12:18 AM   #18
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by 10leej View Post
... figure out how to test arena/boss frames to make sure they work like I want them to ...
Here is (basically; there are a few drycoded adjustments) what I use to test those frames:

Code:
local groups = { -- Change these to the global names your layout will make.
	arena = { "oUFPhanxArena1", "oUFPhanxArena2", "oUFPhanxArena3", "oUFPhanxArena4", "oUFPhanxArena5",  "oUFPhanxArenaPet1", "oUFPhanxArena2", "oUFPhanxArenaPet3", "oUFPhanxArenaPet4", "oUFPhanxArenaPet5" },
	boss = { "oUFPhanxBoss1", "oUFPhanxBoss2", "oUFPhanxBoss3", "oUFPhanxBoss4", "oUFPhanxBoss5" },
}

local function toggle(f)
	if f.__realunit then
		f:SetAttribute("unit", f.__realunit)
		f.unit = f.__realunit
		f.__realunit = nil
		f:Hide()
	else
		f.__realunit = f:GetAttribute("unit") or f.unit
		f:SetAttribute("unit", "player")
		f.unit = "player"
		f:Show()
	end
end

SLASH_OUFPHANXTEST1 = "/otest"
SlashCmdList.OUFPHANXTEST = function(group)
	local frames = groups[strlower(strtrim(group))]
	if not frames then return end
	for i = 1, #frames do
		local frame = _G[frames[i]]
		if frame then
			toggle(frame)
		end
	end
end
Usage: "/otest boss" or "/otest arena"
__________________
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
12-24-13, 12:25 AM   #19
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Originally Posted by Phanx View Post
Here is (basically; there are a few drycoded adjustments) what I use to test those frames:
Awesome saves me the trouble of finding an arena partner and a raid group, lmao
__________________
Tweets YouTube Website
  Reply With Quote
12-24-13, 12:51 AM   #20
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Looks like eclipse bar is still a little bugged, shows on the focus and target frame using the script Phanx provided.
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	271
Size:	231.2 KB
ID:	7976  
__________________
Tweets YouTube Website
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Trying my hand at ouf

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