Advertisement
Guest User

Untitled

a guest
Feb 12th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.91 KB | None | 0 0
  1. -- oUF_Boiler: spawn (Jagwah edit)
  2. -- zork, 2018
  3.  
  4. --------------------------------
  5. -- Variables
  6. --------------------------------
  7.  
  8.     -- to do:
  9.         -- add addon-name variable prefix
  10.  
  11. --------------------------------
  12. -- Config
  13. --------------------------------
  14.  
  15.     cfg = {}
  16.  
  17.     cfg.player = {
  18.         hsize = { 256, 32 },
  19.         psize = { 256, 32 },
  20.         hpoint = { "CENTER", UIParent, "CENTER", -200, -100 },
  21.         ppoint = { "CENTER", UIParent, "CENTER", -200, -100 },
  22.         scale = 1,
  23.         healthbar = {
  24.             colorClass = true,
  25.             colorHealth = true,
  26.             colorReaction = true,
  27.         },
  28.         powerbar = {
  29.             colorPower = true,
  30.         },
  31.  
  32.     }
  33.  
  34.     cfg.target = {
  35.    
  36.  
  37.     }  
  38.  
  39. --------------------------------
  40. -- Functions
  41. --------------------------------
  42.  
  43. local function SetupEvents(self)
  44.     if not self.settings.setupEvents then return end
  45.     self:RegisterForClicks("AnyDown")
  46.     self:SetScript("OnEnter", UnitFrame_OnEnter)
  47.     self:SetScript("OnLeave", UnitFrame_OnLeave)
  48. end
  49.  
  50. local function SetupHealthFrame(self)
  51.     if not self.settings.setupHealthFrame then return end
  52.     self:SetSize(unpack(self.cfg.hsize))
  53.     self:SetPoint(unpack(self.cfg.hpoint))
  54.     self:SetScale(self.cfg.scale)
  55. end
  56.  
  57. local function SetupPowerFrame(self)
  58.     if not self.settings.setupPowerFrame then return end
  59.     self:SetSize(unpack(self.cfg.psize))
  60.     self:SetPoint(unpack(self.cfg.ppoint))
  61.     self:SetScale(self.cfg.scale)
  62. end
  63.  
  64. -- CreateBars
  65.  
  66. local function CreateHealthBar(self)
  67.     --statusbar
  68.     local hb = CreateFrame("StatusBar", nil, self)
  69.     hb:SetAllPoints()
  70.     --bg
  71.     local hbg = hb:CreateTexture(nil, "BACKGROUND")
  72.     hbg:SetColorTexture(0, 0, 0, 0.5)
  73.     hbg:SetAllPoints()
  74.     --attributes
  75.     hb.colorClass = self.cfg.healthbar.colorClass
  76.     hb.colorClass = self.cfg.healthbar.colorHealth
  77.     hb.colorClass = self.cfg.healthbar.colorReaction
  78.     hb.frequentUpdates = self.cfg.healthbar.frequentUpdates
  79.     return hb
  80. end
  81.  
  82. local function CreatePowerBar(self)
  83.     --statusbar
  84.     local pb = CreateFrame("StatusBar", nil, self)
  85.     pb:SetAllPoints()
  86.     --bg
  87.     local pbg = pb:CreateTexture(nil, "BACKGROUND")
  88.     pbg:SetColorTexture(0, 0, 0, 0.5)
  89.     pbg:SetAllPoints()
  90.     --attributes
  91.     pb.colorPower = self.cfg.powerbar.colorPower
  92.     return pb
  93. end
  94.  
  95. -- CreateStyle
  96.  
  97. local function CreateStyle(self)
  98.     SetupHealthFrame(self)
  99.     SetupPowerFrame(self)
  100.     SetupEvents(self)
  101.     self.Health = CreateHealthBar(self)
  102.     self.Power = CreatePowerBar(self)
  103. end
  104.  
  105. -- PlayerStyle
  106.  
  107. local function PlayerStyle(self)
  108.     --config
  109.     self.cfg = cfg.player
  110.     --settings
  111.     self.settings = {}
  112.     self.settings.setupHealthFrame = true
  113.     self.settings.setupPowerFrame = true
  114.     self.settings.setupEvents = true
  115.     --style
  116.     CreateStyle(self)
  117. end
  118.  
  119. oUF:RegisterStyle("PlayerStyle", PlayerStyle)
  120.  
  121.  
  122. --------------------------------
  123. -- Spawn
  124. --------------------------------
  125.  
  126. local function Factory(self)
  127.  
  128.     local oUF = self
  129.  
  130.     --player
  131.     oUF:SetActiveStyle("PlayerStyle")
  132.     local player = oUF:Spawn("player", "Player")
  133.  
  134. end
  135.  
  136. oUF:Factory(Factory)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement