View Single Post
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