Ok im using your template if you don't mind is much better and cleaner than other's
Thanks for help
Code:
-----------------------------
-- FUNCTIONS
-----------------------------
.....
-----------------------------
-- LAYOUT
-----------------------------
local Shared = function(self,unit)
....
end
-----------------------------
-- STYLE FUNCTIONS
-----------------------------
local UnitSpecific = {
player = function(self)
Shared(self)
.......
end,
target = function(self)
Shared(self)
.......
end,
targettarget = function(self)
.......
end,
pet = function(self)
Shared(self)
.......
end,
focus = function(self)
Shared(self)
.......
end,
focustarget = function(self)
Shared(self)
.......
end,
boss = function(self)
Shared(self)
.......
end,
arenaframes = function(self)
Shared(self)
.......
end,
arenatargets = function(self)
Shared(self)
.......
end,
}
-----------------------------
-- SPAWN UNITS
-----------------------------
oUF:RegisterStyle("name", Shared)
for unit,layout in next, UnitSpecific do
oUF:RegisterStyle('name - ' .. unit:gsub("^%l", string.upper), layout)
end
local spawnSpecific = function(self, unit, ...)
if(UnitSpecific[unit]) then
self:SetActiveStyle('name - ' .. unit:gsub("^%l", string.upper))
local object = self:Spawn(unit)
object:SetPoint(...)
return object
else
self:SetActiveStyle'name'
local object = self:Spawn(unit)
object:SetPoint(...)
return object
end
end
oUF:RegisterStyle('oUF_name_Arena', UnitSpecific.arenaframes)
oUF:SetActiveStyle('oUF_name_Arena')
local arena = {}
local arenatarget = {}
for i = 1, 5 do
arena[i] = oUF:Spawn("arena"..i, "oUF_Arena"..i)
if i == 1 then
arena[i]:SetPoint('RIGHT', UIParent, 'RIGHT', -100, 0)
else
arena[i]:SetPoint("BOTTOMRIGHT", arena[i-1], "TOPRIGHT", 0, 20)
end
end
oUF:RegisterStyle("oUF_name_ArenaTarget", UnitSpecific.arenatargets)
oUF:SetActiveStyle("oUF_name_ArenaTarget")
for i = 1, 5 do
arenatarget[i] = oUF:Spawn("arena"..i.."target", "oUF_Arena"..i.."target"):SetPoint("TOPLEFT",arena[i], "TOPRIGHT", 8, 0)
end
oUF:Factory(function(self)
spawnSpecific(self, 'target', "BOTTOM", X, Y)
spawnSpecific(self, 'player', "BOTTOM", X, Y)
spawnSpecific(self, 'pet', "TOPRIGHT", self.units.player, "BOTTOMRIGHT", X, Y)
spawnSpecific(self, 'targettarget', "TOPRIGHT", self.units.target, "BOTTOMRIGHT", X, Y)
spawnSpecific(self, 'focus', "BOTTOM", X, Y)
spawnSpecific(self, 'focustarget', "BOTTOM", X, Y)
self:SetActiveStyle"name - Boss"
local boss = {}
for i = 1, MAX_BOSS_FRAMES do
local unit = self:Spawn("boss"..i, "oUF_Boss"..i)
if i==1 then
unit:SetPoint("TOP", self.units.player, "BOTTOM", 750, 400)
else
unit:SetPoint("TOP", boss[i-1], "BOTTOM", 0, -12)
end
boss[i] = unit
end
end)