View Single Post
08-16-14, 06:35 AM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Just FYI, I'd like to point out that it's completely unnecessary to create a separate function to make the health bar; you can just make the health bar directly in the "CreateBasicStyle" function. The same goes for any other element. The only benefits to splitting them off into their own functions would be to movecode that only applies to one unit (eg. totem bars are only created on the player frame) and code that's very long and/or has a lot of helper functions to go with it (eg. buff icons) off into its own file for organizational purposes.

Also, strictly, speaking, the bare minimum doesn't even require a health bar.

Code:
oUF:RegisterStyle("MyStyle", function(frame, unit, isSingle)
    -- required because frames without dimensions aren't shown:
    frame:SetSize(100, 25)

    -- not strictly required, but without any visible regions/children the frame will be invisible:
    frame:SetBackdrop({ bgFile = "Interface\\BUTTONS\\WHITE8X8" })

    -- add elements here
end)

oUF:SetActiveStyle("MyStyle")

local player = oUF:Spawn("player")
player:SetPoint("CENTER", -100, 0)

local target = oUF:Spawn("target")
target:SetPoint("CENTER", 100, 0)
Once you've got the basics down, you can really just look at the comments at the top of each element file in oUF. Copy the example from the element into the section labeled "add elements here" above, and then modify it to your liking. I'd recommend starting with the more important elements like health bars, and doing one thing at a time, rather than copy/pasting everything at once and then trying to go back and sort it all out.
__________________
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.
  Reply With Quote