Thread Tools Display Modes
12-03-17, 06:45 AM   #1
Naisz
A Deviate Faerie Dragon
 
Naisz's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2015
Posts: 12
Getting Started with oUF

Hello everyone,

after a break from WoW i wanted to start again, but instead of using ElvUI or any other compilation i want to build my UI from scratch this time. Therefore id' like to use oUF for UnitFrames, since it offers much more flexibility regarding specific units and what not.

But right from the start im running into problems.. every module has a basic implementation in the comment at the Top, i used the Boilerplate found at GitHub and started creating a basic HealthBar.. but it doesnt show up but isnt throwing erros either.. so im kind of clueless to the Whys, maybe someone here can help me

Lua Code:
  1. local _, ns = ...
  2.  
  3. local texture = [[Interface\ChatFrame\ChatFrameBackground]]
  4.  
  5. local UnitSpecific = {
  6.     player = function(self)
  7.         -- Player specific layout code.
  8.         --[[ Position and size
  9.         local Power = CreateFrame('StatusBar', nil, self)
  10.         Power:SetHeight(20)
  11.         Power:SetPoint('BOTTOM')
  12.         Power:SetPoint('LEFT')
  13.         Power:SetPoint('RIGHT')
  14.  
  15.         -- Add a background
  16.         local Background = Power:CreateTexture(nil, 'BACKGROUND')
  17.         Background:SetAllPoints(Power)
  18.         Background:SetTexture(1, 1, 1, .5)
  19.  
  20.         -- Options
  21.         Power.frequentUpdates = true
  22.         Power.colorTapping = true
  23.         Power.colorDisconnected = true
  24.         Power.colorPower = true
  25.         Power.colorClass = true
  26.         Power.colorReaction = true
  27.  
  28.         -- Make the background darker.
  29.         Background.multiplier = .5
  30.  
  31.         -- Register it with oUF
  32.         Power.bg = Background
  33.         self.Power = Power
  34.         ]]
  35.     end,
  36.        
  37.         party = function(self)
  38.         -- Party specific layout code.        
  39.         end,
  40. }
  41.  
  42. local Shared = function(self, unit)
  43.     -- general
  44.     self:RegisterForClicks('AnyUp')
  45.     self:SetScript('OnEnter', UnitFrame_OnEnter)
  46.     self:SetScript('OnLeave', UnitFrame_OnLeave)
  47.  
  48.     --self:SetBackdrop(BACKDROP)
  49.     --self:SetBackdropColor(0, 0, 0)
  50.  
  51.     -- Shared layout code.
  52.     -- Position and size
  53.     local Health = CreateFrame('StatusBar', nil, self)
  54.     Health:SetSize(150,20)
  55.     Health:SetStatusBarTexture(texture)
  56.     Health:SetStatusBarColor(1/3, 1/3, 1/3)
  57.     Health:SetReverseFill(true)
  58.     Health.frequentUpdates = true
  59.     self.Health = Health
  60.  
  61.     -- Add a background
  62.     local Background = Health:CreateTexture(nil, 'BACKGROUND')
  63.     Background:SetAllPoints()
  64.     Background:SetTexture(1, 1, 1, .5)
  65.     -- Make the background darker.
  66.     Background.multiplier = .5
  67.  
  68.     -- Register it with oUF
  69.     Health.bg = Background
  70.     -- Options
  71.     Health.frequentUpdates = true
  72.     Health.colorTapping = true
  73.     Health.colorDisconnected = true
  74.     Health.colorClass = true
  75.     Health.colorReaction = true
  76.     --Health.colorHealth = true
  77.  
  78.  
  79.     --self.Health = Health
  80.     if(UnitSpecific[unit]) then
  81.         return UnitSpecific[unit](self)
  82.     end
  83. end
  84.  
  85. oUF:RegisterStyle("MyLayout", Shared)
  86. oUF:Factory(function(self)
  87.  
  88.      self:SetActiveStyle("MyLayout")
  89.  
  90.      self:Spawn("player"):SetPoint('CENTER', -300, -250)
  91.  
  92.      -- oUF:SpawnHeader(overrideName, overrideTemplate, visibility, attributes ...)
  93.      local party = self:SpawnHeader(nil, nil, 'raid,party,solo',
  94.           -- [url]http://wowprogramming.com/docs/secure_template/Group_Headers[/url]
  95.           -- Set header attributes
  96.           'showParty', true,
  97.           'showPlayer', true,
  98.           'yOffset', -20
  99.      )
  100.      party:SetPoint("TOPLEFT", 30, -30)
  101. end)

Thats my current code i am using. I also had a look at oUF_p3lim, there its done in the same way.
The default UI Player frame isnt showing up, but neither is mine..

I appreciate any help regarding my problems!

Thanks in advance

Last edited by Naisz : 12-03-17 at 06:49 AM. Reason: typos..
  Reply With Quote
12-03-17, 08:02 AM   #2
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
You need to give each frame a size, you'd want to do that in the "Shared" function.
One exception to this is for headers, see my layout's header spawning for specifics.

I've been wanting to do a fully commented base layout including all elements oUF has to offer, but I just haven't had the time.

Last edited by p3lim : 12-03-17 at 08:12 AM.
  Reply With Quote
12-03-17, 08:06 AM   #3
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
You need to anchor[0] the Health element as well.

[0] https://github.com/oUF-wow/oUF/blob/...health.lua#L53
__________________
「貴方は1人じゃないよ」
  Reply With Quote
12-03-17, 08:38 AM   #4
Naisz
A Deviate Faerie Dragon
 
Naisz's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2015
Posts: 12
Originally Posted by haste View Post
You need to anchor[0] the Health element as well.

[0] https://github.com/oUF-wow/oUF/blob/...health.lua#L53
Thanks alot! This solved it. Now i can keep on tinkering
  Reply With Quote
12-03-17, 10:18 AM   #5
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 463
Originally Posted by p3lim View Post
You need to give each frame a size, you'd want to do that in the "Shared" function.
One exception to this is for headers, see my layout's header spawning for specifics.

I've been wanting to do a fully commented base layout including all elements oUF has to offer, but I just haven't had the time.
That would be great! I can usually follow code, but sometimes it is just easier to use an existing layout or use a different unit frame that has a gui config.
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote
12-03-17, 10:55 AM   #6
Tim
A Rage Talon Dragon Guard
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 308
Originally Posted by JDoubleU00 View Post
That would be great! I can usually follow code, but sometimes it is just easier to use an existing layout or use a different unit frame that has a gui config.
Now that would be something to see to help out people, a base oUF layout with gui options to help out new folks as well as older folks that never could get how to implement gui stuff.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Getting Started with 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