WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Getting Started with oUF (https://www.wowinterface.com/forums/showthread.php?t=55895)

Naisz 12-03-17 06:45 AM

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

p3lim 12-03-17 08:02 AM

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.

haste 12-03-17 08:06 AM

You need to anchor[0] the Health element as well.

[0] https://github.com/oUF-wow/oUF/blob/...health.lua#L53

Naisz 12-03-17 08:38 AM

Quote:

Originally Posted by haste (Post 325998)
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 :)

JDoubleU00 12-03-17 10:18 AM

Quote:

Originally Posted by p3lim (Post 325997)
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.

Tim 12-03-17 10:55 AM

Quote:

Originally Posted by JDoubleU00 (Post 326000)
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.


All times are GMT -6. The time now is 09:55 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI