Thread Tools Display Modes
Prev Previous Post   Next Post Next
04-18-12, 11:12 AM   #1
Wildbreath
A Cyclonian
 
Wildbreath's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 46
about a Create functions and new instances of objects

For example:
frame1 = CreateFrame("frame","frame1",UIParent)
frame2 = CreateFrame("frame","frame1",UIParent)

frame1 == frame2 ?
or frame2 is new widget object?

If second is right then i have a new snippet for optimize all addons
lua Code:
  1. local oldCreateFrame = CreateFrame
  2. CreateFrame = function(ftype, name, ...)
  3.     local frame, texture, fontstring, animation, animationg
  4.    
  5.     if name ~= nil and name:find('map') then return oldCreateFrame(ftype, name, ...) end
  6.     if _G[name] ~= nil then
  7.         frame = _G[name]
  8.     else
  9.         frame = oldCreateFrame(ftype, name, ...)
  10.     end
  11.    
  12.     local oldCreateTexture = frame.CreateTexture
  13.     frame.CreateTexture = function(name, ...)
  14.         if _G[name] ~= nil then
  15.             texture = _G[name]
  16.         else
  17.             texture = oldCreateTexture(name, ...)
  18.         end
  19.         return texture
  20.     end
  21.    
  22.     local oldCreateFontString = frame.CreateFontString
  23.     frame.CreateFontString = function(name, ...)
  24.         if _G[name] ~= nil then
  25.             fontstring = _G[name]
  26.         else
  27.             fontstring = oldCreateFontString(name, ...)
  28.         end
  29.         return fontstring
  30.     end
  31.    
  32.     local oldCreateAnimationGroup = frame.CreateAnimationGroup
  33.     frame.CreateAnimationGroup = function(name, ...)
  34.         if _G[name] ~= nil then
  35.             animationg = _G[name]
  36.         else
  37.             animationg = oldCreateAnimationGroup(name, ...)
  38.         end
  39.         return animationg
  40.     end
  41.  
  42.  
  43.     local oldCreateAnimation = frame.CreateAnimation
  44.     frame.CreateAnimation = function(atype, name, ...)
  45.         if _G[name] ~= nil then
  46.             animation = _G[name]
  47.         else
  48.             animation = oldCreateAnimation(atype, name, ...)
  49.         end
  50.         return animation
  51.     end
  52.    
  53.     return frame
  54. end
  Reply With Quote
 

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » about a Create functions and new instances of objects


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off