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:	314
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

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


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