Advertisement
suicidalkatt

DynamicBorderTemplate

Jul 7th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.83 KB | None | 0 0
  1. ---------------------------------------------------
  2. --- || DYNAMIC BORDER TEMPLATE || -----------------
  3. ---------------------------------------------------
  4.  
  5. local frames = {
  6.     ["TOPLEFT"] = {
  7.         w = 64,
  8.         h = 64,
  9.         x = -9,
  10.         y = 9
  11.     },
  12.     ["TOPRIGHT"] = {
  13.         w = 64,
  14.         h = 64,
  15.         x = 9,
  16.         y = 9
  17.     },
  18.     ["BOTTOMLEFT"] = {
  19.         w = 64,
  20.         h = 64,
  21.         x = -9,
  22.         y = -9
  23.     },
  24.     ["BOTTOMRIGHT"] = {
  25.         w = 64,
  26.         h = 64,
  27.         x = 9,
  28.         y = -9
  29.     },
  30.     ["TOP"] = {
  31.         h = 64,
  32.         a = {
  33.             ["TOPLEFT"] = {"LEFT","RIGHT"},
  34.             ["TOPRIGHT"] = {"RIGHT","LEFT"}
  35.         }
  36.     },
  37.     ["BOTTOM"] = {
  38.         h = 64,
  39.         a = {
  40.             ["BOTTOMLEFT"] = {"LEFT","RIGHT"},
  41.             ["BOTTOMRIGHT"] = {"RIGHT","LEFT"}
  42.         }
  43.     },
  44.     ["LEFT"] = {
  45.         w = 64,
  46.         a = {
  47.             ["TOPLEFT"] = {"TOP","BOTTOM"},
  48.             ["BOTTOMLEFT"] = {"BOTTOM","TOP"}
  49.         }
  50.     },
  51.     ["RIGHT"] = {
  52.         w = 64,
  53.         a = {
  54.             ["TOPRIGHT"] = {"TOP","BOTTOM"},
  55.             ["BOTTOMRIGHT"] = {"BOTTOM","TOP"}
  56.         }
  57.     }
  58. }
  59.  
  60. local function DynamicBorderTemplate(name, parent, strata, flevel, ...)
  61.     local scale = ...
  62.     for k,v in pairs(frames) do
  63.         local f = CreateFrame("FRAME",name..k,parent)
  64.         -- Anchoring
  65.         if v.a then -- TOP,BOTTOM,LEFT,RIGHT SetPoint frame referencing
  66.             for c,g in pairs(v.a) do
  67.                 f:SetPoint(g[1],_G[name..c],g[2],0,0) -- References the previous frames dynamically
  68.             end
  69.         else
  70.             f:SetPoint(k,parent,v.x,v.y)
  71.         end
  72.         -- Frame Parameters
  73.         if v.w then
  74.             f:SetWidth(v.w)
  75.         end
  76.         if v.h then
  77.             f:SetHeight(v.h)
  78.         end
  79.         if scale then
  80.             f:SetScale(scale)
  81.         end
  82.         f:SetStrata(strata)
  83.         f:SetFrameLevel(flevel)
  84.         -- Textures
  85.         f.tex = f:CreateTexture(nil, strata)
  86.         f.tex:SetParent(f)
  87.         f.tex:SetAllPoints(f)
  88.         f.tex:SetTexture(cfg["DYNAMIC_BORDER_"..k]) -- Note that this is an easier way to reference your textures if you rewrite your config variable names
  89.        
  90.         return f -- Line may not be neccessary
  91.     end
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement