WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Trying my hand at ouf (https://www.wowinterface.com/forums/showthread.php?t=48715)

10leej 12-23-13 01:07 PM

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


MoonWitch 12-23-13 01:15 PM

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

10leej 12-23-13 01:40 PM

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)


MoonWitch 12-23-13 05:10 PM

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)

10leej 12-23-13 09:06 PM

1 Attachment(s)
Quote:

Originally Posted by MoonWitch (Post 288707)
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

Phanx 12-23-13 09:13 PM

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. :p

10leej 12-23-13 09:24 PM

Quote:

Originally Posted by Phanx (Post 288718)
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. :p

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

Phanx 12-23-13 09:36 PM

It's okay, here is a hilarous cat video to cheer you up.

10leej 12-23-13 09:58 PM

Quote:

Originally Posted by Phanx (Post 288720)
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!)

Phanx 12-23-13 10:00 PM

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. :rolleyes:

10leej 12-23-13 10:03 PM

Quote:

Originally Posted by Phanx (Post 288723)
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. :rolleyes:

Yep just found that out.

MoonWitch 12-23-13 11:09 PM

http://goo.gl/rEuVFi
1. The angry cat vs dog -> we've got an example of that running around here too :P

10leej 12-23-13 11:25 PM

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.

MoonWitch 12-23-13 11:36 PM

Quote:

Originally Posted by 10leej (Post 288727)
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!

10leej 12-23-13 11:52 PM

Quote:

Originally Posted by MoonWitch (Post 288728)
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.

Phanx 12-24-13 12:10 AM

Quote:

Originally Posted by 10leej (Post 288727)
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

Quote:

Originally Posted by 10leej (Post 288727)
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


10leej 12-24-13 12:15 AM

Quote:

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?

Quote:

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 >.>

Quote:

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.


Quote:

-- 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.

Phanx 12-24-13 12:18 AM

Quote:

Originally Posted by 10leej (Post 288731)
... 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"

10leej 12-24-13 12:25 AM

Quote:

Originally Posted by Phanx (Post 288736)
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

10leej 12-24-13 12:51 AM

1 Attachment(s)
Looks like eclipse bar is still a little bugged, shows on the focus and target frame using the script Phanx provided.


All times are GMT -6. The time now is 12:01 AM.

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