View Single Post
04-12-13, 09:24 AM   #12
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,327
Originally Posted by fRodzet View Post
Lua Code:
  1. -------------------
  2. --BagBuddy Frames--
  3. -------------------
  4.  
  5.     -- The parent frame of BagBuddy
  6.     local frame = CreateFrame("Frame", "BagBuddy", UIParent)
  7.     frame:SetSize(425, 425)
  8.     frame:SetPoint("CENTER", UIParent, "CENTER")
  9.  
  10.     -- The Body frame of BagBuddy (the border itself)
  11.     frame.body = frame:CreateTexture("BagBuddy_Body", "BORDER")
  12.     frame.body:SetPoint("TOPLEFT")
  13.     frame.body:SetTexture("Interface\\BankFrame\\UI-BankFrame")
  14.    
  15.     -- Making BagBuddy movable
  16.     frame:EnableMouse(true)
  17.     frame:SetMovable(true)
  18.     frame:SetClampedToScreen(true)
  19.     frame:RegisterForDrag("LeftButton")
  20.     frame:SetScript("OnDragStart", frame.StartMoving)
  21.     frame:SetScript("OnDragStop", frame.StopMovingOrSizing)
  22.  
  23.     -- The icon(portrait) texture of BagBuddy
  24.     frame.icon = frame:CreateTexture("BagBuddy_Icon", "BACKGROUND")
  25.     frame.icon:SetSize(60, 60)
  26.     frame.icon:SetPoint("TOPLEFT", 7, -6)
  27.     frame.icon:SetTexture("Interface\\Icons\\INV_Misc_EngGizmos_17")
  28.     SetPortraitToTexture(frame.icon, "Interface\\Icons\\INV_Misc_EngGizmos_17")
  29.  
  30.     -- The title fontstring of BagBuddy.
  31.     frame.title = frame:CreateFontString("BagBuddy_Title", "OVERLAY", "GameFontNormal")
  32.     frame.title:SetPoint("TOP", 0, -18)
  33.     frame.title:SetText("BagBuddy")
  34.  
  35.     -- The close button for BagBuddy.
  36.     frame.close = CreateFrame("Button", "BagBuddy_Close", frame, "UIPanelCloseButton")
  37.     frame.close:SetPoint("TOPRIGHT", -22, -8)
  38.  
  39. -----------------------
  40. --BagBuddy Loop Items--
  41. -----------------------
  42.  
  43. frame.items = {}
  44. for idx = 1, 28 do
  45.     local item = CreateFrame("Button", "BagBuddy_Item" .. idx, frame, "SecureActionButtonTemplate")
  46.     item:SetSize(37, 37)
  47.    
  48.     item:SetNormalTexture("Interface\\Buttons\\UI-Quickslot2")
  49.     item:SetPushedTexture("Interface\\Buttons\\UI-Quickslot-Depress")
  50.     item:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square", "ADD")
  51.     do local tex = item:GetNormalTexture()
  52.         tex:ClearAllPoints()
  53.         tex:SetPoint("CENTER", 0, -1)
  54.         tex:SetSize(64, 64)
  55.     end
  56.    
  57.     item.icon = item:CreateTexture("$parentIconTexture", "BORDER")
  58.    
  59.     item.count = item:CreateFontString("$parentCount", "BORDER", "NumberFontNormal")
  60.     item.coun:SetPoint("BOTTOMRIGHT", -5, 2)
  61.     item.count:SetJustifyH("RIGHT")
  62.     item.count:Hide()
  63.    
  64.     item.glow = item:CreateTexture("$parentGlow", "OVERLAY")
  65.     item.glow:SetPoint("CENTER")
  66.     item.glow:SetSize(70, 70)
  67.     item.glow:SetTexture("Interface\\Buttons\\UI-ActionButton-Border")
  68.     item.glow:SetBlendMode("ADD")
  69.     item.glow:SetAlpha(0.6)
  70.    
  71.     frame.items[idx] = item
  72.    
  73.     if idx == 1 then
  74.         item:SetPoint("TOPLEFT", 40, -73)
  75.     elseif idx == 8 or idx == 15 or idx == 22 then
  76.         item:SetPoint("TOPLEFT", frame.items[idx - 7], "BOTTOMLEFT", 0, -7)
  77.     else
  78.         item:SetPoint("TOPLEFT", frame.items[idx - 1], "TOPRIGHT", 12, 0)
  79.     end
  80. end
Line 60:
Code:
item.coun:SetPoint("BOTTOMRIGHT", -5, 2)


Originally Posted by fRodzet View Post
$parent works for lua aswell? or is that XML only?
$parent works for any function in the Widget API and CreateFrame() that can reference a frame by its name. Just think of Lua as a backend for the XML. Using the right functions, you can just plug in the values directly.



More information on these functions is available in the Widget API page on WoWPedia. Note CreateFrame() is in the WoW API section.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote